// JavaScript Document//clear text box on click
function clearText(field){

if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue;

}



// Cufon

	//Cufon.replace('h1')/*('h2')('h3')('h4')*/('blockquote')('div.text-right p');
	//Cufon.replace('.cufon-font', {hover: true});

	
	
// Blend Images on Hover
$(document).ready(function(){
	$(".homepage-content-box a").blend();
	$(".s02-content-box a").blend();
	$(".the-team-content-box a").blend();
	

});


$(function(){

    $("ul.dropdown li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
	
		$('#masonry').mouseleave(function(){
			//console.log("2");
			$("#masonry a img").each(function(){
				$(this).animate({opacity: 1},300);
			});
		});
		$('#masonry').mouseenter(function(){
			//console.log("1");
			$("#masonry a img").each(function(){
				//$(this).animate({opacity: 0.5},200);
			});
		});
	
	$('#masonry').masonry({ columnWidth: 2 }).find("a img").css("opacity",1)
		.mouseover(function(){
			$(this).animate({opacity: 1},100);
			var bright = this;
			//console.log(this);
			$("#masonry a img").each(function(){
				if(bright != this){
					//console.log(this);
					$(this).animate({opacity: 0.5},200); 
				}
			});
			//$(this).css({opacity: 1},400);
		}).mouseout(function(){
			//$(this).animate({opacity: 0.5},400);
			//$('#masonry a img').css({opacity: 1},400);
			//$('#masonry a img').css({opacity: 0.5},400);
			//console.log("1");
		});
	/*$('#masonry').mouseover(function(){
			$('#masonry').css({opacity: 0.5},400);
		});*/

	
	
		$('.recipes-gallery').mouseleave(function(){
			//console.log("2");
			$(".recipes-gallery a").each(function(){
				$(this).animate({opacity: 1},300);
			});
		});
	
	$('.recipes-gallery').find("a").css("opacity",1)
		.mouseover(function(){
			$(this).animate({opacity: 1},100);
			var bright = this;
			//console.log(this);
			$(".recipes-gallery a").each(function(){
				if(bright != this){
					//console.log(this);
					$(this).animate({opacity: 0.5},200); 
				}
			});
			//$(this).css({opacity: 1},400);
		}).mouseout(function(){
			//$(this).animate({opacity: 0.5},400);
			//$('#masonry a img').css({opacity: 1},400);
			//$('#masonry a img').css({opacity: 0.5},400);
			//console.log("1");
		});
	
	
	window.setTimeout("refreshmasonry()",500);
	window.setTimeout("refreshmasonry()",1000);
	window.setTimeout("refreshmasonry()",2000);
});

/* Breakfast and lunchbox content popup displays modal window of content pulled from web store */
/* Breakfast and lunchbox content popup displays modal window of content pulled from web store */
$(function(){
	$("#showPopup, #showPolicy").click(function(event){
		event.preventDefault();
		//alert("click");
		$("#wrapper").append("<div id='contentPopup'><a id='closePopup' href='#'>X</a><div id='contentPopupContent'><div class='ajaxLoading'></div></div></div>");
		//$("#contentPopupContent").load("/index.php?pageID=13145&merchant_id=0  #page-content-box>*");
		$("#contentPopupContent").load(this.href+"  #page-content-box>*");
		return false;
	});
	$('#closePopup').live('click', function() {
	  $("#contentPopup").remove();
	});
});



$(function(){
	$("#ContinueBookingCheckBox").live('click',function(){
		$("#booking_frm_ctn").removeClass("hide");
		$("#contentPopup").remove();
	});
});


function refreshmasonry() {
	$('#masonry').masonry("refresh");
}



/* - SCROLLPANE
 * =============
 */

$(function() {
			$('#pane1').jScrollPane({showArrows:true, scrollbarWidth:14, scrollbarMargin:0});
			$('#pane2').jScrollPane({showArrows:true, scrollbarWidth:14, scrollbarMargin:0});
			//$('div.right-info').jScrollPane();
});


$(function(){
	$(".form-inner p a.arr_a").click(function(){
		window.scroll(0,0);
		$(".form-rhs").removeClass("hide");
	});
	
	$(".each_job .arr_a").click(function(){
		var targ = $(this).parent().parent().parent().find("h3").text();
		$(".each_job h3").each(function(){
			//var pos = $(this).text();
			//$("input[name=field_878]").val(pos);
		});	
		$("input[name=field_878]").val(targ).focus();
		window.scroll(0,0);
		$(".form-rhs").removeClass("hide");
		return false;
	});	
});

$(function(){
	$(".form-inner p a.arr_a").click(function(){
		window.scroll(0,0);
		$(".form-rhs").removeClass("hide");
	});
	
	$(".each_job .arr_a").click(function(){
		var targ = $(this).parent().parent().parent().find("h3").text();
		$(".each_job h3").each(function(){
			//var pos = $(this).text();
			//$("input[name=field_878]").val(pos);
		});	
		$("input[name=field_1035]").val(targ).focus();
		window.scroll(0,0);
		$(".form-rhs").removeClass("hide");
		return false;
	});	
});

/*
 * FORM UI
 * ------------------------------
 */

$(window).ready(function(){
	$("#form-outer :text, #form-outer textarea, #form-outer :password").focus(function(){
		$(this).parent().find("label.mouseover").hide();
	}).blur(function(){
		validateLabelDisplay(this);
	}).each(function(){
		validateLabelDisplay(this);
	});

	
	
	function validateLabelDisplay(field) {
		if ( field.value.replace(/\s*/g,"")=="" ) {
			$(field).parent().find("label.mouseover").show();
		} else {
			$(field).parent().find("label.mouseover").hide();
		}
	}

});

