//---------------------网站域名列表设置开始---------------------------------
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
}
//--------------------过滤字符串开头和尾巴的空格----------------------  
function StringTrim(string)
{
  var FieldValue=string;
  var Blank=String.fromCharCode(32)+String.fromCharCode(32);
  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,''); 
   //把空的段落内容去掉   
   if(Block!="")
     {myArray.push(Blank+Block);}
   }
  //把字符串整理出来
  for(iRow=0;iRow<myArray.length;iRow++)
  {TempString+=myArray[iRow]+"\n\n";} 
  return TempString;
}
//--------------------把所有按钮的状态设为屏蔽状态----------------------  
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/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)
{
	
	//1\创建层对象
	var objdiv="";
		objdiv+="<div id=\"showresult\" style=\"display:\'\'; position:absolute; left:183px; top:79px; width:200; height:30; 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
		{
			objdiv+="<left:expression((document.body.clientWidth-this.offsetWidth)/2);TOP:expression((document.body.clientHeight-this.offsetHeight)/2);\"> ";	
		}
		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=\"24\" bgcolor=\"#FAD163\">"+msg+"<\/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的结尾
		if(document.forms[0]!=null)
		{
			document.forms[0].insertAdjacentHTML("afterEnd", objdiv);
			
			var lay=document.getElementById("showresult");
			if(lay!=null)
			{
				window.setTimeout(function(){lay.style.display="none";},5000);
			}
		}
	}
//添加网页加载事件
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');
//--------------------评论模块----------------------  
function GotoCommentProduct(ReferArtcID,intParentid,SourcesTitle,UserName)
{
   var URL="/Comment/default.asp?ReferArtcID="+ReferArtcID+"&intParentid="+intParentid+"&SourcesTitle="+SourcesTitle+"&UserName="+UserName+"&ColumnName=Product";
   window.open (URL,'newwindow','height=400,width=500,toolbar=no,menubar=no,scrollbars=yes,resizeable=no,location=no,status=no');
}
function GotoCommentPublish(intParentid,SourcesTitle,UserName)
{
   var URL="/Comment/default.asp?intParentid="+intParentid+"&SourcesTitle="+SourcesTitle+"&UserName="+UserName+"&ColumnName=Publish";
   window.open (URL,'newwindow','height=400,width=500,toolbar=no,menubar=no,scrollbars=yes,resizeable=no,location=no,status=no');
}
function GotoCommentJob(intParentid,SourcesTitle,UserName)
{
   var URL="/Comment/default.asp?intParentid="+intParentid+"&SourcesTitle="+SourcesTitle+"&UserName="+UserName+"&ColumnName=Job";
   window.open (URL,'newwindow','height=400,width=500,toolbar=no,menubar=no,scrollbars=yes,resizeable=no,location=no,status=no');
}
function GotoCommentNews(intParentid,SourcesTitle,UserName,strtitle,strConect,actions)
{
   var URL="/Comment/default.asp?intParentid="+intParentid+"&SourcesTitle="+SourcesTitle+"&UserName="+UserName+"&strtitle="+strtitle+"&strConect="+strConect+"&ColumnName=News"+"&actions="+actions;
   window.open (URL,'newwindow','height=400,width=500,toolbar=no,menubar=no,scrollbars=yes,resizeable=no,location=no,status=no');
}
function GotoComment(intParentid,SourcesTitle,UserName,strtitle,strConect,actions,strTypeName)
{
   var URL="/Comment/default.asp?intParentid="+intParentid+"&SourcesTitle="+SourcesTitle+"&UserName="+UserName+"&strtitle="+strtitle+"&strConect="+strConect+"&ColumnName="+strTypeName+"&actions="+actions;
   window.open (URL,'newwindow','height=400,width=500,toolbar=no,menubar=no,scrollbars=yes,resizeable=no,location=no,status=no');
}
function OpenWindow(URL,Width,Height)
{
   window.open (URL,'newwindow','height='+Height+',width='+Width+',toolbar=no,menubar=no,scrollbars=yes,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 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(tempobj,MaxImagWidth,MaxImagHeight)
{	

    var obj=tempobj;
	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)
		{
			obj.width=ImagWidth;
			obj.height=ImagHeight;
		}
	}
}

	//循环调整对象里面包含图片的长宽
	//参数：对象ID,最长宽度,最长高度
  function AutoAdjustPictures(objID,MaxWidth,MaxHeight) 
  {   
	  var   sfEls   =   document.getElementById(objID);   	  
	  sfEls   =   sfEls.getElementsByTagName("img");
	  for   (var   i=0; i<sfEls.length;i++)  
	   {
			  ImageResize(sfEls[i],MaxWidth,MaxHeight);
		}
  }
