/* ---------------- Document Quick Search Variables ---------------*/

var sCatsSelected;
var sDocSelected;
var sURL;
var arrRollJacketingDS;
var arrSheetsDS;
var arrBandingDS;
var arrElbowsDS;
var arrAccDS;
var arrInstallGuidesDS;
var arrTechInfoDS;
var arrOtherLitDS;
var arrRollJacketingURLs;
var arrSheetsURLs;
var arrBandingURLs;
var arrElbowsURLs;
var arrAccURLs;
var arrInstallGuidesURLs;
var arrTechInfoURLs;
var arrOtherLitURLs;
var objCats;
var objDocs;

/* ---------------- Document Quick Search Functions ---------------*/
function init(){
  arrRollJacketingDS = setRollJacketingDS();
  arrSheetsDS = setSheetsDS();
  arrBandingDS = setBandingDS();
  arrElbowsDS = setElbowsDS();
  arrAccDS = setAccDS();
  arrInstallGuidesDS = setInstallationGuidesDS();
  arrTechInfoDS = setTechInfoDS();
  arrOtherLitDS = setOtherLitDS();
  arrRollJacketingURLs = setRollJacketingURLs();
  arrSheetsURLs = setSheetsURLs();
  arrBandingURLs = setBandingURLs();
  arrElbowsURLs = setElbowsURLs();
  arrAccURLs = setAccessoriesURLs();
  arrInstallGuidesURLs = setInstallationGuidesURLs();
  arrTechInfoURLs = setTechInfoURLs();
  arrOtherLitURLs = setOtherLitURLs();
  objCats = getObject('Cats');
  objDocs = getObject('Docs');
  sCatsSelected = 'Roll Jacketing';
  callSetDocs(sCatsSelected);
  objCats.selectedIndex = 0;
  objDocs.selectedIndex = 0;
}

function callSetDocs(sCatsSelectedText){
  if(objDocs.options.length > 0){
    var bCleared=ClearDocs();
    if(bCleared){
      setDocs(sCatsSelectedText);
    }
  }else{
    setDocs(sCatsSelectedText);
  }
}

function setDocs(sCatsSelectedText){
  if(sCatsSelectedText == 'Roll Jacketing'){
    fillCombo(arrRollJacketingDS);
  }else if(sCatsSelectedText == 'Sheets'){
    fillCombo(arrSheetsDS);
  }else if(sCatsSelectedText == 'Banding'){
    fillCombo(arrBandingDS);
  }else if(sCatsSelectedText == 'Elbows'){
    fillCombo(arrElbowsDS);
  }else if(sCatsSelectedText == 'Accessories'){
    fillCombo(arrAccDS);
  }else if(sCatsSelectedText == 'Installation Guides'){
    fillCombo(arrInstallGuidesDS);
  }else if(sCatsSelectedText == 'Technical Info'){
    fillCombo(arrTechInfoDS);
  }else{
    fillCombo(arrOtherLitDS);
  }
  objDocs.selectedIndex = 0;
  var i = objDocs.options.selectedIndex;
  sDocSelected = objDocs.options[i].text;
}

function resetDocs(){
  ClearDocs();
  var sSelected = objCats.value;
  callSetDocs(sSelected);
}

function ClearDocs(){
  var iLoopCounter;
  var iListCount = objDocs.options.length;
  if(document.all){
    for(iLoopCounter = 0;iLoopCounter < iListCount;iLoopCounter++){
      var iCurrentObj = iLoopCounter +1;
      objDocs.options.remove(iListCount - iCurrentObj);
    }
  }else{
    for(iLoopCounter = 0;iLoopCounter < iListCount;iLoopCounter++){
      var iCurrentObj = objDocs.length - 1;
      objDocs.remove(iCurrentObj);
    }
  }
  return true;
}

function fillCombo(arr){
  var iLoopCounter;
  var iListCount = arr.length;
  for(iLoopCounter = 0;iLoopCounter < iListCount;iLoopCounter++){
    if(document.all){
      var objOption = document.createElement("OPTION");
      objDocs.options.add(objOption);
      objOption.innerText = arr[iLoopCounter].toString();
      objOption.value = arr[iLoopCounter].toString();
    }else{
      AddSelectOption(objDocs,arr[iLoopCounter].toString(),arr[iLoopCounter].toString(),true);
    }
  }
}

