var open = false;

function ShowFlashPopup(url) {//function called when the user clicks on a thickbox link
	if(!open && document.documentElement.clientWidth > 945)
	{
	    try {
               open = true;
               if(document.getElementById("PageBanner") != null)
								document.getElementById("PageBanner").style.display='none';
               document.getElementById("flashsmall_1").style.display='none';
               
                
		        $("body").append("<div id='TB_window'></div>");
		        $(window).resize(TB_remove);
        	
	            var imgPreloader = new Image();
		        imgPreloader.onload = function(){

		        TB_WIDTH = 763;
		        TB_HEIGHT = 100;
        		
	            $("#TB_window").append("<div id='flash_large' style=\"1000\"><p align='right'>"
                                            + "<object width='752' height='187'>"
                                            + "<param name='movie' value='" + url + "'>"
                                            + "<embed src='" + url + "' width='752' height='189'>"
                                            + "</embed>"
                                            + "</object>"
                                         + "</p></div>"
                        + "<div id='TB_closeWindow' style=\"width:727px; height:30px;vertical-align:bottom;\"><table height=30px align=right><tr><td valign=bottom><a alignt=right href='#' id='TB_closeWindowButton'>close</a></td></tr></table></div>"); 
		        $("#TB_closeWindowButton").click(TB_remove);
		        TB_position();
    		    
    		   /*if(navigator.appName == "Microsoft Internet Explorer")
		            $("#TB_window").show("fast");
		        else
		       */     $("#TB_window").show();
		    }
      
		    imgPreloader.src = '/img/arrow_off.gif';
    		
		    
    		
	    } catch(e) {
		    alert( e );
	    }
	}
}

function ShowImagePopup(url, width, height)
{
	if(!open && document.documentElement.clientWidth > 945 )
	{
	    try 
	    {
				open = true;
        //if(document.getElementById("PageBanner") != null)
				//	document.getElementById("PageBanner").style.display='none';
        //document.getElementById("tb-image").style.display='none';
                     
        $("body").append("<div id='TB_window'></div>");
		    $(window).resize(TB_removeImg);
        	
	      var imgPreloader = new Image();
		    imgPreloader.onload = function()
		    {
					TB_WIDTH = width + 10;
		      TB_HEIGHT = height + 10;
	        		
					$("#TB_window").append("<div id='image_large' ><p align='right'>"
												 + "<img src='" + url + "' width='"+width+"' height='"+height+"' alt='' /></p></div>"
												 + "<div id='TB_closeWindow' style=\"width: "+(TB_WIDTH-35)+"px; height:30px;vertical-align:bottom;\"><table height=30px align=right><tr><td valign=bottom><a alignt=right href='#' id='TB_closeWindowButton'>close</a></td></tr></table></div>"); 
					$("#TB_closeWindowButton").click(TB_removeImg);
					TB_positionImg();
	    		    
    			if(navigator.appName == "Microsoft Internet Explorer")
						$("#TB_window").show("fast");
					else
						$("#TB_window").show();
		    }
				imgPreloader.src = '/img/arrow_off.gif';
	    } 
	    catch(e)
	    {
		    alert( e );
	    }
	}
}


//helper functions below
function TB_remove() {
	
	$('#TB_window').remove();
	if(document.getElementById("PageBanner") != null)
		document.getElementById("PageBanner").style.display='';
	document.getElementById("flashsmall_1").style.display='';	
	open = false; 
	return false;
}

function TB_position() {
	var de = document.documentElement;
	var w = (de&&de.clientWidth) || document.body.clientWidth;
	var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;

  	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.scrollMaxY;
  	}
	
	$("#TB_window").css({width:TB_WIDTH+"px",height:TB_HEIGHT+"px",
	left: ((w - TB_WIDTH)/2)+91+"px", top: "109px" });
	
	
	
	if(de.clientWidth < 960)
	{
	    
	    window.resizeTo(960,800);
	    
	}
	
	
	
	window.scroll(0,0);
	
	
	
	
	
}

function TB_removeImg() {
	
	$('#TB_window').remove();
	//document.getElementById("tb-image").style.display='';
	//if(document.getElementById("PageBanner") != null)
	//	document.getElementById("PageBanner").style.display='';
	open = false; 
	return false;
}

function TB_positionImg() {
	var de = document.documentElement;
	var w = (de&&de.clientWidth) || document.body.clientWidth;
	var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;

  	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.scrollMaxY;
  	}
	
	if(document.getElementById("PageBanner") != null)
		$("#TB_window").css({width:TB_WIDTH+"px",height:TB_HEIGHT+"px",
		left: ((w - TB_WIDTH)/2)+91+"px", top: "251px" });
	else
		$("#TB_window").css({width:TB_WIDTH+"px",height:TB_HEIGHT+"px",
			left: ((w - TB_WIDTH)/2)+91+"px", top: "109px" });
//		left: ((w - TB_WIDTH)/2)+91+"px", top: "137px" });
	
	if(de.clientWidth < 960)
	   window.resizeTo(960,800);
	
	window.scroll(0,0);
}


