
//when doc is ready
$(document).ready(function(){

  //fade in content
  $("#mainContent img").hide().fadeIn(700);

  //hilite current link in navbar
  $("*").find("a").each(function(){
		if(window.location.href==this.href || $(this).hasClass("current")){
			$(this).addClass("current");
			$(this).removeClass("rollme");
			
			if (this.id=='menu_logo')
				return;
			
			//change background image to match id
			if(this.id!=''){
				$(this).css('background-image', 'url(common/'+this.id+'_down.png)');
			}
			//change child images
			$(this).children('img').each(function(index) {
   				this.src = this.src.replace(".png","_down.png");
			});
		}
	});
  
  
	//open external links in new window
	$('a[href^="http://"]').attr("target", "_blank");
	$('a[href^="https://"]').attr("target", "_blank");
  
  	//skip rollovers on iphone
  	var useragent = navigator.userAgent;
	var mapdiv = document.getElementById("map_canvas");
	var isIphone =  (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 )

	if (isIphone)
		return;

  //adjust links around rolled images
  $("img.rollme").each(
			function(){
			thisParent=$(this).parent('a');
			thisParent.css('display','inline-block');
			//thisParent.css('width',this.width).css('height',this.height);
			thisParent.css('background','url('+this.src+') no-repeat');
			});
  
  //make image rollable
  $("img.rollme").hover(
		function() {
			//do nothing on down state
			if(this.src.indexOf('_down')>0)
				return;
  			this.src = this.src.replace(".png","_roll.png");
  			this.src = this.src.replace(".jpg","_roll.jpg");
  			$(this).fadeOut(0).fadeIn(200);
 		},
 		function(){
  			this.src = this.src.replace("_roll.png",".png");
  			this.src = this.src.replace("_roll.jpg",".jpg");
  			//$(this).fadeOut(200); //.fadeIn(200);
 		}
	);
/*
  $("a.rollme").hover(
		function() {
			$(this).addClass("hover");
			$(this).css('background-image', 'url(common/'+this.id+'_roll.png)');
  			$(this).hide().fadeIn(200);
 		},
 		function(){
			$(this).removeClass("hover");
  			//$(this).fadeOut(500);
			$(this).css('background-image', 'url(common/'+this.id+'.png)');
 		}
	);
*/

  // make FAQ questions expandable
  //$("*").find("a.question").click( faqOpen ) ;
  
  
});
