﻿
 function fncheckBrand()
        {
            var strCatgName = '';
            var strCatgDesc = '';
            var Strimagecatg='';
            var countimage=0;  	
                strCatgName   = document.getElementById("ctl00_head_txtName").value;
                strCatgDesc   = document.getElementById('ctl00_head_Editor1').value;
                Strimagecatg	=document.getElementById('ctl00_head_FlUploadImage').value;
                countimage=document.getElementById('ctl00_head_FlUploadImage').value.length;
             
                 if (strCatgName == '')
                {
                    window.alert('Brand name cannot be blank.'); 
                    document.aspnetForm.ctl00_head_txtName.focus();
            		
                    return false;	
                }
                 if(Strimagecatg=='')
                {
                    window.alert('Brand image cannot be blank');
                   // document.form1.FlUploadImage.focus();
                    return false;
                }
                if(countimage==0)
                {
                    window.alert('Brand image cannot be blank');
                   // document.form1.FlUploadImage.focus();
                    return false;
                }
//                 if (strCatgDesc == '')
//                {
//                    window.alert('Brand Description cannot be blank.'); 
//                    //document.form1.Editor1.focus();
//                    return false;	
//                }
            	 
        }
function fncheckCustomerInfo()
    {
            var strBrandNm = '';
            var strCustName = '';
            var StrCustoCompNm ='';
            var strFname = '';
            var strLname = '';
            var StrPhno = '';  
	        var strFaxno = '';
            var strShipTo = '';
            var StrUname = '';  
            var StrPWD = ''; 
            var strEmail = '';
            var stradd = '';
            var strCity = '';
            var strZip='';
            var strMK = '';
            var strFR='';
            
            strBrandNm = document.getElementById("ctl00_head_drpBrand").value;
            strCustName = document.getElementById("ctl00_head_txtCustName").value;
            StrCustoCompNm = document.getElementById("ctl00_head_txtCName").value;;
            strFname = document.getElementById("ctl00_head_txtFname").value;
            strLname = document.getElementById("ctl00_head_txtLname").value;
            StrPhno = document.getElementById("ctl00_head_txtPH").value; 
	        strFaxno = document.getElementById("ctl00_head_txtFax").value;
            strShipTo = document.getElementById("ctl00_head_txtShip").value;
            StrUname = document.getElementById("ctl00_head_txtCUname").value; 
            StrPWD = document.getElementById("ctl00_head_txtCUpwd").value;
            strEmail=document.getElementById('ctl00_head_txtEmail').value;
            stradd = document.getElementById("ctl00_head_txtAddress").value;
            strCity = document.getElementById("ctl00_head_txtCity").value;
            strZip = document.getElementById("ctl00_head_txtZip").value;  
//             strMK = document.getElementById("ctl00_head_txtMK").value;
//            strFR = document.getElementById("ctl00_head_txtFR").value;  
//            
               if (strBrandNm == '')
                {
                    window.alert('Please select Brand.'); 
                    document.aspnetForm.ctl00_head_drpBrand.focus();
                    return false;	
                }
               if (strCustName == '')
                {
                    window.alert('Please enter customer name.'); 
                    document.aspnetForm.ctl00_head_txtCustName.focus();
                    return false;	
                }
               if (StrCustoCompNm == '')
                {
                    window.alert('Please enter company name.'); 
                    document.aspnetForm.ctl00_head_txtCName.focus();
                    return false;	
                }
                if (stradd == '')
                {
                    window.alert('Please enter Address.'); 
                    document.aspnetForm.ctl00_head_txtAddress.focus();
                    return false;	
                }
                if (strCity == '')
                {
                    window.alert('Please enter City.'); 
                    document.aspnetForm.ctl00_head_txtCity.focus();
                    return false;	
                }
                if (strZip == '')
                {
                    window.alert('Please enter Zipcode.'); 
                    document.aspnetForm.ctl00_head_txtZip.focus(); 
                    return false;	
                }
//                else
//                {
//                    if (checkInternationalZip(document.getElementById('ctl00_head_txtZip').value)==false)
//                    {
//		                alert("Please enter valid Zipcode.")
//		                document.aspnetForm.ctl00_head_txtZip.focus(); 
//		                return false;
//	                }
//                }
               if (strFname == '')
                {
                    window.alert('Please enter First name.'); 
                    document.aspnetForm.ctl00_head_txtFname.focus();
                    return false;	
                }
                if (strLname == '')
                {
                    window.alert('Please enter Last name.'); 
                    document.aspnetForm.ctl00_head_txtLname.focus();
                    return false;	
                }
                 if (StrPhno == '')
                {
                    window.alert('Please enter Phone number.'); 
                    document.aspnetForm.ctl00_head_txtPH.focus(); 
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('ctl00_head_txtPH').value)==false)
                    {
		                alert("Please enter valid phone number.")
		                document.aspnetForm.ctl00_head_txtPH.focus(); 
		                return false;
	                }
                }
                 if (strFaxno == '')
                {
                    window.alert('Please enter Fax number.'); 
                    document.aspnetForm.ctl00_head_txtFax.focus();
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('ctl00_head_txtFax').value)==false)
                    {
		                alert("Please enter valid Fax number.")
		                document.aspnetForm.ctl00_head_txtFax.focus(); 
		                return false;
	                }
                }
                if (strEmail != '')
                {
                    if (Validateemail(document.getElementById('ctl00_head_txtEmail').value) == false)
                    {
                        window.alert("User's Email is not valid");
                        return false; 
                    }
                }
                if (strShipTo == '')
                {
                    window.alert('Please enter Shipping address.'); 
                    document.aspnetForm.ctl00_head_txtShip.focus();
                    return false;	
                }
                 if (StrUname == '')
                {
                    window.alert('Please enter Username.');
                    document.aspnetForm.ctl00_head_txtCUname.focus();
                    return false;	
                }
                 if (StrPWD == '')
                {
                    window.alert('Please enter Password.'); 
                    document.aspnetForm.ctl00_head_txtCUpwd.focus();
                    return false;	
                }
                
    }
    function fncheckKenanInfoP()
    {
            var strPname = '';
	        var StrPPhno = '';  
	        var strPFaxno = '';
	        var strPEmail = '';
	        strPname = document.getElementById("ctl00_head_txtPname").value;
            StrPPhno = document.getElementById("ctl00_head_txtPPhno").value; 
	        strPFaxno = document.getElementById("ctl00_head_txtPFax").value;
            strPEmail = document.getElementById("ctl00_head_txtPEmail").value;
            
            if (strPname == '')
                {
                    window.alert('Please enter person name.'); 
                    document.aspnetForm.ctl00_head_txtPname.focus();
                    return false;	
                }
                if (StrPPhno == '')
                {
                    window.alert('Please enter person Phone number.'); 
                    document.aspnetForm.ctl00_head_txtPPhno.focus(); 
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('ctl00_head_txtPPhno').value)==false)
                    {
		                alert("Please enter valid phone number.")
		                document.aspnetForm.ctl00_head_txtPPhno.focus(); 
		                return false;
	                }
                }
                 if (strPFaxno == '')
                {
                    window.alert('Please enter person Fax number.'); 
                    document.aspnetForm.ctl00_head_txtPFax.focus();
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('ctl00_head_txtPFax').value)==false)
                    {
		                alert("Please enter valid Fax number.")
		                document.aspnetForm.ctl00_head_txtPFax.focus(); 
		                return false;
	                }
                }
                if (strPEmail == '')
                {
                    window.alert('Please enter email address.'); 
                    document.aspnetForm.ctl00_head_txtPEmail.focus();
                    return false;	
                }
                else
                {
                    if (Validateemail(document.getElementById('ctl00_head_txtPEmail').value) == false)
                    {
                        window.alert("Plese enter valid email address.");
                        document.aspnetForm.ctl00_head_txtPEmail.focus();
                        return false; 
                    }
                }
    }
    function fncheckKenanInfoC()
    {
            var strCNO = '';
            var strAMT = '';
            strCNO = document.getElementById("ctl00_head_txtCNO").value; 
            strAMT = document.getElementById("ctl00_head_txtAmt").value;
            
             if (strCNO == '')
                {
                    window.alert('Please enter compartment number.'); 
                    document.aspnetForm.ctl00_head_txtCNO.focus();
                    return false;	
                }
            if (strAMT == '')
                {
                    window.alert('Please enter total ammount.'); 
                    document.aspnetForm.ctl00_head_txtAmt.focus();
                    return false;	
                }
    }
    function fncheckBrandLoadInfo()
    {
            var strLNO = '';
            var strAMT = '';
            strLNO = document.getElementById("ctl00_head_txtAmt").value; 
            strAMT = document.getElementById("ctl00_head_txtloadFor").value;
            
             if (strLNO == '')
                {
                    window.alert('Please enter Load ammount.'); 
                    document.aspnetForm.ctl00_head_txtAmt.focus();
                    return false;	
                }
            if (strAMT == '')
                {
                    window.alert('Please enter Load for.'); 
                    document.aspnetForm.ctl00_head_txtloadFor.focus();
                    return false;	
                }
    }
    function fncheckNews()
    {
            var strLNO = '';
            var strAMT = '';
            strLNO = document.getElementById("ctl00_head_txtName").value; 
            strAMT = document.getElementById("ctl00_head_Editor1").value;
            
             if (strLNO == '')
                {
                    window.alert('Please enter News title.'); 
                    document.aspnetForm.ctl00_head_txtName.focus();
                    return false;	
                }
//            if (strAMT == '')
//                {
//                    window.alert('Please enter News description.'); 
////                    document.aspnetForm.ctl00_head_Editor1.focus();
//                    return false;	
//                }
    }
     function fncheckPages()
    {
            var strLNO = '';
            var strAMT = '';
            strLNO = document.getElementById("ctl00_head_txtName").value; 
            strAMT = document.getElementById("ctl00_head_Editor1").value;
            
             if (strLNO == '')
                {
                    window.alert('Please enter Page title.'); 
                    document.aspnetForm.ctl00_head_txtName.focus();
                    return false;	
                }
//            if (strAMT == '')
//                {
//                    window.alert('Please enter Page description.'); 
////                    document.aspnetForm.ctl00_head_Editor1.focus();
//                    return false;	
//                }
    }
    function fncheckLogin()
    {
            var strLNO = '';
            var strAMT = '';
            strLNO = document.getElementById("txtUname").value; 
            strAMT = document.getElementById("txtPwd").value;
            
             if (strLNO == '')
                {
                    window.alert('Please enter valid username.'); 
                    document.form1.txtUname.focus();
                    return false;	
                }
            if (strAMT == '')
                {
                    window.alert('Please enter valid password.'); 
                    document.form1.txtPwd.focus();
                    return false;	
                }
    }
     function fncheckUpload()
    {
            var DrpBrand = '';
            var DrpName = '';
            var strLNO = '';
            var strAMT = '';
            var strDate = '';
            DrpBrand = document.getElementById("ctl00_head_DrpBrand").value; 
            DrpName = document.getElementById("ctl00_head_DrpName").value; 
            strLNO = document.getElementById("ctl00_head_txtName").value;
            strAMT = document.getElementById("ctl00_head_FlUploadImage").value;
            strDate = document.getElementById("ctl00_head_txtDate").value;
            
            if (DrpBrand == '' || DrpBrand == 0)
                {
                    window.alert('Please select Brand name.'); 
                    document.aspnetForm.ctl00_head_DrpBrand.focus();
                    return false;	
                }
            if (DrpName == '' || DrpName == 0)
                {
                    window.alert('Please select Customer name.'); 
                    document.aspnetForm.ctl00_head_DrpName.focus();
                    return false;	
                }
             if (strLNO == '')
                {
                    window.alert('Please enter File name.'); 
                    document.aspnetForm.ctl00_head_txtName.focus();
                    return false;	
                }
            if (strAMT == '')
                {
                    window.alert('Please select file to upload.'); 
                    document.aspnetForm.ctl00_head_FlUploadImage.focus();
                    return false;	
                }
            if (strDate == '')
            {
                window.alert('Please enter the Date.'); 
                document.aspnetForm.ctl00_head_txtDate.focus();
                return false;	
            }
    }
    function fncheckKenanInfo()
    {
            
            var StrPhno = '';  
	        var strFaxno = '';
	        var strEmail = '';
	        var strAddress = '';
	        
            StrPhno = document.getElementById("ctl00_head_txtPhno").value;
            strFaxno = document.getElementById("ctl00_head_txtFax").value;
            strEmail = document.getElementById("ctl00_head_txtEmail").value;;
            strAddress = document.getElementById("ctl00_head_txtAddress").value;
            
                if (StrPhno == '')
                {
                    window.alert('Please enter Phone number.'); 
                    document.aspnetForm.ctl00_head_txtPhno.focus(); 
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('ctl00_head_txtPhno').value)==false)
                    {
		                alert("Please enter valid phone number.")
		                document.aspnetForm.ctl00_head_txtPhno.focus(); 
		                return false;
	                }
                }
                 if (strFaxno == '')
                {
                    window.alert('Please enter Fax number.'); 
                    document.aspnetForm.ctl00_head_txtFax.focus(); 
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('ctl00_head_txtFax').value)==false)
                    {
		                alert("Please enter valid Fax number.")
		                document.aspnetForm.ctl00_head_txtFax.focus(); 
		                return false;
	                }
                }
                if (strEmail == '')
                {
                    window.alert('Please enter email address.'); 
                    document.aspnetForm.ctl00_head_txtEmail.focus();
                    return false;	
                }
                else
                {
                    if (Validateemail(document.getElementById('ctl00_head_txtEmail').value) == false)
                    {
                        window.alert("Plese enter valid email address.");
                        document.aspnetForm.ctl00_head_txtEmail.focus();
                        return false; 
                    }
                }
    }
    
