//wxcd
var userAgent = navigator.userAgent.toLowerCase();
var is_firefox = (userAgent.indexOf('firefox') != -1);
var is_iexplore = document.all;
var joyes_club_islogin = false;
joyes_club_islogin = checkIsLogin();

function $(obj)
{
	return document.getElementById(obj);
}

//
function showFlashPics(_w, _pich, _txth, _pic, _lnk, _txt)
{
    var focus_width = _w;
    var focus_height = _pich;
    var text_height = _txth;
    var swf_height = focus_height+text_height;
    var pics = _pic;
    var links = _lnk;
    var texts = _txt;
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
    document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#cccccc">');
    document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
    document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
    document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#cccccc" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');    
}
//

//login begin
function WriteCookie(CookieName,CookieValue)
{
    var days = 1;
    //
	var expires = new Date();
	expires.setTime(expires.getTime() + days*24*60*60*1000);
	document.cookie = CookieName+'='+escape(CookieValue)+';expires=' + expires.toGMTString();
}

function getCookie(cookieName) 
{
	var cookieString = document.cookie;
	var start = cookieString.indexOf(cookieName + '=');
	if (start == -1)
	return null;
	start += cookieName.length + 1;
	var end = cookieString.indexOf(';', start);
	if (end == -1) return unescape(cookieString.substring(start));
	return unescape(cookieString.substring(start, end));
}

function ClearCookie(CookieName)
{
	var expires = new Date();
	expires.setTime(expires.getTime() - 1*24*60*60*1000);
	document.cookie = CookieName+'=;expires=' + expires.toGMTString();
}

function checkIsLogin()
{
    var sta = false;
    
    var oldobj = getCookie("wxcd");
    
    var objuid = "";
	var objun = "";
	if(oldobj != null && oldobj.length > 0)
	{
	    var colist = oldobj.split("&");
	    if(colist.length > 0)
	    {
	        objuid = colist[0].substr(colist[0].indexOf("=") + 1);
	        objun  = colist[1].substr(colist[1].indexOf("=") + 1);
	    }
	    
	    if(objuid != "" && objun != "")
	    {
	        sta = true;
	    }
	}
	
	return sta;
}

function setlogin()
{
    var obj = $("CkiExp").checked;
	
    var ouser = $("user").value;
    if(ouser != null && ouser != '')
    {
        //
    }
    else
    {
	    $("CkiExp").checked = false;
	    alert('请输入您的用户名!');
	    $("user").focus();
	    return false;
    }

    var opass = $("pass").value;
    if(opass != null && opass != '')
    {
        //
    }
    else
    {
	    $("CkiExp").checked = false;
	    alert('请输入用户密码!');
	    $("pass").focus();
	    return false;
    }
    
    return true;
}
//login end

var wapUrlHaveSend = false;
function GetWapUrl()
{
    if(!wapUrlHaveSend)
    {
        var tono = $("tomymobile").value;
        if(tono == "")
        {
            alert("请输入手机号码!\n");
            $("tomymobile").focus();
            return;
        }
        
        if(!MatchPhone(tono))
        {
            alert("手机号码格式不正确!\n");
            $("tomymobile").focus();
            return;
        }
        
        $("jsgetwapurl").src = "/sms/m.aspx?t="+ 2 +"&to="+ tono;
        
        wapUrlHaveSend = true;
        $("tomymobile").value = "";
        //alert("短信发送成功!\n");
    }
    else
    {
        wapUrlHaveSend = true;
        $("tomymobile").value = "";
        alert("请不要频繁发送短信!\n");
    }
}

function MatchPhone(obj)
{
    var r, re;
	var s = obj;
	re = /^((13[4-9])|(15[012789])|188)\d{8}$/i;
	r = s.match(re);
	
	if(r != null)
	{
		return true;
	}
	else
	{
		return false;
	}
}