///******************************************************    
///	FileName: Purchase.js
///	Action: 后台求购添加页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XFY
///	Create Date: 2008-12-17
///	Rewriter:
///	Rewrite Date:
///******************************************************  
var rightIcon="../../images/websen.gif"
function ChkInfo(event){
    obj = "txt"+event.data.dd;
    if(event.data.dd<=5)
    {
        if ($("#"+event.data.ss).attr("value")==""){
	        document.getElementById(obj).innerHTML =QgFb[event.data.dd];
            return false;
	    } 
	    else{
	       document.getElementById(obj).innerHTML ="";
	    }   
    }
    else
    {
        if ($("#"+event.data.ss).attr("value")==""){
	        document.getElementById(obj).innerHTML =QgFb[event.data.dd];
            return false;
	    }
	    else if(!isNumber($("#"+event.data.ss).attr("value"))){
		    document.getElementById(obj).innerHTML =QgFb[8];
		    return false; 
		}
	    else{
	        document.getElementById(obj).innerHTML ="";
	    }
    }

}

var txtjbo=new  Array("txtName","txtKey","txtStartDate","txtEndDate","txtCount","txtPrice")
$(document).ready(function(){
	for(var i=0;i<=txtjbo.length;i++){ 
        $("#"+txtjbo[i]).bind("focus",{dd:i,ss:txtjbo[i]},ChkInfo);
        $("#"+txtjbo[i]).bind("blur",{dd:i,ss:txtjbo[i]},ChkInfo);
	};
    $("#btnSave").bind("click",Server);
 });

function Server(){
    var arr = 0;
    var pos;
    for(var i=0;i<txtjbo.length;i++){
        obj="txt"+i;
        if ($("#"+txtjbo[i]).attr("value")==""){
            document.getElementById(obj).innerHTML=QgFb[i];
            pos=txtjbo[i];
            arr=1;
        }
    }
    if(arr==1){
         //alert(pos);
         return false; 
         pos.focus();
    }
    if (!isNumber($("#"+txtjbo[6]).attr("value"))){
        document.getElementById("txt6").innerHTML =QgFb[8];
        alert("需求数量输入有误!");
	    return false;
    }	
    if (!isNumber($("#"+txtjbo[7]).attr("value"))){
        document.getElementById("txt7").innerHTML =QgFb[8];
        alert("产品单价输入有误!");
	    return false;
    }
    else{
        return true; 
    }
    
}

function ClearErr(value){
    if(value==0){
        document.getElementById("txt2").innerHTML ="";
    }
    else{
        document.getElementById("txt3").innerHTML ="";
    }
}

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