function upload(field,srcId) {
	window.open("../common/uploadPic.jsp?field="+field+"&srcId="+srcId,"","height=400,width=600,left=190,top=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
} 
function selectpic(field,srcId) {
	window.open("../common/selectPic.jsp?field="+field+"&srcId="+srcId,"","height=400,width=600,left=190,top=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
} 
function clearpic() {
	document.theform.myface.value="";
	document.theform.productPic.src="../images/no.gif";
}
  
  function Jtrim(str){

        var i = 0;
        var len = str.length;
        if ( str == "" ) return( str );
        j = len -1;
        flagbegin = true;
        flagend = true;
        while ( flagbegin == true && i< len)
        {
           if ( str.charAt(i) == " " )
                {
                  i=i+1;
                  flagbegin=true;
                }
                else
                {
                        flagbegin=false;
                }
        }

        while  (flagend== true && j>=0)
        {
            if (str.charAt(j)==" ")
                {
                        j=j-1;
                        flagend=true;
                }
                else
                {
                        flagend=false;
                }
        }

        if ( i > j ) return ("")

        trimstr = str.substring(i,j+1);
        return trimstr;
}


function checkdata() {
		var keywords="";
	if(document.theform.keywords.value){
		keywords+=document.theform.keywords.value;
	}
	if(document.theform.keywords2.value){
		keywords+=','+document.theform.keywords2.value;
	}
	if(document.theform.keywords3.value){
		keywords+=','+document.theform.keywords3.value;
	}
	document.theform.keys.value = keywords
	doSubmit();	
	if(Jtrim(document.theform.bigclass.options[document.theform.bigclass.selectedIndex].value)==''){
		window.alert ("请选择行业大类！")
		document.theform.bigclass.focus();
		return false
	}
	
	if(Jtrim(document.theform.category.options[document.theform.category.selectedIndex].value)==''){
		window.alert ("请选择行业子类！")
		document.theform.category.focus();
       		 return false
	}
		
	if (Jtrim(document.theform.products.value)=='') {
	        window.alert ("商机主题不能为空 ！")
		document.theform.products.focus();
	        return false
        }else if(Jtrim(document.theform.products.value)=='供应'){
		window.alert ("供应主题不能为空！")
		document.theform.products.focus();
       		return false
	}else if(Jtrim(document.theform.products.value)=='求购'||Jtrim(document.theform.products.value)=='采购'){
		window.alert ("采购主题不能为空！")
		document.theform.products.focus();
       		return false
	}else if(Jtrim(document.theform.products.value).length>50){
		window.alert ("商机主题不能大于50个字 ！")
		document.theform.products.focus();
       		return false
	}
	

var f=document.theform;
	if(keywords == "") {
		alert("请填写关键词！");
		document.theform.keywords.focus();
		return false;
	}
	var type=document.theform.type.value;
	if(type=="卖方"||type=="招商"){
	
	var _cn=f.country.value;
		if(_cn=="CN"&&f.cncity.value==""){
				alert('请填写产品原产地');
				document.theform.cncity.focus();
				return false;
		}
		//else if(!("HK" == _cn || "TW" == _cn || "MO" == _cn)&&_cn!="CN"&&f.encity.value==""){
//			alert('请选择产品原产地');
//			document.theform.encity.focus();
//			return false;
//		}
	}
	
		var price=f.price.value;
		var sunit=f.unit.value;
		if(price!=""&&sunit==""){
			alert('请填写计量单位');
			f.unit.focus();
			return false;
		}
		if(price==""&&sunit!=""){
			alert('请填写价格');
			f.price.focus();
			return false;
		}
		
		
	if(Jtrim(document.theform.shopTime.options[document.theform.shopTime.selectedIndex].value)==''){
		window.alert ("请选择有效期！")
		document.theform.shopTime.focus();
       		 return false
	}
	/**
	if(Jtrim(document.theform.need.value).length>500){
		window.alert ("对代理商要求不能大于500个字符 ！")
		document.theform.need.focus();
       		return false
	}
	if(Jtrim(document.theform.support.value).length>500){
		window.alert ("可提供的支持不能大于500个字符 ！")
		document.theform.support.focus();
       		return false
	}
	*/
	
	var fck = FCKeditorAPI.GetInstance('description');
	var content = fck.GetXHTML();
	if (Jtrim(content)=='') {
                window.alert ("详细说明不能为空 ！")
		fck.Focus();
                return false
        }else if(Jtrim(content).length>30000){
		window.alert ("详细说明不能大于30000个字 ！")
		fck.Focus();
       		return false
	}	
	
	return true
}
