//Open Modal Window
function OpenWindowAndSetValue(Url,Width,Height,WindowObj,SetObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:yes;help:no;scroll:yes;');
	if (ReturnStr!='') SetObj.value=ReturnStr;
	return ReturnStr;
}
//awen add   selectAll(this.form) 调用即可
function selectAll(f)
{
	for(i=0;i<f.length;i++)
	{
		if(f(i).type=="checkbox" && f(i)!=event.srcElement)
		{
			f(i).checked=event.srcElement.checked;
		}
	}
}
function CheckNumber(Obj,DescriptionStr)
{
	if (Obj.value!='' && (isNaN(Obj.value) || Obj.value<0))
	{
		alert(DescriptionStr+"应填有效数字！");
		Obj.value="";
		Obj.focus();
	}
}
function OpenWindow(Url,Width,Height,WindowObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:no;help:no;scroll:yes;');
	return ReturnStr;
}
//Open Modal Window
function OpenWindowAndSetValue(Url,Width,Height,WindowObj,SetObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:no;help:no;scroll:yes;');
	//	var ReturnStr=OpenEditerWindow(Url,WindowObj,'scrollbars=0,resizable=1,top=50,left=50,width='+Width+',height='+Height);
	if (ReturnStr!='007007007007') SetObj.value=ReturnStr;
	return ReturnStr;
}
//Open Editer Window
function OpenEditerWindow(Url,WindowName,Width,Height)
{
	window.open(Url,WindowName,'toolbar=0,location=0,maximize=1,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,top=50,left=50,width='+Width+',height='+Height);
}
//CSS背景控制
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="hback_1"
		Obj.bgColor="";//颜色要改
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="hback";
		Obj.bgColor="";
	}
}

//===========错误信息显示函数（公共函数） coder by Terry Wen
function ShowErr(msg){
	alert(msg);
	var type = typeof(window.dialogArguments);
	var openerType = typeof(window.opener);
	if ( type != 'undefined' && openerType == 'undefined' )
	{
		//window.dialogArguments.location.reload();
		CloseWin();
	}
	else
	{
		if (document.referrer=="")
			CloseWin();
		else
			window.location.href=document.referrer;
	}
}
//===========关闭窗口的函数(公共函数) coder by Terry Wen
function CloseWin()
{
	var ua=navigator.userAgent
	var ie=navigator.appName=="Microsoft Internet Explorer"?true:false
	if(ie)
	{
		var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
		if(IEversion< 5.5)
		{
			var str  = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'
			str += '<param name="Command" value="Close"></object>';
			document.body.insertAdjacentHTML("beforeEnd", str);
			document.all.noTipClose.Click();
		}
		else
		{
			window.opener =null;
			window.close();
		}
	}
	else
	{
		window.close()
	}
}
function BtnMouseOver(Obj)
{
	if (event.type!='mouseout')
	{
		Obj.className='BtnMouseOver';
		if (Obj.tagName.toLowerCase()=='td' || Obj.tagName.toLowerCase()=='img')
			window.status=Obj.alt;
		else
			window.status=Obj.title;
	}
	else
	{
		window.status=top.Str_Status;
		Obj.className='BtnMouseOut';
	}
}
function Doprnum(PrWords)
{
	if (PrWords!='')
	{
		
			if (document.MallForm.Product_Num.value=='') document.MallForm.Product_Num.value=PrWords;
			else document.MallForm.Product_Num.value=document.MallForm.Product_Num.value+'|'+PrWords;
		}
	if (PrWords == 'Clean')
	{
		//document.MallForm.PrWords.value = '';
		document.MallForm.Product_Num.value = '';
	}
	return;
}
function Docolor(PrColor)
{
	if (PrColor!='')
	{
		
			if (document.MallForm.Product_color.value=='') document.MallForm.Product_color.value=PrColor;
			else document.MallForm.Product_color.value=document.MallForm.Product_color.value+'|'+PrColor;
		}
	if (PrColor == 'Clean')
	{
				document.MallForm.Product_color.value = '';
	}
	return;
}

