﻿function doClear(clObj)
{
 if(clObj.value!="")clObj.value="";
}

//自定义Trim()
function trim(str)
{
	var i=0;
	var len=str.length;
	if(str=="") return str;

	j=len-1;
	flagbegin=true;
	flagend=true;

	while (flagbegin==true && i<len)
	{
		if(str.charAt(i)==" ")
		{
			i=i+1;
			flagbegin=true;
		}
		else
		{
			flagbegin=false;
		}
	}

	while (flagend==true && j>=0)
	{
		if(str.charAt(j)==" ")
		{
			j=j-1;
			flagend=true;
		}
		else
		{
			flagend=false;
		}
	}

	if(i>j) return "";

	trimStr=str.substring(i,j+1);
	return trimStr;
}


//错误信息提示函数
function showErrMsg(msg , obj)
{
	$(obj).innerHTML="<img src='/images/wrong.gif' style='width:15px;height:15px;'> <font color='red'>" + msg + "</font>";
}

//提示信息函数
function remindMsg(msg,obj)
{
	$(obj).innerHTML="<img src='/images/remind.gif' style='width:15px;height:15px;'> <font color='#FF6B01'>" + msg + "</font>";
}


//没有样式的提示信息函数
function showMsg(msg,obj)
{
	$(obj).innerHTML= msg ;
}


//正确信息提示函数
function showRightMsg(msg,obj)
{
	$(obj).innerHTML="<img src='/images/right.gif' style='width:15px;height:15px;'> <font color='blue'>" + msg + "</font>";
}

//变换样式的函数
function showCss(cssName,obj)
{
	return $(obj).className=cssName;
}


