// JavaScript Document

$(document).ready(function(){
	$('div#container').pngFix( );
	$("a#mailto-f").attr({ 
          href: "mailto:?body=" + location.href
        });
	$("a#mailto-a").attr({ 
          href: "mailto:?subject=Feelgood sleep&body=I was reading about how important sound sleep is for health and wellbeing. I thought you might be interested in learning how it's possible to wakeup feeling like it's the beginning of the day and not the end. http://www.feelgoodsleep.com"
        });
	if (bRunRooster) {
		setInterval(runRooster, iJSRoosterRotationTime);
	}
});

/* menu */

$(document).ready(function(){
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function(){ $("ul", this).hide(); }
	);
if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

/* ch img */

function runRooster() {
	  $('img#bg_ch_div').fadeOut('slow', function(){
			$('img#bg_ch_div').attr('src', ''+aRoosterImages[nCurrentItem]+'');
			$('img#bg_ch_div').fadeIn('slow');
		});
	  
  if (nCurrentItem >= aRoosterImages.length - 1) {
    nCurrentItem = 0;
  } else {
    nCurrentItem++;
  }
}

var iJSRoosterRotationTime = 5000;
var bRunRooster     = true;
var aRoosterImages  = new Array('images/bg_cont_pic/bg_index_1.jpg','images/bg_cont_pic/bg_index_2.jpg','images/bg_cont_pic/bg_index_3.jpg');
var nCurrentItem    = 0;


function openWindow(strURL,strFeatures)
{
  window.open(strURL,'',strFeatures);
}

