
/*
	AJAX
*/

var __site = Array();
		/* ajax */
		__site['enabled']			= 1;
		__site['picture']			= '/misc/ajax.gif';
		__site['errorAJAX']		= 'Your browser does not support AJAX';
		__site['errorStatus']	= 'Error, please try later';
		__site['updateNow']		= 0;
		/* site conf */
		__site['headerLen'] 	= 10;
		__site['url']					= '';
		__site['f5']					= 'true';
		/* video player */
		__site['videoPlayer']	= '/misc/flvplayer.swf';
		__site['videoPlayerName'] = 'videoPlayer';
		__site['videoLocation'] = 'videoLocation';
		/* admin text */
		__site['adminText'] = 'fckeditor';
		/* where show loading */
		__site['defaultUpd']	= 'ajl';
		/* online list */
		__site['onlTimeout']	= 120000;
		/* ping */
		__site['pingTimeout']	= 40000;
		/* global messages */
		__site['globalMSGfield'] = 'globalMSG';
		__site['globalMSGshow']  = 1;
		/* enable Google stats */
		__site['google'] = 1;
		
function nulUrl() { __site['url'] = ''; }
function nulf5() { __site['f5'] = 'true'; }
		
function load(url, documentId, params) 
{
	/*
		create object
	*/
	var req;
	var reqTimeout;
	var method;
	if(params.length > 0)
	{
		method = "POST";
	}
	else
	{
		method = "GET";
		params = null;
	}
	req = null;
	if(window.XMLHttpRequest)
	{
		try 
		{
			req = new XMLHttpRequest();
		} catch (e){}
	} 
	else if(window.ActiveXObject) 
	{
		try 
		{
			req = new ActiveXObject('Msxml2.XMLHTTP');
		} 
		catch (e)
		{
			try 
			{
				req = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e){}
		}
	}
	/*
		if success
	*/
	if (req) 
	{
		req.onreadystatechange = function() 
		{
			var updFrame = (documentId.length > 0) ? documentId : __site['defaultUpd'];
			if(req.readyState == 4) 
			{
				clearTimeout(reqTimeout);
				try
				{
					document.getElementById(updFrame).innerHTML = '&nbsp;';
					if(documentId)
					{
						document.getElementById(documentId).innerHTML = (req.status == 200) ? req.responseText : __site["errorStatus"];
						var sRedir = document.getElementById('post_redirect');
						if(sRedir !=  null)
						{
							document.location.href = "#" + sRedir.innerHTML;
						}
					}
					else
					{
						if(req.status == 200)
						{
							var response = req.responseText;
							if(response.length > 0)
							{
								var header   = req.responseText.substring(0, __site["headerLen"]);
								header       = header.replace(/ /gi,"");
								response     = response.substring(__site["headerLen"], response.length);
								try
								{
									document.getElementById(header).innerHTML = response;
									// is Video
									var vpEl = document.getElementById(__site['videoPlayerName']);
									var vlEl = document.getElementById(__site['videoLocation']);
									if(vpEl != null && vlEl != null)
									{
										videoCreate(__site['videoPlayerName'], vlEl.innerHTML);
									}
									// is Admin text
									var adminText = document.getElementById(__site['adminText']);
									if(adminText != null)
									{
										loadFCKEditor();
									}
									// global msg
									var gHeader = document.getElementById('gbox_header');
									var gMessage = document.getElementById('gbox_message');
									var gMsgID = document.getElementById('gbox_mid');
									if(gHeader != null && gMessage != null && (__site['globalMSGshow'] == 1))
									{
										document.getElementById(__site['globalMSGfield']).style.display = 'block';
										document.getElementById('gboxs_header').innerHTML = gHeader.innerHTML;
										document.getElementById('gboxs_message').innerHTML = gMessage.innerHTML;
										document.getElementById('gboxs_mid').value = gMsgID.innerHTML;
									}
									gHeader = null; gMessage = null; gMsgID = null;
									// include google
									if(__site['google'] == 1)
									{
										urchinTracker('/virtual_ajax/' + url);
									}
								}
								catch (e) {}
							}
						}
					}
				} 
				catch (e){}
			}
			else
			{
				try
				{
					document.getElementById(updFrame).innerHTML = '<img src="' + __site["picture"] + '" alt="Loading..." align="center" />';
				} 
				catch (e){}
			}
		}
		req.open(method, url, true);
		if(method == "POST")
		{
			try
			{
				req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				req.setRequestHeader("Content-length", params.length);
				req.setRequestHeader("Connection", "close");
				if(__site['updateNow'] == 1)
				{
					nulf5();
					__site['updateNow'] = 0;
				}
			} catch(e) {}
		}
		req.send(params); 
		//sleep(1000);
		try
		{
			reqTimeout = setTimeout("req.abort();", 30000);
		} 
		catch (e) {}
	} 
	else 
	{
		alert(__site["errorAJAX"]);
  }
}

