function numCheck(calledby,decs,lval,hval,chk,ordinc){ 
 nval = calledby.value.replace(/\,/g,''); 
 if(isNaN(nval)||nval==""){
  alert('Your entry was not valid, please enter a valid number'); 
  nval=lval;
  setTimeout("document.form1."+calledby.getAttribute('name')+".focus()",1); 
  /* return false; */ 
 }
var nvar = parseFloat(nval); 
fmtvar = nvar.toFixed(decs); 
if(fmtvar < lval || fmtvar > hval){ 
if (fmtvar < lval){alert('The amount entered is less than the minimum order quantity. Please enter an amount of ' + lval + ' or more.')}; 
if (fmtvar > hval){alert('Please call customer support to order this large of a quantity.')}; 
nval=lval;fmtvar=lval.toFixed(decs) 
setTimeout("document.form1."+calledby.getAttribute('name')+".focus()",1); 
/* return; */ 
} 
if (ordinc > 0) { 
if (parseInt(fmtvar)%parseInt(ordinc) != 0){ 
tmp = (parseFloat(fmtvar)+parseFloat(ordinc))/parseFloat(ordinc); 
tmp = parseFloat(tmp)-parseFloat(.5); 
tmp = tmp.toFixed(0); 
fmtvar = parseInt(tmp)*parseInt(ordinc) 
alert('The quantity must be in increments of '+ordinc+', quantity round up to '+fmtvar); 
}; 
}; 
if(isNaN(fmtvar)){fmtvar = ''} 
var s=""+fmtvar; 
fmtvar=''; 
while(s.length>3){ 
l=s.length; 
t=s.substring(l-3); 
s=s.substring(0,l-3); 
fmtvar=','+t+fmtvar; 
} 
fmtvar=s+fmtvar; 
calledby.value=fmtvar; 
return; 
} 
function checkEmail(str){
 if (str == '' ){
  return true;
 }
 var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
 if (filter.test(str) == false){
  alert("Please input a valid email address!");
  document.form1.EML.value='';
  document.form1.EML.focus();
  return false;
 }
}

function hdrHvr(div){
document.getElementById(div).className = 'hdrunselectedhvr';
}

function hdrHvrX(div){
document.getElementById(div).className = 'hdrunselected';
}

function showdiv(div){
npages = parseInt(document.form1.pages.value);
document.getElementById('MAIN').style.display = 'none';
document.getElementById('LMAIN').className = 'hdrunselected';
for (i=1;i<=npages;i++){document.getElementById('PAGE'+i).style.display = 'none';document.getElementById('LPAGE'+i).className = 'hdrunselected'}
document.getElementById(div).style.display = 'block'; 
document.getElementById('L'+div).className = 'hdrselected'; 
return;
}

currentpage=1;
function movepage(nbr){
 npages = parseInt(document.form1.pages.value);
 for (i=1;i<=npages;i++){document.getElementById('LPAGE'+i).style.display = 'none'}
 currentpage += nbr;
 if (currentpage > npages-3){currentpage = npages-3}
 if (currentpage < 1){currentpage = 1}
 if (currentpage+3 > npages) {lastpage = npages} else {lastpage = currentpage+3}
 for (i=currentpage;i<=lastpage;i++){document.getElementById('LPAGE'+i).style.display = 'block'}
 return;
}

function doupdate(pmt,rebuild){
/* alert(pmt); 
 alert(rebuild); */
 if (rebuild != '') {document.getElementById('please_wait').style.display = 'block'}
 value = '';
 type = pmt.type.toLowerCase();
 if (type.substr(0,6)=='select'){type='select'};
 switch(type){
  case 'select':
   value = pmt.options[pmt.selectedIndex].value;
   break;
  case 'checkbox':
   if (pmt.checked) {value = pmt.value};
   break;
  case 'radio':
   value = pmt.value;
   break;
  case 'text':
   value = pmt.value; 
   break;
  case 'file':
   value = pmt.value; 
   break;
  case 'textarea':
   value = pmt.value; 
   break;
 }
 value = esctext(value);
 arg = 'netlink.pl?PROGRAM=REXMAIN&amp;SUBMIT=CUSTOMUPDATE&amp;PROMPT='+pmt.name+'&amp;VALUE='+value+'&amp;UPDATEGRAPHIC='+rebuild
 var DATETIME = new Date().getTime();
 arg = arg+'&DATETIME='+DATETIME
 if (window.XMLHttpRequest) objHTTP = new XMLHttpRequest();
 else if (window.ActiveXObject) {
  try {
   objHTTP = new ActiveXObject("Msxml2.XMLHTTP")
  } catch(e) {
   try {
    objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
   } catch(e) {}
  }
 }
 else return;
 objHTTP.onreadystatechange = function() {
  if(objHTTP.readyState == 4){
   var tvar = objHTTP.responseText.substring(objHTTP.responseText.indexOf('<HTML>')+6,objHTTP.responseText.indexOf('<\/HTML>'));
  if (tvar != ''){
    tvars = tvar.split("|");
    divs = tvars[0].split("^");
    vals = tvars[1].split("^");
    rtype = tvars[2].split("^");
    for (i=0;i<divs.length;i++){
     switch(rtype[i]) {
      case 'src':
       document.getElementById(divs[i]).src = vals[i];
       break;
      case 'innerHTML':
       document.getElementById(divs[i]).innerHTML = vals[i];
       break;
     }
    }
   }
   document.getElementById('please_wait').style.display = 'none';
   return;
  }
 };
 objHTTP.open("GET", arg, true);
 objHTTP.send('');
 return;
}

