/* javascript */
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function setVisible(iPath,title_img) {
	grayOut(true);
        w = (f_clientWidth() - 350)/2;
        h = ((f_clientHeight()  - 350)/2) + f_scrollTop();
	newObj = document.getElementById('imgpop');

	if(!newObj)
		newObj = document.createElement("div");

	newObj.id = "imgpop";
	var myBody = document.getElementsByTagName("body")[0];
	myBody.appendChild(newObj);

	newObj.style.left = w + 'px' ;
	newObj.style.top = h + 'px' ;

	newObj.style.width = '350px';
//	newObj.style.height = '350px';
	newObj.style.borderColor = '#000';
	newObj.style.borderWidth = "1px";
	newObj.style.borderStyle = "solid";
	newObj.style.backgroundColor = '#73A9EB';
	newObj.style.position = "absolute";
	newObj.style.padding = "15px";
	newObj.style.zIndex = "60";

	newObj.innerHTML =
		'<p><img src="'+ iPath + '" class="img" width="345" /></p><p align="center"><b>'+title_img+'</b></p><p>' +
		'<a href="javascript:void(0);" onClick="rmLayer(\'imgpop\');">Close</a>';

	newObj.style.visibility = 'visible';
	document.getElementById('mymenus').style.display='none';
	newObj.style.display = 'block';
}

function rmLayer(divId) {
	oldObj = document.getElementById(divId);
	if(oldObj) {
		oldObj.style.display = 'none';
		delete oldObj;
	}
	document.getElementById('mymenus').style.display='';
	grayOut(false);
}

function grayOut(vis, options) {
// Pass true to gray out screen, false to ungray
// options are optional.  This is a JSON object with the following (optional) properties
// opacity:0-100         // Lower number = less grayout higher = more of a blackout
// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
// in any order.  Pass only the properties you need to set.
var options = options || {};
var zindex = options.zindex || 50;
var opacity = options.opacity || 70;
var opaque = (opacity / 100);
var bgcolor = options.bgcolor || '#000000';
var dark=document.getElementById('darkenScreenObject');
if (!dark) {
	// The dark layer doesn't exist, it's never been created.  So we'll
	// create it here and apply some basic styles.
	// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
	var tbody = document.getElementsByTagName("body")[0];
	var tnode = document.createElement('div');           // Create the layer.
	tnode.style.position='absolute';                 // Position absolutely
	tnode.style.top='0px';                           // In the top
	tnode.style.left='0px';                          // Left corner of the page
	tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
	tnode.style.display='none';                      // Start out Hidden
	tnode.id='darkenScreenObject';                   // Name it so we can find it later
	tbody.appendChild(tnode);                            // Add it to the web page
	dark=document.getElementById('darkenScreenObject');  // Get the object.
 }
 if (vis) {
	// Calculate the page width and height
	if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
		var pageWidth = document.body.scrollWidth+'px';
		var pageHeight = document.body.scrollHeight+'px';
	} else if( document.body.offsetWidth ) {
		var pageWidth = document.body.offsetWidth+'px';
		var pageHeight = document.body.offsetHeight+'px';
	} else {
		var pageWidth='100%';
		var pageHeight='100%';
	}
	//set the shader to cover the entire page and make it visible.
	dark.style.opacity=opaque;
	dark.style.MozOpacity=opaque;
	dark.style.filter='alpha(opacity='+opacity+')';
	dark.style.zIndex=zindex;
	dark.style.backgroundColor=bgcolor;
	dark.style.width= pageWidth;
	dark.style.height= pageHeight;
	dark.style.display='block';
} else {
	dark.style.display='none';
}
}
