﻿// JScript File

function EnterKey_onkeypress(event) {
var keyCode = event.keyCode;

    if (keyCode == 13) 
    {
        event.keyCode = 0;
     }
}

function ValidateConsignment(RecName, Add1, TotPcs, CWeight) 
{
    if (document.all(RecName).value == "") 
    {
        alert("Please enter the Receiver Name");    
        document.all(RecName).focus();
        return false;
    }
    
    if (document.all(Add1).value == "") 
    {
        alert("Please enter the Address ");    
        document.all(Add1).focus();
        return false;
    }
    
    if (document.all(TotPcs).value <= 0) 
    {
        alert("Please enter the number of pieces");    
        document.all(TotPcs).focus();
        return false;
    }
    
    if (document.all(CWeight).value <= 0) 
    {
        alert("Please the valid weight");    
        document.all(CWeight).focus();
        return false;
    }
    return true;
}

function ValidateNumeric_onkeypress(event) 
{
    var keyCode = event.keyCode;
    if ((keyCode >= 48 && keyCode <= 57) || keyCode == 46)
     {
     return;        
     } 
     else
     {
     event.keyCode = 0;
     }
}

function ValidateNumericWithoutDecimal_onkeypress(event) 
{
    var keyCode = event.keyCode;
    if (keyCode >= 48 && keyCode <= 57) 
     {
     return;        
     } 
     else
     {
        event.keyCode = 0;
     }
}


function ValidateAlphaNumeric_onkeypress(event)
{
var keycode = event.keyCode;
    if (keycode == 96 && keycode == 39)
    {
        event.keyCode = 0;
        return;
    }else if ((keycode >= 48 && keycode <= 57) || (keycode >=65 && keycode <= 90) || keycode == 46 || keycode == 38 || keycode == 32 || keycode == 44 || keycode == 40 || keycode == 41 || keycode == 45 || keycode == 40 || keycode == 41 || keycode == 42 || keycode == 64 || keycode == 47 || keycode == 58 || keycode == 124)  
    {
        return;        
    }else if (keycode >= 97 && keycode <= 122)
    {
        keycode=keycode - 32;
        event.keyCode=keycode;
    }else
    {
        event.keyCode = 0;
        return;
    }
 }
 
 function ValidateAlphaNumericLUCase(event)
 {
    var keycode = event.keyCode;
    if ((keycode >= 48 && keycode <= 57) || (keycode >=65 && keycode <= 90) || (keycode >=97 && keycode <= 122) || keycode == 46 || keycode == 38 || keycode == 32 || keycode == 44 || keycode == 40 || keycode == 41 || keycode == 45 || keycode == 40 || keycode == 41 || keycode == 42|| keycode == 64 )
    {
        keycode=event.keyCode;
        return;
    }
    else
    {
        event.keyCode=0;
        return;
    }
 }

function Clear_Consignment(ConNo,RecCode,RecName,RContact,RAdd1,RAdd2,RAdd3,RZip,RCity,RState,RCountry,RPhone1,RPhone2,RPhone3,RFax,RDept,TotPcs,ConWeight,InvValue,RRef1,RRef2,CContent,CSplInst,CInsurance,CDim,btnDelete,btnPreview)
{
    document.all(ConNo).value="";
    document.all(RecCode).value="";
    document.all(RecName).value="";
    document.all(RContact).value="";
    document.all(RAdd1).value="";
    document.all(RAdd2).value="";
    document.all(RAdd3).value="";
    document.all(RZip).value="";
    document.all(RCity).value="";
    document.all(RState).value="";
    document.all(RCountry).value="";
    document.all(RPhone1).value="";
    document.all(RPhone2).value="";
    document.all(RPhone3).value="";
    document.all(RFax).value="";
    document.all(RDept).value="";
    document.all(TotPcs).value="";
    document.all(ConWeight).value="";
    document.all(InvValue).value="";
    document.all(RRef1).value="";
    document.all(RRef2).value="";
    document.all(CContent).value="";
    document.all(CSplInst).value="";
    document.all(CInsurance).checked="checked";
    document.all(CDim).value="";
    document.all(ConNo).readOnly="";
    document.all(RecName).focus();
    document.all(btnDelete).disabled=true;
    document.all(btnPreview).disabled=true;
    return false;
}