function esctext(tval){
 tval = escape(tval); 
 while (tval.indexOf('+') != -1){tval = tval.replace('+','%2B')};
 while (tval.indexOf('%0D%0A') != -1){tval = tval.replace('%0D%0A','<CRLF>')};
 return tval;
}

function uploadimage(filepmt){

var iframe;
try {
  iframe = document.createElement('<iframe name="frame2">');
} catch (ex) {
  iframe = document.createElement('iframe');
}

iframe.id = 'frame2';
iframe.name = 'frame2';
iframe.width = 0;
iframe.height = 0;
iframe.marginHeight = 0;
iframe.marginWidth = 0;


document.form1.FILENAME.value = filepmt.name;
document.form1.target = "frame2";
document.form1.action = "fileupload.pl";
document.form1.enctype = "multipart/form-data";
document.form1.encoding = "multipart/form-data";
document.form1.submit();
return;
}


function updateimage(filename){
eval('doupdate(document.form1.'+filename+",'PMTPAGE')");
return;
}


function showprompt(divid,image){
 if (document.getElementById(divid).innerHTML.indexOf('OPEN') > -1) {
  document.getElementById(divid).innerHTML='<font size=-2>Click on the small image to see a larger image<\/font>';
 } else {
  document.getElementById(divid).innerHTML='<INPUT TYPE=HIDDEN NAME="InP'+divid+'" value="OPEN"><font size=-2>Click on the small or large image to close the large image<\/font><br><a href="javascript:showprompt('+"'"+divid+"','close')"+'"><img src="'+image+'" style="border: solid 1px #818181;"><\/a>';
 }
}

var wabc = '';
function loginState(pageid){
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
 var c = ca[i];
 if (c.indexOf('xxabcdxx') != -1){
 var ind1=c.indexOf('=');
 wabc = c.substring(ind1+1,999);
 }
}
 if (wabc == ''){
  ih = '<div style="margin: 0px; padding: 0px;" align="right"><a href="http://www.expressionsondemand.com/cgi-bin/netlink.pl?PROGRAM=REXMAIN&amp;SUBMIT=LOGIN">Log In<\/a> | <a href="http://www.expressionsondemand.com/cgi-bin/netlink.pl?PROGRAM=REXMAIN&amp;SUBMIT=REGISTRATION">CREATE AN ACCOUNT<\/a><\/div>'
 } else {
  ih = '<div align="center">Welcome '+wabc+' | <a href="http://www.expressionsondemand.com/cgi-bin/netlink.pl?PROGRAM=REXMAIN&SUBMIT=Logoff">Logoff<\/a>'
  ih = ih + '<br><a href="http://www.expressionsondemand.com/cgi-bin/netlink.pl?PROGRAM=REXMAIN&amp;SUBMIT=ACCOUNTINFO">Account Information<\/a> | <a href="http://www.expressionsondemand.com/cgi-bin/netlink.pl?PROGRAM=ECCHECKOUT">Viewcart<\/a><\/div>'
 }
 document.getElementById('login').innerHTML = ih;
}


function linkSelect(pmt,zvar,rebuild,seldiv){
 for (var i = 0; i < pmt.length;i++) {
  if (pmt[i].value == zvar) {pmt[i].selected = true}
 }
 showHide(seldiv);
 doupdate(pmt,rebuild);
}

function showHide(theid){
 if(document.getElementById(theid).style.display == ''){
  if(document.getElementById(theid).className == 'seldiv'){
   document.getElementById(theid).style.display = 'none';
  }
  if(document.getElementById(theid).className == 'prompt_box'){
   document.getElementById(theid).style.display = 'block';
  }
 }
 if(document.getElementById(theid).style.display == 'block'){
  document.getElementById(theid).style.display = 'none';
 } else {
  document.getElementById(theid).style.display = 'block';
 }
 return;
}

function promptsteps(pdiv,tdiv,npdivs,pgn){
 for (i=1;i<=npdivs;i++){
  document.getElementById('P'+pgn+i).style.display = 'none';
  document.getElementById('P'+pgn+i).className = 'inactiveprompt';
  document.getElementById('T'+pgn+i).className = 'inactivetitle';
 }
 document.getElementById(pdiv).style.display = 'block'; 
 document.getElementById(pdiv).className = 'activeprompt'; 
 document.getElementById(tdiv).className = 'activetitle'; 
 return;
}
