$(document).ready(function()
		{
		
		var notifed = 0
		
		if ( $("#msgNotify").length > 0 ) { 		
		
		$(".notLogged").click(function() {	
		
		
		if(notifed==1){	
           
           //so it's already open and warning the user

           $("#content").html("");	
           
           $("#content").animate({top: "42px",opacity: 0.1}).animate({top: "2px",opacity: 1});
           
           $("#content").html("<p>You need to login or <a href='" + genLocUrl() + "pagecontent/registeruser'>register</a></p>");
           
            
            
           }
		
		   if(notifed==0){		
		    
           $("#content").html("<p>You need to login or <a href='" + genLocUrl() + "pagecontent/registeruser'>register</a></p>");	
           
           $("#content").animate({top: "2px",opacity: 1});
           
           notifed = 1;
           
           }          
    			 	
		 })		
			
		 }		 
		 
		
			function genLocUrl(){		 
		 	pathArray = window.location.pathname.split( '/' );
			continuePath=true;
			newPathname = "";
			for ( i = 0; i<pathArray.length; i++ ) {						
			if(pathArray[i]=="web"){
			newPathname += pathArray[i];
			newPathname += "/";
			break;
			} else {			
			newPathname += pathArray[i];
			newPathname += "/";
			 }
			}	
					
			return window.location.protocol + '//' + window.location.host + newPathname;
					 
		 }

		   	
		   	$("#postCodeLookUp").click(function() {		   	
		   	var pc = $('#pc').val().replace(/ /g,'');
		   	if(pc==""){
		   	alert('Please enter a postcode to use the lookup service');
		   	} else {
		   	$("#postCodeLookUp").attr('src', genLocUrl()+"images/public/mcr2/ajax-loader.gif");

            $.post("/pagecontent/pcLookUp", {pc:pc}, function(data)
               { 			              
			       				        
			   
 $('#add1').val($("add1",data).text());
				    $('#add1').animate({ opacity: 0.1 }, 500 ).animate({ opacity: 1 }, 500 );
				    $('#add2').val($("add2",data).text()); 
				    $('#add2').animate({ opacity: 0.1 }, 500 ).animate({ opacity: 1 }, 500 );
				    $('#add3').val($("add3",data).text());
				    $('#add3').animate({ opacity: 0.1 }, 500 ).animate({ opacity: 1 }, 500 );
				    $('#cty').val($("cty",data).text());
				    $('#cty').animate({ opacity: 0.1 }, 500 ).animate({ opacity: 1 }, 500 );
				    $('#town').val($("town",data).text());
				    $('#town').animate({ opacity: 0.1 }, 500 ).animate({ opacity: 1 }, 500 );
				    $('#cntry').val($("cntry",data).text()); 
				    $('#cntry').animate({ opacity: 0.1 }, 500 ).animate({ opacity: 1 }, 500 );
				    
				    
				    $("#postCodeLookUp").attr('src', genLocUrl()+"images/public/mcr2/postcodeLook.png");  		       
				       					  					
			        }, "xml");	
			        
			        }			
				
		   	}); 	
		   	
		   	
			
		});