function DoprLoft(PrLoft)
{
	if (PrLoft!='')
	{
		
			if (document.MallForm.Product_Loft.value=='') document.MallForm.Product_Loft.value=PrLoft;
			else document.MallForm.Product_Loft.value=document.MallForm.Product_Loft.value+'|'+PrLoft;
		}
	if (PrLoft == 'Clean')
	{
				document.MallForm.Product_Loft.value = '';
	}
	return;
}
function Doprnam(Prnam)
{
	if (Prnam!='')
	{
		
			if (document.MallForm.Product_nam.value=='') document.MallForm.Product_nam.value=Prnam;
			else document.MallForm.Product_nam.value=document.MallForm.Product_nam.value+'|'+Prnam;
		}
	if (Prnam == 'Clean')
	{
				document.MallForm.Product_nam.value = '';
	}
	return;
}


function DoprFlex(PrFlex)
{
	if (PrFlex!='')
	{
		
			if (document.MallForm.Product_Flex.value=='') document.MallForm.Product_Flex.value=PrFlex;
			else document.MallForm.Product_Flex.value=document.MallForm.Product_Flex.value+'|'+PrFlex;
		}
	if (PrFlex == 'Clean')
	{
				document.MallForm.Product_Flex.value = '';
	}
	return;
}

//表格鼠标移动
function MouseIn()
{
	this.style.background='#f1f1f1';
	
	}
function MouseOut()
{
	this.style.background='';
	
	}
	
function opencat(cat)
{
  if(cat.style.display=="none"){
     cat.style.display="";
  } else {
     cat.style.display="none"; 
  }
}

//CSS背景控制
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="onthemouse"
		Obj.bgColor="";//颜色要改
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="";
		Obj.bgColor="";
	}
}

//CSS背景控制
function overtrColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="onthetrmouse"
		Obj.bgColor="";//颜色要改
	}
	
}
function outtrColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="fline";
		Obj.bgColor="";
	}
}

function delspaceline(docu)
{
	mystr = docu.value;
	var mypos = 0;
	var mypos2;
	//while(mystr.substr(0, 2) == "\r\n")  //文章前的空行不要
   // mystr = mystr.substr(2, mystr.length - 2); 
     
    while(mystr.substr(mystr.length - 2, 2) == "\r\n")  //文章后的空行不要
    mystr = mystr.substr(0, mystr.length - 2); 
    
	while((mypos1= mystr.indexOf("\r\n",mypos)) != -1)
	{
		mypos1 += 2;
		mypos2 = mypos1;
		if(mystr.substr(mypos1,2) == "\r\n")
		{
			mypos1 += 2;
			mypos2 = mypos1;
			while(mystr.substr(mypos1,2) == "\r\n")
			{
				mypos1 += 2;
			}
		}
		mystr = mystr.substr(0,mypos2)+mystr.substr(mypos1);
		mypos = mypos1;
	}
	docu.value = mystr;
}

function delkongchar(docu)
{
	// goseaside@2005-05-26 13:09
	s = docu.value;
	s= s.replace(/[ ][ ]+/g, ' ');
	s= s.replace(/([^a-zA-Z]) ([^a-zA-Z])/g, '$1$2');
	
	docu.value = s;
}
function LTrim(str)
{
    var i;
    for(i=0;i<str.length;i++)
    {     
        //if(str.charAt(i)!=" "&&str.charAt(i)!="")break;
        if(str.charAt(i)!=" "&&str.charAt(i)!=""&&str.charAt(i)!="　")break;
    }    
    str=str.substring(i);    
    return str;
}
function RTrim(str)
{
    var i;
    for(i=str.length-1;i>=0;i--)
    {
        //if(str.charAt(i)!=" "&&str.charAt(i)!="")break;
        if(str.charAt(i)!=" "&&str.charAt(i)!=""&&str.charAt(i)!="　")break;
    }    
    str=str.substring(0,i+1);    
    return str;
}
function Trim(str)
{
    return LTrim(RTrim(str));
}
function autopp(docu)
{
	delspaceline(docu);
	delkongchar(docu);
  	str = docu.value + "\r\n";
  	var orderstr="";
  	var tempstr="";
  	var pos = 0; //加空格
 	 while((pos1 = str.indexOf("\r\n", pos)) != -1)
  	{	           
      
      tempstr=Trim(str.substr(pos, pos1));            
      orderstr=orderstr +""+tempstr+"\r\n";	
      str =str.substr(pos1+2);      
  }
  docu.value = orderstr;
}

