// JavaScript Document
function ShowContent(file_name)
{	
	if(document.getElementById('div_window'))
	{
		var dobj = document.getElementById('div_window');
		
		if(dobj.style.display == "none")
		{
			dobj.style.display = "block";
			ToggleComboBoxVisibility(false);
		}

		div_ht = 270;
		div_wt = 496;
		
		dobj.style.top = divY(div_ht);
		dobj.style.left = divX(div_wt);

		var iobj = document.getElementById("iframe_content");
		iobj.src = file_name;
//		var url_str = file_name+"&";
//		var myRandom=parseInt(Math.random()*99999999);  // cache buster
	
//		alert(file_name +"?rand=" + myRandom);
//		http.open("POST", file_name +"?rand=" + myRandom, true);
//		http.onreadystatechange = handleHttpStatusResponse;
//		http.send(null);
	}
}

function handleHttpStatusResponse()	// return type flag~id~display string
{
	if (http.readyState == 4)
	{
		//alert(http.responseText);
		result_str = http.responseText;

//		if(results[0]==1) // only if successful...
//		{
			document.getElementById("div_window").innerHTML=http.responseText;
//		alert(result_str);
//		var iobj = document.getElementById("iframe_content");
//		iobj.src = result_str;
//		}
  	}
}

function HideContent()
{
	if(document.getElementById('div_window'))
	{
		var dobj = document.getElementById('div_window');
		
		if(dobj.style.display == "block")
		{
			dobj.style.display = "none";
			ToggleComboBoxVisibility(true);
		}
	}
}
function ToggleComboBoxVisibility(disp_flag)
{
	visibility_mode = (disp_flag)? "visible": "hidden";

	for(var i = 0; i < document.forms.length; i++) 
		for(var j=0; j < document.forms[i].elements.length; j++)
			if(document.forms[i].elements[j].type == 'select-one')
				document.forms[i].elements[j].style.visibility = visibility_mode;
}

function divX(div_width) // width
{
	var screen_width = (screen.width);
	var width_offset = posLeft();
	var x = (width_offset + (screen_width/2) - (div_width/2));
	return x;
}

function divY(div_height) // height
{
	var screen_height = (screen.height - 100);
	var height_offset = posTop();
	var y = height_offset + (screen_height/2) - (div_height/2);
	return y;
}

function posTop() 
{
	return (typeof window.pageYOffset != 'undefined') 
			? window.pageYOffset : (document.documentElement && document.documentElement.scrollTop) 
									? document.documentElement.scrollTop: document.body.scrollTop;
}

function posLeft() 
{
	return (typeof window.pageXOffset != 'undefined') 
			? window.pageXOffset : (document.documentElement && document.documentElement.scrollLeft) 
									? document.documentElement.scrollLeft: document.body.scrollLeft;
}

function SetCss(td_obj, css_nm)
{
//	alert(css_nm);
	if(!td_obj || !css_nm)
		return false;
		
	td_obj.className = css_nm;
}