function ValidateRequest(ReqBy,NCons,NFlyers,NSBox,NMBox,NLBox,OthItem,OthQty)
{    
    if (document.all(ReqBy).value == "") 
    {
        alert("Please enter the Name(Requested by)");    
        document.all(ReqBy).focus();
        return false;
    }
    
    if ((document.all(OthQty).value >= 1) && (document.all(OthItem).value == ""))
    {
        alert("Please enter the descrption for Other Item");
        document.all(OthItem).focus();
        return false; 
    }
    
    if  (document.all(OthItem).value == "")
    {
    
    }
    else
    {
        if ((document.all(OthQty).value == "") || (document.all(OthQty).value < 1))
        {
            alert("Please enter the valid quantity(other quantity)");
            document.all(OthQty).focus();
            return false; 
        }
    }
    
    if ((document.all(NCons).value == "") && (document.all(NFlyers).value == "") && 
        (document.all(NSBox).value == "") && (document.all(NMBox).value == "") && 
        (document.all(NLBox).value == "") && (document.all(OthQty).value == ""))
    {
        alert("Please enter the valid quantity");
        document.all(NCons).focus();
        return false;
    }
    return true;
}

function Clear_Request(ReqBy,NCons,NFlyers,NSBox,NMBox,NLBox,OthItem,OthQty)
{
    document.all(ReqBy).value="";
    document.all(NCons).value="";
    document.all(NFlyers).value="";
    document.all(NSBox).value="";
    document.all(NMBox).value="";
    document.all(NLBox).value="";
    document.all(OthItem).value="";
    document.all(OthQty).value="";
    document.all(ReqBy).focus();
    return false;
}

function ValidateChangePass(clientID,oldPass,newPass,confPass,cIdValue)
{
    if (document.all(clientID).value == "")
    {
        alert("Please enter the valid Client ID");
        document.all(clientID).focus();
        return false;
    }
    
    if (document.all(clientID).value != cIdValue)
    {
        alert("Invalid Client ID, Please enter the valid Client ID");
        document.all(clientID).focus();
        return false;
    }

    if (document.all(oldPass).value == "")
    {
        alert("Please enter the valid password(Old)");
        document.all(oldPass).focus();
        return false;
    }
    if (document.all(newPass).value == "") 
    {
        alert("Please enter the valid password(New)");
        document.all(newPass).focus();
        return false;
    }
    if (document.all(confPass).value == "")
    {
        alert("Please enter the valid password(Confirm)");
        document.all(confPass).focus();
        return false;
    }
    
    if (document.all(newPass).value != document.all(confPass).value)
    {
        alert("Please enter the valid password, New password and confirm password should be the same");
        document.all(newPass).focus();
        return false;
    }
    return true;
}

function ClearChangePass(clientID,oldPass,newPass,confPass)
{
    document.all(clientID).value=""
    document.all(oldPass).value=""
    document.all(newPass).value=""
    document.all(confPass).value=""
    document.all(clientID).focus();
    return false;
}


function ClearClientSignup(cCode,cName,cContact,cAdd1,cAdd2,cAdd3,cPostal,cCity,cState,cCountry,cPhone1,cPhone2,cFax,cEmail)
{
    document.all(cCode).value=""
    document.all(cName).value=""
    document.all(cContact).value=""
    document.all(cAdd1).value=""
    document.all(cAdd2).value=""
    document.all(cAdd3).value=""
    document.all(cPostal).value=""
    document.all(cCity).value=""
    document.all(cState).value=""
    document.all(cCountry).value=""
    document.all(cPhone1).value=""
    document.all(cPhone2).value=""
    document.all(cFax).value=""
    document.all(cEmail).value=""
    document.all(cCode).focus()
    return false;
}

