
/*OpenDialog: opens given URL as dialog window - focus can't be set on parent until child is closed.*/

function WindowFocus(event)
{
    if(activeDialog)
    {
	    try
	    {
		    activeDialog.focus();
	    }
	    catch(e)
	    {
		    activeDialog = 0;
	    }
    }
}
function openDialog(strURL, title ,properties)
{
	window.onfocus = WindowFocus;
	activeDialog = window.open(strURL, title, properties);
	return true;
}

/* function for calculate resolution to fix flash animation in window.*/

function changeResolution(status)
{
	if(status == 1)
	{
		var width=screen.width*.165;
		var height=screen.height*.4555;
		document.getElementById('changeRes').style.top=width+'px';
		document.getElementById('changeRes').style.left=height+'px';
		document.getElementById('changeRes').style.display="block";
	}
}

/* function for Hide Flash Div*/

function hideFlashdiv()
{
	document.getElementById('changeRes').style.display="none";	
}


/* function for open open online chat details url */


function openURL()
{
	openDialog('http://68.178.136.254/Jabber/InputForm.aspx','chatwindow','width=506px,height=475px');
	if(document.getElementById('changeRes'))
		document.getElementById('changeRes').style.display="none";
}

/* Function for Page Header */

function fnPageHeader(authenFlag,status)
{
	var ImageStr="";
	
		if(status == 1)
			ImageStr += "<img border='0' usemap='#Map' style='cursor:pointer' src='../../templates/vernalis/images/online.jpg' >";
		else if(status == 0)
			ImageStr += "<img border='0' usemap='#Map' style='cursor:pointer' src='../../templates/vernalis/images/offline.jpg' onclick=\"openDialog('../../modules/mod_customfooter/offlineDetails.php','chatOfflineWindow','width=488px,height=510px');\">";
		else
			ImageStr += "<img border='0' usemap='#Map' style='cursor:pointer' src='../../templates/vernalis/images/offline.jpg' onclick=\"openDialog('../../modules/mod_customfooter/offlineDetails.php','chatOfflineWindow','width=488px,height=480px');\">";
		// to show status image (online or offline)
		
		document.getElementById("statusImg").innerHTML = ImageStr;
		
		/*HeaderStr = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr>";
		HeaderStr += "<div id='productsandservices' class='yuimenubar'><div class='bd'><ul class='first-of-type'><li class='yuimenubaritem first-of-type'><a href='../home/index.php'>Home</a></li><li class='yuimenubaritem'><a href='../business-services/business-services.php'>Services</a></li><li class='yuimenubaritem'><a href='../products/vernalis-products.php'>Products</a></li><li class='yuimenubaritem'><a href='../vernalis-contact/contact-us.php'>Contact Us</a></li></ul></div></div></td>";
		if(authenFlag == 1)
			HeaderStr+= "<td>&nbsp;&nbsp;<a href='../home/listBackOffice.php' class='c'>Back Office</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='../home/logOut.php' class='c'>Log out</a>&nbsp;&nbsp;|</td>";
		
		HeaderStr += "</tr></table>";
		//alert(HeaderStr);
		
		document.getElementById("top_link").innerHTML = HeaderStr;*/
}

var req = false;
var doesNotSupport = true;
var RequestReady = 4;
var browser = navigator.appName; //find the browser name

if(browser == "Microsoft Internet Explorer")
{
	/* Create the object using MSIE's method */
	try
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		alert(e.message);
	}
}
else
{
	/* Create the object using other browser's method */
	try
	{
		req = new XMLHttpRequest();
	}
	catch(e)
	{
		alert(e.message);
	}
}	

var getAuthenFlag;
var getResolutionFlag;
function statusCheck(authenFlag, resolutionFlag)
{
	getAuthenFlag=authenFlag;
	getResolutionFlag=resolutionFlag;
	if (req)
	{
		req.open('POST',  '../home/index.php');  // We send the request using post method
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send('statusFlag=1');
		req.onreadystatechange = processReqChange;
	}
	else
	{
		 alert("Your browser does not support XMLHttpRequest technology!");
		 doesNotSupport = false;
	}
}

function processReqChange()
{
	if (req.readyState == 4)
    {
    	var response = req.responseText;    	
    	fnPageHeader(getAuthenFlag,response);
		if(getResolutionFlag == 1) //show online div in index page only
			changeResolution(response);
	}
	
}