function closediv(){ 
document.body.removeChild(divbg);
document.body.removeChild(msgDiv);
}
function createbigDiv(divtitle,dw,dh,durl){ 
var h = document.body.clientHeight;
var w = document.body.clientWidth;
var dv = document.createElement("div");
dv.setAttribute('id','divbg');
dv.style.height = h ;
dv.style.width = w ;
dv.style.zIndex = "11000";
dv.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=1,finishOpacity=80)";
dv.style.background = "#ffffff";
dv.style.top = 0;
dv.style.position = "absolute";
document.body.appendChild(dv);

var msgObj=document.createElement("div") 
        msgObj.setAttribute("id","msgDiv"); 
        msgObj.setAttribute("align","center"); 
        msgObj.style.background="white"; 
        msgObj.style.border="1px solid #2866a1"; 
        msgObj.style.position = "absolute"; 
        msgObj.style.left = (window.screen.availWidth)/2+"px"; 
        msgObj.style.top = (window.screen.availHeight-dh-100)/2+"px"; 
        msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
        msgObj.style.marginLeft = "-225px" ; 
        msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; 
        msgObj.style.width = dw + "px"; 
        msgObj.style.height =dh + "px"; 
        msgObj.style.textAlign = "center"; 
        msgObj.style.lineHeight ="25px"; 
        msgObj.style.visibility = 'visible'; 
        msgObj.style.zIndex = "11002"; 
        var title=document.createElement("h4"); 
        title.setAttribute("id","msgTitle"); 
        title.setAttribute("align","left"); 
        title.style.margin="0px auto"; 
        title.style.padding="5px"; 
        title.style.background="url(images/titlebg.gif) repeat-x "; 
        title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";        title.style.opacity="0.75";
        title.style.height="24px"; 
        title.style.font="14px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
        title.style.color="white"; 
        //title.style.cursor="pointer"; 
        title.innerHTML=divtitle; 
		var img=document.createElement("img");
		img.src="images/goexit.gif"
		img.className = "ke-toolbar-close";
		img.alt="关闭窗口";
		img.onclick = new Function("document.body.removeChild(divbg);document.body.removeChild(msgDiv);");
        document.body.appendChild(msgObj); 
        document.getElementById("msgDiv").appendChild(title); 
		document.getElementById("msgDiv").appendChild(img); 
        var txt=document.createElement("<iframe>"); 
		txt.width = dw + 'px';
        txt.height =dh-40 + 'px';
        txt.setAttribute("frameBorder", "0");
		txt.setAttribute("id", "dialog");
		txt.setAttribute("scrolling", "no");
       document.getElementById("msgDiv").appendChild(txt); 
       document.getElementById("dialog").src=durl;
    	} 
		
function showemoticons ()
{
    for (var i = 1; i <= 35; i++) {
			  var img = document.createElement('img');
                img.src = 'images/emoticons/etc_'+i+'.gif';
				img.onclick = new Function('document.getElementById("Comments").value=document.getElementById("Comments").value +"[etc_'+i+']"');
			document.getElementById("showemoticon").appendChild(img);
            }

}
		