	var subNavTimeout = null;
	var subNavTimeout2 = null;


	function viewVideo(src)
	{
	
		testwindow= window.open ("/videoplayer/videos.php?src=" + escape(src) , "mywindow", "location=0,status=0,scrollbars=0,width=380,height=320");

	}
	
	function highlight(divname, link)
	{		
		document.getElementById("sub_nav_brands").style.visibility = 'hidden';
		document.getElementById("sub_nav_sizes").style.visibility = 'hidden';
		
		document.getElementById("sub_nav_aboutus").style.visibility = 'hidden';
		document.getElementById("sub_nav_sleepcenter").style.visibility = 'hidden';
		
		var div = document.getElementById(divname);
		div.style.visibility = 'visible';
		div.onmouseout= function() {prolongSubNav();}
		div.onmouseover= function() {dontHideSubNav();}
		
		dontHideSubNav();
		link.onmouseout = function () { subNavTimeout2 = setTimeout("hideSubNav()", 2000); }
		clearTimeout(subNavTimeout);
	}
	
	function hideSubNav()
	{
		document.getElementById("sub_nav_brands").style.visibility = 'hidden';
		document.getElementById("sub_nav_sizes").style.visibility = 'hidden';
		
		document.getElementById("sub_nav_aboutus").style.visibility = 'hidden';
		document.getElementById("sub_nav_sleepcenter").style.visibility = 'hidden';
		
		try 
		{
			sectionMenuDisplay();
		} catch (e) { }
		
	}
	
	function prolongSubNav()
	{
		clearTimeout(subNavTimeout);
		subNavTimeout = setTimeout("hideSubNav()", 1000);
	}
	
	function dontHideSubNav()
	{
		clearTimeout(subNavTimeout);
		clearTimeout(subNavTimeout2);
	}
	
	function sectionMenuDisplay()
	{
		document.getElementById("sub_nav_home").style.visibility = 'visible';
	}
	
	function toggleModifySearch()
	{
		var myRow = document.getElementById("modify_search_row");
		if (myRow.className == 'hiddenRow')
			myRow.className = '';
		else 
			myRow.className = 'hiddenRow';
	}
	
	function trackEvent(a, b)
	{
		if (a.length > 28)
		{
			var fpm_img = new Image();
			fpm_img.src = a;

		}
		if (b.length > 31)
		{
			var atlas_img = new Image();
			atlas_img.src = b;
		}
		/*if (a == 'http://www.flyingpt.com/pix_373') 
		{
			setTimeout("window.location='/redirectors/20061222_holidaysealy.php';", 1000);
		}*/
	}
	
	function validatezip()
	{
			if (document.frmstore.zip.value.length !=5 || isNaN(document.frmstore.zip.value))
			{
				alert ("Please enter a valid 5 digit zip code");		
				document.frmstore.zip.focus();
				return false;
			}
			document.frmstore.submit();
	}
	
	function validateemail()
	{
			var EMAIL = "^[a-zA-Z0-9_-]+(\.([a-zA-Z0-9_-])+)*@[a-zA-Z0-9_-]+[.][a-zA-Z0-9_-]+([.][a-zA-Z0-9_-]+)*$";
	  		var re = new RegExp(EMAIL);
	
	  		if (!document.frmspecoffer.email.value.match(re)) 
			{
				alert('Please enter a valid email address.');
	  			document.frmspecoffer.email.focus();
	  			return false;
			
			}				
			document.frmspecoffer.submit();
	}
	
	function validateSendToFriend()
	{
	
			var EMAIL = "^[a-zA-Z0-9_-]+(\.([a-zA-Z0-9_-])+)*@[a-zA-Z0-9_-]+[.][a-zA-Z0-9_-]+([.][a-zA-Z0-9_-]+)*$";
	  		var re = new RegExp(EMAIL);
	  			  			
	  		if (!document.frmsendemail.emailto.value.match(re)) 
			{
				alert('Please enter a valid email address.');
	  			document.frmsendemail.emailto.focus();
	  			return false;		
			}					
			
			if (!document.frmsendemail.emailfrom.value.match(re)) 
			{
				alert('Please enter a valid email address.');
	  			document.frmsendemail.emailfrom.focus();
	  			return false;		
			}			
			
			if (document.frmsendemail.sendername.value =="") 
			{
				alert('Please enter your name.');
	  			document.frmsendemail.sendername.focus();
	  			return false;		
			}
						
			if (document.frmsendemail.message.value =="") 
			{
				alert("Please enter the cover message.");
	  			document.frmsendemail.message.focus();
	  			return false;		
			}
			
			if (document.frmsendemail.message.value.length > 1000) 
			{				
				alert("The Cover message cannot exceed 1000 characters.");
	  			document.frmsendemail.message.focus();
	  			return false;		
			}	
			
			document.frmsendemail.submit();
	}
	
	
	function specialOfferSignup(frm)
	{
		if (frm.sleepyemail.value.length == 0)
		{
			alert("Please enter your e-mail address.");
			return false;
		}
		// submit this email via ajax...
		new Ajax.Request("/widgets/specialoffers.php?email=" + escape(frm.sleepyemail.value));
		
		$('newsletterBar').innerHTML = '&nbsp;';
		$('newsletterBar').style.background = "url('/images/newsletter_bar_thx.gif')";
		
		//var specialOffers = new Image();
		//specialOffers.src = 'http://www.flyingpt.com/pix_10';
		return false;
	}
	
	function launchJobApplication()
	{
		
		window.open('/downloads/EmploymentApplication.pdf', '_blank');
	}
	
