/**************************************************/
/*                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.action)
	
	theform.method = "POST"
	theform.action="?action=" + action
}

function SubmitOperate(theform,Operate)
{
	//alert (theform.action
	theform.method = "POST"
	theform.Operate.value=Operate;
	//theform.action= theform.action + "?action=" + action
}

function Delete()
{
	if(confirm("你确定要删除吗？"))
	{
		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 SelectedImg1(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
	}
	opener.document.anchors["ProductPhoto"];
	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 ShowObjectByValue(formKey,listElementName, showElementName, currentValue )
{
	var listElement=document.forms[formKey].elements[listElementName];
	//var showElement=document.forms[formKey].elements[showElementName];
	var showElement=document.all(showElementName);
	var selectValue = listElement.options[listElement.selectedIndex].value;
	if( selectValue == currentValue)
	{
		showElement.style.display="block";
	}
	else
	{
		showElement.style.display="none";
	}	

}

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("请选择搜索类型！");
			searchType.focus();
		}
		else
		{
			if (objKeywords !=null)
			{
				keywords = objKeywords.value
			}
			window.open(search + keywords);
		}
		
	}
}



function SearchAll()
{	
	objKeywords= document.all("txtKeywords");
	var keywords = objKeywords.value;	
	var searchUrl = "http://search.wchem.com/ChemSearch.aspx?sort=0&q=";
	
	if(keywords=="输入关键词...")
	{
		//alert("请输入关键词！");
		//objKeywords.focus();
		//return false;
		window.open("http://search.wchem.com/");
		return false;
	}	
	window.open(searchUrl + 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("请选择搜索类型！")
		}
		else
		{
			if (objKeywords !=null)
			{
				keywords = objKeywords.value
			}
			window.open(search +"?id=" + id + "&keywords=" + keywords);
		}
		
	}
}

//- 得到不能通过审核的原因
function GetCause(value)
{
	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 ==value)
			{			
				cause.options[i].selected = true;
				existing = true
			}

		}
		
		if (!existing)
		{
			txtCause = document.all("txtCause")
			if (txtCause != null)
			{
				txtCause.value = value;
				txtCause.style.display = "block";
				cause.options[len-1].selected = true;
			}

		}
	}
	}
}

//得到焦点时置空

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 doZoom(size){
document.getElementById('zoom').style.fontSize=size+'px'
}

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)
{

	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("请输入" + tip +"！");
			keywordsColl[0].focus();
			result = false;
		}
	}
	return result;
}

//选择年份
function selectYear(formKey,elementName, minYear, maxYear, currentValue )
{
	var j=0;
	var element=document.forms[formKey].elements[elementName];
	
	for (var i=maxYear; i>=minYear; i--)
	{
		element.options.add(new Option(i +"年", i));
		if( i == currentValue ) element.options[j+1].selected = true;
		j++;
	} 
}

//验证描述
function CheckDetail(theEditor,tip)
{
	var result = true;
	if( theEditor.getHTML()=="" )
	{
		alert("请输入"+ tip +"！");
		theEditor.VerifyFocus();
		result = false;
			
	}
	return result;
}

//增加字符串 Trim 属性
String.prototype.trim = function()
{
   return this.replace(/(^\s+)|\s+$/g,"");
 }
 
 
//根据TraCQID调用在线会话
function OnlineTalk(ID){
	window.open("http://tracq.net/inter.jsp?uin=" + ID ,"SubWin" +ID ,"width=430,height=315,location=no,resizable=0,scrollbars=0,status=no,toolbar=no,menu=no,top=100,left=200");
}
//根据ID直接对商业机会询盘
function InquiryTradeLead(ID){
	window.open("http://www.wchem.com/Inquire.asp?Type=2&id=" +ID ,"SubWin"+ID,"location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=550,left=0,top=0");
}

//根据ID查直接对产品询盘
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");
}

// 发送企业咨询信息
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");
}

function SendSMS(ID, SendType){
	window.open("/SMS/Send.asp?CellNumber=" + ID + "&SendType=" + SendType ,"SendSMS","scrollbars=yes,resizable=yes,width=244,height=412,left=300,top=100");
}

function Delete()
{
	if(confirm("你确定要删除吗？"))
	{
		return true;
	}	
	else
	{
		return false;
	}
}

function AddMedia(ID, Name, Putdate, MemberType,MediaType,Pic){
	//alert(Name)
	window.open("../E-Media/ShowMedia.asp?Operate=Add&ID="+ ID + "&Name=" + Name + "&PutDate=" + Putdate + "&MemberType=" + MemberType + "&MediaType=" + MediaType + "&Pic=" + Pic, "Medita","width=500;height=400,scrollbars=yes,resizable=yes");	
}

function Subscribe(theForm, Action){
	var txtEmail = theForm.txtEmail;
	if(txtEmail.value == "" || txtEmail.value =="输入您的E-mail..." ){
		alert("请输入您的Email!");
		txtEmail.focus();
		return false;
	}
	theForm.action = "/Subscribe/subscribe.asp?action=" + Action
	return true;
}

function minWindow(){
//--------------------------------------------------------------------------------
//  Author 		:       Sam
//  Version     Date			Description
//  1.0         12/12/2004   	将窗体放到最大 
//								
//  Parameters		:
//  Name				Mode		Description
//
//  Return Value        :   none
//	Return Type         :   none
//
//--------------------------------------------------------------------------------
	
	window.moveTo(1400,1400);
	window.resizeTo(10,10);
}



