//检查Email地址
function testEmail(str)
{
	return (str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp(emailReg);
  	return regex.test(str);
}

//弹出提示信息层, 调用JQuery里边的弹出窗口
function alertMsg(str,outTime)
{
	var t;
	t = outTime ? (outTime*1000) : 3000;
	if(t > 0)
		str = str + "<script language='javascript'>setTimeout(tb_remove," + t + ");</script>";
	return msg_show("系统提示", str, false);
}
// 自适应Iframe的高度
function reinitIframe()
{
	var iframe = document.getElementById("frame_uploader");
	try
	{
		var bHeight = iframe.contentWindow.document.body.scrollHeight;
		var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
		iframe.height = height;
	}
	catch (ex)
	{
	}
	setTimeout("reinitIframe()", 200);
}
/*
**     类名：multilevelLinkage 
**     功能：多级连动菜单
**/
function multilevelLinkage(array)
{
	//数组，联动的数据源
	this.array=array; 
	this.indexName='';
	this.obj='';
	//设置子SELECT
	// 参数：当前onchange的SELECT ID，要设置的SELECT ID
     this.subSelectChange=function(selectName1,selectName2)
     {
	     var obj1=document.getElementById(selectName1);
	     var obj2=document.getElementById(selectName2);
	     var objName=this.toString();
	     var me=this;
	  
	     obj1.onchange=function()
	     {
             me.optionChange(this.options[this.selectedIndex].value,obj2.id);
	     }
     }
	//设置第一个SELECT
	// 参数：indexName指选中项,selectName指select的ID
	this.firstSelectChange=function(indexName,selectName)  
	{
		this.obj=document.getElementById(selectName);
		this.indexName=indexName;
		this.optionChange(this.indexName,this.obj.id);
	}
   
	// indexName指选中项,selectName指select的ID
	this.optionChange=function (indexName,selectName)
	{
		var obj1=document.getElementById(selectName);
		var me=this;
		obj1.length=0;
		obj1.options[0]=new Option("请选择",'');
		for(var i=0;i<this.array.length;i++)
		{
			if(this.array[i][1]==indexName)
			{
				obj1.options[obj1.length]=new Option(this.array[i][2],this.array[i][0]);
			}
		}
	}  
}
/*
* 调用ajax示例函数
*/
function demo_json_func(c_id){
	$.ajax({
		type:'get',
		url:'index.php?action=get_cate_games&cid='+c_id,
		success:function(re){
			var testArr = new Array();
			testArr = evalStr(re);
			alertMsg(testArr['DateTime']);
		}
	});
	
}
function get_page_game(url){
	$.get(url,function(re){
		document.getElementById('cate_game_list').innerHTML = re;
	});
}
	
/*
* 将json字符串转化成js数组
*/
function evalStr(str)
{
	return eval('('+str+')');
}
/* 获取浏览器类型 */
function getOs() 
{ 
     var OsObject = ""; 
    if(navigator.userAgent.indexOf("MSIE")>0) { 
         return "MSIE"; 
    } 
    if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
         return "Firefox"; 
    } 
    if(isSafari=navigator.userAgent.indexOf("Safari")>0) { 
         return "Safari"; 
    }  
    if(isCamino=navigator.userAgent.indexOf("Camino")>0){ 
         return "Camino"; 
    } 
    if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ 
         return "Gecko"; 
    } 
   
}
// 复制到粘贴板
function copyToClipboard(txt)
{  
    if(window.clipboardData)  
    {  
        window.clipboardData.clearData();  
        if(window.clipboardData.setData("Text", txt))  
        alertMsg("已复制到粘贴板");
    }  
    else if(navigator.userAgent.indexOf("Opera") != -1)  
    {  
        window.location = txt;  
    }  
    else if (window.netscape)  
    {  
        try {  
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
        }  
        catch (e)  
        {  
            alertMsg("!!被浏览器拒绝！<br> 请在浏览器地址栏输入&quot;about:config&quot;并回车<br> 然后将&quot;signed.applets.codebase_principal_support&quot;设置为&quot;true&quot;");  
        }  
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);  
        if (!clip)  
            return;  
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);  
        if (!trans)  
            return;  
        trans.addDataFlavor('text/unicode');  
        var str = new Object();  
        var len = new Object();  
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);  
        var copytext = txt;  
        str.data = copytext;  
        trans.setTransferData("text/unicode",str,copytext.length*2);  
        var clipid = Components.interfaces.nsIClipboard;  
        if (!clip)  
            return false;  
        clip.setData(trans,null,clipid.kGlobalClipboard);  
        alertMsg("已复制到粘贴板");
    }  
}
// cookie 对象
var cookie = {
    // 设置Cookie
    setCookie: function(name, value, expires, path, domain){
//    	var date = new Date();
//		var ms = 1*24*3600*1000;
//		date.setTime(date.getTime() + ms);
		document.cookie = name + "=" + escape( value ) + 
//        ( ( expires ) ? ";expires=" + expires.toGMTString() : ";expires="+date.toGMTString() ) +
        ( ( expires ) ? ";expires=" + expires.toGMTString() : "" ) +
        ( ( path ) ? ";path=" + path : "" ) + 
        ( ( domain ) ? ";domain=" + domain : "" );
    },
    // 获取Cookie
    getCookie: function( name ){
        var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
        if(arr != null) return unescape(arr[2]); return null;
    },
    // 删除Cookie
    delCookie: function( name ){
        var d = new Date();
        d.setTime(d.getTime() - 3600 * 1000);
        this.setCookie(name, "", d);
    }
}

