var Hotsales = {
	vfrm : null,
	GetBrowser:function(){//检测浏览器类型
		var s = navigator.userAgent.toLowerCase();
		if( s.indexOf('opera') != -1 ) return 'opera';
		if( s.indexOf('gecko') != -1 ) return 'gecko';
		if( s.indexOf('msie') != -1 ) return 'msie';
		return 'unknown';
	},
	existSymbol:function(text)
	{
		var regChar = new RegExp("[~|`|!|@|#|\$|%|\^|&|\*|\(|\)|_|=|\+|\\\\|\||\{|\}|\[|:|\"|;|'|<|>|\,|/|\\.|\\?|\\]|\\-|\\x20]+");
		return regChar.test(text);
	},
	existUpperCase:function(text)
	{
		var regChar = new RegExp("[A-Z]+");
		return regChar.test(text);
	},
	existLowerCase:function(text)
	{
		var regChar = new RegExp("[a-z]+");
		return regChar.test(text);
	},
	existNumber:function(text)
	{
		var str = text.trim();
		var regChar = new RegExp("[0-9]+");
		return regChar.test(str);
	},
	existDecimal:function(text,dotNum,sign)
	{
		var regChar = new RegExp("[0-9]+[\.]?[0-9]*");
		return regChar.test(text);
	},
	isNumber:function(text,dotNum)
	{
		var str = text.trim();
		var regChar;
		if (dotNum == null || dotNum == ""|| dotNum == "0")
		{
			regChar = new RegExp("^[0-9]+$");
		}
		else if (dotNum == "*")
		{
			regChar = new RegExp("^[0-9]+([\\.][0-9]*)?$");
		}
		else
		{
			regChar = new RegExp("^[0-9]+([\\.][0-9]{0,"+ dotNum +"})?$");
		}
		return regChar.test(str);
	},
	isEMail:function(text)
	{
		var regChar = new RegExp("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
		return regChar.test(text.trim());
	},
	isZipCode:function(text)
	{
		var regChar = new RegExp("^[0-9]{6}$");
		return regChar.test(text.trim());
	},
	isMobilePhone:function(text)
	{
		var regChar = new RegExp("^(13|15)\\d{9}$");
		var regChar1 = new RegExp("^([0-9]{1,5}\-)?([0-9]{1,5}\-)?[0-9]{6,12}(\-[0-9]{1,})?$");
		return ( regChar.test(text.trim())  || regChar1.test(text.trim())   );
	},
	isTelphone:function(text)
	{
		var regChar = new RegExp("^([0-9]{1,5}\-)?([0-9]{1,5}\-)?[0-9]{6,12}(\-[0-9]{1,})?$");
		return regChar.test(text.trim());
	},
	isID : function (text)
	{
		var regChar = new RegExp("([0-9]{6}[0-9][0-9][0|1][0-9][0|1|2|3][0-9][0-9]{3})|([0-9]{6}[1|2][0|9][0-9][0-9][0|1][0-9][0|1|2|3][0-9][0-9]{4})|([0-9]{6}[1|2][0|9][0-9][0-9][0|1][0-9][0|1|2|3][0-9][0-9]{3}X)")
		return regChar.test(text.trim());
	},
	isDomain :function(text)
	{
		// edit by yls
		//old var regChar = new RegExp("^http[s]?:\/\/([\\w-]+\\.)+([\\w-]+(\\.)?)$")
		var regChar = new RegExp("^([\\w-]+\\.)+([\\w-]+(\\.)?)$")
		//\\\
		return regChar.test(text.trim());
	},
	checkNull:function(objName,msgName)
	{
		if (document.getElementById(objName).value.trim() == "")
		{
			alert(msgName + "不可为空！");
			return false;
		}
		return true;
	},
	checkEnNull:function(objName,msgName)
	{
		if (document.getElementById(objName).value.trim() == "")
		{
			alert("Please enter "+msgName + " ！");
			return false;
		}
		return true;
	},
	checkNum:function(objName,msgName)
	{
		if (!Hotsales.isNumber(document.getElementById(objName).value.trim()))
		{
			alert(msgName + "输入的必须为整数！");
			return false;
		}
		return true;
	},
	checkFloat:function(objName,msgName,dotNum)
	{
		if (!Hotsales.isNumber(document.getElementById(objName).value.trim(),dotNum))
		{
			alert(msgName + "输入的格式不正确，必须为不超过"+ dotNum +"位的小数！");
			return false;
		}
		return true;
	},
	checkLen:function(objName,msgName,len)
	{
		if ( document.getElementById(objName).value.length > parseInt(len)  )
		{
			alert(msgName + "过长，请不要超出" + len + "个字符！");
			return false;
		}
		return true;
	},
	checkEnLen:function(objName,msgName,len)
	{
		if ( document.getElementById(objName).value.length > parseInt(len)  )
		{
			alert(msgName + " too long，Please don't enter over " + len + " characters！");
			return false;
		}
		return true;
	},
	checkEMail:function(objName,msgName)
	{
		if ( ! Hotsales.isEMail(document.getElementById(objName).value)  )
		{
			alert(msgName + "格式错误，请重新输入！\n\n正确格式如：smile@ebdoor.com");
			return false;
		}
		return true;
	},
	checkTelphone : function (objName,msgName)
	{
	    if ( ! Hotsales.isTelphone(document.getElementById(objName).value) )
	    {
			alert(msgName + "格式错误，请重新输入！\n\n正确格式如：086-021-28534896");
			return false;
	    }
	    return true;
	},
	checkZipCode : function (objName,msgName)
	{
	    if ( ! Hotsales.isZipCode(document.getElementById(objName).value) )
	    {
			alert(msgName + "格式错误，请重新输入！\n\n正确格式如：210000");
			return false;
	    }
	    return true;
	},
	checkID : function (objName,msgName)
	{
	    if ( ! Hotsales.isID(document.getElementById(objName).value) )
	    {
			alert(msgName + "格式错误，请重新输入！");
			return false;
	    }
	    return true;
	},
	checkDomain : function (objName,msgName)
	{
	    if ( ! Hotsales.isDomain(document.getElementById(objName).value) )
	    {
			alert(msgName + "格式错误，请重新输入！");
			return false;
	    }
	    return true;
	},
	checkStringLen: function (objName,msgName,len)
	{
		var s = document.getElementById(objName).value.trim();
		var j= 0;
		var hanzi = 0;

		for (var i=0; i<s.length; i++)   
		{
			if (s.charCodeAt(i) > 255)
			{
				j=j+2;
				hanzi++;
			}   
			else
			{
				j++;
			}
		}
		if(j > parseInt(len))
		{
			alert(msgName + "不能超过"+parseInt(len/2)+"个中文字符或"+ len +"英文字符！");
			return false;
		}
		return true;
	},
	diffDate:function( startDate,endDate )
	{
		return !(startDate > endDate);
//		var sDate = startDate.toString().replace("-",",");
//		var eDate = endDate.toString().replace("-",",");
//		
//		var c = new Date(sDate) - new Date(eDate);
//		
//		if(c > 0)
//		{
//			return false;
//		}
//		return true;
	},
	checkDate:function(objName,msgName,len)// 仅支持形如2005-11-11的格式
	{
			ptext = document.getElementById(objName).value.trim();
			if (ptext !="") 
			{
				var reg = new RegExp("^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$")
				if (!reg.test(ptext))
				{
					alert(msgName+"输入格式不正确，请重新输入！");
					document.getElementById(objName).value = "";
					return false;
				}
			}
			return true;
	},
	attachEvent:function(obj,objEventName,objfunction)//加载控件事件
	{
		var thisobj;
		//try
		//{
			thisobj=eval(obj);
		//}
		//catch()
		//{
		//	return;
		//}
		switch(Hotsales.GetBrowser()){
			case 'gecko':
				thisobj.addEventListener(objEventName,objfunction,true);				
				break;
			default:
				thisobj.attachEvent('on'+objEventName,objfunction);				
		}
	},
	attachEventOnWindowBeforeunload:function(f){//加载Window onbeforeunload事件
		switch(Hotsales.GetBrowser()){
			case 'gecko':
				window.addEventListener('beforeunload',f,true);
				break;
			default:
				window.attachEvent('onbeforeunload',f);
		}
	},
	WindowOnBeforeUnLoad:function(){//创建透明IFRAME
		var frm = document.createElement('iframe');
		document.body.appendChild(frm);
		document.body.scroll = 'no';
		frm.style.position = "absolute";
		frm.style.top = '-50px';
		frm.style.left = '-50px';
		frm.style.width = document.body.offsetWidth + 100;
		frm.style.height = document.body.offsetHeight + 100;
		frm.style.background = "#FFFFFF";
		frm.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=50,finishOpacity=50);';
		frm.style.opacity = '0.5';	
	},
	WinList:{},//窗体列表
	OpenWin:function(url,name,w,h){//打开一个居中的窗口
		if( Hotsales.WinList[name] && !Hotsales.WinList[name].closed ){
			Hotsales.WinList[name].focus();
			return;
		}
		var sw = screen.availwidth;
		var sh = screen.height;
		var l = w<sw?(sw-w)/2:0;
		var t = h<sh?(sh-h)/2:0;
		var features = ' width=' + w
					 + ',height=' + h
					 + ',left=' + l
					 + ',top=' + t;
		var winHandle = window.open(url,name,features);
		winHandle.focus();
		Hotsales.WinList[name] = winHandle;
	},
	fResizeImg1:function(w,h,obj)
    {   
        var img = $id(obj);        
        var MaxWidth = w;//设置图片宽度界限 
        var MaxHeight = h;//设置图片高度界限 
        var HeightWidth = img.offsetHeight / img.offsetWidth;//设置高宽比 
        var WidthHeight = img.offsetWidth / img.offsetHeight;//设置宽高比   
        
        if(img.width<=0||img.height<=0)
        {
            img.width = parseInt(MaxWidth); 
            img.height = parseInt(MaxHeight);
        }
        if(img.offsetWidth > parseInt(MaxWidth))
        { 
            img.width = parseInt(MaxWidth); 
            img.height = MaxWidth * HeightWidth; 
        }  
        if(img.offsetHeight > parseInt(MaxHeight))
        { 
            img.height = parseInt(MaxHeight); 
            img.width = MaxHeight * WidthHeight; 
        }            
    },
    ResizeImgWidth:function(w,obj)
    {   
        var img = $id(obj);        
        var MaxWidth = w;//设置图片宽度界限 
        
        if(img.width<=0)
        {
            img.width = parseInt(MaxWidth); 
            return;
        }
        if(img.offsetWidth > parseInt(MaxWidth))
        { 
            img.width = parseInt(MaxWidth); 
        }  
    },

    //每个参数都是数组，而且数组的各元素为：0-宽，1-高，2-img标签id
    addImgEvent:function()
    {                     
        var outerArgs=arguments;
        function innerFun()
        {
            for(var i=0;i<outerArgs.length;i++)  
            {  
                Hotsales.fResizeImg1(outerArgs[i][0],outerArgs[i][1],outerArgs[i][2]);  
            }
        } 
        Hotsales.attachEvent("window","load",innerFun);     
    },
    //添加收藏夹
    AddFavorite:function(addName)
    {
        if(navigator.appName.indexOf("Microsoft Internet Explorer")>=0)
        {
            eval("window.external.addFavorite(document.location.href,'" + addName + "');");
        }
        else if(navigator.appName.indexOf("Netscape")>=0)
        {
            eval("window.sidebar.addPanel('" + addName + "',document.location.href,'');");
        }
    },
	SetHomePage:function(url)
	{
		try
		{
			if(window.netscape)
			{
				try 
				{  
					netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
				}  
				catch (e) 
				{
					alert("error");
				}
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage',url);
			}
			else
			{
				document.body.style.behavior='url(#default#homepage)';
				document.body.setHomePage(url);
			}
		}
		catch(e){}
	},
    ShowDivWithMask:function(divId)
    {
        MaskDiv.Show();
        obj = $id(divId);
        
        obj.style.display = "";
        obj.style.left = ((window.screen.availWidth - document.getElementById(divId).scrollWidth)/2) + "px" ;			
        obj.style.top = ((window.screen.availHeight - 200- document.getElementById(divId).scrollHeight)/2 + document.documentElement.scrollTop)+ "px";
    },
    HiddenDivWithMask:function(divId)
    {
        $id(divId).style.display = "none";
        MaskDiv.Hide();
    },    
    // yls by add, 2008-07-03, 自己实现回调
    CallbackMethod:function(paramList)
    {
    	var result = new Object(); 
        var xmlhttp = null;
        if(window.XMLHttpRequest){
            xmlhttp = new XMLHttpRequest();                
        }else if(window.ActiveXObject){
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } else {
            result.status = -1;
            result.errmsg = "浏览器不支持 XMLHttpRequest.";
            result.value = "";
            return result;
        }
        
        var params = paramList;
        if (params == undefined || params == null)
            params = "";
        var url = document.location.href;
        var ipos = url.indexOf("?");
        if (ipos > 0)
            url = url.substring(0, ipos);
        url = url + "?callback=1";
        xmlhttp.open("POST", url, false);
        xmlhttp.setRequestHeader("Content-Length", params.length);
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xmlhttp.send(params);
        if (xmlhttp.status != 200 && xmlhttp.status != 0)
        {
            result.status = -2;
            result.errmsg = xmlhttp.statusText;
            result.value = "";
        }
        else
        {
            result.status = xmlhttp.responseXML.getElementsByTagName("status")[0].firstChild.nodeValue;
            result.errmsg = xmlhttp.responseXML.getElementsByTagName("errmsg")[0].firstChild.nodeValue;
            result.errmsg = unescape(result.errmsg);
            result.value = xmlhttp.responseXML.getElementsByTagName("value")[0].firstChild.nodeValue;
            result.value = unescape(result.value);
        }
        return result;
    }
};	

