/************************** GLOBAL VARIABLES ******************************************/
/*************************************************************************************/
var ie = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))
var ns = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 5))
function obj(id) { return document.getElementById(id) }
/**************************************************************************************/
/*******************               GLOBAL VARIABLES       ******************************************/
var imagesCnt = 0;
var imgarray;
var helpWindow;
/////////// Turn Page Function ///////////////////
 var ppArray = new Array(7);
 var curpg = 0;
 var maxpg;
var mytimeout, runImg, runImg2
/***************************************************************************************/
/**************************************************************************************/

/* IMAGE ROLLOVER */
var IMGSimg1 = 0;
var IMGSimg1list = ['imgRollOver', 'images/trans/'];
var IMGSimg2 = 0;
var IMGSimg2list = ['imgRollOver2', '../ebay/images/'];
var IMGSimg3 = 0;
var IMGSimg3list = ['picture', '../ebay/images/'];


var date = new Date()

getMap = function() {
  var map;
  var callback = function() {
    var result = map.query_singlecell("SELECT map FROM wareHouseMap");
    obj("a_innerhtml").innerHTML = result;
  };
  map = new Xml_SqlSelect.open('../../bin-data/wareHouseMap.xml', callback);
};

function changeImage(imgID, myID, myDir, myList, interval) {
  var LIST = myList.split(',');
  var arrayPos = getRandom(LIST.length-1);
  obj(myID).src = myDir+LIST[arrayPos];
  eval("IMGS"+imgID+" = setTimeout(\"changeImage('"+imgID+"', '"+myID+"', '"+myDir+"', '"+myList+"', '"+interval+"');\", "+interval+")");
}

// getRandom(100) = Gets any number between 0 and 100.
// getRandom(100,10) = Gets any 10 numbers between 0 and 100.
// getRandom(100,10,1) = Gets 10 numbers between 0 and 100 with no one number used twice.
var randomStr
function getRandom() {
    randomStr = ''
    if (arguments[0] && arguments[1] && arguments[2]) {
      tmpArray = new Array()
      cnt = 0
      for (h = 0; h < arguments[0]*600; h++) {
        rand = Math.round(Math.random(arguments[0]) * arguments[0])
        if (rand <= arguments[0]) {
          aCopy = 0
          for (i in tmpArray) {
            if (tmpArray[i] == rand) {
              aCopy = 1
              break
            }
          }
          if (aCopy == 0) {
            if (tmpArray.length < arguments[1]) tmpArray[cnt] = rand
            else return tmpArray.join(':')
            cnt++
          }
        }
      }
    } else if (arguments[0] && arguments[1]) {
      for (i = 0; i < arguments[1]; i++) {
        if (i == arguments[1]-1) randomStr += Math.round(Math.random(arguments[0])*arguments[0])
        else randomStr += Math.round(Math.random(arguments[0])*arguments[0])+":"
      }
      return randomStr
    } else {
      return Math.round(Math.random(arguments[0])*arguments[0])
    }
}


function doRollOvers(imgID, interval) {
    eval('clearTimeout(IMGS'+imgID+')');
    eval('IMGS'+imgID+' = 0;');
    if (interval) {
        var myID = eval('IMGS'+imgID+'list[0]');
        var myDir = eval('IMGS'+imgID+'list[1]');
        var myList = eval('IMGS'+imgID+'list[2]');
        eval("IMGS"+imgID+" = setTimeout(\"changeImage('"+imgID+"', '"+myID+"', '"+myDir+"', '"+myList+"', '"+interval+"');\", "+interval+")");
    }
}
/*END NEWSLETTERS IMAGE ROLLOVER*/
/*END HOME PAGE ALL*/

/* DISPLAYS THE MOUSE OVER EVENTS*/
function colorIt(v,h){
    obj(v).style.border = "solid 2px #ffcc33";
    obj(h).style.background = "white";
}
function colorIn(v,h){
    obj(v).style.border ="solid 2px white";
    obj(h).style.background  ="#ffcc33";
}
/* ENDS OF THE DISPLAYS THE MOUSE OVER EVENTS*/

/*TURN PAGE FUNCTION FOR THE PRESENTATION */
function turnpg(dir){
    if (dir == "prev"){
        curpg--;
        if (curpg == -1){
            curpg++;
           obj("prev").disabled = true
        }
    } else if (dir == "next"){
        curpg++;
        if (curpg == ppArray.length)curpg--;
    }
    if (curpg == ppArray.length-1) obj("next").disabled = true
    else if (curpg <= ppArray.length-1) obj("next").disabled = false
    if (curpg == 0) obj("prev").disabled = true
    else if (curpg >= 1) obj("prev").disabled = false

    obj("ppText").innerHTML = obj("pp_"+curpg).innerHTML
    var pageNumb = obj("pp_"+curpg).id.split("_")


    if (pageNumb[1] >= 0)  obj("ppNumb").innerHTML = "Page "+ pageNumb[1]

}
/*END OF TURN PAGE FUNCTION FOR THE PRESENTATION */