function AddSelectOption(selectObj, text, value, isSelected){
  if (selectObj != null && selectObj.options != null){
     selectObj.options[selectObj.options.length] = new Option(text, value, false, isSelected);
  }
}


function getDoc(){
  var i = objDocs.options.selectedIndex;
  sDocSelected = objDocs.options[i].text;
  var sCurrentURL = getURL();
  window.open(sCurrentURL);
}

function getURL(){
  sCatsSelected = objCats.value;
  var i = objDocs.options.selectedIndex;
  sDocSelected = objDocs.options[i].text;
  if(sCatsSelected == 'Roll Jacketing'){
    return getRollJacketingURL();
  }else if(sCatsSelected == 'Sheets'){
    return getSheetsURL();
  }else if(sCatsSelected == 'Banding'){
    return getBandingURL();
  }else if(sCatsSelected == 'Elbows'){
    return getElbowsURL();
  }else if(sCatsSelected == 'Accessories'){
    return getAccessoriesURL();
  }else if(sCatsSelected == 'Installation Guides'){
    return getInstallationGuidesURL();
  }else if(sCatsSelected == 'Technical Info'){
    return getTechInfoURL();
  }else{
    return getOtherLitURL();
  }
}

function getRollJacketingURL(){
  if(sDocSelected == 'Aluminum Rolled Jacketing'){
    return arrRollJacketingURLs[0];
  }else if(sDocSelected == 'Aluminum Painted'){
    return arrRollJacketingURLs[1];
  }else if(sDocSelected == 'Stainless Steel Roll Jacketing'){
    return arrRollJacketingURLs[2];
  }else if(sDocSelected == 'Ultrolon'){
    return arrRollJacketingURLs[3];
  }else{
    return arrRollJacketingURLs[4];
  }
}

function getSheetsURL(){
  if(sDocSelected == 'Aluminum Deep Corrugated Sheets'){
    return arrSheetsURLs[0];
  }else if(sDocSelected == 'Box Rib'){
    return arrSheetsURLs[1];
  }else{
    return arrSheetsURLs[2];
  }
}

function getBandingURL(){
  return arrBandingURLs[0];
}

function getElbowsURL(){
  if(sDocSelected == 'Aluminum Sure-Fit/Ell Jacs'){
    return arrElbowsURLs[0];
  }else if(sDocSelected == 'Aluminum Multi-Fit'){
    return arrElbowsURLs[1];
  }else if(sDocSelected == 'Stainless Steel T-316 Sure-Fit/Ell Jacs'){
    return arrElbowsURLs[2];
  }else if(sDocSelected == 'Packaging Chart 90 Degrees'){
    return arrElbowsURLs[3];
  }else if(sDocSelected == 'Packaging Chart 45 Degrees'){
    return arrElbowsURLs[4];
  }else if(sDocSelected == 'Packaging Chart 90 Degrees Metric'){
    return arrElbowsURLs[5];
  }else if(sDocSelected == 'Packaging Chart 45 Degrees Metric'){
    return arrElbowsURLs[6];
  }else if(sDocSelected == 'Conversion Chart'){
    return arrElbowsURLs[7];
  }else{
    return arrElbowsURLs[8];
  }
}

function getAccessoriesURL(){
  if(sDocSelected == 'Fabstraps/Pab Bands'){
    return arrAccURLs[0];
  }else if(sDocSelected == 'Apply Fabstraps'){
    return arrAccURLs[1];
  }else{
    return arrAccURLs[2];
  }
}

function getInstallationGuidesURL(){
  if(sDocSelected == 'Muffl-Jac Installation Instructions'){
    return arrInstallGuidesURLs[0];
  }else if(sDocSelected == 'Matching Deep Corrugated Sheets'){
    return arrInstallGuidesURLs[1];
  }else{
    return arrInstallGuidesURLs[2];
  }
}