function fncheckUpdateCustomerInfo()
    {
            var strBrandNm = '';
            var strCustName = '';
            var StrCustoCompNm ='';
            var strFname = '';
            var strLname = '';
            var StrPhno = '';  
	        var strFaxno = '';
            var strShipTo = '';
            var StrUname = '';  
            var StrPWD = ''; 
            var strEmail = '';
            var stradd = '';
            var strCity = '';
            var strZip='';
            
            strCustName = document.getElementById("txtCustName").value;
            StrCustoCompNm = document.getElementById("txtCName").value;;
            strFname = document.getElementById("txtFname").value;
            strLname = document.getElementById("txtLname").value;
            StrPhno = document.getElementById("txtPH").value; 
	        strFaxno = document.getElementById("txtFax").value;
            strShipTo = document.getElementById("txtShip").value;
            StrUname = document.getElementById("txtCUname").value; 
            StrPWD = document.getElementById("txtCUpwd").value;
            strEmail=document.getElementById('txtEmail').value;
            stradd = document.getElementById("txtAddress").value;
            strCity = document.getElementById("txtCity").value;
            strZip = document.getElementById("txtZip").value;  
               
               if (strCustName == '')
                {
                    window.alert('Please enter customer name.'); 
                    document.aspnetForm.txtCustName.focus();
                    return false;	
                }
               if (StrCustoCompNm == '')
                {
                    window.alert('Please enter company name.'); 
                    document.aspnetForm.txtCName.focus();
                    return false;	
                }
                if (stradd == '')
                {
                    window.alert('Please enter Address.'); 
                    document.aspnetForm.txtAddress.focus();
                    return false;	
                }
                if (strCity == '')
                {
                    window.alert('Please enter City.'); 
                    document.aspnetForm.txtCity.focus();
                    return false;	
                }
                if (strZip == '')
                {
                    window.alert('Please enter Zipcode.'); 
                    document.aspnetForm.txtZip.focus(); 
                    return false;	
                }
//                else
//                {
//                    if (checkInternationalZip(document.getElementById('txtZip').value)==false)
//                    {
//		                alert("Please enter valid Zipcode.")
//		                document.aspnetForm.txtZip.focus(); 
//		                return false;
//	                }
//                }
               if (strFname == '')
                {
                    window.alert('Please enter First name.'); 
                    document.aspnetForm.txtFname.focus();
                    return false;	
                }
                if (strLname == '')
                {
                    window.alert('Please enter Last name.'); 
                    document.aspnetForm.txtLname.focus();
                    return false;	
                }
                 if (StrPhno == '')
                {
                    window.alert('Please enter Phone number.'); 
                    document.aspnetForm.txtPH.focus(); 
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('txtPH').value)==false)
                    {
		                alert("Please enter valid phone number.")
		                document.aspnetForm.txtPH.focus(); 
		                return false;
	                }
                }
                 if (strFaxno == '')
                {
                    window.alert('Please enter Fax number.'); 
                    document.aspnetForm.txtFax.focus();
                    return false;	
                }
                else
                {
                    if (checkInternationalPhone(document.getElementById('txtFax').value)==false)
                    {
		                alert("Please enter valid Fax number.")
		                document.aspnetForm.txtFax.focus(); 
		                return false;
	                }
                }
                if (strEmail != '')
                {
                    if (Validateemail(document.getElementById('txtEmail').value) == false)
                    {
                        window.alert("User's Email is not valid");
                        return false; 
                    }
                }
                if (strShipTo == '')
                {
                    window.alert('Please enter Shipping address.'); 
                    document.aspnetForm.txtShip.focus();
                    return false;	
                }
                 if (StrUname == '')
                {
                    window.alert('Please enter Username.');
                    document.aspnetForm.txtCUname.focus();
                    return false;	
                }
                 if (StrPWD == '')
                {
                    window.alert('Please enter Password.'); 
                    document.aspnetForm.txtCUpwd.focus();
                    return false;	
                }
    }
    