/*PRINTING FUNCTION FOR THE PRICE LISTING IN THE INDEX PAGE */
function printPricing(){
    w = window.open('','','addressbar=no,menubar=yes,scrollbars=yes');
    w.document.writeln("<html><body style=font:normal 12pt verdana;color:3b5a6f>");
    w.document.writeln("<table cellpadding=4 cellspacing=5 >");
    w.document.writeln("<tr><th colspan=100%><h3>CSPA Recycle Fee</h3></th></tr>");
    w.document.writeln("<tr><td width=2% valign=top align=center><font style='font-family: wingdings; '>l </font></td><td>The standard pick up hourly charge of \$40.00 is waived if there is a minimum of 10 items to pick up.</td></tr>");
    w.document.writeln("<tr><td width=2% valign=top align=center><font style='font-family: wingdings; '>l </font></td><td>Items are send to a certified recycler of electronic waste materials.</td></tr>");
    w.document.writeln("<tr><td width=2% valign=top align=center><font style='font-family: wingdings; '>l </font></td><td>Fees are periodically reviewed and are subject to changes based on actual recycler fees</td></tr>");
    w.document.writeln("<tr><td width=2% valign=top align=center><font style='font-family: wingdings; '>l </font></td><td>Items Fees:</td></tr>");
    w.document.writeln("<tr ><td colspan=2 align=center valigh=top><table width=90%><tr><td width=60%>CPU - \$7.00 each<br>Monitor (color) - \$7.00 each <br>Printer - \$5.00 each <br> Copier, Desktop - \$7.00 each <br> Copier, Stand alone - Cost is by actual weight, \.10 cents per pound, plus 5% for S&H <br>Fax Machine - \$7.00 each <br> Scanner - \$7.00 each <br>Television - less than 19', are \$10.00, larger than 19',\$15.00, plus \$5.00 for S&H.</td></tr></table></td></tr>");
    w.document.writeln("</table></body></html>");
    w.document.close();
    w.focus;
    w.print();
    setTimeout("w.close()", 2000);
}
/*END OF PRINTING FUNCTION FOR THE PRICE LISTING IN THE INDEX PAGE */



//COMMMENTS FORM//
function submitCommentForm(v){
//Create your array that you are bringing into javascript

  var formLength = custComments.elements.length
  for (var i =0; i < formLength;i++){
    if (custComments.elements[i].value ==""){
      obj(custComments.elements[i].id).style.background = "#ffffcc"
      obj(custComments.elements[i].id).value="Info required!"
      return false;
    } else continue;
  }
  var textArray = new Array(obj("agencyName").value,obj("contactName").value,obj("eMail").value,obj("telephone").value,obj("comments").value);
  var formInfo = textArray.join("|");
  var values = {"action":"comments~"+obj('eMail').value+"~"+formInfo+"~"+'saveData'};
  var reply = function(data){eval(data)};
  index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', values, reply);
}


function surpApplication(emailValue){
  var reply = function(v){
    var newData = v.split("\n");
    if (v){
      for (var i=0; i < newData.length; i++){
        var regNumb = newData[i].split("~");
        var persData = regNumb[1].split("_Z_");
        if (persData[2].match(RegExp(emailValue,"i"))){
          obj("agencyApp2").value = persData[0];
          obj("app2").value = persData[1];
          obj("phone2").value = persData[3];
          obj("fax2").value = persData[4];
          obj("address2").value = persData[5];
          obj("city2").value = persData[6];
          obj("st2").value = persData[7];
          obj("zip2").value = persData[8];
          if (persData[9] == "stateAge") obj("stateAge").checked = true
          else obj("higherEd").checked = true
          obj("codeMessage").innerHTML = "<div class=sixthheaderNR>You are registered with us. If you have forgotten your SP# please request the email for that number by clicking the button.<div><br>";
          obj("SPButton").innerHTML = "<button onclick=requestNumber(obj('email2').value) class=plain_out_80 onmouseover=this.className='plain_over_80' onmouseout=this.className='plain_out_80'>Email SP#</button>";
        }
      }
    }
  }
  if (emailValue){
    var values = {"action":"~"+emailValue+"~~getRegAppInfo"};
    index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', values, reply);
  } else validate(obj('email2').value, 'email', obj('email2').id)
}

function requestNumber(v){ //Simple script running to the generalForms.cgi to email the patrons number.
  var reply = function(data){eval(data)};
  var values = {"action":"surplusregistered~"+v+"~~emailRegAppNumber"};
  index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', values, reply);
}