function getTechInfoURL(){
  if(sDocSelected == 'Waterstained Aluminum'){
    return arrTechInfoURLs[0];
  }else if(sDocSelected == 'Corrosion'){
    return arrTechInfoURLs[1];
  }else if(sDocSelected == 'Metal Melting Points'){
    return arrTechInfoURLs[2];
  }else if(sDocSelected == 'Application Mity Spring'){
    return arrTechInfoURLs[3];
  }else if(sDocSelected == 'Application Super Mity Spring'){
    return arrTechInfoURLs[4];
  }else if(sDocSelected == 'Polysurlyn Techncial Data Sheet'){
    return arrTechInfoURLs[5];
  }else if(sDocSelected == 'Polysurlyn, General Handout'){
    return arrTechInfoURLs[6];
  }else if(sDocSelected == 'PSMB vs. Bare Metal Jacketing'){
    return arrTechInfoURLs[7];
  }else if(sDocSelected == 'PSMB vs. Paint or Polykraft'){
    return arrTechInfoURLs[8];
  }else if(sDocSelected == 'Stainless Steel Finish'){
    return arrTechInfoURLs[9];
  }else if(sDocSelected == 'Article Letter - Metal Products'){
    return arrTechInfoURLs[10];
  }else if(sDocSelected == 'MSDS Alternative - Aluminum Jacketing'){
    return arrTechInfoURLs[11];
  }else if(sDocSelected == 'MSDS Alternative - Stainless Steel Jacketing'){
    return arrTechInfoURLs[12];
  }else if(sDocSelected == 'MSDS Alternative - Metal Jacketing Accessories'){
    return arrTechInfoURLs[13];
  }else if(sDocSelected == 'Dimensional Tolerances'){
    return arrTechInfoURLs[14];
  }else if(sDocSelected == 'ARRA Certification'){
    return arrTechInfoURLs[15];
  }else{
    return arrTechInfoURLs[16];
  }
}

function getOtherLitURL(){
  if(sDocSelected == 'ITW Metal Overview'){
    return arrOtherLitURLs[0];
  }else if(sDocSelected == 'Applications Instr - Metal Jacketing'){
    return arrOtherLitURLs[1];
  }else{
    return arrOtherLitURLs[2];
  }
}

function setRollJacketingDS(){
  var RollJacketingDS = new Array();
  RollJacketingDS[0]="Aluminum Rolled Jacketing";
  RollJacketingDS[1]="Aluminum Painted";
  RollJacketingDS[2]="Stainless Steel Roll Jacketing";
  RollJacketingDS[3]="Ultrolon";
  RollJacketingDS[4]="Muffl-Jac";
  return RollJacketingDS;
}

function setSheetsDS(){
  var SheetsDS = new Array();
  SheetsDS[0]="Aluminum Deep Corrugated Sheets";
  SheetsDS[1]="Box Rib";
  SheetsDS[2]="Stainless Steel Deep Corrugated Sheets Document"
  return SheetsDS;
}

function setBandingDS(){
  var BandingDS = new Array();
  BandingDS[0]="Strapping & Seals";
  return BandingDS;
}

function setElbowsDS(){
  var ElbowsDS = new Array();
  ElbowsDS[0]="Aluminum Sure-Fit/Ell Jacs";
  ElbowsDS[1]="Aluminum Multi-Fit";
  ElbowsDS[2]="Stainless Steel T-316 Sure-Fit/Ell Jacs";
  ElbowsDS[3]="Packaging Chart 90 Degrees";
  ElbowsDS[4]="Packaging Chart 45 Degrees";
  ElbowsDS[5]="Packaging Chart 90 Degrees Metric";
  ElbowsDS[6]="Packaging Chart 45 Degrees Metric";
  ElbowsDS[7]="Conversion Chart";
  ElbowsDS[8]="O.D. Chart 90 Degrees";
  return ElbowsDS;
}

function setAccDS(){
  var AccDS = new Array();
  AccDS[0]="Fabstraps/Pab Bands";
  AccDS[1]="Apply Fabstraps";
  AccDS[2]="Springs";
  return AccDS;
}


function setInstallationGuidesDS(){
  var InstallationGuidesDS = new Array();
  InstallationGuidesDS[0]="Muffl-Jac Installation Instructions";
  InstallationGuidesDS[1]="Matching Deep Corrugated Sheets";
  InstallationGuidesDS[2]="Aluminum Elbow Sizes and Installation";
  return InstallationGuidesDS;
}

