// page initialization
$(document).ready(function(){


	pid = $('body').attr("class");
	
	resizer(pid);
	
	$(window).bind("resize", function(){
    	resizer(pid);
	});


	var isIE6 = ('ActiveXObject' in window && !('XMLHttpRequest' in window));

	if (isIE6) $(document).pngFix(); 

	if (pid == "eoyhome") {

		if (isIE6) {
			$('div#bigpix').show();
			$('div#bigpicture').show();
			$('div#bigpicture div.quoteBox').show();
			$('div#bigpicture div.donateBox').show();
		} else {
			$('div#bigpix div#bigpicture').fadeIn(1500);		
			st = setTimeout("startFader()",3000);
		}
			
	} else if ((pid == "eoypregnant") || (pid == "eoychildbirth")) {
		
		$('div.quoteBox').cycle({ 
			fx:      'fade', 
			timeout: 2500,
			speed:   750,
			random:  0,
			pause:   0,
			autostop: 3
		}); 
	
	}
	
	
});

function resizer(p) {

	var browserwidth = $(window).width();
	var browserheight = $(window).height();
	
	$("div#foreground").width(browserwidth);
	
	$("div#foreground div.stripBox").width(browserwidth);
	
	$("div#bigpix").width(browserwidth);
	$("div#bigpix").height(browserheight);

	if ((p == "eoydonation") && (browserwidth < 990)) {
		$("div#bigpicture").width("990");
		$("div#contentBox").width("990");
	} else {
		$("div#bigpicture").width(browserwidth);
	}
	$("div#bigpicture").height(browserheight);
	

	$("div#bigpicture2").width(browserwidth);
	$("div#bigpicture2").height(browserheight);
	
	if ((p == "eoypregnant") || (p == "eoychildbirth") || (p == "eoydonation")) {
		$("div#bigpicture div.contentBox").width(browserwidth);
	}
	
	$("div#bigpicture3").width(browserwidth);
	$("div#bigpicture3").height(browserheight);
	
	if (p == "eoyhome") {
		t = Math.round(browserheight*3/5);
		tp = t + "px";
		$("div.quoteBox").css({'margin-top':tp});
	} else {
		t = Math.round(browserheight*1.6/5);
		tp = t + "px";
		$("div.quoteBox").css({'margin-top':tp});
	}
}

function startFader() {

	$('div#bigpix div div').fadeIn(1500);

	$('div#bigpix').cycle({ 
		fx:      'fade', 
		timeout: 4000,
		speed:   1250,
		random:  0,
		pause:   0
	}); 

}

function rndm(n) { return Math.round((Math.random())*n); }