function submitNewApp(){
   //If they are not registered with us we want to give them a new number .
  var formLength = supApplication.elements.length
  for (var i =0; i < formLength;i++){
    if (supApplication.elements[i].value == ""){
      obj(supApplication.elements[i].id).style.background = "#ffffcc"
      obj(supApplication.elements[i].id).value="Info required!"
      return false;
    } else continue;
  }

  var newCust = function (newData){
    if (newData) {
      var lastNo;
      if (newData.length == 1) lastNo = "00000"+newData;
      if (newData.length == 2) lastNo = "0000" + newData;
      if (newData.length == 3) lastNo = "000" + newData;
      if (newData.length == 4) lastNo = "00" + newData;
      if (newData.length == 5) lastNo = "0" + newData;
      if (obj("stateAge").checked == true) var NewNumber = lastNo + "ST";
      if (obj("higherEd").checked == true) NewNumber = lastNo + "HE";
    }
    if (obj("stateAge").checked == true) var group = "stateAge";
    else if (obj("higherEd").checked == true) group = "higherEd";
    var newApps = new Array(obj("agencyApp2").value, obj("app2").value, obj("email2").value, obj("phone2").value, obj("fax2").value, obj("address2").value, obj("city2").value, obj("st2").value, obj("zip2").value,group,date)
    newApps = newApps.join("_Z_")

    var reply = function(data){eval(data)};
    var newvalues = {"action":"surplusapps~"+NewNumber+"~"+newApps+"~"+'saveData'};
    index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', newvalues, reply);
  }
  var values = {"action":"~~~getNumb"};
  index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', values, newCust);

}

//WISH LIST FORM
function wishlistItems(editType,v) {

  var tmp = [];
  if (editType == "add") {
    if(v) var s = v.split("^")
    if (v && s[0]){
      obj("WLqty").value = s[1];
      obj("WLdesc").value = s[2];
      obj("WLfin").value = s[3];
      if (s[1]==obj("WLqty").value) obj("itemsRequested").options[obj("itemsRequested").selectedIndex] = null;
    } else {
      if (obj("WLdesc").value=="") return false
      tmp[tmp.length] = obj('itemsRequested').options.length+1+".";
      tmp[tmp.length] = obj("WLqty").value;
      tmp[tmp.length] = obj("WLdesc").value;
      tmp[tmp.length] = obj("WLfin").value;
      obj("itemsRequested").options[obj("itemsRequested").options.length] = new Option(tmp.join("^"), tmp.join("^"), 0, 1);
      var formLength = itemsInBox.elements.length
      for (var i =0; i < formLength;i++){
        obj(itemsInBox.elements[i].id).value = ""
      }
      obj("WLqty").focus()
    }
  } else if (editType == "delete") {
      if (!obj('itemsRequested').options.length) return false;
      else obj("itemsRequested").options[obj("itemsRequested").selectedIndex] = null;
  } else if (editType == "save") {
    var formLength = prodRequest.elements.length
    for (var i =0; i < formLength;i++){
      if (prodRequest.elements[i].value == ""){
        obj(prodRequest.elements[i].id).style.background = "#ffffcc"
        obj(prodRequest.elements[i].id).value="Info required!"
        return false;
      } else continue;
    }
    if (!obj('itemsRequested').options.length) return false
    for (var i = 0; i < obj("itemsRequested").options.length; i++)  tmp[tmp.length] = obj("itemsRequested").options[i].value;

    var tmp2 = [];
    tmp2.push("<table>");
    for (var i = 0; i < tmp.length; i++){
      var tmpData = tmp[i].split("^")
      tmp2.push("<tr><td><b>"+tmpData[0]+"</b></td><td>"+tmpData[1]+"</td><td>"+tmpData[2]+"</td><td>"+tmpData[3]+"</td></tr>");
    }
    tmp2.push("</table>");
    tmp2 = tmp2.join("")

    var tmp3 =[];
    for (var j =0; j < formLength;j++){
      tmp3 += prodRequest.elements[j].value+"^"
    }
    var finalData = tmp3+"|"+tmp2;
    var reply = function(data){eval(data)};
    var newvalues = {"action":"productRequest~"+prodRequest.elements[0].value+"~"+finalData+"~sendRequest"};
    index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', newvalues, reply);
  }
}

//END OF WISH LIST FORM


/* VALIDATION CODE FOR THE FORMS ALL see "var s"  which is the string comming in. */

function validate(v, s, Id){

    if (obj(Id).value == "Info required!") return false;

    if (s == "nonumb"){
        if ((v == "") || (v == "Info required!") || (!v.match(/[a-z]/ig)) ){
            obj(Id).value = ""
            obj(Id).style.background = "#ffffcc"
            obj(Id).value="Info required!"
        } else {
         obj(Id).style.background = "f5f5f6"
        }
    }else if (s == "required"){
        if ((v == "") || (v == "Info required!")){
            obj(Id).value = ""
            obj(Id).style.background = "#ffffcc"
            obj(Id).value="Info required!"
        }else{
          obj(Id).style.background = "f5f5f6"
        }
    }else if (s == "email"){
        if ((v == "") || (v == "Email required!")
                || (!v.match(/[a-z]+@[a-z]+\./ig))
                && (!v.match(/[0-9]+@[a-z]+\./ig))
                && (!v.match(/[a-z]+[0-9]+@[a-z]+\./ig))
                && (!v.match(/[0-9]+[a-z]+@[a-z]+\./ig))
                && (!v.match(/[0-9]+[a-z]+[0-9]+@[a-z]+\./ig))
                && (!v.match(/[a-z]+[0-9]+[a-z]+@[a-z]\./ig))
                && (!v.match(/[a-z]+[0-9]+[a-z]+[0-9]+[a-z]+@[a-z]+\./ig))
                && (!v.match(/[0-9]+[a-z]+[0-9]+[a-z]+[0-9]+@[a-z]+\./ig))){
            obj(Id).value = ""
            obj(Id).style.background = "ffffcc"
            obj(Id).value = "Info Required!"
        }else {
         obj(Id).style.background = "f5f5f6"
        }
    } else if (s == "numbers"){
        if ((v == "") || (v == "Info required!") || (v.match(/[a-z]/ig))){
            obj(Id).value = ""
            obj(Id).style.background = "ffffcc"
            obj(Id).value="Info required!"
        } else {
            obj(Id).style.backgroundColor = "f5f5f6"
        }
    } else if (s == "regular"){
        obj(Id).style.background = "#f5f5f6"
    }

}