function setTechInfoDS(){
  var TechInfoDS = new Array();
  TechInfoDS[0]="Waterstained Aluminum";
  TechInfoDS[1]="Corrosion";
  TechInfoDS[2]="Metal Melting Points";
  TechInfoDS[3]="Application Mity Spring";
  TechInfoDS[4]="Application Super Mity Spring";
  TechInfoDS[5]="Polysurlyn Techncial Data Sheet";
  TechInfoDS[6]="Polysurlyn, General Handout";
  TechInfoDS[7]="PSMB vs. Bare Metal Jacketing";
  TechInfoDS[8]="PSMB vs. Paint or Polykraft";
  TechInfoDS[9]="Stainless Steel Finish";
  TechInfoDS[10]="Article Letter - Metal Products";
  TechInfoDS[11]="MSDS Alternative - Aluminum Jacketing";
  TechInfoDS[12]="MSDS Alternative - Stainless Steel Jacketing";
  TechInfoDS[13]="MSDS Alternative - Metal Jacketing Accessories";
  TechInfoDS[14]="Dimensional Tolerances";
  TechInfoDS[15]="ARRA Certification";
  TechInfoDS[16]="What is ASTM C1729";
  return TechInfoDS;
}

function setOtherLitDS(){
  var OtherLitDS = new Array();
  OtherLitDS[0] = "ITW Metal Overview";
  OtherLitDS[1] = "Applications Instr - Metal Jacketing";
  OtherLitDS[2] = "Oregon Brominated Diphenyl Ether Compliance";
  return OtherLitDS;
}

function setRollJacketingURLs(){
  var RollJacketingDSURLs = new Array();
  RollJacketingDSURLs[0]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/2.10 ALUMINUM ROLL JACKETING.pdf";
  RollJacketingDSURLs[1]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/2.20_painted_aluminum_roll_jacketing.pdf";
  RollJacketingDSURLs[2]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/2.30  STAINLESS STEEL ROLL.pdf";
  RollJacketingDSURLs[3]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/2.40 ULTROLON.pdf";
  RollJacketingDSURLs[4]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/2.70 MUFFL-JAC.pdf";
  return RollJacketingDSURLs;
}

function setSheetsURLs(){
  var SheetsURLs = new Array();
  SheetsURLs[0]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/3.10_alum_deep_corrugated_sheets.pdf";
  SheetsURLs[1]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/3.20_box_rib.pdf";
  SheetsURLs[2]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/3.15_ss_deep_corrugated_sheets.pdf";
  return SheetsURLs;
}

function setBandingURLs(){
  var BandingDSURLs = new Array();
  BandingDSURLs[0]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/4.10 STRAPPING & SEALS.pdf";
  return BandingDSURLs;
}

function setElbowsURLs(){
  var ElbowsURLs = new Array();
  ElbowsURLs[0]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/5.10_aluminum_elbows.pdf";
  ElbowsURLs[1]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/5.30  MULTI-FIT.pdf";
  ElbowsURLs[2]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/5.40 STAINLESS STEEL ELBOWS.pdf";
  ElbowsURLs[3]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/pc90d.htm";
  ElbowsURLs[4]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/pc45d.htm";
  ElbowsURLs[5]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/pd90dmetric.htm";
  ElbowsURLs[6]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/pd45dmetric.htm";
  ElbowsURLs[7]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/cc.htm";
  ElbowsURLs[8]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/odc90d.htm";
  return ElbowsURLs;
}

function setAccessoriesURLs(){
  var AccessoriesURLs = new Array();
  AccessoriesURLs[0]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/6.10 FABSTRAPS.pdf";
  AccessoriesURLs[1]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/6.20  APPLY FABSTRAPS.pdf";
  AccessoriesURLs[2]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/6.60  SPRINGS.pdf";
  return AccessoriesURLs;
}

function setInstallationGuidesURLs(){
  var InstallationGuidesURLs = new Array();
  InstallationGuidesURLs[0]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/Muffl-Jac_Installation_Instructions.pdf";
  InstallationGuidesURLs[1]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/matching_deep_corrugated_sheets.pdf";
  InstallationGuidesURLs[2]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/aluminum_elbow_sizes_installation.pdf";
  return InstallationGuidesURLs;
}

