// ******************************************************************
/*
 * PartSpecSheet.js

 * For LMS & LMC Quote and Drawing Downloads
 */
// ******************************************************************

// --------------------------------------------------------
// Determine browser type and version
// --------------------------------------------------------

var msg="";
var ckvalue="";

function addToCart(Desc)
{
    var qty = document.getElementById("qtySelect").value;
    var code = parsePartNumber();
    if (code=="Part Number:") return;
    //var qty = parseInt(qtyList.options[qtyList.selectedIndex].text);
    var cfmmsg = "Do you wish to add the following to your\nquotation list?\n\n" +
              "Part Number: " + code + "\n" +
              "Quantity: " + qty + "\n";
               

    if (confirm(cfmmsg)) {
        ReadCookie('lmsck'); 
        Insert(code,Desc,qty); 
        setCookie(msg);
    }
    // qtyList.selectedIndex = 0;
}

function showquote(){
document.location.href="../tibsRFQ.htm";
}

function setCookie(value){
 document.cookie = 'lmsck' + "=" + escape(value)+"; path=/";
}

function ReadCookie(CookieName) {
  var SelectSize
  var ReturnValue = "";
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
    var CookiePieces
    var x = 0;
  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) 
     {
    CookiePieces = CookieSet[x].split ('=');
    if (CookiePieces[0].substring (0,1) == ' ')
       {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
       }
    if (CookiePieces[0] == CookieName)
       {
      ckvalue = unescape(CookiePieces[1]);
     
     } }
}


function Insert(code,name,qty){    
var Fld='';
gg = new Array(7);

var SelectSize=0;
var FldSet='';
msg=ckvalue;
if (msg.length <  3) msg='';
if (msg.length > 2) 
{
FldSet = msg.split ('+');
SelectSize=FldSet.length;
for (i = 0; i < 7; i++)
{ gg[i]=""; }
if (SelectSize > 7 ) SelectSize=7;
  for (x = 0; x < SelectSize; x++)
{
  Fld = FldSet[x].split ('=');
  if (Fld[0]==code) return;
}
msg=msg + "+";
} 
msg = msg +code+"="+name+"="+qty; 

if (SelectSize == 6){
    var msg10='Max. of 7 Items allowed per request have been selected.\n';
    msg10=msg10+'Please proceed to Quote Request Form by clicking '+'"REVIEW QUOTE'+'" button.';
    alert(msg10);
   }

}
