/**************************************************/
/*                Html在线编辑器                    */
/**************************************************/
//得到Html编辑器的值
function GetContent()
{
	frmEditer = window.frames("editer").frames("Composition")
	content = document.all("content")
	if ( frmEditer !=null && content !=null )
	{
		content.value=frmEditer.document.body.innerHTML;
	}	
	//wt = setTimeout("GetContent()",1000)
}
//赋值给Html编辑器的值
function WriteContent()
{
	frmEditer = window.frames("editer").frames("Composition")
	content = document.all("content")
	if ( frmEditer !=null && content !=null )
	{
		frmEditer.document.body.innerHTML = content.value;
	}
}


function Check()
{
	chkAll = document.all("chkAll").checked
	var coll = document.all("checkbox");
	
	if (coll != null)
	{
		for(j=0; j < coll.length; j++)
		{
			coll[j].checked = 	chkAll		
		}
	}

	//alert(document.all("chkAll").checked)
}

function Add(theform)
{
	
	theform.operate.value="Add"
	theform.submit();
}

function SubmitAction(theform,action)
{
	//alert (theform)
	theform.action="?action=" + action
}

function Delete()
{
	if(confirm("Are you sure to delete?"))
	{
		return true;
	}	
	else
	{
		return false;
	}
}


var ie = document.all?1:0 
function CA(frm){
var trk=0;
isOnload = 0;

for (var i=0;i<frm.elements.length;i++)
{
var e = frm.elements[i];
if ((e.name != 'allbox') && (e.type=='checkbox'))
{

if (isOnload != 1)
{
trk++;
e.checked = frm.allbox.checked;
if (frm.allbox.checked)
{
	if (e.checked)
	{
		hL(e);
	}
	else
	{
		dL(e);
	}
}
else
{
	if (e.checked)
	{
		hL(e);
	}
	else
	{
		dL(e);
	}
}
}
}
}
}


function CCA(CB){
var frm = CB.form
if (CB.checked)
hL(CB);
else
dL(CB);
var TB=TO=0;
for (var i=0;i<frm.elements.length;i++)
{
var e = frm.elements[i];
if ((e.name != 'allbox') && (e.type=='checkbox'))
{
TB++;
if (e.checked)
TO++;
}
}

if (TO==TB)
frm.allbox.checked=true;
else
frm.allbox.checked=false;
}
function hL(E){
if (ie)
{
while (E.tagName!="TR")
{E=E.parentElement;}
}
else
{
while (E.tagName!="TR")
{E=E.parentNode;}
}
E.className = "H";
}
function dL(E){
if (ie)
{
while (E.tagName!="TR")
{E=E.parentElement;}
}
else
{
while (E.tagName!="TR")
{E=E.parentNode;}
}
E.className = "";
}

//选择图片
function SelectedImg(ImgPath,thisImg)
{
	//ImgPath = "../image/Club/Product/"
	ImgName =opener.document.all("ImgName");
	txtImgName = opener.document.all("txtImgName");
	if (ImgName != null)
	{
		ImgName.src = ImgPath + thisImg;
	}

	if (txtImgName != null)
	{
		txtImgName.value = thisImg
	}
	window.close();
}

function openWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
}

function Jump(value)
{
	location.href=value
}

//选中列表项
function SelectedItem(listName, value)
{
	objList = document.all(listName)
	if (objList != null)
	{
		len = objList.length;
		if (len != 0 )
		{
		for(i=0;i<len;i++)
		{
			if (objList.options[i].value ==value)
			objList.options[i].selected = true;

		}
	}
	}
}

function GetProvince(value)
{
	province = document.all("Province")
	if (province != null)
	{
		len = province.length;
		if (len != 0 )
		{
		for(i=0;i<len;i++)
		{
			if (province.options[i].value ==value)
			province.options[i].selected = true;

		}
	}
	}
}

function SelectChecked(chkChecked, lstCause){
	lstCause = document.all(lstCause);
	if( chkChecked.value == -1 ){		
		lstCause.disabled = false;		
	}
	else if( chkChecked.value == 1){
		lstCause.disabled = true;
	}
	//alert(txtCause.value)
	
}

function ChangeCause(the, causeName, otherValue)
//--------------------------------------------------------------------------------
//  Author 		:       SAM
//  Version     Date			Description
//  1.0         05/15/2004  	change Cause
//  Parameters		:
//	the					Input		the list cause
//	causeName			Input		the cause name
//	otherValue			Input		其它选项的值
//
//  Return Value        :   None
//	Return Type         :   None
//	Functions Called    :	setTextFocus
//
//--------------------------------------------------------------------------------
{
	if(the.options[the.selectedIndex].value==otherValue){ 
		document.all(causeName).style.display='block'}
	else{
		document.all(causeName).style.display='none'
	}
}

function SelectedCause(lstCause, txtCause, selectedValue)
//--------------------------------------------------------------------------------
//  Author 		:       SAM
//  Version     Date			Description
//  1.0         07/18/2003   	Selected list Cause
//  Parameters		:
//	lstCause			Input		the list Cause
//	txtCause			Input		textbox cause
//	selectedValue		Input		selectedValue
//
//  Return Value        :   None
//	Return Type         :   None
//	Functions Called    :	setTextFocus
//
//--------------------------------------------------------------------------------
{
	var existing=false
	cause = document.all(lstCause);
	
	if (cause != null)
	{
		len = cause.length;
		if (len != 0 )
		{
		for(i=0;i<len;i++)
		{
			if (cause.options[i].value ==selectedValue)
			{			
				cause.options[i].selected = true;
				existing = true
			}

		}
		
		if (!existing)
		{
			txtCause = document.all(txtCause)
			if (txtCause != null)
			{
				txtCause.value = selectedValue;
				txtCause.style.display = "block";
				cause.options[len-1].selected = true;
			}

		}
	}
	}
}