function ValidateClientSignup(cCode,cName,cContact,cAdd1,cAdd2,cAdd3,cPostal,cCity,cState,cCountry,cPhone1,cPhone2,cFax,cEmail)
{
    if (document.all(cCode).value=="")
    {
        alert("Please enter valid Client Code");
        document.all(cCode).focus();
        return false;
    }
    
    if (document.all(cName).value=="")
    {
        alert("Please enter the valid Client Name");
        document.all(cName).focus();
        return false;
    }
    
    if (document.all(cContact).value=="") 
    {
        alert("Please enter the valid Contact");
        document.all(cContact).focus();
        return false;
    }
    
    if (document.all(cAdd1).value=="")
    {
        alert("Please enter the valid Address");
        document.all(cAdd1).focus();
        return false;
    }
    
    if (document.all(cPostal).value=="") 
    {
        alert("Please enter the valid Postal");
        document.all(cPostal).focus();
        return false;
    }

    if (document.all(cCity).value=="") 
    {
        alert("Please enter the valid City");
        document.all(cCity).focus();
        return false;
    }
    
    if (document.all(cState).value=="") 
    {
        alert("Please enter the valid State");
        document.all(cState).focus();
        return false;
    }
    
    if (document.all(cPhone1).value=="") 
    {
        alert("Please enter the valid Phone");
        document.all(cPhone1).focus();
        return false;
    }
    
    if (document.all(cEmail).value=="") 
    {
        alert("Please enter the valid E-mail");
        document.all(cEmail).focus();
        return false;
    }
    return true;
}


function ValidateForgotPass(reqBy,cId)
{
    if (document.all(reqBy).value=="" ) 
    {
        alert("Please enter the Requested by");
        document.all(reqBy).focus();
        return false;
    }
    if (document.all(cId).value=="" ) 
    {
        alert("Please enter the valid Client Code");
        document.all(cId).focus();
        return false;
    }
    return true;
}
function ClearForgotPass(reqBy,cId)
{
    document.all(reqBy).value=""
    document.all(cId).value=""
    document.all(reqBy).focus()
    return false;
}

function printAAA(doc)
{
    var a;
    alert('hell');
    a = open('http://192.168.0.160/AvantiWeb/RptConNote.aspx?ConNo=' + doc );
    a.print();
    a.close();
    
}


function popupConlist(vCtl) {
    var pop;
    var WinSettings = "center:yes;resizable:yes;dialogHeight:300px";
    //pop=window.open('Conlist.aspx?formname=aspnetForm.'+ vCtl,'width=160,height=188,toolbar=no,menubar=no,location=no,top=250, left=350');
    pop=window.showModalDialog('Conlist.aspx',WinSettings);
}


function Print()
{
	window.print();
}

function showDetails(rCode, rName, rContact, rAdd1, rAdd2, rAdd3, rPostal, rCity, rState, rCountry, rPhone1, rPhone2, rPhone3, rFax)
{
    opener.document.getElementById(Request.QueryString("rName")).value=rName;
    opener.document.getElementById(Request.QueryString("rCode")).value=rCode;  
    opener.document.getElementById(Request.QueryString("rContact")).value=rContact;
    opener.document.getElementById(Request.QueryString("rAdd1")).value=rAdd1;
    opener.document.getElementById(Request.QueryString("rAdd2")).value=rAdd2;
    opener.document.getElementById(Request.QueryString("rAdd3")).value=rAdd3;
    opener.document.getElementById(Request.QueryString("rPostal")).value=rPostal;
    opener.document.getElementById(Request.QueryString("rCity")).value=rCity;
    opener.document.getElementById(Request.QueryString("rState")).value=rState;
    opener.document.getElementById(Request.QueryString("rCountry")).value=rCountry;
    opener.document.getElementById(Request.QueryString("rPhone1")).value=rPhone1;
    opener.document.getElementById(Request.QueryString("rPhone2")).value=rPhone2;
    opener.document.getElementById(Request.QueryString("rPhone3")).value=rPhone3;
    opener.document.getElementById(Request.QueryString("rFax")).value=rFax;
    window.close();        
}       

