/*zmolo.com (2008|v1.04)*/

var str_array=new Array();
var href_array=new Array();

var news_id=0;
var ind=1;
var runNews;
var currentStr;

function run_list(allnews){
	clearTimeout(runNews);
	ind=1;
	if (news_id>=allnews.length) news_id=0;
	objRun.href = href_array[news_id];
	currentStr = allnews[news_id];
	run_thru(currentStr);
}


function run_thru(val){
		if (ind<=val.length){
			objRun.innerHTML = val.substr(0,ind);
			ind ++;
			eval('runTimer='+setTimeout('run_thru("'+addslashes(val)+'")',50));
		} else {
			clearTimeout(runTimer);
			news_id++;
			eval("runNews="+setTimeout("run_list(str_array)",3000));
		}


}

function isdefined(variable) {
	return (typeof(window[variable]) == "undefined") ?  false: true;
}

function pauseRun(){
	objRun.innerHTML = currentStr;
	clearTimeout(runTimer);
	clearTimeout(runNews);
	return false;
}

function nextRun(){
	clearTimeout(runNews);
	clearTimeout(runTimer);
	news_id++;
	run_list(str_array);
	return false;
}


var popupWidth=300;

function refIm(imagename){
	var ima=document.getElementById(imagename);
	var src=ima.src;
	var regs=	/\&tst\=.*/;
	if (src.match(regs))
	{
		newshit="&tst="+Math.random();
		src = src.replace(regs,newshit);
	} else {
		src=src+"&tst="+Math.random();
	}
	ima.src = src;
	return false;
}


function putaj(){
	var fr=document.createElement('iframe');
	
	var content = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>";

	content1="<form name=upd method=post action='/upd.php'><input type=hidden name=act value=''><input type=hidden name=passed value=''></form>";
	content += '</head>\n<body id=wsw>'+content1+'</body>\n</html>';

	fr.name="ajaxObj";
	fr.id="ajaxObj";
	fr.style.position='absolute';
	fr.style.margin=fr.style.padding='0px';
	fr.style.zIndex=1;
	fr.style.visibility='hidden';
	fr.style.display='block';
	fr.style.width=fr.style.height='0px';
	document.getElementsByTagName('body')[0].appendChild(fr);
	frm = document.getElementById ('ajaxObj');
	frm.src='/init.htm';
}


function create_fader(){
	var bodyObj=document.getElementsByTagName('body')[0];
	var fadeObj = document.createElement("div");
	fadeObj.setAttribute('id','fade');
	fadeObj.onclick = function () {destrpopcont();};
	fadeObj.style.display = 'none';
	fadeObj.style.position = 'absolute';
	fadeObj.style.top = '0';
	fadeObj.style.left = '0';
	fadeObj.style.zIndex = '20';
 	fadeObj.style.width = '100%';
	bodyObj.insertBefore(fadeObj, bodyObj.firstChild);
}



function sbmtr(formname,copyfrom,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	var getfrom=document.getElementById(copyfrom);
	if (keycode == 13){
		var func = new Function;
		func = getfrom.onclick;
		func();
		return false;
	}else return true;
}





function sbmt(formname,newparam){
	if (newparam)
	{
		eval("document.forms['"+formname+"'].su.value=newparam");
	}
	
	eval("document.forms['"+formname+"'].submit()");
}


function wholePage(){
	
	var pageXscroll, pageYscroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		pageXscroll = document.body.scrollWidth;
		pageYscroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ 
		pageXscroll = document.body.scrollWidth;
		pageYscroll = document.body.scrollHeight;
	} else { 
		pageXscroll = document.body.offsetWidth;
		pageYscroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	

	if(pageYscroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = pageYscroll;
	}

	if(pageXscroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = pageXscroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}


function getPageScroll(){
	var pageYscroll;

	if (self.pageYOffset) {
		pageYscroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		pageYscroll = document.documentElement.scrollTop;
	} else if (document.body) {
		pageYscroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',pageYscroll); 
	return arrayPageScroll;
}


function getpopup(cond){
	var popupObj= document.getElementById ? document.getElementById("popup") : null;
	if (cond)
	{
		var coords= wholePage();
		var scroll=getPageScroll();
		var fadeObj = document.getElementById('fade');

		chngvis('fade','block');
		fadeObj.style.height = (coords[1] + 'px');
		fadeObj.style.display = 'block';

		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }

		popupObj.style.display = 'block';
		popupObj.style.top = scroll[1]+(coords[3]-300)/2+'px';
		popupObj.style.left = (coords[0]-popupWidth)/2+'px';
	} 
	else 
	{
		popupObj.style.display = 'none';
	}

}

function destrpopcont() {
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
	}

	chngvis('fade','none');
	var objPop = document.getElementById ? document.getElementById("popcont") : null;
	objPop.innerHTML = '';
	chngvis('popup','none');
	return false;
}

function chngvis(name,val){
	var obj = document.getElementById ? document.getElementById(name) : null;
	obj.style.display=val;

	var objok = document.getElementById ? document.getElementById('oks') : null;
	var objerror = document.getElementById ? document.getElementById('error') : null;
	
	if (objok)
	{
		objok.style.display='none';
	}

	if (objerror)
	{
		objerror.style.display='none';
	}

	return false;
}


function getA(actpar,val,clockholder){
	var objaj = document.getElementById ? document.getElementById("ajaxObj") : null;
	var obJholder = document.getElementById ? document.getElementById(clockholder) : null;
	obJholder.innerHTML="<img src='/im/clock.gif' style='margin:150px 165px;'>";
	objaj.src = "/upd.php?act="+actpar+"&value="+val+"&tst="+Math.random();
	return false;
}

