function addMSN (address) {
if (MsgrUIA.MyStatus == 1)
{
alert('you didnot login your msn,please login it firstly');
}
else if(MsgrUIA.MyStatus == 2 || MsgrUIA.MyStatus == 10 || MsgrUIA.MyStatus == 14 || MsgrUIA.MyStatus == 34 || MsgrUIA.MyStatus == 50 || MsgrUIA.MyStatus == 66 || MsgrUIA.MyStatus == 6) { //2,10, 14, 34, 50,66,6
MsgrUIA.InstantMessage(address);
}
else if (MsgrUIA.MyStatus == 512 || MsgrUIA.MyStatus == 768)
{
alert('your msn is loginning ,please wait...');
}
else {
alert('you didnot setup msn or you didnot use Ie explorer. Please set up  and add msn by hand.' + address );
}
}

var activex = ((navigator.userAgent.indexOf('Win')  != -1) && (navigator.userAgent.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion) >= 4 ));
var CantDetect = ((navigator.userAgent.indexOf('Safari')  != -1) || (navigator.userAgent.indexOf('Opera')  != -1));







//---------------------网站域名列表设置开始---------------------------------
var __WebsiteDomain;
__WebsiteDomain=[[0,"www.cgmgc.com"],[0,"www.cgmgc.cn"],[0,"www.chinachaosu.com"],[1,"bj.cgmgc.com"]]
//---------------------网站域名列表设置结束---------------------------------

//--------------------检查表单字段长度基本函数----------------------
function CheckValueBy(strFormName,strFieldName,strMessage,strCompare,intLen)
{  var objField;
   var objFieldValue;
   var objFieldValueLen;
   objField=eval(strFormName+"."+strFieldName);
   objFieldValue=eval(strFormName+"."+strFieldName+".value");
   objFieldValueLen=eval(strFormName+"."+strFieldName+".value.length");
   if (eval(objFieldValueLen+strCompare+intLen))
   {
      alert(strMessage);
	  objField.focus();
	  return true;
   }
   else
   {return false;}
}
//--------------------检查字段的邮件是否规范----------------------
function CheckEmail(strFormName,strFieldName)
{  var objField;
   objField=eval(strFormName+"."+strFieldName);
   objFieldValue=eval(strFormName+"."+strFieldName+".value");
   var filter=/^\s*([A-Za-z0-9_-]+(\.\w+)*@(\w+\.)+\w{2,3})\s*$/;
   if (!filter.test(objFieldValue)) { 
        alert("邮件地址不正确,请重新填写！"); 
        objField.focus();
        return true; 
       } 
   else
   {return false;}
}
//--------------------删除对象行----------------------
   function DeleteByParameter(Parameter)
   {
	 url="?"+Parameter;
	 url+="&Actions=Delete" ;
	 if (confirm("确实要删除吗？"))
       {location.href=url;}
   }
//--------------------保存对象行----------------------   
   function AddSubject(FormName,Action)
   {
       { eval(FormName).action=Action;
	     eval(FormName).Actions.value="Save";
	     disableButton(FormName);
		 eval(FormName).submit();
		 }
   }
//--------------------显示更新对象行----------------------      
   function UpdateSubject(FormName,Parameter)
   { //把参数打散成数组
     //Parameter参数格式：a=1$b=2$c=3
     var arryParameter=Parameter.split("$");
     for (var i=0;i<arryParameter.length;i++)
	    {
		   //找出变量名,值
		   arryParameterLen=arryParameter[i].length;
		   ThePlace=arryParameter[i].indexOf("=");
		   FieldName=arryParameter[i].substr(0,ThePlace)
		   FieldValue=arryParameter[i].substr(ThePlace+1,arryParameterLen-ThePlace)
		   if (eval(FormName+"."+FieldName)!=null)
		      {
			   if (eval(FormName+"."+FieldName).type!="checkbox")
			       {eval(FormName+"."+FieldName).value=ReHtmlFilter(FieldValue);}
			   else
			       {//alert(FieldValue)
	                if (FieldValue=="True")
	                   {eval(FormName+"."+FieldName).checked=true;}
	                else
	                   {eval(FormName+"."+FieldName).checked=false;}				   
				   }
			   }
		}	 
	 eval(FormName).Button.value="更新";
   }
//--------------------初始化控件的值---------------------- 
function ResetState(FormName)
   { eval(FormName).Button.value="添加";   
     eval(FormName).reset();}
//--------------------表单提交---------------------- 	 
function FormSubmit(FormName,Action)
   {
       { //alert(eval(FormName).Actions.value)
	     eval(FormName).action=Action;
	     disableButton(FormName);
	     eval(FormName).submit();
		 }
   }  