//Hotsales.attachEventOnWindowBeforeunload(Hotsales.WindowOnBeforeUnLoad);
/*去空格  2006/09/19   donglj */
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|\s*$/g,"");
}

/*按字节计算字符串长度，注：一个汉字两个字节，一个英文一个字节*/
String.prototype.BitLength=function(){return this.replace(/[^\x00-\xff]/g,"**").length;}

/*MSN聊天*/
function SendMSNMessage(MsgrObj,name)
{
     //Send a message through MSN , only for IE
     //and you must have installed MSN or Window Message
     try
     {
        MsgrObj.InstantMessage(name); 
     }
     catch(ex)
     {
        document.location = 'msnim:' + name;
     }
}
function AddMSNContact(MsgrObj,name)
{
     //Add a people to MSN , only for IE
     //and you must have installed MSN or Window Message
     try
     {
        MsgrObj.AddContact(0, name);
     }
     catch(ex){}
}


/*根据ID获取对象  2006/12/29   xul */
function $id(objId)
{
	return 	document.getElementById(objId);
}

function $$slt(objId)
{
	if (document.getElementById(objId) == "undifined" ||document.getElementById(objId) == null)
	{
		return "";
	}
	if ($id(objId).options.length <=0)
	{
		return "";
	}
	if ($id(objId).selectedIndex < 0)
	{
		return "";
	}
	return $id(objId).options[$id(objId).selectedIndex].value;
}

