﻿// 共用函数
var noMatchInfo = "暂无相关赛事,客服电话:0757-86188808，QQ：93283<br><font color=red>注:澳门开盘时间为北京时间中午12点</font>"; //足球
var LQnoMatchInfo = "暂无相关赛事,客服电话:0757-86188808，QQ：93283<br><font color=red>注:澳门开盘时间为北京时间中午12点</font>"; //篮球

/////////////////////////// Steven

if( typeof ZT == 'undefined' )
	var ZT = new Object();


ZT.$ = function(id)
{
	return "string" == typeof id ? document.getElementById(id) : id;
}

var VerifyCodeObject = new function ()
{	
	this.vilidated = function()
	{
		var oImage = ZT.$('verifyCodeImg');
		oImage.isExpire = true;
	}
	this.change = function(isFire)
	{
		var oImage = ZT.$('verifyCodeImg');
		if (typeof (oImage.isExpire) == 'undefined' || oImage.isExpire ||isFire )
		{
			oImage.src = "../verifyCode.aspx?t=" + new Date().valueOf();
			oImage.isExpire = false;
		}
	}
}

//var verifyCodeObject = new VerifyCodeObject();


function changeVerifyCode(obj)
{
	VerifyCodeObject.change(true);
}

function showVerifyCode( sID )
{
	if (ZT.$(sID).style.display != '')
	{
		ZT.$(sID).style.display = '';
		ZT.$(sID).value = '';
	}
	VerifyCodeObject.change();
}

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.format = function()
{
	var tmpStr = this;
	var iLen = arguments.length;
	for(var i=0;i<iLen;i++){
		tmpStr = tmpStr.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]);
	}
	return tmpStr;
}

String.prototype.countChar = function()
{
	if (!this) return 0;

	var str = this;
	var count = 0;
	for (var i = 0; i < str.length; i++)
	{
		var intCode = str.charCodeAt(i);
		if (intCode >= 0 && intCode <= 128)
			count = count + 1;
		else
			count = count + 2;
	}
	return count;
}

var UrlParams = function()
{
	var params = document.location.search.substr(1).split('&');
	var object = {};
	for (i = 0; i < params.length; i++)
	{
		var param = params[i].split('=');
		object[param[0]] = param[1];
	}
	return object;
}

/////////////////////////// Steven


function $i(id){
	return document.getElementById(id);
}
var iwms=new Object();



//菜单位置 =====  begin =====
iwms.msgPos=function(ele,msg){
	var pos=[0,0];
	var vis=[msg.style.display.toString(),msg.style.visibility.toString()];
	with(document.documentElement){
		var cw=clientWidth;
		var sl=scrollLeft;
		var st=scrollTop;
	}
	msg.style.display="block";
	msg.style.visibility="hidden";
	// 在ele下显示
	if (ele){
		var p=iwms.elePos(ele);
/*		do{
			pos[0] += ele.offsetLeft || 0;
			pos[1] += ele.offsetTop  || 0;
			ele=ele.offsetParent;
		}while(ele);
*/
		pos[0]=p.x;
		pos[1]=p.y + p.h;
		
		if (pos[0]+msg.offsetWidth>cw+sl){
			pos[0]=cw+sl-msg.offsetWidth;
			if(pos[0]<0){
				pos[0]=0;
			}
		}
	}else{
		pos[0]=cw+sl-msg.offsetWidth-3;
		pos[1]=st;
	}
	msg.style.display=vis[0];
	msg.style.visibility=vis[1];
	return {x:pos[0],y:pos[1]};
};
iwms.elePos=function(ele){
	var p={'x':0,'y':0,'w':0,'h':0};
	p.h = ele.offsetHeight;
	p.w = ele.offsetWidth;
	do{
		p.x += ele.offsetLeft || 0;
		p.y += ele.offsetTop  || 0;
		ele=ele.offsetParent;
	}while(ele);

	return p;
};
// 菜单位置 ===== end =====

// 显示菜单 ===== begin =====
iwms.popDivs=new Array();
iwms.popMsg=function(kind,ele,cld,cls)
{
	var div;
	iwms.clearPopTimer(kind);
	// 取div
	for(var i=0;i<iwms.popDivs.length;i++){
		if(iwms.popDivs[i].id=="pop_"+kind){
			div=iwms.popDivs[i];
		}
	}
	if(div==null){
		div=document.createElement("DIV");
		div.id="pop_"+kind;
		iwms.popDivs.push(div);
		div.className=cls?cls:"aj_msg";
		div.onmouseout=function(){iwms.hideMsg(kind,800)};
		div.onmouseover=function(){iwms.clearPopTimer(kind);};
		document.body.appendChild(div);
	}else{
		div.removeChild(div.childNodes[0]);
	}
	if(typeof(cld)=="string"){
		div.innerHTML=cld;
	}else{
		div.appendChild(cld);
	}
	
	var pos=iwms.msgPos(ele,div);
	with(div.style){
		top=pos.y+"px";
		left=pos.x+"px";
		display="block";
		zIndex=100;
	}
	iwms.dropShadow(kind,div);
	ele.onmouseout=function(){iwms.hideMsg(kind,800);};
};


