// simple light box
/* when document is ready (fully loaded) blind to classes and id for functionality */
$(document).ready(function(){
			/* single out special links */
			$("area.litePanel").bind("click", function(e){ e.preventDefault();dc();})
			/* for text usage */
			$(".getCont").bind("click", function(e){ e.preventDefault(); this.blur(); launchInter(this.href);})
			/* for image usage */
			$(".imgP").bind("click", function(e){ e.preventDefault(); this.blur(); launchInter2(this.href);})
			/* for closing the model */
			$(".closeit").bind("click", function(e){ resetIt(); this.blur();})
			$("#overlay").bind("click", function(e){ resetIt(); this.blur();})
			/* add an alignment fix for the mac with firefox and safari, for powered by link */
			if($.client.os=="Mac"){
					if($.client.browser=="Firefox"){
							$("head").append('<link rel="stylesheet" href="/common/styles/firefox.mac.css" type="text/css" media="screen" />');
						}
					if($.client.browser=="Safari"){
						$("head").append('<link rel="stylesheet" href="/common/styles/safari.mac.css" type="text/css" media="screen" />');
						}
				}
		});


/* resize overlay if window size changes and overlay is display block */
$(window).resize(function() {
		if(document.getElementById("overlay").style.display == "block"){			  
 			 $("#overlay").css({width:$(window).width()+"px",height:$(window).height()+"px"});
			 figureWindowWidth=($(window).width()-560)/2;
			 $("#interLayer").css({display:"block", left:figureWindowWidth+"px", top:sc+"px", width: "560px"});
		}
});

   
  

/* functionality for ajax bring in basic rental information and repair service information */
function launchInter(links){
	/* set height from top of page */
	sc=$(document).scrollTop()+80;
	/* unhide overlay */
	$("#overlay").css({width:$(window).width()+"px",height:$(window).height()+"px",display:"block",opacity:0});
	/* bring opacity up from 0 to needed opacity */
	$("#overlay").animate({opacity:.43},400);
	/* center the model in window */
	figureWindowWidth=($(window).width()-560)/2;
	/* place model */
	$("#interLayer").css({display:"block", left:figureWindowWidth+"px", top:sc+"px", width: "560px"});
	/* split the url for content */
	splitURL=links.split("#");
	/* set up url for model load of jquery */
	fixURL=splitURL[0]+" #"+splitURL[1];
	/* load text content via ajax and jquery's load functionality */
	$('#middleCont').load(fixURL);
	$('#tempcont').load(fixURL, function(){animateIt()});
	fixHi="#"+splitURL[1];
	
	fixHi=fixHi.toString();
	/* to figure out height, must wait a short time for div to be populated */
	//setTimeout("animateIt()", 125);
	
	}
	
/* functionality for images to be brought in */
function launchInter2(links){
	/* set height from top of page */
	sc=$(document).scrollTop()+40;
	/* unhide overlay */
	$("#overlay").css({width:$(window).width()+"px",height:$(window).height()+"px",display:"block",opacity:0});
	/* bring opacity up from 0 to needed opacity */
	$("#overlay").animate({opacity:.43},400);
	/* center the model in window */
	figureWindowWidth=($(window).width()-560)/2;
	/* place model */
	$("#interLayer").css({display:"block", left:figureWindowWidth+"px", top:sc+"px", width: "560px"});
	/* place code for image */
	$('#middleCont').html('<div align="center"><img class="theImage" onload="animateIt2()" src="'+links+'" align="center" style="margin:0px auto 0px auto" alt="" /></div>');
	
	
	/* to figure out height, must wait a short time for div to be populated */
	//setTimeout("animateIt2()", 125);
	
	}
	
function animateIt(theDivHi){
	//display content
	$('#middleCont').css({display:"block"});
	/* quickly animate to correct height for image or text */
	$('#middleCont').animate({height:$("#tempcont").height()+"px"}, 500);
	}
	
function animateIt2(theDivHi){
	//display content
	$('#middleCont').css({display:"block"});
	/* quickly animate to correct height for image or text */
	$('#middleCont').animate({height:$("#middleCont img").height()+"px"}, 500);
	}
	
function resetIt(){
	/* animate the close */
	$('#middleCont').animate({height:"0px"}, 500);
	/* animate overlay opacity to 0 */
	$("#overlay").animate({opacity:0},700);
	/* same amount of time as animations */
	setTimeout("resetIt2()", 500);
	}
	
function resetIt2(){
	/* close the overlay and interlayer, clear out content */
	$("#overlay").css({display:"none"});
	$("#interLayer").css({display:"none"});
	
	$('#middleCont').html();
	$("#middleCont").css({height:"0px"});
	$('#middleCont').css({display:"none"});
	}

/* allow esc key to close model (currently doesn't work on firefox) */
$(document).keyup(function() {
  if (event.keyCode == 27) {
    /* animate the close */
	$('#middleCont').animate({height:"0px"}, 500);
	/* same amount of time as animations */
	setTimeout("resetIt2()", 500)
   }
});
/* special stuff */
function dc(){
		var datas=$("area.litePanel").attr("href");
		datas=datas.split('.html')
		datas=$.base64Decode(datas[0]);
		//alert(datas);
		window.location=datas;
		
	}