var Recall = 
{
    GetRecall:function()
    {
        if ( ! $id("Div_Recall"))
        {
            var obj = document.createElement("div");
            obj.style.display = "none";
            obj.style.position = "absolute";
            obj.style.width = 500;
            obj.style.height = 370;
            obj.style["z-index"] = 1;
            obj.id = "Div_Recall";
            obj.innerHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td height='24' class='TitleL2Yellow RecallTitleBg'>&nbsp;&nbsp;免费回呼电话</td><td align='right'  class='RecallTitleBg' > <b style='cursor:pointer;' onclick='javascript:try{window.parent.Recall.Hide();}catch(e){}'>&nbsp;×&nbsp;</b>&nbsp;</td></tr></table><iframe src=\"javascrip:return false;\" frameborder=\"0\"  id=\"IFrame_Recall\" style=\"width: 100%; height: 100%;z-index:1px; \"></iframe>";
            document.body.appendChild(obj);
        }
        return  $id("Div_Recall");
    },
    Show:function(Url,MemberPKId)
    {
        if (! Url) 
        {
            throw "请传入主站网址！";
            return;
        }
        Url = Url +"/Business/Recall/Recall.aspx?MemberPKId=" + MemberPKId;
        Hotsales.OpenWin(Url,"Recall",500,424)
    },
    Hide:function()
    {
	    this.GetRecall().style.display="none";
        MaskDiv.Hide();
    }
}