function SignupClick()
{
    a=window.open('Clientsignup.aspx','Consignment','height=433, width=833, toolbar=no, menubar=no,location=no,top=298, left=185'); 
    a.focus();
    return false;
}

function ForgotPassClick()
{
    a=window.open('ForgotIDPass.aspx','Consignment','height=433, width=833, toolbar=no, menubar=no,location=no,top=298, left=185'); 
    a.focus();
    return false;
}


function EnableClientProfileTextbox(subName,contact,add1,add2,add3,postal,city,state,country,phone1,phone2,fax,email) 
{
  document.all(subName).disabled ="";
  document.all(contact).disabled ="";
  document.all(add1).disabled ="";
  document.all(add2).disabled ="";
  document.all(add3).disabled ="";
  document.all(postal).disabled="";
  document.all(city).disabled="";
  document.all(state).disabled="";
  document.all(country).disabled="";
  document.all(phone1).disabled="";
  document.all(phone2).disabled="";
  document.all(fax).disabled="";
  document.all(email).disabled="";
  return false;
}



function NewWindow(mypage, myname, w, h, scroll) 
{ 
    var winl = ((screen.width - w) / 2); 
    var wint = ((screen.height - h) / 2); 
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'; 
    win = window.open(mypage, myname, winprops);
}





function imgBtnRecList_onclick(rCode, rName, rContact, rAdd1, rAdd2, rAdd3, rPostal, rCity, rState, rCountry, rPhone1, rPhone2, rPhone3, rFax) {
    calendar_window=window.open("ConList.aspx?formName=aspnetForm&rCode=" + rCode +
                     "&rName=" + rName + "&rContact=" + rContact + "&rAdd1=" + rAdd1 + "&rAdd2=" +
                      rAdd2 + "&rAdd3=" + rAdd3 + "&rPostal=" + rPostal + "&rCity=" + rCity +
                      "&rState=" + rState + "&rCountry=" + rCountry + "&rPhone1=" + rPhone1 +"&rPhone2=" + rPhone2 +"&rPhone3=" + rPhone3 +
                      "&rFax=" + rFax, 'ConList','width=700,height=225,toolbar=no,menubar=no,location=no,top=405, left=273');                
    calendar_window.focus();   
    return false;
}

