jQuery(function() {	
	
	/* EMPTY INPUTS ON FOCUS */
		
		jQuery('#postCode').focus(function(){
			if(jQuery('#postCode').val() == INPUTPOSTCODE){
				jQuery('#postCode').val('');
				jQuery('#postCode').removeClass('originalState');
			}
		});
		
		jQuery('#postCode').blur(function(){
			if(jQuery('#postCode').val() == ''){
				jQuery('#postCode').val(INPUTPOSTCODE);
				jQuery('#postCode').addClass('originalState');
			}
		});
		
		jQuery('#location').focus(function(){
			if(jQuery('#location').val() == INPUTLOCATION){
				jQuery('#location').val('');
				jQuery('#location').removeClass('originalState');
			}
		});
		
		jQuery('#location').blur(function(){
			if(jQuery('#location').val() == ''){
				jQuery('#location').val(INPUTLOCATION);
				jQuery('#location').addClass('originalState');
			}
		});
		
	/* #LocationBox OPEN & CLOSE */

    if(jQuery.browser.msie) {
    	jQuery("#locationboxTrigger").click(function(){
	      	jQuery("#locationBox .inner").show();
	      	jQuery("#site").css("margin-top", 135);
	      	jQuery("#locationboxTrigger").hide();
	      	jQuery("#overlayer").show();
	      	var DOCHEIGHT = jQuery(document).height();
	      	jQuery("#overlayer").css("height", DOCHEIGHT-135);
	    });
	    
	    jQuery("#locationboxTrigger2").click(function(){

			if (document.getElementById('flashMap') == null) {
				jQuery("#locationBox .inner").hide();
		      	jQuery("#site").css("margin-top", 0);
		      	jQuery("#overlayer").hide();
		      	jQuery("#locationboxTrigger").show();
		     }
		     else {
		     	// Reload page if Flashmap visible
		     	document.getElementById('frm').submit();
		     }
	    });
   }
    else {
	    jQuery("#locationboxTrigger").click(function(){
	      jQuery("#locationBox .inner").slideDown(500);
	      jQuery("#site").animate({marginTop: '137'}, 400, function() {
	      	jQuery("#overlayer").fadeIn(300);
	      	var DOCHEIGHT = jQuery(document).height();
	      	jQuery("#overlayer").css("height", DOCHEIGHT-135);
	      });
	      
	    });
	    
	    jQuery("#locationboxTrigger2").click(function(){
		    jQuery("#overlayer").fadeOut(300, function() {
		      	jQuery("#locationBox .inner").slideUp(500);
		      	jQuery("#site").animate({marginTop: '0'}, 550);
		      });

			// Reload page if Flashmap visible
		    if (document.getElementById('flashMap') != null) {
				document.getElementById('frm').submit();
		    }
		});
	}
});