iwms.popTimers=new Array();
iwms.hideMsg=function(kind,time){
//	alert('hide');
	if (time && time>0){
		iwms.popTimers.push([kind,window.setTimeout("iwms.hideMsg('"+kind+"')",time)]);
	}else{
		var div;
		for(var i=0;i<iwms.popDivs.length;i++){
			if(iwms.popDivs[i].id=="pop_"+kind){
				div=iwms.popDivs[i];
			}
		}
		if (div){
			div.style.display="none";
			iwms.clearShadow(kind);
		}
	}
};

iwms.clearPopTimer=function(kind){
//	alert('clear');
	var n=-1;
	for(var i=0;i<iwms.popTimers.length;i++){
		if(iwms.popTimers[i][0]==kind){
			n=i;
			break;
		}
	}
//	alert("timers:"+iwms.popTimers.length+","+n);
	if(n>=0){
		var tm=iwms.popTimers.splice(n,1)[0][1];
//		alert("timer"+tm);
		if(tm){
			window.clearTimeout(tm);
		}
	}
};

// 显示消息 ===== end =====



// 菜单脚本 ===== begin =====
var linkset=[];

var menu=function(){
};

menu.container=null;	// 外容器
menu.ele=null;	// 显示菜单链接
menu.done=false;

menu.show=function(e,idx,p,paging){
	//p为当前页数,paging为当前是不是翻页
	if (!menu.done){
		return false;
	}
	if (!document.all&&!document.getElementById&&!document.layers){
		return false;
	}

	menu.ele=e;
	var cur=linkset[idx];
	var pSize=25;	//每页连接数
	var pNum=Math.floor((cur.length-1)/pSize)+1;		//页数
	
	// 无下级不显示
	if(cur.length==0){
		return;
	}
	
	if (menu.container==null){
		var o=document.createElement("DIV");
		menu.container=o;
	}
	
	//设置菜单内容
	if (pNum==1){
		menu.addItem(cur);
	}else{
		cur=cur.slice( (p-1)*pSize, p*pSize );
		menu.addItem(cur);
		var o_d=document.createElement("DIV");
		o_d.className="menuitems";
		o_d.style.textAlign="right";
		o_d.style.paddingRight="10px";
		o_d.style.whiteSpace="nowrap";
		var o_a=document.createElement("FONT");
		o_a.face="arial";
		o_a.innerHTML="&#9668;";
		if (p==1){
			o_a.color="#cccccc";
		}else{
			o_a.style.cursor="pointer";
			o_a.onclick=new Function("menu.show(menu.ele,"+ idx +","+ (p-1) +",true);iwms.hideMsg('menu',1500);");
		}
		o_d.appendChild(o_a);
		o_a=document.createElement("FONT");
		o_a.face="arial";
		o_a.innerHTML="&#9658;";
		if (p==pNum){
			o_a.color="#cccccc";
		}else{
			o_a.style.cursor="pointer";
			o_a.onclick=new Function("menu.show(menu.ele,"+ idx +","+ (p+1) +",true);iwms.hideMsg('menu',1500);");
		}
		o_d.appendChild(o_a);
		menu.container.appendChild(o_d);
	}
	
	iwms.popMsg("menu",e,menu.container,"menuskin");
	return false;
};

menu.addItem=function(arr)
{
	for(var i=menu.container.childNodes.length;i--;i>=0){
		menu.container.removeChild(menu.container.childNodes[i]);
	}
	for(var i=0; i<arr.length; i++){
		var a = arr[i];
		var o_d=document.createElement("DIV");
		o_d.className="menuitems";
		o_d.onmouseover=new Function("menu.highlight(this,'on');");
		o_d.onmouseout=new Function("menu.highlight(this,'off');");
		var o_a=document.createElement("A");
		if (iwms.urlPrefix.length>0 && a[1].isRelate()){
			o_a.href=iwms.urlPrefix+a[1];
		}else{
			o_a.href=a[1];
		}
		if (a[2]){
			o_a.target="_blank";
		}
		o_a.innerHTML=a[0];
		o_d.appendChild(o_a);
		menu.container.appendChild(o_d);
	}
};

menu.highlight=function(ele,state){
	ele.id=(state=="on") ? "mouseoverstyle" : "";
};
// 菜单脚本 ===== end =====
