/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
		  
var tb_pathToImage = "jsp/img/ajax-loader.gif";
var IE = false;

function wait(message)
{
	var v='hidden'
	if (message == null)
	{
		message = 'waiting';
	}
	tb_show(message, 'jsp/img/ajax-loader.gif');
	if (IE == false)
	{
		visibility(v);
	}
}

function stop()
{
	window.jQuery('#TB_overlay').hide();
	window.jQuery('#TB_load').hide();
	window.jQuery('#TB_window').hide();	
	window.jQuery('#TB_HideSelect').hide();	
	if (IE == true)
	{
		document.getElementById("TB_HideSelect").style.visibility = 'hidden';		
	}	
	else
	{
		var v='visible';
		visibility(v);
	}

}


function tb_show(caption, url) {//function called when the user clicks on a thickbox link
	try {
		if (typeof document.body.style.maxHeight === "undefined") 
		{//if IE 6
			//window.jQuery("body","html").css({height: "100%", width: "100%"});
			//window.jQuery("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) 
			{//iframe to hide select elements in ie6
				window.jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");	
				IE = true;			
			}
			else
			{
				window.jQuery('#TB_HideSelect').show();
				window.jQuery('#TB_overlay').show();
				window.jQuery('#TB_window').show();
				if (IE == true)
				{
					document.getElementById("TB_HideSelect").style.visibility = 'visible';			
				}
			}
		}
		else
		{//all others
			if(document.getElementById("TB_overlay") === null)
			{
				window.jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
			}
			else
			{
				window.jQuery('#TB_overlay').show();
				window.jQuery('#TB_window').show();	
			}
		}
		
		if(tb_detectMacXFF())
		{			
			window.jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}
		else
		{
			window.jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		
		if(caption===null)
		{
			caption="";
		}
		window.jQuery("body").append("<div id='TB_load'><img src='"+url+"' /></div>");//add loader to the page
		window.jQuery('#TB_load').show();
	} 
	catch(e)
	{
		//nothing here		
	}
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}


function visibility(h){
	tag=document.getElementsByTagName('select');
	
	for(i=tag.length-1; i>=0; i--)
	{
		tag[i].style.visibility=h;
	}
	
	tag=document.getElementsByTagName('iframe');
	for(i=tag.length-1;	i>=0; i--)
	{
		tag[i].style.visibility=h;
	}
	tag=document.getElementsByTagName('object');
	for(i=tag.length-1;	i>=0; i--)
	{
		tag[i].style.visibility=h;
	}
}


