// JavaScript Document
function _clientHeight()
{
	varmyHeight = 0;
	
	if( typeof window.innerHeight != 'undefined' ) 
	{
		//Non-IE
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

function _clientWidth() 
{
	var myWidth = 0, myHeight = 0;
	
	if( typeof window.innerWidth != 'undefined' )
	{
		//Non-IE
		myWidth = window.innerWidth;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

//function addEvent(obj, event_name, func_name)
//{
//	if (obj.attachEvent)
//	{
//		obj.attachEvent("on"+event_name, func_name);
//	}
//	else if(obj.addEventListener)
//	{
//		obj.addEventListener(event_name,func_name,true);
//	}
//	else
//	{
//		obj["on"+event_name] = func_name;
//	}
//}

var timeoutID;
var intBackColor = 0;
var timeoutBackColor;

function _LoadFreeTrial()
{
	var isLoggedIn = document.getElementById('<%=hdnIsLoggedIn.ClientID %>').getAttribute("value");
	var isError = document.getElementById('<%=hdnError.ClientID %>').getAttribute("value");
	
	if(isError == "1")
	{
		_openErrorFading();
	}
	else
	{
		if(isLoggedIn == "0")
			timeoutID = setTimeout("_openFading( )", 500);
	}
}

function _openFading()
{
	var divLoginRegistrationBackground = document.getElementById("divLoginRegistrationBackground");
	var divLoginRegistration = document.getElementById("divLoginRegistration");
	
	divLoginRegistrationBackground.style.width = (document.body.clientWidth) + 'px';
//	divLoginRegistrationBackground.style.height = (document.body.clientHeight + 100) + 'px';
	divLoginRegistrationBackground.style.height = _clientHeight()+'px';//(document.body.clientHeight + 100) + 'px';

	
	divLoginRegistration.style.top = ((parseFloat(_clientHeight()) - 550)) + 'px';
	divLoginRegistration.style.left = ((parseFloat(_clientWidth()) - 470)) + 'px';
	
	divLoginRegistrationBackground.style.MozOpacity = ".01";
	divLoginRegistrationBackground.style.filter = "alpha(opacity=1)";
	divLoginRegistrationBackground.style.display = "block";
	
	divLoginRegistrationBackground.style.zIndex = "11000";
	divLoginRegistration.style.zIndex = "11001";
	divLoginRegistrationBackground.focus();
	
	clearTimeout(timeoutID);
	
	timeoutBackColorID = setTimeout("_goDarkBackgound( )", 100);
}

function _goDarkBackgound()
{
	var divLoginRegistrationBackground = document.getElementById("divLoginRegistrationBackground");
	var divLoginRegistration = document.getElementById("divLoginRegistration");
	
	if(intBackColor <= 60)
	{
		var strBackColor = "0" + intBackColor;
		if(strBackColor.length > 2)
		{
			divLoginRegistrationBackground.style.MozOpacity = "." + intBackColor;
			divLoginRegistrationBackground.style.opacity = "." + intBackColor;
		}
		else
		{
			divLoginRegistrationBackground.style.MozOpacity = "." + strBackColor;
			divLoginRegistrationBackground.style.opacity = "." + strBackColor;
		}
		divLoginRegistrationBackground.style.filter = "alpha(opacity=" + intBackColor + ")";
		
		
		//intBackColor++;
		intBackColor = intBackColor + 2;
		timeoutBackColorID = setTimeout("_goDarkBackgound( )", 10);
	}
	else
	{
		divLoginRegistration.style.display = "";
		clearTimeout(timeoutBackColorID);
		return;
	}
}
function getxmlobj()
{
		var xmlhttp1=null;
		if (window.XMLHttpRequest)
		{
			xmlhttp1=new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
		}
		return xmlhttp1;
}
function closewindow()
{

	xmlhttp1=getxmlobj();
	if (xmlhttp1!=null)
	{
		var url1="index.aspx";
		xmlhttp1.onreadystatechange=funhandler2
									
		xmlhttp1.open("GET",url1,true);
		xmlhttp1.send(null);
	}	
	document.getElementById("divLoginRegistrationBackground").style.display="none";
	document.getElementById("divLoginRegistration").style.display="none";
}
function funhandler2()
{
			if (xmlhttp1.readyState==4)
			{///do something
				if (xmlhttp1.status==200)
				{	
					var temp=xmlhttp1.responseText;
					if(temp==1)
					document.getElementById('sitestate_img').src="adminsection/images/orange_light.gif";
					if(temp==2)
					document.getElementById('sitestate_img').src="adminsection/images/red_light.gif";
				}
			}	
			
}
function login(frm)
{
	if(trim(frm.txtusername.value)=="")
	{
		alert("Please enter username.");
		frm.txtusername.focus();
		return false;
	}
	
	if(trim(frm.txtpassword.value)=="")
	{
		alert("Please enter password.");
		frm.txtpassword.focus();
		return false;
	}
	
	return;
}
function opensubwindow(filepath)
{
	document.getElementById('frpopup').src = filepath;
	intBackColor = 0;
	timeoutID = setTimeout("_openFading( )", 500);
}