//--------------------数据Html语法过滤后反转换----------------------    
function ReHtmlFilter(fString)
{
	 //还原原来的Html标式付
    fString = fString.replace(/&gt;/g, ">")
    fString = fString.replace(/&lt;/g, "<")
    fString = fString.replace(/''/g, "'")
	fString = fString.replace(/&nbsp;/g, String.fromCharCode(32))// 
    fString = fString.replace(/&quot;/g, String.fromCharCode(34))//"
    fString = fString.replace(/&#39;/g, String.fromCharCode(39))//'
    fString = fString.replace(/<BR>/g, String.fromCharCode(10))
	fString = fString.replace(/<P>/g, String.fromCharCode(10))
	return fString
}
//---------------------对齐文本---------------------------------------//
//参数：文本控件对象,模式：0代表普通文本输入框,1代表FCKeditor文本输入框
function ContentAlign(objcontrolName,mode)
{

	var objcontrol;
	//0\检验变量 
	if(mode==null||isNaN(mode)){mode=0;}
	var objcontrolString;
	//1\检查对象是否存在
	if(mode==0)
	{
		objcontrol=document.getElementById(objcontrolName);
	}
	else
	{
		objcontrol=FCKeditorAPI.GetInstance(objcontrolName);	
	}
	
	if(objcontrol!=null)
	{
		//2\如果是普通文本输入框
		if(mode==0) 
		{
			//1>检查字符串是否为空和长度是否为0
			objcontrolString=objcontrol.value;
			if(objcontrolString!=null&&objcontrolString.length>0)
			{
				objcontrol.value=StringTrim(objcontrolString);
				objcontrol.value=StringTrim(objcontrol.value);
			}
		}
		//3\如果是FCKeditor文本输入框
		else
		{
			var objcontrolStringLen;
			var oDOM = objcontrol.EditorDocument ;
			objcontrolString=oDOM.body.innerText;
			if ( document.all )		// If Internet Explorer.
			{
				objcontrolStringLen = objcontrolString.length ;
			}
			else					// If Gecko.
			{
				var r = oDOM.createRange() ;
				r.selectNodeContents( oDOM.body ) ;
				objcontrolStringLen = r.toString().length ;
			}			
			
			if(objcontrolStringLen>0)
			{
				oDOM.body.innerText=StringTrim(oDOM.body.innerText);
				oDOM.body.innerText=StringTrim(oDOM.body.innerText);
			}			
		}
	}

}

//--------------------过滤字符串开头和尾巴的空格----------------------  
function StringTrim(string)
{
  var FieldValue=string;
  var Blank=String.fromCharCode(32)+String.fromCharCode(32);
  //var Blank="aabb";
  var myArray=new Array;
  var ContentArray=FieldValue.split("\n");
  var TempString="";
  var Block="";
  //循环去掉空字符串
  for(iRow=0;iRow<ContentArray.length;iRow++)
  {Block=ContentArray[iRow].replace(/^\s*|\s*$/g,'');
   Block=Block.replace("　",'');
   //把空的段落内容去掉
   if(Block!="")
     {myArray.push(Blank+Block);}
   }
  //把字符串整理出来
  for(iRow=0;iRow<myArray.length;iRow++)
  {TempString+=myArray[iRow]+"\n\n";} 
  return TempString;
}
//--------------------获取当前时间----------------------  
function GetCurrentTime()
{
   var now = new Date();
   var year =now.getYear();
   var month =now.getMonth();
   month=month+1;
   if (month>=12)
   {month=12;}
   var day=now.getDate();
   var hours = now.getHours();
   var minutes = now.getMinutes();
   var seconds =  now.getSeconds()  
   return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
}
//--------------------把所有按钮的状态设为屏蔽状态----------------------  
function disableButton(FormName)
{
   //列举FormName里面的元素，如果是按钮的话
   //并且出现提交状态请等候信息 
   var howMany,iRow,theObject;
   theObject=eval(FormName);
   if (theObject!=null)
   {howMany=theObject.elements.length;
   for(iRow=0;iRow<howMany;iRow++)
   { 
      if(theObject.elements(iRow).type=="button")
	  {theObject.elements(iRow).disabled="true";}
   }
   showSending(FormName);
   }
}
//--------------------显示数据提交题是信息层----------------------  
function showSending(FormName)
{
var theObject=eval(FormName);
var objLayer ='<div id="sending" style="position:absolute; width:200px; height:30px; z-index:2"><img src="/images/system/transfer.gif" width="200" height="30" border="0" style="filter:alpha(opacity=70)"></div>';  
	theObject.insertAdjacentHTML("afterEnd", objLayer);
	sending.style.posLeft =  document.body.scrollLeft+(document.body.offsetWidth-4)/2-100;
	sending.style.posTop = document.body.scrollTop+(document.body.offsetHeight)/2;
}
//-------------------显示操作结果-------------------------
function showResult(msg,align,left,top)
{
	align=align.toLowerCase();
	//1\创建层对象
	var objdiv="";
		objdiv+="<div id=\"showresult\" style=\"display:\'\'; position:absolute; left:183px; top:79px; width:200; height:25; z-index:1;";
		if(align=="rightbottom")
		{
			objdiv+="left:expression(document.body.clientWidth-this.offsetWidth-10);TOP:expression(document.body.clientHeight-this.offsetHeight-10);";
		}
		else if(align=="righttop")
		{
			objdiv+="left:expression(document.body.clientWidth-this.offsetWidth-10);TOP:expression(10);";
		}
		else if(align=="lefttop")
		{
			objdiv+="left:expression(10);TOP:expression(10);";
		}
		else if(align=="leftbottom")
		{
			objdiv+="left:expression(10);TOP:expression(document.body.clientHeight-this.offsetHeight-10);";
		}				
		else if(align=="center")
		{
		    objdiv+="left:expression((document.body.clientWidth-this.offsetWidth)/2);TOP:expression(document.body.clientHeight/2-10);";
		}
		else
		{
			if(left==null||isNaN(left)||left==0)
			{
				objdiv+="left:expression((document.body.clientWidth-this.offsetWidth)/2);";
			}
			else if(left>0)
			{
				objdiv+="left:expression("+left+");";
			}
			if(top==null||isNaN(top))
			{
				objdiv+="TOP:expression((document.body.clientHeight-this.offsetHeight)/2);";
			}
			else
			{
				objdiv+="TOP:expression("+top+");";
			}
		}
		objdiv+="\"> ";
		objdiv+="  <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		objdiv+="    <tr> ";
		objdiv+="      <td width=\"3\" height=\"3\"><img src=\"\/Images\/System\/i.c.l.t.gif\" width=\"3\" height=\"3\"><\/td>";
		objdiv+="      <td bgcolor=\"#FAD163\"><\/td>";
		objdiv+="      <td width=\"3\" height=\"3\"><img src=\"\/Images\/System\/i.c.r.t.gif\" width=\"3\" height=\"3\"><\/td>";
		objdiv+="    <\/tr>";
		objdiv+="    <tr> ";
		objdiv+="      <td bgcolor=\"#FAD163\"><\/td>";
		objdiv+="      <td height=\"20\" bgcolor=\"#FAD163\" align=\"center\"><font size=2>"+msg+"</font><\/td>";
		objdiv+="      <td bgcolor=\"#FAD163\"><\/td>";
		objdiv+="    <\/tr>";
		objdiv+="    <tr> ";
		objdiv+="      <td><img src=\"\/Images\/System\/i.c.l.b.gif\" width=\"3\" height=\"3\"><\/td>";
		objdiv+="      <td bgcolor=\"#FAD163\"><\/td>";
		objdiv+="      <td><img src=\"\/Images\/System\/i.c.r.b.gif\" width=\"3\" height=\"3\"><\/td>";
		objdiv+="    <\/tr>";
		objdiv+="  <\/table>";
		objdiv+="<\/div>";


		//4\把层添加到form的结尾
		document.forms[0].insertAdjacentHTML("afterEnd", objdiv);
		
    	var lay=document.getElementById("showresult");
		if(lay!=null)
		{
			window.setTimeout(function(){lay.style.display="none";},3000);
		}
	}
//添加网页加载事件
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
    window.onload = func;
}else {
    window.onload = function() {
        oldonload();
        func();
    }
}
}	
function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}
//---------------------把图片预先调出来-------------
MM_preloadImages('/images/transfer.gif','/Images/System/i.c.l.t.gif','/Images/System/i.c.r.t.gif','/Images/System/i.c.l.b.gif','/Images/System/i.c.r.b.gif');
function OpenWindow(URL,Width,Height)
{
   window.open (URL,'newwindow','height='+Height+',width='+Width+',toolbar=no,menubar=no,scrollbars=yes,top=10,left=10,resizeable=no,location=no,status=no');
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function readCookie(name){
  var cookieValue = "";
  var search = name + "=";
  //alert(search);
  if(document.cookie.length > 0){ 
    offset = document.cookie.indexOf(search);
    if (offset != -1){ 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function readURLParameter(FieldName)
{
	var search = FieldName + "=";
	var FieldValue="";
	var URL=location.href;
	var offset = URL.indexOf(search);
	if (offset != -1)
	{ 
	  offset += search.length;
	  end = URL.indexOf("&", offset);
	  if (end == -1)
	  { 
		FieldValue=URL.substring(offset);
	  }
	  else
	  {
		FieldValue=URL.substring(offset,end);
	  }
	}
	return FieldValue;
}

function writeCookie(name, value, hours){
  var expire = "";
  if(hours != null){
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function ShowLayer(id,CustomerType)
{
	var CustomerType;
	CustomerType=CustomerType;
    MM_showHideLayers('Menu','','show');
	Menu.style.posLeft = window.event.x-100;
	Menu.style.posTop = window.event.y;
}
function ShowLayerMenuSub()
{
    MM_showHideLayers('MenuSub','','show');
}
function ShowLayerMenu()
{
	MenuSub.style.posLeft = window.event.x;
	MenuSub.style.posTop = window.event.y;
    MM_showHideLayers('MenuSub','','show');
}
function ShowLayerMenun(layername)
{  
    MM_showHideLayers(layername,'','show');
}
//限制图片的长宽
function ImageResize(obj,MaxImagWidth,MaxImagHeight)
{	

	var ImagWidth=obj.width;
	var ImagHeight=obj.height;
	var TempImagWidth = ImagWidth;
	var TempImagHeight = ImagHeight;
	//1\检测参数，如果图片不是对象，则退出
	if(obj==null)
	{	
		return;
	}
	//2\如果图片是对象，并且没能检测图片的宽高，  如果图片的最大宽度不为0 ，则返回图片的最大宽度
	else if(obj!=null&&(ImagWidth==0||ImagHeight==0))
	{
		if(MaxImagWidth>0)
		{obj.width=MaxImagWidth;}
		else if(MaxImagHeight>0)
		{obj.height=MaxImagHeight;}
		else
		{return;}
	}
	//3\如果能够检测出图片的实际宽高，则进行宽度调整处理
	else
	{
		try{
	
				//1\如果只限制宽度，则处理宽度就可以了 
				if ((MaxImagWidth!=null&&MaxImagWidth>0)&&MaxImagHeight==0)
				{if(ImagWidth>MaxImagWidth)ImagWidth=MaxImagWidth;} 
				
				
				//2\如果只限制高度，则处理高度就可以了
				else if ((MaxImagHeight!=null&&MaxImagHeight>0)&&MaxImagWidth==0)
				{if(ImagHeight>MaxImagHeight)ImagHeight=MaxImagHeight;}	
				
				
				//3\如果限制高度和宽度，则进行复杂的处理
				else if ((MaxImagHeight!=null&&MaxImagHeight>0)&&(MaxImagWidth!=null&&MaxImagWidth>0))
				{
					//重新计算图片的长度和高度
					//先限制图片的宽度
					//---------------------------------------------------
					//情况1：图片的宽度超过最大限定宽度  
					
					if(ImagWidth > MaxImagWidth)
					{
					
					
						var TempWidth,TempHeight;
						//第一次计算
						TempWidth = MaxImagWidth;
						//计算图片的高度
						TempHeight = parseInt(ImagHeight / ImagWidth * MaxImagWidth);
					
						//第二次计算
						//判断图片的高度是否超出制定的高度
						if(TempHeight > MaxImagHeight)
						{
							TempHeight = MaxImagHeight;
							//重新计算图片的宽度
							TempWidth = parseInt(ImagWidth / ImagHeight * MaxImagHeight);
						}
						ImagWidth = TempWidth;
						ImagHeight = TempHeight;
						
						//alert("a="+ImagHeight / ImagWidth +"b="+parseInt(ImagHeight / ImagWidth * MaxImagWidth))
					}
					//情况2：图片的宽度不超过最大限定宽度，但是高度超过了限定宽度
					else if(ImagHeight > MaxImagHeight)
					{//alert("a="+MaxImagHeight +"b="+parseInt(TempImagWidth / TempImagHeight * MaxImagHeight))
						ImagHeight = MaxImagHeight;
						ImagWidth = parseInt(TempImagWidth / TempImagHeight * MaxImagHeight);
					}
				}
		}
		catch(e)
		{
			//alert(e);
		}
		if(ImagWidth>0&&ImagHeight>0)
		{
			obj.width=ImagWidth;
			obj.height=ImagHeight;
		}
		else
		{
			if(MaxImagWidth!=null&&MaxImagWidth>0)
			{obj.width=MaxImagWidth;}
		}
	}
}

	//循环调整对象里面包含图片的长宽
	//参数：对象ID,最长宽度,最长高度
  function AutoAdjustPictures(objID,MaxWidth,MaxHeight) 
  {   
	  var   sfEls   =   document.getElementById(objID);   
	  for   (var   i=0;   i<sfEls.length;   i++)  
	   {   
			if(sfEls[i].tagName.toLowerCase()=="img")
			{
			  sfEls[i].onload=function(){ImageResize(sfEls[i],MaxWidth,MaxHeight)};
			 }
	
		}   
  }
function actionjax(str_1){  
	var xmlhttp = false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}		
	//var   xmlhttp   =   new   ActiveXObject("Microsoft.XMLHTTP");   
	xmlhttp.open("POST",  str_1,   false);   
	xmlhttp.send();
	return xmlhttp.ResponseText;
}   

