
var ie6;

$(document).ready(function() {
	
	// js/jquery.pngFix.js	
	$(document).pngFix(); 
	
	// initialize lightbox for the whole website.
	$(".myGalleries a[rel^='prettyPhoto']").prettyPhoto({
		theme:'dark_rounded',
		default_width: 688,
		show_title: false
		});
	
	 // stick the footer to the very bottom of the viewing window.
    $(function(){
	positionFooter(); 
	function positionFooter(){
		$("#footer").css({position: "absolute",top:($(window).scrollTop()+$(window).height()-$("#footer").height())+"px"})	
	}
 
	$(window)
		.scroll(positionFooter)
		.resize(positionFooter)
	});
	
	ie6 = $.browser.msie && parseInt($.browser.version) === 6 && typeof window['XMLHttpRequest'] !== "object";

	if (!ie6) {  
	
	// animate logo...
	$('#logo').hide();
	$('#logo').show('puff', { percent: 200 }, 1000);
	$('#logo').effect('bounce', { times: 4 }, 100);
	}
   
	
});

	
	var counter = 0;
	// make sure slide 2 is hidden.
	$('#homepageChips2').hide();	

	
 function startUp() {
	 //shakeItUp('homepageChips');
	 //setInterval("shakeItUp('homepageChips')",10000);
	 }
	
 function shakeItUp(myElement) {
	 
	 var elementToShake = '#' + myElement;
	 var elementToShake2 = elementToShake + '2';
	 var boolMainMode = false;  
	 	//alert(counter % 2 == 0);
		 if (counter % 2 == 0 || counter == 0)  {
		 // use main element...
		 
		 mainElement = elementToShake;
		 nextElement = elementToShake2;
		 boolMainMode = true;
		 
		 }
		 else {
		 mainElement = elementToShake2; 
		 nextElement = elementToShake;
		 boolMainMode = false;
		 }
		 
		// alert(mainElement + " | " + nextElement);
		if (boolMainMode) {
		 $(mainElement).effect('shake', { times: 4 }, 50).delay(100).fadeOut("slow");
		 
		 $(nextElement).delay(400).fadeIn("slow");
		}
		else {
		  $(mainElement).hide('scale', {  }, 200);
		 
		  $(nextElement).delay(300).show('scale', {  }, 100);
		}
		 
		 
	counter++;
   }
   
function homepageAnimations() {
	
	

	$('#welcomeMessage').hide();
	$('#welcomeMessage').delay(4300).show('slide', { direction: 'right' }, 1000);
	$('.welcomeMessageContent').delay(5500).effect('highlight', {'color' : '#333'},1000);

	if (!ie6) { 
	//$('#welcomeMessage').effect('bounce', { times: 2 }, 100);	
	$('#homepageImage').hide();
	//$('#homepageImage').fadeIn('slow');
	$('#homepageImage').show('puff', {  percent: 200  }, 1000);
	//$('#homepageImage').effect('bounce', { times: 4 }, 100);
	
	// set chips to shake occasionally...
	//shakeItUp('homepageChips');
	
	setTimeout("startUp()",5000);
	}
}


function repositionElements() {
	
	//alert($(window).width());
	
	var windowWidth = $(window).width()
	var widthDiff = '';
	var finalPosition = '';
	// position we want 940
	if (windowWidth <= 1000) { 
	finalPositionRight = '900px';
	finalPositionLeft = '-100px';
	}
	else
	{
	finalPositionRight = ((windowWidth - 960)/2) + 900 + 'px';
	finalPositionLeft = ((windowWidth - 960)/2) - 100 + 'px';
	}
	$('#frog').css('left',finalPositionRight);
	$('#leavesRight').css('left',finalPositionRight);
	$('#leavesLeft').css('left',finalPositionLeft);
	

}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
