///******************************************************    
///	FileName: Purchase.js
///	Action: 会员中心求购添加页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XFY
///	Create Date: 2008-12-17
///	Rewriter:
///	Rewrite Date:
///******************************************************  
var rightIcon="../images/websen.gif"
var rightIcons="../../images/icon_nothing.gif";
var txtjbo=new  Array("ctl00_ContInfo_txtName","ctl00_ContInfo_txtKey","ctl00_ContInfo_txtBrand","ctl00_ContInfo_txtModel","ctl00_ContInfo_txtCount","ctl00_ContInfo_txtPrice")
//得到焦点
for(var i=0;i<txtjbo.length;i++){ $(txtjbo[i]).onfocus =function ()
{for (var j=0;j<txtjbo.length;j++)
{if (txtjbo[j]==event.srcElement.id){postobj(j);}}}}
function postobj(num)
{
obj = "txt"+num;
document.getElementById(obj).innerHTML =Purchase[num];
}
function oo(){$("yc").style.display="none"}
//失去焦点
for(var i=0;i<txtjbo.length;i++){ $(txtjbo[i]).onblur =function ()
{for (var j=0;j<txtjbo.length;j++)
{if (txtjbo[j]==event.srcElement.id){postobjs(j);}}}}
function postobjs(num)
{
  var obj="txt"+num;
if ($(obj).innerHTML!="")
  {$(obj).innerHTML=""}
else 
  {$(obj).innerHTML=ok;}
 
}
function getobj(objName){
   if ($) {
      return eval('$("'+ objName +'")');
   }else{
      return eval('document.all["'+ objName +'"]');
   }
}

$("ctl00_ContInfo_btnSave").onclick=function(){
   var Purases=new Array()
   Purases[0]=Purchases(txtjbo[0],0,0)
   Purases[1]=Purchases(txtjbo[1],1,0)
   Purases[2]=Purchases(txtjbo[4],4,1)
   Purases[3]=Purchases(txtjbo[5],5,1)
   var flag=1;
   for (i=0;i<Purases.length;i++){
      if (Purases[i]==false){
         flag=0;
         break;
      } 
   } 
   if(flag==0){
      return false;
   // else if(FileUPload(2)!=0)
   //{alert("上传图片不能为空！")
   //return false;}
   }else if($("ctl00_ContInfo_txtStartDate").value=="" || $("ctl00_ContInfo_txtEndDate").value==""){
      alert("时间不能为空！")
      return false
   }else{
      return true;
   }
}

//方法
function Purchases(name,num,bernum)
{
   var obj="txt"+num
   if($(name).value.replace(/\s/g,'')==""){
     $(obj).innerHTML=QgFb[num]
     return false;
   }else if(bernum==1){
      if (!isNumber(getobj(txtjbo[num]).value.replace(/\s/g,''))){
         $(obj).innerHTML=QgFb[6];
         return false 
      }else{
         $(obj).innerHTML=ok;
         return true
      } 
   }else{
      $(obj).innerHTML=ok;
      return true
   }
}

//显示信息
var ok="<font color=#999999>输入符合规范</font>";
var title="<p>";
var titles="</p>"
var Purchase=new Array()
Purchase[0]=title+"请输入商机名称"+titles
Purchase[1]=title+"请输入关键字，以便快速搜索该产品"+titles
Purchase[2]=title+"请输入该产品的品牌名称"+titles
Purchase[3]=title+"请输入该产品的型号"+titles
Purchase[4]=title+"请输入需求多少数量"+titles
Purchase[5]=title+"请输入产品的单价"+titles

//求购信息
var QgFb=new Array(9);
QgFb[0]="<img src="+rightIcon+" width=\"19\" height=\"16\" align=\"absmiddle\"> <font color=#FF0000>商机名称不能为空</font>";
QgFb[1]="<img src="+rightIcon+" width=\"19\" height=\"16\" align=\"absmiddle\"> <font color=#FF0000>关键字不能为空</font>";
QgFb[2]="<font></font>";
QgFb[3]="<font></font>";
QgFb[4]="<img src="+rightIcon+" width=\"19\" height=\"16\" align=\"absmiddle\"> <font color=#FF0000>需求数量不能为空</font>";
QgFb[5]="<img src="+rightIcon+" width=\"19\" height=\"16\" align=\"absmiddle\"> <font color=#FF0000>产品单价不能为空</font>";
QgFb[6]="<img src="+rightIcon+" width=\"19\" height=\"16\" align=\"absmiddle\"> <font color=#FF0000>输入不符合规范,请输入数字!</font>";
