// JavaScript Document
$(document).ready(function(){
						   
	$('#Tellafriend').jqm({ajax: '/clientdata/tellafriend.php', trigger: 'a.jqTellafriend', toTop: true, onLoad: tellFriendLoad});	
	
	function tellFriendLoad(){
		$('#frmTellAFriend').submit(function(){								 
			var thisForm = $(this);		
			
			if($('#your_email').val()==''){
				alert('You must enter an email address.');
				$('#your_email').focus();
				return false;
			}
			
			$.ajax({
				type: 'post',
				url: thisForm.attr('action'),
				data: thisForm.serialize(),
				success: function(results){
					$('#Tellafriend').html(results);	
					$('.jqmClose').click(function(){
						$('#Tellafriend').jqmHide();
					});
				}
			});
			return false;
		});		
	}
	
	//********************* Holiday Shipping ***********************/s
	
	var divClosed = true;
	if( divClosed == true) {

		var location = window.location.href;
		var turduckenPage =  false;
		var checkoutPage = false;
		
		
		//alert(location);
		if (location.lastIndexOf('turducken') > 0) {
			turduckenPage = true;
		}		
		
		if (location.lastIndexOf('checkout') > 0) {
			checkoutPage = true;
		}	
		
		
		if (turduckenPage == true ) {
			//alert('turducken page');
			if (getTurduckenCookie() == false) {
				
				$('#holidayDropdown').slideDown(2000);
				divClosed = false;
				setTurduckenCookie();
			} 
			
		}
		
		else if (checkoutPage == true ) {
			//alert('checkout page');
			if (getCheckoutCookie() == false) {
				
				$('#holidayDropdown').slideDown(2000);
				divClosed = false;
				setCheckoutCookie();
			} 
			
		}
		else {
			//alert('else');
			$('#holidayDropdown').slideDown(2000);
			divClosed = false;
		}
	
	}
	
	$('#closeDropdown').click(function(){
		if( divClosed == false) {
			$('#holidayDropdown').slideUp(2000);	
		}
	});	
		
	
	$('#bizrate').jqm({ajax: '/clientdata/bizrate.html', trigger: 'a.jqBizrate', toTop: true});
	$('#meetmarcelle').jqm({ajax: '/clientdata/meetmarcelle.html', trigger: 'a.jqMeetMarcelle', toTop: true});
	$('#Sharethis').jqm({ajax: '/clientdata/bizrate.html', trigger: 'a.jqSharethis', toTop: true});	
						  
	$(".delta,.deltaOpen").bind("click", function menuBind(){
	
			var showMenu = $(this).attr("id");
			var openMenu = $(".deltaOpen");
			
			if (openMenu.attr("id")!=showMenu){
				if (openMenu.attr("id")){	//if another menu is open, close it
					$("." + openMenu.attr("id")).hide("slow");
					openMenu.removeClass("deltaOpen");		
					openMenu.addClass("delta");	
				}
				$(this).removeClass("delta");
				//$(this).unbind()
				$(this).addClass("deltaOpen"); 
				$("." + showMenu).show("slow");
			}
			else{	
				if ($(this).attr("id")){	//if menu open, close it
					$("." + $(this).attr("id")).hide("slow");
					$(this).removeClass("deltaOpen");		
					$(this).addClass("delta");	
					$(this).unbind("click", openMenuBind());
				}
			}
	 });
});

function FP_openNewWindow(w,h,nav,loc,sts,menu,scroll,resize,name,url) {	//v1.0
	var windowProperties='';
	if(nav==false) 
	windowProperties+='toolbar=no,';
	else
	windowProperties+='toolbar=yes,';
	
	if(loc==false) 
		windowProperties+='location=no,';
	else 
		windowProperties+='location=yes,';
	if(sts==false) 
		windowProperties+='status=no,';
	else 
		windowProperties+='status=yes,';
	if(menu==false) 
		windowProperties+='menubar=no,';
	else 
		windowProperties+='menubar=yes,';
	if(scroll==false)
		windowProperties+='scrollbars=no,';
	else
		windowProperties+='scrollbars=yes,';
	if(resize==false) 
		windowProperties+='resizable=no,';
	else
		windowProperties+='resizable=yes,';
	if(w!="")
		windowProperties+='width='+w+',';
	if(h!="")
		windowProperties+='height='+h;
	if(windowProperties!="") {
		if( windowProperties.charAt(windowProperties.length-1)==',') 
			windowProperties=windowProperties.substring(0,windowProperties.length-1);} 
	window.open(url,name,windowProperties);
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());

}

function getCookie(c_name) {
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
	return "";
}

function setTurduckenCookie(){
	var cookie = getCookie("turducken");
	if(cookie.length == 0){
		setCookie('turducken','visitedthispage',50);
	}
}
function getTurduckenCookie(){
	var cookie = getCookie("turducken");

	if(cookie.length > 0)
		return true;
	else	
		return false;
}

function setCheckoutCookie(){
	var cookie = getCookie("/checkout");
	if(cookie.length == 0){
		setCookie('checkout','visitedthispage',50);
	}
}
function getCheckoutCookie(){
	var cookie = getCookie("/checkout");

	if(cookie.length > 0)
		return true;
	else	
		return false;
}