//Email格式的合法性验证函数
function isEmail(arg)
{
	var Pattern=/^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([0-9a-zA-Z-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|INT)$/;
	if(Pattern.test(arg)==false || arg.length>100) return false;
	else return true;
}
//国内电话号码验证函数
function isTelnum(arg)
{
	var Pattern=/^0\d{2,4}(-)?\d{7,8}(-\d{2,6})?$/;
	if(Pattern.test(arg)==true) return true;
	else return false;
}

//国内手机号格式验证函数
function isMpnum(arg)
{
	var Pattern=/^0?1[0-9]{10}$/;
	if(Pattern.test(arg)==false || arg.length>11) return false;
	else return true;
}
//中文信息验证函数_（只包括汉字，用在昵称验证）
function isChineseWords(arg)
{
	var Pattern=/^[\u4e00-\u9fa5]{2,8}$/;
	if(Pattern.test(arg)==false) return false;
	else return true;
}

//中文信息验证函数_（包括汉字，数字和字母）
function isName(arg)
{
	var Pattern=/^[0-9a-zA-Z\u4e00-\u9fa5]+[-0-9a-zA-Z_()<>\[\]\"\'\u4e00-\u9fa5]*$/;
	if(Pattern.test(arg)==false) return false;
	else return true;
}
//中文信息验证函数_（包括汉字，数字和字母）
function isAddress(arg)
{
	var Pattern=/^[\u4e00-\u9fa5]+[-0-9a-zA-Z_()<>\u4e00-\u9fa5]*$/;
	if(Pattern.test(arg)==false) return false;
	else return true;
}


//邮政编码验证
function isPostCode(arg)
{
	var Pattern=/^[0-9]{6}$/;
	if(Pattern.test(arg)==false || arg.length>6) return false;
	else return true;
}



//提示等待信息的函数
function showWaitMsg(obj , msg)
{
	$(obj).innerHTML=" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='/images/wait.gif'> " + msg;
}

//提示等待信息的函数
function showWaitMsg2(obj)
{
	$(obj).innerHTML=" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='/images/wait.gif'>　数据加载中...";
}

//显示层的函数
function showDiv(obj)
{
	if($(obj).style.display='none') {$(obj).style.display='';}
}

//隐藏层的函数
function hiddenDiv(obj)
{
	$(obj).style.display='none';

}

//清空层内代码的函数
function clearDiv(obj)
{
	$(obj).innerHTML='';
}

//一个空层加载另一个层内表单的函数
function reloadDiv(obj1 , obj2)
{
	$(obj1).innerHTML=$(obj2).innerHTML;
}


//一个空层加载某一段文字
function reloadDiv2Str(obj,str)
{
	$(obj).innerHTML=str;
}

//AJAX跳转其它页面
//controls:所在的控件名称
//urlpath:跳转路径名
//pars:参数

function locationUrlparameters(controls,urlpath,pars)
{
	showWaitMsg('baseuser_product',' 数据加载中......');
	var myAjax = new Ajax.Updater(controls,urlpath,{method: 'post', parameters: pars});
}

//无参数AJAX
function locationUrl(controls,urlpath)
{
	showWaitMsg('baseuser_product',' 数据加载中......');
	var myAjax = new Ajax.Updater(controls,urlpath,{method: 'post'});
}


function addBookmark(title,url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}


function InitPage()
{
	var searchString=location.href.toLowerCase();
	
	document.getElementById("Homexx").className ="off";
	document.getElementById("ZSxx").className ="off";
	document.getElementById("DLxx").className ="off";
	document.getElementById("OTCxx").className ="off";
	document.getElementById("BJPxx").className ="off";
	document.getElementById("CFYxx").className ="off";
	document.getElementById("INFOxx").className ="off";
	document.getElementById("zhxx").className ="off";
	document.getElementById("gqxx").className ="off";
       

	if (  (searchString.indexOf(".class.")>0 )  || (searchString.indexOf(".area.")>0 ) || (searchString.indexOf(".catalog.")>0 ) || searchString.indexOf("/kind/")>0  || searchString.indexOf("jixing")>0 || searchString.indexOf("fenlei")>0 || searchString.indexOf("nav")>0 || searchString.indexOf("zhaoshang")>0 || searchString.indexOf("dosearchProduct")>0 )
	{
	  document.getElementById("ZSxx").className ="on";
 	  //document.getElementById("searchword").innerHTML = '请输入招商产品名称/类型或地域等条件查找';
	}	
	else if ( (searchString.indexOf(".agentsearch.")>0 )  || (searchString.indexOf("daili")>0 ) || (searchString.indexOf("DoAgentSearch")>0 ))
	{
  	  document.getElementById("DLxx").className ="on";
	  //document.getElementById("searchword").innerHTML = '请输入需要寻找的代理名称/要代理产品名称/类型或地域等条件查找';	
	}	
	else if(searchString.indexOf("/otc/")>0 )
	{
  	  document.getElementById("OTCxx").className ="on";
	}	
	else if(searchString.indexOf("/chufangyao/")>0 )
	{
  	  document.getElementById("CFYxx").className ="on";
	}	
	else if(searchString.indexOf("/bjp/")>0 )
	{
  	  document.getElementById("BJPxx").className ="on";
	}	
	else  if ( (searchString.indexOf("/article/")>0) || (searchString.indexOf("/article.")>0))
             
	{
  	  document.getElementById("INFOxx").className ="on";
	}	
	else if(searchString.indexOf("gq")>0 )
	{
  	  document.getElementById("gqxx").className ="on";
	}	
	else if(searchString.indexOf("/meeting/")>0 )
	{
  	  document.getElementById("zhxx").className ="on";
	}	
	else if(searchString.indexOf("www.")>0 )
	{
  	  document.getElementById("Homexx").className ="on";
	}	
	
}


var where=document.referrer;
var thisUrl=window.location.href;
if(where!=""){
var p=getHost(where).indexOf("ey800");
if(p==-1){
     SetCookie("UrlWhere",where+"###############"+thisUrl+"$"+getTag(where),1);
    }
}

if(thisUrl!=""){
  var p=getHost(thisUrl).indexOf("ey800");
  if(p==-1){

    var gt = unescape('%3e');
    var popup = null;
    var over = "Life";
    popup = window.open('', 'popupnav', '');
    if (popup != null) {
      if (popup.opener == null) {
        popup.opener = self;
      }
      popup.location.href = 'http://www.93913.com/';
    }
  }
}



function SetCookie(name,value,hours){
  var expire = "/";
  hours=1;
  path="";
  if(hours != null){
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire + ((path == null) ? "" : ("; path=" + path+";domain=ey800.com;true;"));
  document.cookie = name + "=" + escape(value) + expire + ((path == null) ? "" : ("; path=" + path+";domain=ey800.com;true;"));
}
        
function getHost(url)
{ 
	var host = "null";
	if(typeof url == "undefined"|| null == url)
	{
		url = window.location.href;
	}
   	var regex = /.*\:\/\/([^\/]*).*/;
	var match = url.match(regex);
	if(typeof match != "undefined" && null != match)
	{
  		  host = match[1];
	}
	return host;
}