//  VALIDATION CODE FOR THE FORMS

//   FUNCTION FOR THE 276 FORM TO DISPLAY INFORMATION //
function form276Choice(choice){
    obj("choices").style.display = "block"
    if (choice == "1") obj("choices").innerHTML = "I want our surplus items to be picked up and removed by CSPA staff. The items are in good condition.The CSPA will review, schedule a pick up date, estimate a pick up fee and notify customer via email comfirmation."
    else if (choice == "2") obj("choices").innerHTML = "I will deliver our surplus items to the CSPA warehouse. The items are in good condition. The CSPA will review and schedule a time for items to be delivered via email confirmation."
    else if (choice == "3") obj("choices").innerHTML = "I want to dispose of surplus items as ordinary trash in a dumpster or landfill. The items are in poor condition. The CSPA will review and send email confirmation for disposal."
    else if (choice == "4") obj("choices").innerHTML = "I want the CSPA to pick up and dispose of our surplus items as ordinary trash. The items are in poor condition. The CSPA will determine an estimated cost for trash disposal and schedule a pick up time via email confirmation. The fee will be based on current trash disposal and handling fees."
    else if (choice == "5") obj("choices").innerHTML = "I want the CSPA to pick up our electronic waste materials and dispose of them through a recycler. The CSPA will determine an estimated cost for disposal and schedule a pick up time via email confirmation."
    else if (choice == "6") obj("choices").innerHTML = "I want to trade-in surplus items to a vendor for a credit applied to like items I am purchasing. The CSPA will review and approve based on the cost savings to the state. Confirmation will be sent back to you via email."
    else return false
}
//  END OF  FUNCTION FOR THE 276 FORM TO DISPLAY INFORMATION //

//  CHECKING THE REGISTERED NUMBERS For THE ForMS //

function checkRegNumb(regNumb,doWhat,v){

 choice = v.split("_")[1];

  if (doWhat == "validate"){
    var reply = function(data){
      if (!data || (data == " ")){
        alert("Sorry you are not registered with us. or your application has not been approved at this time. Please contact CSPA by phone if problem persists. Thank you for your time.");
        setTimeout("document.location = 'index.html?surpApplication'", 500);
      }
      var newData = data.split("~");
      var N_s = newData[1].split("_Z_");

      obj("agency3").value = N_s[0];
      obj("address3").value  = N_s[5];
      obj("city3").value  = N_s[6];
      obj("state3").value  = N_s[7];
      obj("zip3").value  = N_s[8];
      obj("contactPerson3").value  = N_s[1];
      obj("email3").value  = N_s[2];
      obj("conPerPhone3").value  = N_s[3];
      obj("conPerFax3").value  = N_s[4];
      if (choice.match(/1|3|4|5/i)){
        obj("pickUpAddress").value  = N_s[5];
        obj("pickUpCity").value  = N_s[6];
        obj("pickUpState").value  = N_s[7];
        obj("pickUpZip").value  = N_s[8];
      }
        obj("agencyType").value  = N_s[9];
    };
    var values = {"action":"form276~"+regNumb+"~~validate"};
    index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', values, reply);
  }

}