function send(elID, formID)
{
	var f = document.getElementById(formID);
	var s = '';
	if(!f) return 0;
	for(var i=0; i<f.elements.length; i++)
	{
		var c = 0;
		// type=radio
		if(f.elements[i].type == 'radio')
		{
			var radioObj = f.elements[i];
			if(radioObj.checked)
				s = s + radioObj.name + '=' + encodeURIComponent(radioObj.value) + '&';
			c++;
		}
		// type=select
		if(f.elements[i].type == 'select-one')
		{
			var selIndex = f.elements[i].selectedIndex;
			if(selIndex > -1) s = s + f.elements[i].name + '=' + encodeURIComponent(f.elements[i].options[selIndex].value) + '&';
			c++;
		}
		// type=checkbox
		if(f.elements[i].type == 'checkbox')
		{
			if(f.elements[i].checked==true) s = s + f.elements[i].name + '=' + encodeURIComponent(f.elements[i].value) + '&';
			c++;
		}
		// type=button, type=submit
		if((f.elements[i].type == 'button') || (f.elements[i].type == 'submit')) c++;
		// type=text or type=hidden or type=password or type == textarea
		if(c == 0)
		{
			if(f.elements[i].value) s = s + f.elements[i].name + '=' + encodeURIComponent(f.elements[i].value) + '&';
		}
		// check for update NOW
		if(f.elements[i].name == 'ajax_updateNow')
		{
			__site['updateNow'] = 1;
		}
	}
	load(('/ajax.php?rn=' + Math.random() + '&action=' + 'false' + '/post/' + __site['url']), elID, s);
}

function currentUrl()
{
	var uri = document.location.href;
	if(uri.match(/([\.lv\/]+)/))
	{
		var pattern = /^(http\:\/\/)(.*)(\.lv\/)(.*)$/;
		if(uri.match(pattern)) return uri.replace(pattern, '$4');
	}
	return false;
}

function loadEngine()
{
	if(__site['enabled'] > 0)
	{
		var url = currentUrl();
		if((__site['f5'] == 'true') || ((url != false) && (url != __site['url'])))
		{
			__site['url'] = url;
			var updatedUrl = '/ajax.php?rn=' + Math.random() + '&action=' + __site['f5'] + '/get/'  + url;
			load(updatedUrl, '', '');
			__site['f5'] = 'false';
		}
		setTimeout("loadEngine()", 100);
	}
}

/* Ajax file upload */

AIM = {

	frame : function(c)
	{
		var n = 'f' + Math.floor(Math.random() * 99999);
		var d = document.createElement('DIV');
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);
		var i = document.getElementById(n);
		if(c && typeof(c.onComplete) == 'function') 
		{
			i.onComplete = c.onComplete;
		}
		return n;
	},
	
	form : function(f, name) 
	{
		f.setAttribute('target', name);
	},

	submit : function(f, c) 
	{
		AIM.form(f, AIM.frame(c));
		if(c && typeof(c.onStart) == 'function') 
		{
			return c.onStart();
		}
		else 
		{
			return true;
		}
	},

	loaded : function(id)
	{
		var i = document.getElementById(id);
		if(i.contentDocument) 
		{
			var d = i.contentDocument;
		} 
		else if(i.contentWindow) 
		{
			var d = i.contentWindow.document;
		} 
		else 
		{
			var d = window.frames[id].document;
		}
		if (d.location.href == "about:blank") return;
		if (typeof(i.onComplete) == 'function') 
		{
			i.onComplete(d.body.innerHTML);
		}
	}
	
}