function Search()
{
	searchType = document.all("lstSearchType");	
	objKeywords= document.all("txtKeywords");
	var keywords = ""

	if (searchType != null)
	{
		search = searchType.options[searchType.selectedIndex].value;
		if (search == "no")
		{
			alert("Please select search type");
			searchType.focus();
		}
		else
		{
			if (objKeywords !=null)
			{
				keywords = objKeywords.value
			}
			window.open(search + keywords);
		}
		
	}
}

function SearchClub(id)
{
	searchType = document.all("lstSearchType");	
	objKeywords= document.all("txtKeywords");
	var keywords = ""

	if (searchType != null)
	{
		search = searchType.options[searchType.selectedIndex].value;
		if (search == "no")
		{
			alert("Please select search type!")
		}
		else
		{
			if (objKeywords !=null)
			{
				keywords = objKeywords.value
			}
			window.open(search +"?id=" + id + "&keywords=" + keywords);
		}
		
	}
}

//得到焦点时置空

function SetEmptyValue( the, initValue)
{
	if(the.value==initValue)
	{
	  the.value="";
	}	
}
//得到原来方字提示
function GetOriTip( the, oriTip)
{
//	if(the.value=="")
	if(StringIsNull(the.value)==true)
	{
	  the.value=oriTip;
	}	
}

function checkImg(theImgSrc, limitWidth, limitHeight, theUrl, sTitle , sTip){
	var imgObj;
	var imgWidth;
	var imgHeight;
 
  	// 创建图像对象
    imgObj = new Image();
    // 设置图像源
    imgObj.src = theImgSrc;
	imgWidth = imgObj.width;
	imgHeight = imgObj.height;
	if ( sTip !="" && sTip!= null ){
		sTip="<br>" + sTip;
	}
	else
	{
		sTip="";		
	}

    // 是否已取得了图像的高度和宽度
    if (( imgWidth != 0) && ( imgHeight != 0)){
		//根据图片宽度、高度，限制的宽度、高度得到最终的宽度、高度
		if( imgWidth > imgHeight ){//判断图片宽度是否大于图像高度
			if (imgWidth > limitWidth){					
					imgWidth = limitWidth;	
			}
			sImg = "<img src='" + theImgSrc + "' width=" + imgWidth + " onmousewheel='return bbimg(this)' border=0>";
			if ( theUrl !="" && theUrl!= null ){
				sImg = "<a href='" + theUrl + "' target='_blank' title='" + sTitle + "'> " + sImg + sTip +  "</a>";
			}
			document.writeln(sImg)
		}
		else{
			if (imgHeight > limitHeight){					
					imgHeight = limitHeight;	
			}
			sImg =" <img src='" + theImgSrc + "' height=" + imgHeight + " onmousewheel='return bbimg(this)' border=0>";			
			if ( theUrl !="" && theUrl!= null ){
				sImg = "<a href='" + theUrl + "' target='_blank' title='" + sTitle + "'>" + sImg +  sTip +"</a>";
			}
			document.writeln( sImg )
		}		
	}
	else{
		document.writeln("暂无图片")
	}
      
    
}

function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;
	zoom+=event.wheelDelta/12;
	if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}

//HTML过滤函数
function HTMLEncode(text)
{
	text = text.replace(/&/g, "&amp;") ;
	text = text.replace(/"/g, "&quot;") ;
	text = text.replace(/</g, "&lt;") ;
	text = text.replace(/>/g, "&gt;") ;
	text = text.replace(/'/g, "&#146;") ;

	return text ;
}

//设置语言操作	
function setOptElement(theElement, sValue, sClassName, bDisabled){
	//theElement.value = sValue;
	theElement.className = sClassName;
	theElement.disabled = bDisabled;
}


//验证关键词
function CheckKeywords(theElement,tip)
{
	var result = true;
	var keywordsColl = document.all(theElement);
	var strKeywords="";
	if(keywordsColl != null)
	{
		for(var i=0; i < keywordsColl.length; i++ )
		{
			strKeywords += keywordsColl[i].value.trim();
			/*
			if(keywordsColl[i].value.indexOf(",") > 0)
			{
				alert("请在商机的关键词不要包含,");
				keywordsColl[i].focus();
				return false;
			}
			*/			
		}
		
		if(strKeywords =="")
		{
			alert("Please enter " + tip +".");
			keywordsColl[0].focus();
			result = false;
		}
	}
	return result;
}

//验证描述
function CheckDetail(theEditor,tip)
{
	var result = true;
	if( theEditor.getHTML()=="" )
	{
		alert("Please enter "+ tip +".");
		theEditor.VerifyFocus();
		result = false;
			
	}
	return result;
}


String.prototype.trim = function()
{
   return this.replace(/(^\s+)|\s+$/g,"");
 }
 
 //?ù?YID?±?ó??éìòμ?ú?á?ˉ?ì
function InquiryTradeLead(ID){
	window.open("/Inquire.asp?Type=2&id=" +ID ,"SubWin"+ID,"location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=550,left=0,top=0");
}

//?ù?YID2é?±?ó??2ú?·?ˉ?ì
function InquiryProductLeads(ID){
	window.open("http://www.wchem.com/Inquire.asp?Type=1&id=" +ID ,"SubWin"+ID,"location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=680,height=550,left=0,top=0");
}

// ·￠?í?óòμ×é?ˉD??￠
function InquiryCompany(ID){
	window.open("http://www.wchem.com/Inquire.asp?ID=" + ID +"&Type=3","SubWin"+ID,"scrollbars=yes,resizable=yes,width=680,height=550,left=0,top=0");
}