//wwonline
var wangwangInstalled = false;
try {
	if (document.getElementById('clientCaps') && document.getElementById('clientCaps').isComponentInstalled("{99560E1D-E17E-44b5-90E4-5DE25BF6F7B1}", "componentID")) {
		wangwangInstalled = true;
	}
	if (!wangwangInstalled) {
		var obj = new ActiveXObject("WangWangX.WangWangObj");
		if (obj) {
			wangwangInstalled = true;
			delete obj;
		}
	}
}catch (e) {
	//alert(e.message);
}

var exitpop=false;
function PopPage(strURL, name, width, height, left, top)
{
    if(width==null) width=800;
    if(height==null) height=500;
    if(left==null) left = ( screen.width - width ) / 2;
    if(top==null) top  = ( screen.height - height ) / 2;
    temp = "width="+width+",height="+height+",left="+left+",top="+top+",scrollbars=1,toolbar=no,location=no,directories=no,status=no,resizable=no";
    w = window.open(strURL,name,temp);
    w.focus();
}
function openThisAbout()
{
    temp = "width=618,height=400,left=0,top=0,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no";
    window.open("/home/about/about_taobao.html","",temp);
}
function GetCookie(cookiename)
{
    var thebigcookie = document.cookie;
    var firstchar = thebigcookie.indexOf(cookiename);
    if (firstchar != -1) {
        firstchar += cookiename.length + 1;
        lastchar = thebigcookie.indexOf(";",firstchar);
        if(lastchar == -1) lastchar = thebigcookie.length;
        return unescape(thebigcookie.substring(firstchar, lastchar));
    }
    return "";
}
function setCookie(cookiename,cookievalue,cookieexpdate,domainname)
{
    document.cookie = cookiename + "=" + cookievalue
    + "; domain=" + domainname
    + "; path=" + "/"
    + "; expires=" + cookieexpdate.toGMTString();

}
function unloadpopup(cookiename,popurl,popwidth,popheight,domainname,tr)
{
    //return;
    try {
        if (!tr)
            return;
        if( GetCookie(cookiename) == "" )
        {
            var expdate = new Date();
            expdate.setTime(expdate.getTime() + 1 * (24 * 60 * 60 * 1000)); //+1 day
            setCookie(cookiename,"yes",expdate,domainname);
            if( exitpop )
            {
                w = window.open(popurl,cookiename,"width="+popwidth+",height="+popheight+",scrollbars=1,toolbar=yes,location=yes,menubar=yes,status=yes,resizable=yes");
                w.focus;
            }
        }
    }catch (e) {}
}
function setCheckboxes(theForm, elementName, isChecked)
{
    var chkboxes = document.forms[theForm].elements[elementName];
    var count = chkboxes.length;

    if (count)
    {
        for (var i = 0; i < count; i++)
        {
            chkboxes[i].checked = isChecked;
        }
    }
    else
    {
        chkboxes.checked = isChecked;
    }
    return true;
}

var imageObject;
function ResizeImage(obj, MaxW, MaxH)
{
    if (obj != null) imageObject = obj;
    var state=imageObject.readyState;
	if(state!='complete') {
        setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",50);
		return;
    }
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH;
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0) {
        imageObject.width=dW;
		imageObject.height=dH;
	}
}


function CheckEmpty(Field)
{
	if (Field.value == "")
	{
		return false;
	}
		
	return true;
}
	
function CheckInteger(Field)
{
	if (Field.value != "")
	{
		for (i = 0; i < Field.value.length; i++)
		{
			ch = Field.value.charAt(i);
				
			if ( (ch < '0' || ch > '9') && ch != '-' ) {
				return	false;
			}
		}
	}
		
	return true;
}
	
function CheckReal(Field)
{
	if (Field.value != "")
	{
		DotNum = 0;
		for (i = 0; i < Field.value.length;  i++)
		{
			ch = Field.value.charAt(i);
				
			if ((ch < '0' || ch > '9') && ch != '.') 
			{
				return false;
			}
				
			if (ch == '.')
			{
				if (DotNum > 0) 
				{
					DotNum++;
					return false;
				}
			}
		}
	}
		
	return	true;
}

function CheckMaxLength(Field, MaxLength)  
{  
	if (Field.value != "")  
	{  
		if (Field.value.length > MaxLength)  
		{  
			return false;  
		}  
	}  
			  
	return true;  
}
	  
function CheckMinLength(Field, MinLength)  
{  
	if (Field.value != "")  
	{  
		if (Field.value.length < MinLength)  
		{  
			Field.focus();  
			return false;  
		}  
	}  
			  
	return true;  
}  
	
function CheckOption(Field) 
{
	for (i = 0; i < Field.length; i++)
		if (Field[i].checked)
			return true;
	return false;
}
	
	//此函数用于判断Email地址是否正确
function CheckEmail(Field)
{
   // there must be >= 1 character before @, so we
   // start looking at character position 1
   // (i.e. second character)
   var i = 1;
   var len = Field.value.length;
	if (len > 50)
	{
		return false;
	}
	pos1 = Field.value.indexOf("@");
	pos2 = Field.value.indexOf(".");
	pos3 = Field.value.lastIndexOf("@");
	pos4 = Field.value.lastIndexOf(".");
	//check '@' and '.' is not first or last character
	if ((pos1 <= 0)||(pos1 == len-1)||(pos2 <= 0)||(pos2 == len-1))  
	{
		return false;
	}
	else
	{
		//check @. or .@
		if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1) 
		  || ( pos1 != pos3 )  //find two @
		  || ( pos4 < pos3 ) ) //. should behind the '@'  		
		{
			return false;
		}
	}
	return true;
}
	
function CheckMustLength(Field, MustLength)  
{  
		if (Field.value.length != MustLength)  
		{  
			return false;  
		}  
	return true;  
}  
	  
function CheckIntRange(field,min,max) {  
	if ( ! CheckInteger(field) )  
		return	false;  
	ival = parseInt(field.value);  
	if ( ival < min || ival > max ) {  
		return	false;  
	}  
	return	true;  
}  


//列表框选择值
function SelectValue(objSelect,strValue){
	if (strValue=="") return;
	for(i=0;i<objSelect.options.length;i++){
		if(objSelect.options[i].value==strValue){
			objSelect.options[i].selected=true;
			break;
		}
	}
}

//单选框选择值
function RadioValue(objSelect,strValue){
	if (strValue=="") return;
	for(i=0;i<objSelect.length;i++){
		if(objSelect[i].value==strValue){
			objSelect[i].checked=true;
			break;
		}
	}
}

//复选框选择值
function CheckValue(objSelect,strValue){
	if (strValue=="") return;
	if(objSelect.value==strValue){
		objSelect.checked=true;
	}
}

//复选框选择值
function CheckValues(objSelectList,strValue){
	if (strValue=="") return;
	for(i=0;i<objSelectList.length;i++){
		if(strValue.indexOf(objSelectList[i].value)>=0){
			objSelectList[i].checked=true;
		}
	}
}

//复选框选择值
function CheckValue1(objSelect,strValue){
	if (strValue=="") return;
	if(objSelect.value==strValue){
		objSelect.checked=true;
	}
	else{
		objSelect.checked=false;
	}
}