var MaskDiv =
{
	GetMask:function()
	{
		if ($id("LayerCover"))
		{
		}
		else
		{
            var divobj = document.createElement("div");
            divobj.innerHTML = "<div id=\"LayerCover\" style=\"border-right: #000000 1px; border-top: #000000 1px; display: none;z-index: 0; filter: Alpha(Opacity=80); left: 0px; border-left: #000000 1px;border-bottom: #000000 1px; position: absolute; top: 0px; background-color: #ffffff;layer-background-color: #330033; mozopacity: '0.5'\"><iframe src=\"about:blank\" style=\"position: absolute; visibility: inherit; top: 0px;left: 0px; width: 100%; height: 100%; z-index: 0; filter='progid:dximagetransform.microsoft.alpha(style=0,opacity=0)';\"></iframe></div>";
            document.body.appendChild(divobj);
		}
		return $id("LayerCover");
	},
	Show:function()
	{
	    var divobj = this.GetMask();
	    divobj.style.height = document.body.scrollHeight + "px";
	    divobj.style.width = document.body.scrollWidth + "px";
	    divobj.style.display="";
	},
	Hide:function()
	{
	    this.GetMask().style.display="none";
	}
}
function setFlash()
{
    if($id("Flash1"))
    {
        var h = $id("Flash1").GetVariable("Stage.height"); 
        $id("Flash1").height = h;
        $id("Flash1").style.zoom = 1;  
    }
}