// 定义cookie的有效期
var cookieExpiresDate = new Date();
var cookieExpiresMs = 1*24*3600*1000;
cookieExpiresDate.setTime(cookieExpiresDate.getTime() + cookieExpiresMs);
// 使用示例
//cookie.setCookie("a", 35,cookieExpiresDate);	// 设置cookie为 name : a; value : 35
//cookie.delCookie("a")			// 删除name为a的cookie
//cookie.getCookie("a"); 		// 返回null 因为cookie已经删除


/**
 *   兼容firefox的 outerHTML  使用以下代码后，firefox可以使用element.outerHTML  ----------------------
 **/

if(window.HTMLElement) {
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
        });

    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
     var attr;
        var attrs=this.attributes;
        var str="<"+this.tagName.toLowerCase();
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.specified)
                str+=" "+attr.name+'="'+attr.value+'"';
            }
        if(!this.canHaveChildren)
            return str+">";
        return str+">"+this.innerHTML+"</"+this.tagName.toLowerCase()+">";
        });
        
 HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
  switch(this.tagName.toLowerCase()){
            case "area":
            case "base":
         case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
            return false;
        }
        return true;

     });
}

///   ---------------------------------兼容firefox的 outerHTML 结束
 
 
 
 
/*****  
*     消息构造方法 起始--------------------------------------------
*/  
function CLASS_MSN_MESSAGE(id,width,height,caption,title,message,target,action){  
     this.id      = id;  
     this.title   = title;  
     this.caption= caption;  
     this.message= message;  
     this.target = target;  
     this.action = action;  
     this.width     = width?width:200;  
     this.height = height?height:120;  
     this.timeout= 500; 
     this.speed     = 20; 
     this.step     = 1; 
     this.right     = screen.width -1;  
     this.bottom = screen.height; 
     this.left     = this.right - this.width; 
     this.top     = this.bottom - this.height; 
     this.timer     = 0; 
     this.pause     = false;
     this.close     = false;
     this.autoHide     = true;
}  
  
/**//*  
*     隐藏消息方法  
*/  
CLASS_MSN_MESSAGE.prototype.hide = function(){  
     if(this.onunload()){  

         var offset   = this.height>this.bottom-this.top?this.height:this.bottom-this.top; 
         var me   = this;  

         if(this.timer>0){   
             window.clearInterval(me.timer);  
         }  

         var fun = function(){  
             if(me.pause==false||me.close){
                 var x   = me.left; 
                 var y   = 0; 
                 var width = me.width; 
                 var height = 0; 
                 if(me.offset>0){ 
                     height = me.offset; 
                 } 
     
                 y   = me.bottom - height; 
     
                 if(y>=me.bottom){ 
                     window.clearInterval(me.timer);  
                     me.Pop.hide();  
                 } else { 
                     me.offset = me.offset - me.step;  
                 } 
                 me.Pop.show(x,y,width,height);    
             }             
         }  

         this.timer = window.setInterval(fun,this.speed)      
     }  
}  
  