function setvalue(name,value){
	var obj = document.getElementById ? document.getElementById(name) : null;
	obj.innerHTML = value;
}

function setvalue1(formname,elementname,elvalue){
	eval("document.forms['"+formname+"']."+elementname+".value = elvalue");
}




function SS(frm,alert){
	if (!(alert))
	{	
		Calert("Checking ....");
	} else {
		Cmessage("Checking ....");
	}
	
	document.forms[frm].submit();
	return false;
}



function addslashes(str) {
/*str=str.replace(/\'/g,'\\\'');*/
str=str.replace(/\"/g,'\\\"');
/*str=str.replace('/\\/g','\\\\');*/
/*str=str.replace(/\0/g,'\\0');*/
return str;
}



function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}



function Calert(message,okbt){
	var error_content = document.getElementById('popcont');
	var popup = document.getElementById('popup');
	var top = document.getElementById('toppop');
	var ssubmit = document.getElementById('popupsubmit');
	ssubmit.className='sbmt1';
	popup.className='';
	top.className='';
	error_content.className='';
	if (okbt)
	{
		ssubmit.style.display='none';
	} else {
		ssubmit.style.display='inline';
	}
	getpopup(1);
	error_content.innerHTML = message;
}



function Cmessage(message,okbt){
	var error_content = document.getElementById('popcont');
	var popup = document.getElementById('popup');
	var top = document.getElementById('toppop');
	var ssubmit = document.getElementById('popupsubmit');
	ssubmit.className='sbmt';
	popup.className='okout';
	top.className='okbg';
	error_content.className='oktext';
	if (okbt)
	{
		ssubmit.style.display='none';
	} else {
		ssubmit.style.display='inline';
	}
	getpopup(1);
	error_content.innerHTML = message;
}





function Clearemail(){
	for (var i=1; i<=7; i++)
	{
		eval ("document.forms['ad'].email_"+i+".value='';");
	}
}


function chUp(action,formname,showalert){
	if (!(showalert))
	{
		Cmessage("<br><img src='/im/clock4.gif'><br><br>",1);
	} else {
		var processing = document.forms[formname].processing.value;
		Cmessage(processing,1);
	}
	
	var objScript = document.getElementById ? document.getElementById("ajaxObj") : null;
	var reqLine='';
	var currform	=	eval("document."+formname);
	for(var i=0;i<currform.length;i++){
		reqLine+=currform[i].name+"="+escape(currform[i].value)+"&";
	}
	reqLine+="&frm="+formname+"&timestamp="+Math.random();
	objScript.contentWindow.document.forms['upd'].passed.value = reqLine;
	objScript.contentWindow.document.forms['upd'].act.value = action;
	objScript.contentWindow.document.forms['upd'].submit();
	return false;
}



function chPg(contid,newsid,page,language,showalert){
	if (!(showalert))
	{
		Cmessage("Processing ...",1);
	}
	
	var objScript = document.getElementById ? document.getElementById("ajaxObj") : null;
	var reqLine='';
	reqLine= "/upd.php?lng="+language+"&contid="+contid+"&commentnewsid="+newsid+"&pg="+page+"&act=chpage&timestamp="+Math.random();
	objScript.src = reqLine;

	return false;
}




function chgLoc(loc){
	var timerA;
	timerA=setTimeout(document.location.href=loc, 500);
}




function initAnchors()
{
	
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "iinfo")){
			anchor.onmouseover = function () {showTip1(this); return false;};
			anchor.onmouseout = function () {hideTip1(); return false;};
		}
	}

	var objBody = document.getElementsByTagName("body").item(0);
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','tip');
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.zIndex = '90';
	
	objBody.insertBefore(objOverlay, objBody.firstChild);
}


function loadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}


function showTip1(obj){
	var tipid=obj.getAttribute("id");
	if (tipid == '1')
	{
		objtxt='Invite this team to join your Mini Leagues.';
		showtip('tip',objtxt,obj);
	}
	
}

function hideTip1(){
	var ObjTip = document.getElementById ? document.getElementById('tip') : null;
	ObjTip.style.display='none';
	
}

function showtip(tipid,objtxt,obj){
	var ObjTip = document.getElementById ? document.getElementById(tipid) : null;
	ObjTip.style.top = obj.offsetTop-45;
	ObjTip.style.left = obj.offsetLeft+50;
	if (ObjTip.style.display == 'none') 
	{
		
		ObjTip.style.display='block';
		ObjTip.innerHTML="<div>"+objtxt+"</div>";
	}
	
}

function hidetip(){	
	str='hideLayer()';				
	timerB=setTimeout('eval(str)', 500);
}

function hideLayer(){
	var ObjTip = document.getElementById ? document.getElementById("tip") : null;
	var objScript = document.getElementById ? document.getElementById("tipcontainer") : null;
	ObjTip.style.visibility="hidden";objScript.src = "/tip.php";

}


function updatetip(name,value){
	var obj = document.getElementById ? document.getElementById(name) : null;
	obj.innerHTML = value;
}


function movetip(obj){
	var ObjTip = document.getElementById ? document.getElementById("tip") : null;
	ObjTip.style.top=obj.clientY+document.body.scrollTop;
	ObjTip.style.left=obj.clientX+document.body.scrollLeft-250;
}


loadEvent(initAnchors);