function RObj(ea){
var LS="";
var QS=new Object();
var un="undefined";
var x=null;
var f="function";
var n="number";
var r="string";
var e1="ERROR:Index out of range in\r\nRequest.QueryString";
var e2="ERROR:Wrong number of arguments or invalid property assignment\r\nRequest.QueryString";
var e3="ERROR:Object doesn't support this property or method\r\nRequest.QueryString.Key";
function Err(arg){if(ea){alert("Request Object:\r\n"+arg)}};
function URID(t){var d="";
if(t){for(var i=0;i<t.length;++i){
var c=t.charAt(i);d+=(c=="+"?" ":c)}};
return unescape(d)};
function OL(o){var l=0;for(var i in o){if(typeof o[i]!=f){l++}};return l};
function AK(key){var auk=true;
for(var u in QS){if(typeof QS[u]!=f&&u.toString().toLowerCase()==key.toLowerCase()){auk=false;return u}}if(auk){QS[key]=new Object();
QS[key].toString=function(){return TS(QS[key])};
QS[key].Count=function(){return OL(QS[key])};QS[key].Count.toString=function(){return OL(QS[key]).toString()};
QS[key].Item=function(e){if(typeof e==un){return QS[key]}else {if(typeof e==n){var a=QS[key][Math.ceil(e)];
if(typeof a==un){Err(e1+"(\""+key+"\").Item("+e+")")};
return a}else {Err("ERROR:Expecting numeric input in\r\nRequest.QueryString(\""+key+"\").Item(\""+e+"\")")}}};
QS[key].Item.toString=function(e){if(typeof e==un){return QS[key].toString()}else {var a=QS[key][e];
if(typeof a==un){Err(e1+"(\""+key+"\").Item("+e+")")};
return a.toString()}};
QS[key].Key=function(e){var t=typeof e;
if(t==r){var a=QS[key][e];
return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e3+"("+(e?e:"")+")")}};
QS[key].Key.toString=function(){return x}};
return key};
function AVTK(key,val){if(key!=""){var key=AK(key);
var l=OL(QS[key]);
QS[key][l+1]=val}};
function TS(o){var s="";
for(var i in o){var ty=typeof o[i];
if(ty=="object"){s+=TS(o[i])}else if(ty!=f){s+=o[i]+", "}};
var l=s.length;if(l>1){return(s.substring(0,l-2))}return(s==""?x:s)};
function KM(k,o){var k=k.toLowerCase();
for(var u in o){if(typeof o[u]!=f&&u.toString().toLowerCase()==k){return u}}}if(window.location&&window.location.search){LS=window.location.search;
var l=LS.length;
if(l>0){LS=LS.substring(1,l);
var preAmpAt=0;
var ampAt=-1;
var eqAt=-1;
var k=0;
var skip=false;
for(var i=0;i<l;++i){var c=LS.charAt(i);
if(LS.charAt(preAmpAt)=="="||(preAmpAt==0&&i==0&&c=="=")){skip=true}if(c=="="&&eqAt==-1&&!skip){eqAt=i}if(c=="&"&&ampAt==-1){if(eqAt!=-1){ampAt=i}if(skip){preAmpAt=i+1};
skip=false}if(ampAt>eqAt){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,ampAt)));
preAmpAt=ampAt+1;eqAt=ampAt=-1;++k}}if(LS.charAt(preAmpAt)!="="&&(preAmpAt!=0||i!=0||c!="=")){if(preAmpAt!=l){if(eqAt!=-1){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,l)))}else if(preAmpAt!=l-1){AVTK(URID(LS.substring(preAmpAt,l)),"")}}if(l==1){AVTK(LS.substring(0,1),"")}}}};var TC=OL(QS);if(!TC){TC=0};QS.toString=function(){return LS.toString()};QS.Count=function(){return(TC?TC:0)};QS.Count.toString=function(){return(TC?TC.toString():"0")};QS.Item=function(e){if(typeof e==un){return LS}else {if(typeof e==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return QS[i]}};Err(e1+"().Item("+e+")")}else {return QS[KM(e,QS)]}};return x};QS.Item.toString=function(){return LS.toString()};QS.Key=function(e){var t=typeof e;if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return i}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e2+"().Key("+(e?e:"")+")")};Err(e1+"().Item("+e+")")};QS.Key.toString=function(){Err(e2+"().Key")};this.QueryString=function(k){if(typeof k==un){return QS}else {var k=KM(k,QS);if(typeof QS[k]==un){t=new Object();t.Count=function(){return 0};t.Count.toString=function(){return "0"};t.toString=function(){return x};t.Item=function(e){return x};t.Item.toString=function(){return x};t.Key=function(e){Err(e3+"("+(e?e:"")+")")};t.Key.toString=function(){return x};return t}if(typeof k==n){return QS.Item(k)}else {return QS[k]}}};this.QueryString.toString=function(){return LS.toString()};this.QueryString.Count=function(){return(TC?TC:0)};this.QueryString.Count.toString=function(){return(TC?TC.toString():"0")};this.QueryString.Item=function(e){if(typeof e==un){return LS.toString()}else {if(typeof e==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return QS[i]}};Err(e1+".Item("+e+")")}else {return QS[KM(e,QS)]}}if(typeof e==n){Err(e1+".Item("+e+")")};return x};this.QueryString.Item.toString=function(){return LS.toString()};this.QueryString.Key=function(e){var t=typeof e;if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]=="object"&&(++c==e)){return i}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e2+".Key("+(e?e:"")+")")};Err(e1+".Item("+e+")")};this.QueryString.Key.toString=function(){Err(e2+".Key")};this.Version=1.3;this.Author="Andrew Urquhart (www.andrewu.co.uk)"};var Request=new RObj(false);