function setTechInfoURLs(){
  var TechInfoURLs = new Array();
  TechInfoURLs[0]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/7.10  WATER STAINED ALUM.pdf";
  TechInfoURLs[1]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/7.20  POULTICE CORROSION.pdf";
  TechInfoURLs[2]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/7.40 MELTING POINT.pdf";
  TechInfoURLs[3]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/7.50 APPLICATION MITY SPRING.pdf";
  TechInfoURLs[4]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/7.60 APPLICATION SUPER MITY SPRING.pdf";
  TechInfoURLs[5]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/polysurlyn_moisture_barrier.pdf";
  TechInfoURLs[6]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/ITW_PSMB_Handout_General.pdf";
  TechInfoURLs[7]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/ITW_PSMB_BareMetal_broch.pdf";
  TechInfoURLs[8]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/ITW_PSMB_vs_Paint.pdf";
  TechInfoURLs[9]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/SSFinish.pdf";
  TechInfoURLs[10]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/article_letter_for_metal_products.pdf";
  TechInfoURLs[11]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/article_letter_for_metal_products.pdf";
  TechInfoURLs[12]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/article_letter_for_metal_products.pdf";
  TechInfoURLs[13]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/article_letter_for_metal_products.pdf";
  TechInfoURLs[14]="http://www.itwinsulation.com/List_Price/page02.pdf";
  TechInfoURLs[15]="http://www.itwinsulation.com/pabco-childers/Data_Sheets/ARRA_Certification_of_all_products.pdf";
  TechInfoURLs[16]="http://www.itwinsulation.com/Pabco-Childers/Data_Sheets/what_is_astm_c1729.pdf";
  return TechInfoURLs;
}

function setOtherLitURLs(){
  var OtherLitURLs = new Array();
  OtherLitURLs[0] = "http://www.itwinsulation.com/pabco-childers/Data_Sheets/ITW_Metal_DSheet_FINAL.pdf";
  OtherLitURLs[1] = "http://www.itwinsulation.com/pabco-childers/Data_Sheets/applications_instructions_4-12-10.pdf";
  OtherLitURLs[2] = "http://www.itwinsulation.com/Pabco-Childers/Data_Sheets/Oregon_Fire_Retardant_Laws_Compliance.pdf";
  return OtherLitURLs;
}


function setLinkClass(sLnkID,sClassName){
  var objLnk = getObject(sLnkID);
  objLnk.className = sClassName;
}

function setCellBorder(sCellID,sClassName){
  var objCell = getObject(sCellID);
  if(document.all){
    objCell.style.cursor = "hand";
  }else{
    objCell.style.cursor = "pointer";
  }
  objCell.className = sClassName;
}

function setTRLnkBordersOn(sLnkID,sTblID,sTopCellID,sBotCellID){
  var objLnk = getObject(sLnkID);
  var objTbl = getObject(sTblID);
  var objTopCell = getObject(sTopCellID);
  var objBotCell = getObject(sBotCellID);
  objLnk.style.textDecoration = "none";
  if(document.all){
    objTopCell.style.cursor = "hand";
    objBotCell.style.cursor = "hand";
    objLnk.style.cursor = "hand";
  }else{
    objTopCell.style.cursor = "pointer";
    objBotCell.style.cursor = "pointer";
    objLnk.style.cursor = "pointer";
  }
  objTopCell.style.paddingBottom = "0";
  objTopCell.style.borderBottomStyle = "solid";
  objTopCell.style.borderBottomWidth = "1px";
  objTopCell.style.borderBottomColor = "#800000";
  objBotCell.style.borderBottomStyle = "solid";
  objBotCell.style.borderBottomWidth = "1px";
  objBotCell.style.borderBottomColor = "#800000";
}

function setTRLnkBordersOff(sLnkID,sTblID,sTopCellID,sBotCellID){
  var objLnk = getObject(sLnkID);
  var objTbl = getObject(sTblID);
  var objTopCell = getObject(sTopCellID);
  var objBotCell = getObject(sBotCellID);
  objLnk.style.textDecoration = "none";
  objLnk.style.cursor = "none";
  objTbl.style.borderStyle = "none";
  objTopCell.style.paddingBottom = "1px";
  objTopCell.style.borderBottomStyle = "none";
  objBotCell.style.borderBottomStyle = "none";
}

function getObject(sObjID){
  var obj;
  var q = "\"";
  if(document.layers){
    obj = eval("document." + sObjID);
  }else if(document.all){
    obj = eval("document.all." + sObjID);
  }else if(document.getElementById){
    var sID = q + sObjID.toString() + q;
    obj = eval("document.getElementById(" + sID + ")");
  }
  return obj;
}