function startCallback() 
{
	return true;
}

function completeCallback(response) 
{
	document.getElementById('uploadDiv').innerHTML = response;
}

/* Search */

function search()
{
	var optionID = 'what';
	var searchID = 'search';
	var optionVal = document.getElementById(optionID).options[document.getElementById(optionID).selectedIndex].value;
	var searchVal = document.getElementById(searchID).value;
	if((optionVal.length > 0) && (searchVal.match(/^([^\/]+)$/)))
	{
		document.location.href = '/' + searchID + '/' + optionVal + '/' + searchVal;
	}
}

/* FKCEditor */

function loadFCKEditor()
{
	var oFCKeditor = new FCKeditor('source');
	var el = document.getElementById('source_edit');
	if(el != null)
	{
		oFCKeditor.Value	= el.value;
	}
	oFCKeditor.Height	= 400;
	oFCKeditor.Create();
}

function saveFCK()
{
	var form  = 'textForm';
	var opts  = 'textOptions';
	var content = FCKeditorAPI.GetInstance('source').GetXHTML();
	document.getElementById(form).source.value = content;
	send(opts, form); 
}

/* Stuff functions */

function show_hide(elID)
{
	var ost = document.getElementById(elID).style.display;
	var nst = (ost == 'block') ? 'none' : 'block';
	document.getElementById(elID).style.display = nst;
}

function show(elID) { document.getElementById(elID).style.display = 'block'; }
function hide(elID) { document.getElementById(elID).style.display = 'none'; }
function setInputValByID(elID, val) { document.getElementById(elID).value = val; } 
function setInputVal(formN, inpN, val) { eval('document.forms.'+formN+'.'+inpN+'.value = val;'); }
function href(url) { document.location.href = url; }

function setField(t1, t2, cupID, moveBack)
{
	if(moveBack != 1) moveBack = 0;
	// assign hidden vars
	document.getElementById('team1').value = t1;
	document.getElementById('team2').value = t2;
	document.getElementById('moveBack').value = moveBack;
	// dis
	document.getElementById('team1res').disabled = false;
	document.getElementById('team2res').disabled = false;
	document.getElementById('teambutton').disabled = false;
	document.getElementById('team1res').focus();
}

function needRemember()
{
	document.forms['loginForm'].standalone.value=1;
}

/* Actions list */

function loadOnline()
{
	load('/ajax.moduled.php?option=onlineUpdate', 'onlineUpdate', '');
	setTimeout('loadOnline()', __site['onlTimeout']);
}

function loadPinger()
{
	load('/ajax.moduled.php?option=ping', 'pinger', '');
	setTimeout('loadPinger()', __site['pingTimeout']);
}

/* Loader */

function siteLoader()
{
	/* engine load */
	/*loadEngine();*/
	__site['url'] = currentUrl();
	__site['f5'] = 'false';
	/* online list update */
	//setTimeout('loadOnline()', __site['onlTimeout']);
	/* online pinger load */
//	setTimeout('loadPinger()', __site['pingTimeout']);
}

/* Stuff */

function cd(link) { document.location.href = link; }

/* Groups */

var
	t1  = "",
	t2  = "",
	t1h = "",
	t2h = "";

function teamAdd(id, fatherID)
{

	if(t1.length == 0)
	{
		t1h = id.replace("team","");
		t1  = document.getElementById(id).innerHTML;
	}
	else
	{
		t2h = id.replace("team","");
		t2  = document.getElementById(id).innerHTML;
	}
	
	if((t1 && t2) && (t1 != t2))
	{
		document.getElementById(fatherID).innerHTML = t1 + ' [vs] ' + t2;
		document.getElementById('t1').value = t1h;
		document.getElementById('t2').value = t2h;
		document.getElementById('sbmt').disabled = false;
	}
	
}

