// JavaScript Document

IE = document.all?true:false;
isNN=!document.all&&document.getElementById;
	
ResponseText = "";

function makeRequest(url, targetID) {
	
  var xmlHttp;
  try {
	xmlHttp=new XMLHttpRequest();
    }
  catch (e){
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e){
      try{
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e){
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function(){
      if(xmlHttp.readyState==4)
        if (xmlHttp.status == 200) {
			if (targetID != ""){
			 if (document.getElementById){
				 target = document.getElementById(targetID);
                 target.innerHTML = xmlHttp.responseText;
				 	$(document).ready(function(){ 
        		 		$(document).pngFix(); 
    			 	});
					if (document.getElementById("Window_Inner")){
						var divHeight = parseInt(document.getElementById("Window_Inner").style.height.replace('px',''));
						if (document.getElementById("lightbox")){
							document.getElementById("lightbox").style.height = divHeight-72+"px";
						}
						if (document.getElementById("lightbox_scroll")){
							document.getElementById("lightbox_scroll").style.height = divHeight-122+"px";
						}
					}
			 }
			}
			if (xmlHttp.responseText != ''){
			}
            } else {
                alert('There was a problem with the request.');
            }
      }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
  }
  
  function makeRequestSJAX(url, targetID) {
  var xmlHttp;
  try {
	xmlHttp=new XMLHttpRequest();
    }
  catch (e){
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e){
      try{
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e){
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
  if (xmlHttp) {
     xmlHttp.open("GET", url, false);                             
     xmlHttp.send(null);
	 if (xmlHttp.status == 200) {
	if (targetID != ""){
	if (document.getElementById){
	 target = document.getElementById(targetID);
     target.innerHTML = xmlHttp.responseText;
	 	$(document).ready(function(){ 
     		$(document).pngFix(); 
    	});
		if (document.getElementById("Window_Inner")){
						var divHeight = parseInt(document.getElementById("Window_Inner").style.height.replace('px',''));
						if (document.getElementById("lightbox")){
							document.getElementById("lightbox").style.height = divHeight-72+"px";
						}
						if (document.getElementById("lightbox_scroll")){
							document.getElementById("lightbox_scroll").style.height = divHeight-122+"px";
						}
					}
	}
	}
	 }else {
     alert('There was a problem with the request.');
	 return false;
    }
  } else {
     alert("Your browser does not support AJAX!");
        return false;
  }                                             
}

function hideElements(action) { 
		if (navigator.appName.indexOf("MSIE")) {
			for (var i = 0; i < document.forms.length; i++){
				for (var e = 0; e < document.forms[i].length; e++) {
					if (document.forms[i].elements[e].options) {
						document.forms[i].elements[e].style.visibility = action;
					}
				}
			}
		}
}

function showWindow(URL, Width, Height, hideEle, hideEleType){
	
	 if (document.getElementById){
		 
		hideElements("hidden");
					   
		var Body = document.getElementById('Body');
		var scrollHeight = document.body.scrollTop;
		var scrollWidth = document.body.scrollLeft;

		var newDiv = document.createElement('div');
		newDiv.setAttribute("id","newWindow");
		if (IE) {newDiv.setAttribute("className","window");} else {newDiv.setAttribute("class","window");}
		
		Body.appendChild(newDiv);
		
		newDiv.style.marginTop = parseInt(scrollHeight)+"px";
		newDiv.style.marginLeft = parseInt(scrollWidth)+"px";
		
		document.getElementById('Body').style.overflow = 'hidden';
		
		var innerDiv = document.createElement('div');
		innerDiv.setAttribute("id","Window_Inner");
		if (IE) {innerDiv.setAttribute("className","window_body");} else {innerDiv.setAttribute("class","window_body");}
		
		Body.appendChild(innerDiv);
		
		innerDiv.style.width = IE ? parseInt(Width-0+53)+"px" : parseInt(Width-0+43)+"px";
		innerDiv.style.height = Height+"px";
		innerDiv.style.marginLeft = IE ? -parseInt(Width/2)+parseInt(scrollWidth)+"px" : -parseInt(Width/2)+parseInt(scrollWidth)+"px";
		if (Height >= 400){
			innerDiv.style.marginTop = IE ? -parseInt((Height/2))+parseInt(scrollHeight)+"px" : -parseInt((Height/2))+parseInt(scrollHeight)+"px";
		} else {
			innerDiv.style.marginTop = IE ? -parseInt((Height/2))+parseInt(scrollHeight)+"px" : -parseInt((Height/2)+60)+parseInt(scrollHeight)+"px";
		}
		
		innerDiv.innerHTML = "<div id=\"Window_Right\"><span id=\"close_window\"><a href=\"Javascript:void(0)\" onClick=\"closeWindow('',false,'','');\"><img src=\"/images/lightbox_close.png\" border=\"0\" width=\"43\" height=\"43\"></a></span></div><div id=\"lightbox_top\"></div><div id=\"lightbox\" style=\"height: "+(Height-72)+"px;\"></div><div id=\"lightbox_bottom\"></div>";
		
		preLoader("lightbox");
		
		makeRequestSJAX(URL, "Window_Inner");
		
		document.getElementById("lightbox").style.height = Height-72+"px";
		document.getElementById("lightbox_scroll").style.height = Height-122+"px";
		
		}
	}
	
function showWindowWide(URL, Width, Height, hideEle, hideEleType){
	
	 if (document.getElementById){
		 
		hideElements("hidden");
					   
		var Body = document.getElementById('Body');
		var scrollHeight = document.body.scrollTop;
		var scrollWidth = document.body.scrollLeft;

		var newDiv = document.createElement('div');
		newDiv.setAttribute("id","newWindow");
		if (IE) {newDiv.setAttribute("className","window");} else {newDiv.setAttribute("class","window");}
		
		Body.appendChild(newDiv);
		
		newDiv.style.marginTop = parseInt(scrollHeight)+"px";
		newDiv.style.marginLeft = parseInt(scrollWidth)+"px";
		
		document.getElementById('Body').style.overflow = 'hidden';
		
		var innerDiv = document.createElement('div');
		innerDiv.setAttribute("id","Window_Inner");
		if (IE) {innerDiv.setAttribute("className","window_body");} else {innerDiv.setAttribute("class","window_body");}
		
		Body.appendChild(innerDiv);
		
		innerDiv.style.width = IE ? parseInt(Width-0+53)+"px" : parseInt(Width-0+43)+"px";
		innerDiv.style.height = Height+"px";
		innerDiv.style.marginLeft = IE ? -parseInt(Width/2)+parseInt(scrollWidth)+"px" : -parseInt(Width/2)+parseInt(scrollWidth)+"px";
		if (Height >= 400){
			innerDiv.style.marginTop = IE ? -parseInt((Height/2))+parseInt(scrollHeight)+"px" : -parseInt((Height/2))+parseInt(scrollHeight)+"px";
		} else {
			innerDiv.style.marginTop = IE ? -parseInt((Height/2))+parseInt(scrollHeight)+"px" : -parseInt((Height/2)+60)+parseInt(scrollHeight)+"px";
		}

			innerDiv.innerHTML = "<div id=\"Window_Right\"><span id=\"close_window\"><a href=\"Javascript:void(0)\" onClick=\"closeWindow('',false,'','');\"><img src=\"/images/lightbox_close.png\" border=\"0\" width=\"43\" height=\"43\"></a></span></div><div id=\"lightbox_top_wide\"></div><div id=\"lightbox_wide\" style=\"height: "+(Height-72)+"px;\"></div><div id=\"lightbox_bottom_wide\"></div>";
		
		preLoader("lightbox_wide");
		
		makeRequestSJAX(URL, "Window_Inner");
		
		document.getElementById("lightbox_wide").style.height = Height-72+"px";
		document.getElementById("lightbox_scroll_wide").style.height = Height-122+"px";
		
		}
	}
	
function showVideo(URL, Width, Height, hideEle, hideEleType){
	
	 if (document.getElementById){
		 
		hideElements("hidden");
					   
		var Body = document.getElementById('Body');
		var scrollHeight = document.body.scrollTop;
		var scrollWidth = document.body.scrollLeft;

		var newDiv = document.createElement('div');
		newDiv.setAttribute("id","newWindow");
		if (IE) {newDiv.setAttribute("className","window");} else {newDiv.setAttribute("class","window");}
		
		Body.appendChild(newDiv);
		
		newDiv.style.marginTop = parseInt(scrollHeight)+"px";
		newDiv.style.marginLeft = parseInt(scrollWidth)+"px";
		
		document.getElementById('Body').style.overflow = 'hidden';
		
		var innerDiv = document.createElement('div');
		innerDiv.setAttribute("id","Window_Inner");
		if (IE) {innerDiv.setAttribute("className","window_body");} else {innerDiv.setAttribute("class","window_body");}
		
		Body.appendChild(innerDiv);
		
		innerDiv.style.width = IE ? parseInt(Width-0+53)+"px" : parseInt(Width-0+43)+"px";
		innerDiv.style.height = Height+"px";
		innerDiv.style.marginLeft = IE ? -parseInt(Width/2)+parseInt(scrollWidth)+"px" : -parseInt(Width/2)+parseInt(scrollWidth)+"px";
		if (Height >= 400){
			innerDiv.style.marginTop = IE ? -parseInt((Height/2))+parseInt(scrollHeight)+"px" : -parseInt((Height/2))+parseInt(scrollHeight)+"px";
		} else {
			innerDiv.style.marginTop = IE ? -parseInt((Height/2))+parseInt(scrollHeight)+"px" : -parseInt((Height/2)+60)+parseInt(scrollHeight)+"px";
		}
		
		innerDiv.innerHTML = "<div id=\"Video_Right\"><span id=\"video_close\"><a href=\"Javascript:void(0)\" onClick=\"closeWindow('',false,'','');\"><img src=\"/images/lightbox_close.png\" border=\"0\" width=\"43\" height=\"43\"></a></span></div><div id=\"Video_Left\" style=\"width: "+(Width-0)+"px; height: "+(Height-0)+"px;\"></div>";
		
		preLoader("Video_Left");
		
		makeRequestSJAX(URL, "Window_Inner");
		
		}
	}
	
function closeWindow(URL,DoNotShow,showEle,showEleType){
		
	hideElements("visible");
		
	if (document.getElementById){
	var Body = document.getElementById('Body');
	var oldDiv = document.getElementById("newWindow");
	Body.removeChild(oldDiv);
	var oldDiv = document.getElementById("Window_Inner");
	Body.removeChild(oldDiv);
	document.getElementById('Body').style.overflow = '';
	}
}

function preLoader(targetID){
	document.getElementById(targetID).innerHTML = "<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"enlarge_table\"><tr><td><img src=\"/images/ajax-loader.gif\"></td></tr></table>"
}