function get276Form(v){
  obj("form276").style.display="";
  var tmp = [];
  tmp.push("<table width=605px><tr><td class=thirdheaderB align=center>Disposition Form 276 for Surplus Property </td></tr>");
  tmp.push("<tr><th height=1 bgcolor='#0f3e5b'></th></tr>");
  tmp.push("<tr><th height=10></th>");
  tmp.push("</tr>");
  tmp.push("<tr><th class=fifthheaderB style='padding:5px;border:double 3px #396e8e;' bgcolor=#eeeeee>");

  if (v == "choice_1") tmp.push("I want our Surplus Property items to be picked up and removed by CSPA staff. The items are in good condition.");
  if (v == "choice_2") tmp.push("I will deliver our surplus items to the CSPA warehouse. The items are in good condition.");
  if (v == "choice_3") tmp.push("I want to dispose of surplus items as ordinary trash in a dumpster or landfill. The items are in poor condition.");
  if (v == "choice_4") tmp.push("I want the CSPA to pick up and dispose of our surplus items as ordinary trash. The items are in poor condition.");
  if (v == "choice_5") tmp.push("I want the CSPA to pick up our electronic waste materials and dispose of them through a recycler.");
  if (v == "choice_6") tmp.push("I want to trade-in surplus items to a vendor for a credit applied to like items I am purchasing.");

  tmp.push("</th>");
  tmp.push("</tr>");
////////////  Agency's Name and address   /////////////////////////

  tmp.push("<tr>");
  tmp.push("<td>");
  tmp.push("<table width=605px cellpadding=1 cellspacing=1 border=0 style=\"font-size: 11pt;\">");
  tmp.push("  <tr><td height=10></td></tr>");

  tmp.push("  <form id=form276Info>");
  tmp.push("  <tr>");
  tmp.push("    <td>");
  tmp.push("      <span class=darkforthheaderB>SP #</span>:&nbsp;&nbsp;<span >");
  tmp.push("      <input id='regNumb'  type=text size=45 value'000010ST'");
  tmp.push("        onblur=\"this.value = this.value.toUpperCase(); ");
  tmp.push("          checkRegNumb(this.value,'validate','"+v+"');\" ");
  tmp.push("        style='border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("    </td>");
  tmp.push("  </tr>");
  tmp.push("  <tr>");
  tmp.push("    <td><span class=darkforthheaderB>Agency Full Name</span>:&nbsp;&nbsp;<span ><input id='agency3'  type=text size=65 onblur=\"if (obj('regNumb').value == ''){ alert('You must be approved to fill out Disposition Form 276. Please Register.'); document.location='$script?application'}; validate(this.value, 'nonumb',this.id); \" style='border:none;border-bottom:solid 1px #396e8e'></span></td>");
  tmp.push("  </tr>");
  tmp.push("  <tr>");
  tmp.push("    <td ><span class=darkforthheaderB>Address</span>:&nbsp;&nbsp;<span><input id='address3'  type=text size=77 onblur=\"validate(this.value, 'required', this.id)\" style='border:none;border-bottom:solid 1px #396e8e'></span></td>");
  tmp.push("  </tr>");
  tmp.push("  <tr><td>");
  tmp.push("      <span class=darkforthheaderB>City</span>:&nbsp;&nbsp;<span><input id='city3'  type=text size=16  onblur=\"validate(this.value, 'nonumb',this.id) \" style='border:none;border-bottom:solid 1px #396e8e'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>");
  tmp.push("      <span class=darkforthheaderB>State</span>:&nbsp;&nbsp;<span><input id='state3'  type=text size=3 onKeyPress=\"return chkKey('state',event)\" onblur=\"validate(this.value, 'nonumb', this.id)\" style='border:none;border-bottom:solid 1px #396e8e'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>");
  tmp.push("      <span class=darkforthheaderB>Zip code</span>:&nbsp;&nbsp;<span><input id='zip3'  type=text size=10 onKeyPress=\"return chkKey('3',event)\" onblur=\"validate(this.value, 'numbers',this.id)\" style='border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("  </td></tr>");
  tmp.push("  <tr><td>");
  tmp.push("      <span class=darkforthheaderB>Agency/Higher Ed Type</span>:&nbsp;&nbsp;<input type=text  id=agencyType style='border:none;border-bottom:solid 1px #396e8e'>");
  tmp.push("  </td></tr>");
  tmp.push("  <tr><td><hr width=605px color=#999999 size=2></td></tr>");

  /////////// Contact Persons name email, phone, fax ////////////

  tmp.push("  <tr><th class=fifthheader>CONTACT INFORMATION.</th></tr>");
  tmp.push("  <tr>");
  tmp.push("    <td ><span class=darkforthheaderB>Contact Person</span>:&nbsp;&nbsp;<span><input id=contactPerson3  type=text size=57 onblur=\"validate(this.value, 'nonumb',this.id) \" style='border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("    </td>");
  tmp.push("  </tr>");
  tmp.push("  <tr><td >");
  tmp.push("      <span class=darkforthheaderB>Email</span>:&nbsp;&nbsp;<span><input id=email3 type=text size=44 onKeyPress=\"return chkKey('email',event)\" onblur=\"validate(this.value, 'email',this.id)\" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("  <tr><td >");
  tmp.push("      <span class=darkforthheaderB>Phone</span>:&nbsp;&nbsp;<span><input id=conPerPhone3  type=text size=14 onKeyPress=\"return chkKey('phone',event)\" onblur=\"validate(this.value, 'numbers', this.id)\" style='border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("      &nbsp;&nbsp;<span class=darkforthheaderB>Fax</span>:&nbsp;&nbsp;<span><input id=conPerFax3  type=text size=14 onKeyPress=\"return chkKey('phone',event)\" onblur=\"validate(this.value, 'numbers', this.id)\" style='border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("  </td></tr>");
  tmp.push("    </form>");
  tmp.push("</table>");
  tmp.push("       </td>");
  tmp.push("     </tr>");
  tmp.push("     <tr><td><hr width=605px color=#999999 size=2></td></tr>");
/////// Location of Property /////

if ((v == "choice_1") || (v == "choice_3") || (v == "choice_4") || (v == "choice_5")){
  tmp.push(" <form id=puchUpForm>");
  tmp.push("    <table width=605px cellpadding=1 cellspacing=1 border=0 style=\"font-size: 11pt;\">");
  tmp.push("     <tr><th class=fifthheader>Please insure the location of the property.</th></tr>");
  tmp.push("     <tr>");
  tmp.push("       <td ><span class=darkforthheaderB>Address</span>:&nbsp;&nbsp;<span><input id=pickUpAddress type=text size=67 onblur=\"validate(this.value, 'required', this.id)\" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span></td>");
  tmp.push("     </tr>");
  tmp.push("     <tr>");
  tmp.push("       <td>");
  tmp.push("          <span class=darkforthheaderB>City</span>:&nbsp;&nbsp;<span><input id=pickUpCity type=text size=16 onblur=\"validate(this.value, 'nonumb',this.id) \" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>");
  tmp.push("          <span class=darkforthheaderB>State</span>:&nbsp;&nbsp;<span><input id=pickUpState type=text size=3 onKeyPress=\"return chkKey('state',event)\" onblur=\"validate(this.value, 'nonumb', this.id)\" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>");
  tmp.push("          <span class=darkforthheaderB> Zip code</span>:&nbsp;&nbsp;<span><input id=pickUpZip type=text size=10 onKeyPress=\"return chkKey('zip',event)\" onblur=\"validate(this.value, 'numbers',this.id)\" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("       </td></tr>");

  tmp.push("      <tr>");
  tmp.push("        <td >");
  tmp.push("          <span class=fifthheader>Special Notes on Pick Up if applicable</span>:<br>");
  tmp.push("          <textarea id=pickUpNote style=width:605;height:80></textarea>");
  tmp.push("        </td>");
  tmp.push("      </tr>");
  tmp.push("      <tr><td height=2 bgcolor=#999999></td></tr>");
  tmp.push("    </table >");
  tmp.push("    </form>");
}

////  Starts the process of accepting the information ////////////////////
  tmp.push("    <table width=605px cellpadding=1 cellspacing=1 border=0 align=center >");
  tmp.push("      <tr>");
  tmp.push("        <td>");
  tmp.push("          <p>Enter items controlled by serial number. A <u>serial number is mandatory for computers, computer monitors and servers</u>. ");
  tmp.push("          Serial number tracking is recommended for other items and may be required by your agency's internal requirements. ");
  tmp.push("        </td>");
  tmp.push("      </tr>");
  tmp.push("     <tr><td height=5 ></td></tr>");

  tmp.push("      <tr>");
  tmp.push("        <td colspan=2>");
  tmp.push("            Request Items: To submit your list of refurbished products follow these steps.");
  tmp.push("            <ol>");
  tmp.push("              <li>Fill in the three fields (Serial/ID#,Quantity,Description) with the proper information as applicable.");
  tmp.push("              <li>Click the \"Add Item\" button and the information will be placed in the list below.");
  tmp.push("              <li>Repeat steps 1 and 2 to complete the desired list.");
  tmp.push("              <li>To remove an item from the list select it and click the \"Delete Item\" button.");
  tmp.push("            <ol>");
  tmp.push("        </td>");
  tmp.push("      </tr>");
  tmp.push("     <tr><td height=5 ></td></tr>");
  tmp.push("      <form id=fields276>");
  tmp.push("      <tr>");
  tmp.push("        <td>");
  tmp.push("          <span class=darkforthheaderB>Serial / ID #</span>:&nbsp;");
  tmp.push("          <span><input type=text id=item276 size=30 style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>&nbsp;&nbsp;&nbsp;&nbsp;");
  tmp.push("          <span class=darkforthheaderB>Quantity</span>: &nbsp;");
  tmp.push("          <span><input type=text id=qty276 size=10 style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("        </td>");
  tmp.push("      </tr>");
  tmp.push("      <tr>");
  tmp.push("        <td>");
  tmp.push("          <span class=darkforthheaderB>Item Description</span>&nbsp;");
  tmp.push("          <span><input type=text id=desc276 size=70 style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
  tmp.push("      <tr>");
  tmp.push("      </form>");
  tmp.push("      <tr>");
  tmp.push("        <td>");
  tmp.push("          <input type=button value=\"Add Item\" onclick=addItems276('add','') class=plain_out_100 onmouseover=this.className='plain_over_100' onmouseout=this.className='plain_out_100'>");
  tmp.push("          <input type=button value=\"Delete Item\" onclick=addItems276('delete','') class=plain_out_100 onmouseover=this.className='plain_over_100' onmouseout=this.className='plain_out_100'>");
  tmp.push("        </td>");
  tmp.push("      </tr>");
  tmp.push("      <tr>");
  tmp.push("        <th class=darkforthheaderB>Items List box</th>");
  tmp.push("      </tr>");
  tmp.push("      <tr>");
  tmp.push("        <td>");
  tmp.push("          <select id='selectBox276' style='width:580px;font:normal 10pt tahoma' size=6 onclick=addItems276('add',this.value) >");
  tmp.push("        </td>");
  tmp.push("      </tr>");
  tmp.push("      </table>");


  tmp.push("    <table width=605px cellpadding=1 cellspacing=1 border=0 align=center >");
  if (v == "choice_2"){
    tmp.push("      <tr><td><p>I understand that only items in good condition may be delivered to the CSPA warehouse. Items that are not in good condition will be rejected. I also understand that I must have a confirmed date to drop items off. Unscheduled or undocumented items will not be accepted.</td></tr>");
  }
  if (v == "choice_3"){
    tmp.push("      <tr><td >");
    tmp.push("        <span style=\"border:none;padding:5px;background-color:#f5f5f6\" onMouseup=\"if (!obj('digitalHardware').checked) this.style.background='white'; else if (obj('digitalHardware').checked) this.style.background='#FFFFCC' \" ><input type=checkbox id=digitalHardware value=yes></span>&nbsp;&nbsp;");
    tmp.push("        <span class=donationspan> I understand that hazardous waste materials must be disposed of in accordance with state and federal laws.</span>");
    tmp.push("      </td></tr>");
  }
  if ((v == "choice_1") || (v == "choice_3") || (v == "choice_4") || (v == "choice_5")){
    tmp.push("      <tr><td>");
    tmp.push("        <input type=checkbox id=funds>");
    tmp.push("        <span class=donationspan>I am authorized to obligate my agency's surplus property and to obligate my agency's funds for payment if applicable.</span>");
    tmp.push("      </td></tr>");
  }
  if ((v == "choice_1") || (v == "choice_4") || (v == "choice_5")){
    tmp.push("      <tr><td>");
    tmp.push("          <input type=checkbox id=purchaseMethod>");
    tmp.push("        <span class=donationspan>I will pay by signing a state invoice, submission of a purchase order or by state issued credit card.</span>");
    tmp.push("      </td></tr>");
    if (v == "choice_4") tmp.push("     <tr><td><input type=checkbox id=trash4><span class=donationspan>I want the CSPA to pick up listed items and dispose of them as trash.</span></td></tr>");
    if (v == "choice_5") tmp.push("     <tr><td><input type=checkbox id=trashComputer5><span class=donationspan>I understand that I must comply with standards for protecting the State of Colorado from liability by the improper release of personal information, which may reside on computer or server hard drives.</span></td></tr>");
    if (v == "choice_5") tmp.push("     <tr><td><input type=checkbox id=trashElectronic5><span class=donationspan>I understand that the CSPA offers the service of tracking hard drives by serial number through their destruction by shredding. I also understand that \"destroyed\" hard drives are considered electronic waste and must be disposed of through a recycler.</span></td></tr>");
  }
  if (v == "choice_6"){
    tmp.push("      <tr><td>");
    tmp.push("        <span class=donationspan>Enter the amount the state will be credited for the trade in.</span>:&nbsp;&nbsp;");
    tmp.push("        <span><input id=reserveBid type=text size=10 onKeyPress=\"return chkKey('price',event)\" onblur=\"validate(this.value, 'price',this.id)\" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
    tmp.push("      </td></tr>");
    tmp.push("      <tr><td>");
    tmp.push("        <span class=donationspan>Enter the name of the vendor receiving the trade-in</span>:&nbsp;&nbsp;");
    tmp.push("        <span><input id=buyNowAmount type=text size=19  style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
    tmp.push("      </td></tr>");
    tmp.push("      <tr><th class=fifthheader>Enter the name and telephone number for the receiving vendor's point of contact.</th></tr>");
    tmp.push("      <tr><td >");
    tmp.push("        <span class=donationspan>Vendor's Name</span>:&nbsp;&nbsp;<span><input id=venderName type=text size=40 onblur=\"validate(this.value, 'nonumb',this.id)\" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
    tmp.push("      </td></tr>");
    tmp.push("      <tr><td >");
    tmp.push("        <span class=donationspan>Phone</span>:&nbsp;&nbsp;<span><input id=vendorPhone type=text size=13 onKeyPress=\"return chkKey('phone',event)\" onblur=\"validate(this.value, 'numbers', this.id)\" style='background:#f5f5f6;border:none;border-bottom:solid 1px #396e8e'></span>");
    tmp.push("      </td></tr>");
  }
  tmp.push("      <tr>");
  tmp.push("        <td align=\"right\" >");
  tmp.push("          <input");
  tmp.push("            type=\"button\"");
  tmp.push("            value=\"Submit\"");
  tmp.push("            class=plain_out_80 onmouseover=this.className='plain_over_80' onmouseout=this.className='plain_out_80' ");
  tmp.push("            onclick=\"if (obj('selectBox276').options.length == -1) alert('This Form is Incomplete!') ; else addItems276('save','"+v+"');this.disabled=1\">");
  tmp.push("        </td>");
  tmp.push("      </tr>");
  tmp.push("    </table >");
  tmp.push("  <tr><td align=center id=footer colspan=2>&nbsp;</td></tr></table>");
  obj("276Form").innerHTML = tmp.join("");

}


//  ForM 276 EDITor
function addItems276(editType,v) {
  var tmp = [];
  var formLength = fields276.elements.length
  if (editType == "add") {
    if(v) var s = v.split("_XX_")
    if (v && s[0]){
      obj("item276").value = s[0];
      obj("qty276").value = s[1];
      obj("desc276").value = s[2];
      if (s[1]==obj("qty276").value) obj("selectBox276").options[obj("selectBox276").selectedIndex] = null;
    } else {
      if (obj("desc276").value=="") return false
      //tmp[tmp.length] = obj('selectBox276').options.length+1+".";
      tmp[tmp.length] = obj("item276").value;
      tmp[tmp.length] = obj("qty276").value;
      tmp[tmp.length] = obj("desc276").value;
      obj("selectBox276").options[obj("selectBox276").options.length] = new Option(tmp.join("_XX_"), tmp.join("_XX_"), 0, 1);
      for (var i =0; i < formLength;i++){
        obj(fields276.elements[i].id).value = ""
      }
      obj("item276").focus()
    }
  } else if (editType == "delete") {
      if (!obj('selectBox276').options.length) return false;
      else obj("selectBox276").options[obj("selectBox276").selectedIndex] = null;
  } else if (editType == "save") {

//  var newForm = function (newData){

    var form276Lg = form276Info.elements.length
    var N_formInfo = [];

      for (var i =0; i < form276Lg;i++){
        N_formInfo.push(form276Info.elements[i].value)
      }
      if (v.match(RegExp("choice_1|choice_3|choice_4|choice_5","i"))){
        var cnt = puchUpForm.elements.length
        for (var i =0;i < cnt; i++){
          N_formInfo.push(puchUpForm.elements[i].value)
        }
      }

    var checkBoxArray = new Array("digitalHardware","funds","purchaseMethod","trash4","trashComputer5","trashElectronic5");

    for (var i = 0; i < checkBoxArray.length; i++) {
      if (obj(checkBoxArray[i])){
        if (obj(checkBoxArray[i]).checked){
          obj(checkBoxArray[i]).value  = "YES"
        } else obj(checkBoxArray[i]).value  = "NO"
      }
    }

    /*
    all forms
    0<==>formtype,1<==>regNumb,2<==>agency3,3<==>address3,4<==>city3,5<==>state3,6<==>zip3,7<==>agencyType,8<==>contactPerson3,9<==>email3,10<==>conPerPhone3,11<==>conPerFax3,
    only form 1,3,4,5[12<==>pickUpAddress,13<==>pickUpCity,14<==>pickUpState,15<==>pickUpZip,16<==>pickUpNote,] only form "3"[17<==>digitalHardware]
    only form "1,3,4,5"[18<==>funds] only form "1,4,5"[19<==>purchaseMethod]  only form "4" 20<==>trash4  only form "5" 21<==>trashComputer5,22<==>trashElectronic5
    only form "6"[23<==>reserveBid,24<==>buyNowAmount,25<==>venderName,26<==>vendorPhone] 27<==>date
    */

//pickup info
      if (v == "choice_1") N_formInfo.push("_C_"+obj('funds').value+","+obj('purchaseMethod').value+"_C__C__C__C__C__C__C__C_"+date);
      if (v == "choice_3") N_formInfo.push(obj('digitalHardware').value+"_C_"+obj('funds').value+"_C__C__C__C__C__C__C__C__C_"+date);
      if (v == "choice_4") N_formInfo.push("_C_"+obj('funds').value+"_C_"+obj('purchaseMethod').value+"_C_"+obj('trash4').value+"_C__C__C__C__C__C__C_"+date);
      if (v == "choice_5") N_formInfo.push("_C_"+obj('funds').value+"_C_"+obj('purchaseMethod').value+"_C__C_"+obj('trashComputer5').value+"_C_"+obj('trashElectronic5').value+"_C__C__C__C__C_"+date);
      if (v == "choice_2") N_formInfo.push("_C__C__C__C__C__C__C__C__C__C__C__C__C__C__C_"+obj('dateSubmitted').value);
      if (v == "choice_6") N_formInfo.push("_C__C__C__C__C__C__C__C__C__C__C_"+obj('reserveBid').value+"_C_"+obj('buyNowAmount').value+"_C_"+obj('venderName').value+"_C_"+obj('vendorPhone').value+"_C_"+date);
      if (v == "choice_1") N_formInfo.unshift("form1 -- Pick up and remove by CSPA.")
      if (v == "choice_2") N_formInfo.unshift("form2 -- Delivery by agency")
      if (v == "choice_3") N_formInfo.unshift("form3 -- Disposal by agency.")
      if (v == "choice_4") N_formInfo.unshift("form4 -- Pick up and remove by CSPA.")
      if (v == "choice_5") N_formInfo.unshift("form5 -- Pick up electronic waste by CSPA")
      if (v == "choice_6") N_formInfo.unshift("form6 -- Agency trade in items.")

    N_formInfo = N_formInfo.join("_C_")

    if (!obj('selectBox276').options.length) return false
    for (var i = 0; i < obj("selectBox276").options.length; i++){
        tmp.push(obj('selectBox276').options[i].value);
    }
    tmp = tmp.join("_T_")
    var formData = N_formInfo+"_Z_"+tmp

    var reply = function(data){eval(data)};
    var newvalues = {"action":"form276~"+obj('email3').value+"~"+formData+"~form276"};
    index_default.HTTP('POST', docRoot+'serviceproviders/surplus/bin-cgi/generalForms.cgi', newvalues, reply);
  }
}
//  ForM 276 EDITor  //