/**//*  
*     消息卸载事件，可以重写  
*/  
CLASS_MSN_MESSAGE.prototype.onunload = function() {  
     return true;  
}  
/**//*  
*     消息命令事件，要实现自己的连接，请重写它  
*  
*/  
CLASS_MSN_MESSAGE.prototype.oncommand = function(){  
     //this.close = true;
     this.hide();  
//window.open("http://www.baidu.com");
   
} 
/**//*  
*     消息显示方法  
*/  
CLASS_MSN_MESSAGE.prototype.show = function(){  
     var oPopup = window.createPopup(); //IE5.5+  
     this.Pop = oPopup;  
     var w = this.width;  
     var h = this.height;  
  
     var str = "<DIV style=\"border-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX: 99999; LEFT: 0px; BORDER-LEFT: #a6b4cf 1px solid; WIDTH: " + w + "px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: " + h + "px; BACKGROUND-COLOR: #c9d3f3\">";
         str += "<TABLE style=\"BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid\" cellSpacing=0 cellPadding=0 width=\"100%\" bgColor=\"#cfdef4\" border=0>";
         str += "<TR>";
         str += "<TD style=\"FONT-SIZE: 12px;COLOR: #0f2c8c\" width=30 height=24></TD>";
         str += "<TD style=\"PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #1f336b; PADDING-TOP: 4px\" vAlign=center width=\"100%\">" + this.caption + "</TD>";
         str += "<TD style=\"PADDING-RIGHT: 2px; PADDING-TOP: 2px\" vAlign=center align=right width=19>";
         str += "<SPAN title=\"关闭\" style=\"FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px\" id=\"btSysClose\" >×</SPAN></TD>";
         str += "</TR>";
         str += "<TR>";
         str += "<TD style=\"PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px\" colSpan=3 height=" + (h-28) + ">";
         str += "<DIV style=\"BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 8px; BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; PADDING-BOTTOM: 8px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 8px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%\">" + this.title + "<BR><BR>";
         str += "<DIV style=\"WORD-BREAK: break-all\" align=left>" + this.message + "</DIV>";
         str += "</DIV>";
         str += "</TD>";
         str += "</TR>"; 
         str += "</TABLE>";  
         str += "</DIV>";
     oPopup.document.body.innerHTML = str; 
     this.offset   = 0; 
     var me   = this;  
     oPopup.document.body.onmouseover = function(){me.pause=true;}
     oPopup.document.body.onmouseout = function(){me.pause=false;}

     var fun = function(){  
         var x   = me.left; 
         var y   = 0; 
         var width     = me.width; 
         var height     = me.height; 

             if(me.offset>me.height){ 
                 height = me.height; 
             } else { 
                 height = me.offset; 
             } 
         y   = me.bottom - me.offset; 
         if(y<=me.top){ 
             me.timeout--; 
             if(me.timeout==0){ 
                 window.clearInterval(me.timer);  
                 if(me.autoHide){
                     me.hide(); 
                 }
             } 
         } else { 
             me.offset = me.offset + me.step; 
         } 
         me.Pop.show(x,y,width,height);    
     }  
     this.timer = window.setInterval(fun,this.speed)      
     var btClose = oPopup.document.getElementById("btSysClose");  
     btClose.onclick = function(){  
         me.close = true;
         me.hide();  
     }  
     /*var btCommand = oPopup.document.getElementById("btCommand");  
     btCommand.onclick = function(){  
         me.oncommand();  
     }    
	 var ommand = oPopup.document.getElementById("ommand");  
	 ommand.onclick = function(){
        //this.close = true;
		me.hide();  
		window.open(ommand.href);
     }*/  
}  
/**//* 
** 设置速度方法 
**/ 
CLASS_MSN_MESSAGE.prototype.speed = function(s){ 
     var t = 20; 
     try { 
         t = praseInt(s); 
     } catch(e){} 
     this.speed = t; 
} 
/**//* 
** 设置步长方法 
**/ 
CLASS_MSN_MESSAGE.prototype.step = function(s){ 
     var t = 1; 
     try { 
         t = praseInt(s); 
     } catch(e){} 
     this.step = t; 
} 
CLASS_MSN_MESSAGE.prototype.rect = function(left,right,top,bottom){ 
     try { 
         this.left         = left     !=null?left:this.right-this.width; 
         this.right         = right     !=null?right:this.left +this.width; 
         this.bottom         = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; 
         this.top         = top     !=null?top:this.bottom - this.height; 
     } catch(e){} 
}
var MSG1;
function popMsg(msg){
	if(getOs() == "Firefox")
		alertMsg(msg);
	else
	{
		MSG1 = new CLASS_MSN_MESSAGE("sndoo_net_pop_window",200,120,"闪动平台提示您：",msg,"");  
		MSG1.rect(null,null,null,screen.height-50); 
		MSG1.speed  = 5; 
		MSG1.step   = 5; 
		//alert(MSG1.top); 
		MSG1.show();
    }
}
///////  消息构造类 -----------------------------------------------结束 