function teamReset(fatherID)
{
	t1  = "";
	t2  = "";
	t1h = "";
	t2h = "";
	document.getElementById(fatherID).innerHTML = '';
	document.getElementById('sbmt').disabled = true;
}


/* SWFobject && video */

function videoCreate(frameID, movieLink)
{
	var s2 = new SWFObject(__site["videoPlayer"],"single","645","400","7");
	s2.addParam("allowfullscreen","false");
	s2.addVariable("file", movieLink);
	s2.addVariable('logo', '/misc/watermark2.png');
	s2.addVariable('linkfromdisplay','true');
	s2.addVariable("displayheight","400");
	s2.addVariable("backcolor","0x000000");
	s2.addVariable("frontcolor","0xCCCCCC");
	s2.addVariable("lightcolor","0x557722");
	s2.addVariable("autostart","true");
	s2.addVariable("width","645");
	s2.addVariable("height","400");
	s2.write(frameID);
}

if(typeof deconcept=="undefined")
{
	var deconcept=new Object();
}
if(typeof deconcept.util=="undefined")
{
	deconcept.util=new Object();
}
if(typeof deconcept.SWFObjectUtil=="undefined")
{
	deconcept.SWFObjectUtil=new Object();
}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a)
{
	if(!document.getElementById){return;}
	this.DETECT_KEY=_a?_a:"detectflash";
	this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params=new Object();
	this.variables=new Object();
	this.attributes=new Array();
	if(_1)
	{
		this.setAttribute("swf",_1);
	}
	if(id)
	{
		this.setAttribute("id",id);
	}
	if(w)
	{
		this.setAttribute("width",w);
	}
	if(h)
	{
		this.setAttribute("height",h);
	}
	if(_5)
	{
		this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));
	}
	this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
	if(!window.opera&&document.all&&this.installedVer.major>7)
	{
		deconcept.SWFObject.doPrepUnload=true;
	}
	if(c)
	{
		this.addParam("bgcolor",c);
	}
	var q=_7?_7:"high";
	this.addParam("quality",q);
	this.setAttribute("useExpressInstall",false);
	this.setAttribute("doExpressInstall",false);
	var _c=(_8)?_8:window.location;
	this.setAttribute("xiRedirectUrl",_c);
	this.setAttribute("redirectUrl","");
	if(_9)
	{
		this.setAttribute("redirectUrl",_9);
	}
};
deconcept.SWFObject.prototype=
{
	useExpressInstall:function(_d)
	{
		this.xiSWFPath=!_d?"expressinstall.swf":_d;
		this.setAttribute("useExpressInstall",true);
	},
	setAttribute:function(_e,_f){this.attributes[_e]=_f;},
	getAttribute:function(_10){return this.attributes[_10];},
	addParam:function(_11,_12){this.params[_11]=_12;},
	getParams:function(){return this.params;},
	addVariable:function(_13,_14){this.variables[_13]=_14;},
	getVariable:function(_15){return this.variables[_15];},
	getVariables:function(){return this.variables;},
	getVariablePairs:function()
	{
		var _16=new Array();
		var key;var _18=this.getVariables();
		for(key in _18)
		{
			_16[_16.length]=key+"="+_18[key];
		}
		return _16;
	},
	getSWFHTML:function()
	{
		var _19="";
		if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length)
		{
			if(this.getAttribute("doExpressInstall"))
			{
				this.addVariable("MMplayerType","PlugIn");
				this.setAttribute("swf",this.xiSWFPath);
			}
			_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
			var _1a=this.getParams();
			for(var key in _1a)
			{
				_19+=[key]+"=\""+_1a[key]+"\" ";
			}
			var _1c=this.getVariablePairs().join("&");
			if(_1c.length>0)
			{
				_19+="flashvars=\""+_1c+"\"";
			}
				_19+="/>";
		}
		else
		{
			if(this.getAttribute("doExpressInstall"))
			{
				this.addVariable("MMplayerType","ActiveX");
				this.setAttribute("swf",this.xiSWFPath);
			}
			_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";
			_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
			var _1d=this.getParams();
			for(var key in _1d)
			{
				_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";
			}
			var _1f=this.getVariablePairs().join("&");
			if(_1f.length>0)
			{
				_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";
			}
			_19+="</object>";
		}
		return _19;
	},
	write:function(_20)
	{
		if(this.getAttribute("useExpressInstall"))
		{
			var _21=new deconcept.PlayerVersion([6,0,65]);
			if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version")))
			{
				this.setAttribute("doExpressInstall",true);
				this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
				document.title=document.title.slice(0,47)+" - Flash Player Installation";
				this.addVariable("MMdoctitle",document.title);
			}
		}
		if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version")))
		{
			var n=(typeof _20=="string")?document.getElementById(_20):_20;
			n.innerHTML=this.getSWFHTML();
			return true;
		}
		else
		{
			if(this.getAttribute("redirectUrl")!="")
			{
				document.location.replace(this.getAttribute("redirectUrl"));
			}
		}
		return false;
	}
};
deconcept.SWFObjectUtil.getPlayerVersion=function()
{
	var _23=new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins&&navigator.mimeTypes.length)
	{
		var x=navigator.plugins["Shockwave Flash"];
		if(x&&x.description)
		{
			_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));
		}
	}
	else
	{
		if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0)
		{
			var axo=1;
			var _26=3;
			while(axo)
			{
				try
				{
					_26++;
					axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);
					_23=new deconcept.PlayerVersion([_26,0,0]);
				}
				catch(e)
				{
					axo=null;
				}
			}
		}
		else
		{
			try
			{
				var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			}
			catch(e)
			{
				try
				{
					var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					_23=new deconcept.PlayerVersion([6,0,21]);
					axo.AllowScriptAccess="always";
				}
				catch(e)
				{
					if(_23.major==6)
					{
						return _23;
					}
				}
				try
				{
					axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				}
				catch(e){}
			}
			if(axo!=null)
			{
				_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			}
		}
	}
	return _23;
};