/*
产品中国设定
*/

//EBDoorShop = {}; 
//var ResourceSite = "http://127.0.0.1/ebdoorweb/resource";
//var ProductSite = "http://127.0.0.1/ebdoorweb/product";
//var WwwSite = "http://127.0.0.1/ebdoorweb/www";

//var DefualtProdImg = ResourceSite +  "";
	/*
//编号:GF10238
//作者: 
//完整定义:void  fwindowopen(string url,string name,int width,int height)
//参数描叙:url:要打开的文件位置
//         name:窗口名
//         width:宽度
//         width:高度
//功能描叙: 打开一个居中的窗口
//类型:页面控制
function fwindowopen(url,name,width,height)
{
	var screenwidth = screen.availwidth; 
	var screenheight = screen.height;
	var winleft = 0;
	var wintop = 0;
	var features = '';
	var winHandle;
	if(width < screenwidth)
		winleft = (screenwidth - width)/2
	if(height < screenheight)
		wintop = (screenheight - height)/2	
		
	features += ' width = ' + width.toString() + ',height = ' + height.toString() + ',left = ' + winleft.toString() + ',top = ' + wintop .toString() + ',channelmode =no,directories =no,fullscreen =no,menubar =no,resizable =no,scrollbars =no,status =no,titlebar =yes,toolbar =no';	
	
	winHandle = window.open(url,name,features);
	winHandle.focus();
	
	//向首页中写入窗口句柄
	var TopWin = window.top;
	try
	{
		while( TopWin.opener && (!TopWin.opener.closed) )
		{
			TopWin = TopWin.opener.top;
		}
	
		TopWin.writetogroup(winHandle);
	}
	catch(e){}


	
	return winHandle;
}	*/	