function checkInternationalPhone(strPhone)
{
    var Sl = strPhone.length;
    if ( Sl < 10 || Sl > 10)
    {
      return false;
    }
    else
    {
      return true;
    }
}
function checkInternationalZip(strPhone)
{
    var Sl = strPhone.length;
    if ( Sl < 5 || Sl > 5)
    {
      return false;
    }
    else
    {
      return true;
    }
}

function Validateemail(str)
 {	 
	var at='@';
	var dot='.';
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1)
	{
    	return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		return false;
	}
	if (str.indexOf(at,(lat+1))!=-1)
	{
	   return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
	return false;
	}
	if (str.indexOf(dot,(lat+2))==-1)
	{
	return false;
	}
	if (str.indexOf(" ")!=-1)
	{
	return false;
	}
 	return true;				
}

function ValidateZip(zip)
{
	var valExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	if (!(valExp.test(zip)))
        {
			return false;
		}
	
	return true;
}
  
function fncheckOrder()
        {
            var strDelDate = '';
            var strDelStTime = '';
            var strDelStTimeAP='';
            var strDelEndTime = '';
            var strDelEndTimeAP='';
            var strLocation='';
            var strLocation1='';
            
            strDelDate   = document.getElementById("ctl00_head_txtDelDate").value;
            strDelStTime   = document.getElementById('ctl00_head_drpTimeStrat').value;
            strDelStTimeAP	=document.getElementById('ctl00_head_drpTimeStartAP').value;
            strDelEndTime = document.getElementById('ctl00_head_drpTimeEnd').value;
            strDelEndTimeAP = document.getElementById('ctl00_head_drpTimeEndAP').value;
            strLocation = document.getElementById('ctl00_head_rbtnLocation_0').value;
            strLocation1 = document.getElementById('ctl00_head_rbtnLocation_1').value;

                 if (strDelDate == '')
                {
                    window.alert('Please select Delivery date.'); 
                    document.aspnetForm.ctl00_head_txtDelDate.focus();
                    return false;	
                }
                 if (strDelStTime == 0)
                {
                    window.alert('Please select Delivery Start Time.'); 
                    document.aspnetForm.ctl00_head_drpTimeStrat.focus();
                    return false;	
                }
                 if(strDelStTimeAP==0)
                {
                    window.alert('Plese Select AM/PM.');
                    document.aspnetForm.ctl00_head_drpTimeStartAP.focus();
                    return false;
                }
                if(strDelEndTime==0)
                {
                    window.alert('Please select Delivery End Time.');
                   document.aspnetForm.ctl00_head_drpTimeEnd.focus();
                    return false;
                }
                 if (strDelEndTimeAP == 0)
                {
                    window.alert('Plese Select AM/PM.'); 
                    document.aspnetForm.ctl00_head_drpTimeEndAP.focus();
                    return false;	
                }
            	  if (strLocation == '' && strLocation1 == '')
                {
                    window.alert('Plese Select Location.'); 
                    return false;	
                }
        } 
 function fncheckInvoice()
    {
            var DrpBrand = '';
            var DrpName = '';
            var strDrpSt = '';
            var strAMT = '';
            
            DrpBrand = document.getElementById("ctl00_head_DrpBrand").value; 
            DrpName = document.getElementById("ctl00_head_DrpName").value; 
            strDrpSt = document.getElementById("ctl00_head_drpStatement").value;
            strAMT = document.getElementById("ctl00_head_FlUploadImage").value;
            
            if (DrpBrand == '' || DrpBrand == 0)
                {
                    window.alert('Please select Brand name.'); 
                    document.aspnetForm.ctl00_head_DrpBrand.focus();
                    return false;	
                }
            if (DrpName == '' || DrpName == 0)
                {
                    window.alert('Please select Customer name.'); 
                    document.aspnetForm.ctl00_head_DrpName.focus();
                    return false;	
                }
             if (strDrpSt == '' || strDrpSt == 0)
                {
                    window.alert('Please select statement.'); 
                    document.aspnetForm.ctl00_head_drpStatement.focus();
                    return false;	
                }
            if (strAMT == '')
                {
                    window.alert('Please select file to upload.'); 
                    document.aspnetForm.ctl00_head_FlUploadImage.focus();
                    return false;	
                }
      } 
      
   function fncheckInsp()
    {
            var DrpBrand = '';
            var DrpName = '';
            var strLNO = '';
            var strAMT = '';
            var strDate = '';
            DrpBrand = document.getElementById("ctl00_head_DrpBrand").value; 
            DrpName = document.getElementById("ctl00_head_DrpName").value; 
            strLNO = document.getElementById("ctl00_head_txtName").value;
            strAMT = document.getElementById("ctl00_head_FlUploadImage").value;
            
            if (DrpBrand == '' || DrpBrand == 0)
                {
                    window.alert('Please select Brand name.'); 
                    document.aspnetForm.ctl00_head_DrpBrand.focus();
                    return false;	
                }
            if (DrpName == '' || DrpName == 0)
                {
                    window.alert('Please select Customer name.'); 
                    document.aspnetForm.ctl00_head_DrpName.focus();
                    return false;	
                }
             if (strLNO == '')
                {
                    window.alert('Please enter File name.'); 
                    document.aspnetForm.ctl00_head_txtName.focus();
                    return false;	
                }
            if (strAMT == '')
                {
                    window.alert('Please select file to upload.'); 
                    document.aspnetForm.ctl00_head_FlUploadImage.focus();
                    return false;	
                }
    }