var ie_pathToImage = "http://virtualevaluator.com/images/loadingAnimation.gif";
/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
//on page load call tb_init
$(document).ready(function(){   
  ie_init('a.ieLB, area.ieLB, input.ieLB');//pass where to apply thickbox
  imgLoader = new Image();// preload image
  imgLoader.src = ie_pathToImage;
});
//add thickbox to href & area elements that have a class of .thickbox
function ie_init(domChunk){
  $(domChunk).click(function(){
  var t = this.title || this.name || null;
  var a = this.href || this.alt;
  var g = this.rel || false;
  ie_show(t,a,g);
  this.blur();
  return false;
  });
}
function ie_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
  try {
    if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
      $("body","html").css({height: "100%", width: "100%"});
      $("html").css("overflow","hidden");
      if (document.getElementById("IE_HideSelect") === null) {//iframe to hide select elements in ie6
        $("body").append("<iframe id='IE_HideSelect'></iframe><div id='IE_overlay'></div><div id='IE_window'></div>");
        //$("#TB_overlay").click(tb_remove);
      }
    }else{//all others
      if(document.getElementById("IE_overlay") === null){
        $("body").append("<div id='IE_overlay'></div><div id='IE_window'></div>");
        //$("#TB_overlay").click(tb_remove);
      }
    }
    
    if(ie_detectMacXFF()){
      $("#IE_overlay").addClass("IE_overlayMacFFBGHack");//use png overlay so hide flash
    }else{
      $("#IE_overlay").addClass("IE_overlayBG");//use background and opacity
    }
    
    if(caption===null){caption="";}
    $("body").append("<div id='IE_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
    $('#IE_load').show();//show loader
     
      IE_WIDTH = 750; //defaults to 630 if no paramaters were added to URL
      IE_HEIGHT = 568; //defaults to 440 if no paramaters were added to URL
      ajaxContentW = IE_WIDTH - 40;
      ajaxContentH = IE_HEIGHT - 45;
      
	$("#IE_iframeContent").remove();
	$("#IE_window").append("<div id='IE_closeAjaxWindow'><a href='#' id='IE_closeWindowButton' title='Close'><img src='http://parkingestimator.com/engine/images/TBClose.jpg' alt='Close'></a></div><iframe frameborder='0' hspace='0' src='"+ url +"' id='IE_iframeContent' name='IE_iframeContent"+Math.round(Math.random()*1000)+"' onload='ie_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' scrolling='no' > </iframe>");

	$("#IE_closeWindowButton").click(ie_remove);
	
	ie_position();
	
	if($.browser.safari){//safari needs help because it will not fire iframe onload
		$("#IE_load").remove();
		$("#IE_window").css({display:"block"});
	}
	
  } catch(e) {
    //nothing here
  }
}     
  
//helper functions below
function ie_showIframe(){
  $("#IE_load").remove();
  $("#IE_window").css({display:"block"});
}
function ie_remove() {
   $("#IE_imageOff").unbind("click");
  $("#IE_closeWindowButton").unbind("click");
  $("#IE_window").fadeOut("fast",function(){$('#IE_window,#IE_overlay,#IE_HideSelect').trigger("unload").unbind().remove();});
  $("#IE_load").remove();
  if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
    $("body","html").css({height: "auto", width: "auto"});
    $("html").css("overflow","");
  }
  document.onkeydown = "";
  document.onkeyup = "";
  return false;
}

function ie_position() {
$("#IE_window").css({marginLeft: '-' + parseInt((IE_WIDTH / 2),10) + 'px', width: IE_WIDTH + 'px'});
  if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
    $("#IE_window").css({marginTop: '-' + parseInt((IE_HEIGHT / 2),10) + 'px'});
  }
}
function ie_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}
function ie_getPageSize(){
  var de = document.documentElement;
  var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
  arrayPageSize = [w,h];
  return arrayPageSize;
}
function ie_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}