//shared global vars
_jhtml = new Array();


//Global vars
_sp = new Array();
_spop = new Array();
_spL = null;
_wlc = String(window.location);
_futuredate = new Date(Date.parse("Jan 1, 2999"));

_aGn = new String(navigator.userAgent);
_aGn = _aGn.toLowerCase();
_deskL = screen.width;
_deskT = screen.height;

_hsT = location.host;
_hsP = location.pathname;
_hspro = location.protocol;
_BASE = _hspro+"//"+_hsT+"/";
ali = null;

function play(GAME, W, H)
{
//W=W+200;
	var now = new Date();
	var mm = now.valueOf();	
	
	if(GAME=="chess")
	{
	//W = W + 100;
	}
	//else if(GAME=="8ball")
	//{
	H = H + 40;
	//}
	//
	
	
	var ITFOLDER = 'http://www.alilg.com/p/gameplay.php?W='+W+'&&H='+H+'&&game='+GAME+'&&aid=8&mx='+mm+'';
	var _newin = window.open(ITFOLDER,GAME, "menubar=no,width="+W+"px,height="+H+"px,toolbar=no,status=no,resizable=no,top=100px,left=100px,scrollable=no,location=no,addressbar=no");
}

function alilg()
{
	this._j2htm = function(item)
	{
		if(_e(item))
		_e(item).innerHTML = _jhtml[item];
	}
	this.webtop = function(item)
	{
		alert('Loading my alilg-webtop');
	}
	this.access = function(ITEM,H,W,ID,aid,URL)
	{
		var L = (_deskL-W)/2;
		var T = (_deskT-H)/4;
		T = T - 30;
		
if(ITEM=='multichess')
		{
			ITFOLDER = "/"+ITEM+"/"+ID+"/";
		}
else if(ITEM=='chesssuper')
		{
			ITFOLDER = "/gameplay.php?aid="+aid;
			
			
			var now = new Date();
			ITFOLDER = "/gameplay.php?aid="+aid+"&&mx="+now.valueOf();
		}
		else
		{
			ITFOLDER = "/"+ITEM+"/?ID="+ID+"&&aid="+aid;;
		}


//if(ITEM=='chesssuper')
//{
//var _newin = window.open(ITFOLDER,ITEM, "menubar=no,width="+W+"px,height="+H+"px,toolbar=no,status=yes,resizable=yes,top="+T+"px,left="+L+"px,scrollbars=yes,location=no,addressbar=no");
//}
//else
//{
var _newin = window.open(ITFOLDER,ITEM, "menubar=no,width="+W+"px,height="+H+"px,toolbar=no,status=yes,resizable=no,top="+T+"px,left="+L+"px,scrollable=no,location=no,addressbar=no");
//}		
		
		if(!_newin)
		{
			this.popupblocked(ITEM)
		}
		else
		{
			//_newin.window.focus()
		}
	}
	
	this.popupblocked = function(item)
	{
		alert(item+" popup box blocked by your popup clock blocker, please turn it off and try again")
	}
	this._jmenu = function(targ,selObj,restore)
	{
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if(restore)
		{
			selObj.selectedIndex=0;
		}
	}
	this.readmore = function()
	{
		
	}
	
	this.download = function(item, _id)
	{
		if(item.toLowerCase() == 'alinegar')
		{
			window.location = _BASE+'win_software.php?download=1&&id='+_id;
			return;
		}
		_e('tos').innerHTML = _jhtml['loading'];
		this.ajax(_BASE+"software.php?term="+item, "http", "DOWN_tos", "get");
	}
	
	this.downloaded = function()
	{
		_e('SBT').disabled = 'disabled';
		_e('SBT').value='Downloading...';
		setTimeout('_e(\'SBT\').style.backgroundImage=\'url(img/span_bt_bg_down.gif)\'',100)
	}
	
	this.clear = function()
	{
		ssession('cmname', "", new Date(0), "/");
		ssession('cmhome', "", new Date(0), "/");
		ssession('remme', "nope", _futuredate, "/");
		_e('cmname').value = "";
		_e('cmhome').value = "";
		_e('remme').checked = "";
	}
	


	this.ajaxto = function(item, _c)
	{
		if(item == "favc")
		{
			aliFA.favc(_c);
		}
		else if(item == "DOWN_tos")
		{
			_e('tos').innerHTML = _c;
			_e('tos').scrollIntoView();
		}
	}
	


	this.los = function(item)
	{
		return item.toLowerCase();
	}
	
	this.get_http = function()
	{
		if (typeof XMLHttpRequest != "undefined")
		{
			return new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			var aVersions = [ "MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
			for (var i = 0; i < aVersions.length; i++)
			{
				try {	var oXmlHttp = new ActiveXObject(aVersions[i]);
				return oXmlHttp;
				} catch (oError)
				{
					
				}
			}
		}
		else
		{
			alert("NO XML SUPPORT");
			return;
		}
	}
	
	this.iexml = function()
	{
		var aVersions = [ "MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", 
						 " MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument"," Microsoft.XmlDom"];
		for (var i = 0; i < aVersions.length; i++)
		{
			try
			{
				var oXmlDom = new ActiveXObject(aVersions[i]);
				return oXmlDom;
			}
			catch (oError)
			{
				
			}
		}
		throw new Error("MSXML is not installed.");
	}
	
	this.ajax = function(xml_url, kind, ajaxfor, method)
	{
		this._kind = kind;
		this._ajaxfor = ajaxfor;
		XMLOBJECT = new this.get_http();
		
		XMLOBJECT.open(method, xml_url, true);
		if(method=="post")
		{
			XMLOBJECT.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		}
		
		
		XMLOBJECT.onreadystatechange = function ()
		{
			if (XMLOBJECT.readyState == 4)
			{
				if (XMLOBJECT.status == 200)
				{
					if(method == "get")
					{
					if(ali._kind == "http")
					{
						var ajaxed = XMLOBJECT.responseText;
					}
					else if(ali._kind == "xml")
					{
						if(_aGn.indexOf("msie") != -1 && _aGn.indexOf("opera") == -1)
						{
							var ajaxed = ali.iexml();
							ajaxed.loadXML(XMLOBJECT.responseText);
						}
						else
						{
							var ajaxed = XMLOBJECT.responseXML;
						}
					}
					}
					else
					{
						if(_aGn.indexOf("msie") != -1 && _aGn.indexOf("opera") == -1)
						{
							var ajaxed = ali.iexml();
							ajaxed.loadXML(XMLOBJECT.responseText);
						}
						else
						{
							var ajaxed = XMLOBJECT.responseXML;
						}
					}
					ali.ajaxto(ali._ajaxfor, ajaxed);
				}
			}
		}
		if(method == "get")
		{
			var narenjack = null;
		}
		else
		{
			var rrm = document.forms[0];
			var m = grb(rrm);
			var narenjack = m;
		}
		XMLOBJECT.send(narenjack);
	}
	

}

function alilg_pub()
{
	return "pub-6989666508364537";
}

function _e(item)
{
	var _i = document.getElementById(item);
	return _i;
}

function body_onload()
{
	



	ali = new alilg();
	//ali._j2htm('sponsor');
	//ali._j2htm('copyright');
	//ali._j2htm('myims');
	
	if(_e('login-form'))
	{
		_e('login-form').innerHTML = '<form action="" method="post" align="center" name="loginForm" id="loginForm"><div class="top-login" align="center"><table width="340" border="0" cellpadding="0" cellspacing="0" style="margin-top:2px;"><tr><td><div style="width:132px;height:26px;background-image:url(\'img/login-bg.gif\');" id="div-login-login"><input type="text" name="nickname" onfocus="_e(\'div-login-login\').style.backgroundPosition = \'0px 26px\'" style="width:132px;height:26;background-color:Transparent;border:solid 0px #d3d3d3;color:#6b6b6b;padding:4px;" /></div></td><td><div style="width:132px;height:26px;background-image:url(\'img/login-bg.gif\');background-position:0px -26px;" id="div-login-pass"><input type="password" name="pass"  onfocus="_e(\'div-login-pass\').style.backgroundPosition = \'0px 26px\'" style="width:132px;height:26;background-color:Transparent;border:solid 0px #d3d3d3;color:#6b6b6b;padding:4px;" /></div></td><td><div style="width:64px;height:26px;background-image:url(\'img/login-bg-go.gif\');"><input type="submit" name="login" value="Login" style="width:64px;height:26px;background-color:Transparent;border:solid 0px #d3d3d3;color:#6b6b6b;padding:4px;" /></div></td></tr></table><table width="300" border="0" cellpadding="0" cellspacing="0" style="margin-top:2px;"><tr><td style="white-space:nowrap"><input type="checkbox" checked="checked" name="reme" value="1" />&nbsp;</td><td style="white-space:nowrap">Remember me | <a target="_blank" href="http://www.alilgtalk.com/member.php?action=register">Register</a> | <a target="_blank" href="http://www.alilgtalk.com/member.php?action=lostpw">Forgot your password?</a></td><td width="99%"></td>  </tr></table></div></form>';
	}
	
	setTimeout(cleanlogin, 1000);
	
}

$redofadeOBJ = null;
$redofade_NO = 0;


_jhtml['copyright'] = '<div style="padding:5px">Copyright &copy; 2006-2010 <a href="http://www.alilg.com">AlilG Application</a> | All Rights Reserved | All Games and Software Developed by alilg.com</div>';


_jhtml['loading'] = '<div style="padding:5px;" align="left"><img src="img/loading.gif" alt="" align="middle" /> Getting contents... please wait!</div>';


function cleanlogin()
{
	if(document.loginForm)
	{
	if(document.loginForm.nickname.value!=='')
	_e('div-login-login').style.backgroundPosition = '0px 26px';
	
	if(document.loginForm.pass.value!=='')
	_e('div-login-pass').style.backgroundPosition = '0px 26px';
	}
}