deconcept.PlayerVersion=function(_29)
{
	this.major=_29[0]!=null?parseInt(_29[0]):0;
	this.minor=_29[1]!=null?parseInt(_29[1]):0;
	this.rev=_29[2]!=null?parseInt(_29[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv)
{
	if(this.major<fv.major)
	{
		return false;
	}
	if(this.major>fv.major)
	{
		return true;
	}
	if(this.minor<fv.minor)
	{
		return false;
	}
	if(this.minor>fv.minor)
	{
		return true;
	}
	if(this.rev<fv.rev)
	{
		return false;
	}
	return true;
};
deconcept.util={
	getRequestParameter:function(_2b)
	{
		var q=document.location.search||document.location.hash;
		if(_2b==null)
		{
			return q;
		}
		if(q)
		{
			var _2d=q.substring(1).split("&");
			for(var i=0;i<_2d.length;i++)
			{
				if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b)
				{
					return _2d[i].substring((_2d[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
};
deconcept.SWFObjectUtil.cleanupSWFs=function()
{
	var _2f=document.getElementsByTagName("OBJECT");
	for(var i=_2f.length-1;i>=0;i--)
	{
		_2f[i].style.display="none";
		for(var x in _2f[i])
		{
			if(typeof _2f[i][x]=="function")
			{
				_2f[i][x]=function(){};
			}
		}
	}
};
if(deconcept.SWFObject.doPrepUnload)
{
	if(!deconcept.unloadSet)
	{
		deconcept.SWFObjectUtil.prepUnload=function()
		{
			__flash_unloadHandler=function(){};
			__flash_savedUnloadHandler=function(){};
			window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);
		};
		window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet=true;
	}
}
if(!document.getElementById&&document.all)
{
	document.getElementById=function(id)
	{
		return document.all[id];
	};
}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;


