function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}





function DisplayMiniCart(name,style) {

  var free_shipping = 75;

  var cookies=document.cookie;  //read in all cookies

  var start = cookies.indexOf(name + "=");  //set start to beginning of ss_cart cookie

  var cartvalues = "";

  var linecount = 0;

  var start1;

  var end1;

  var tmp;

  // Start Output

  document.write("<div>");

  document.write("<div class=\"checkOutLink\">");

  document.write("<a href=\"http://www.icedoutgear.com/cgi/sc/order.cgi?storeid=*1a47a445d009aacd09a679ff29eb5d&function=show\">");

	document.write("Checkout");

	document.write("</a>");

	document.write("</div>");

  if (style == "Detail")

  {

   document.write("<table border=\"1\">\n");

    document.write("<tr>\n");

    document.write("<th colspan=\"3\">");

    document.write("<a href=\"http://www.icedoutgear.com/cgi/sc/order.cgi?storeid=*1a47a445d009aacd09a679ff29eb5d&function=show\">");

    document.write("Your Shopping Cart");

    document.write("</a></th></tr>");

  }

  else if (style == "Summary")

  {

    document.write("<a href=\"http://www.icedoutgear.com/cgi/sc/order.cgi?storeid=*1a47a445d009aacd09a679ff29eb5d&function=show\">");

    document.write("Your Shopping Cart");

    document.write("</a>");

  }

  else

  {

	document.write("<a href=\"http://www.icedoutgear.com/cgi/sc/order.cgi?storeid=*1a47a445d009aacd09a679ff29eb5d&function=show\">");

    document.write("<img src=\"https://www.icedoutgear.com/media/images/header/cart.gif\" border=\"0\" name=\"cart\" align=\"top\">");

    document.write("</a>&nbsp;");

  }

  if (start == -1)  //No cart cookie

  {

    if (style == "Detail")

    {

      document.write("</table>\n");

    }

    else if ((style == "ItemCount") || (style == "Subtotal"))

    {

      document.write("<a href=\"http://www.icedoutgear.com/cgi/sc/order.cgi?storeid=*1a47a445d009aacd09a679ff29eb5d&function=show\">");

      document.write("<span class=\"cartItems\">\(0 Items\)</span>");

      document.write(freeShippingTxt(free_shipping, 0));

      document.write("</a>&nbsp;");

      document.write("</div>");

    }

    else

    {

      document.write("</div>");

    }      

  }

  else   //cart cookie is present

  {

    start = cookies.indexOf("=", start) +1;  

    var end = cookies.indexOf(";", start);  

    if (end == -1)

    {

      end = cookies.length;

    }

    cartvalues = unescape(cookies.substring(start,end)); //read in just the cookie data

    start = 0;

    while ((start = cartvalues.indexOf("|", start)) != -1)

    {

	  start++;

      end = cartvalues.indexOf("|", start);

      if (end != -1)

      {

        linecount++;

        if ((linecount == 2) && (style != "Detail"))  // Total Quantity of Items

        {

          tmp = cartvalues.substring(start,end);

          colon = tmp.indexOf(":", 0);

          if ((style == "ItemCount") || (style == "Subtotal"))

          {

            document.write("<a href=\"http://www.icedoutgear.com/cgi/sc/order.cgi?storeid=*1a47a445d009aacd09a679ff29eb5d&function=show\">");

          }

          if (style == "Summary")

         {

           document.write("<br>Contains <b>");

          } 

          document.write(tmp.substring(colon+1,end - start));

          if (style == "Summary")

         {

           document.write("</b>");

          }

          if ((tmp.substring(colon+1,end - start)) == 1 )

          {

            document.write(" Item");

          }

          else

          {

            document.write(" Items");

          }

          if (style == "ItemCount")

          {

            document.write("</a>");

          } 

          else if (style == "Subtotal")

          {

            document.write(": ");

          } 

          else if (style == "Summary")

          {

            document.write("<br>Subtotal: <b>");

          }

        }

        if (linecount == 3)  // Product Subtotal

       {

         if ((style == "Subtotal") || (style == "Summary"))

          {

            tmp = cartvalues.substring(start,end);

            colon = tmp.indexOf(":", 0);

            document.write(tmp.substring(colon+1,end - start));

            document.write(freeShippingTxt(free_shipping, tmp.substring(colon+1,end - start)));

            if (style == "Summary") 

            {

              document.write("</b>");

            }

            else

            {

            document.write("</a>");

            }

          }

          else if (style == "Detail")

          {

            start1 = start;

            end1 = end;

            document.write("<tr><td class=\"MiniCartHead\">Qty</td>");

            document.write("<td class=\"MiniCartHead\">Product</td>");

            document.write("<td class=\"MiniCartHead\">Price</td></tr>\n");

          }

        }

       if ((linecount > 3) && (style == "Detail"))  // individual products

        {

          tmp = cartvalues.substring(start,end);

          colon = tmp.indexOf(":", 0);

          document.write("<tr>");

          document.write("<td class=\"MiniCartQty\">");

          document.write(tmp.substring(0,colon));

          document.write("</td><td class=\"MiniCartProduct\">");

          colon2 = tmp.indexOf(":", colon+1);

          document.write(tmp.substring(colon2+1,end - start));

          document.write("</td><td class=\"MiniCartPrice\">");

          document.write(tmp.substring(colon+1,colon2));

          document.write("</td></tr>\n");

        }

        start = end;

      }

      else

        break;

    } // end while loop

    //close minicart HTML

    if (style != "Detail")

    {

      document.write("</div>");

    }

    else

    {

      document.write("<tr>");

      document.write("<td class=\"MiniCartSubtotalText\" colspan=\"2\">Subtotal</td>");

      document.write("<td class=\"MiniCartSubtotal\">");

      tmp = cartvalues.substring(start1,end1);

      colon = tmp.indexOf(":", 0);

      document.write(tmp.substring(colon+1,end1 - start1));

      document.write(freeShippingTxt(free_shipping, tmp.substring(colon+1,end1 - start1)));

      document.write("</td>");

      document.write("</tr>");

      document.write("</table>\n");

      document.write("</div>");

    }

  }

}



function MoreToBuy(name,style) {

  var free_shipping = 75;

  var cookies=document.cookie;  //read in all cookies

  var start = cookies.indexOf(name + "=");  //set start to beginning of ss_cart cookie

  var cartvalues = "";

  var linecount = 0;

  var start1;

  var end1;

  var tmp;

  // Start Output

  if (start != -1)  //No cart cookie

  {

    start = cookies.indexOf("=", start) +1;  

    var end = cookies.indexOf(";", start);  

    if (end == -1)

    {

      end = cookies.length;

    }

    cartvalues = unescape(cookies.substring(start,end)); //read in just the cookie data

    start = 0;

    while ((start = cartvalues.indexOf("|", start)) != -1)

    {

	  start++;

      end = cartvalues.indexOf("|", start);

      if (end != -1)

      {

        linecount++;

        if ((linecount == 2) && (style != "Detail"))  // Total Quantity of Items

        {

          tmp = cartvalues.substring(start,end);

          colon = tmp.indexOf(":", 0);

          if ((style == "ItemCount") || (style == "Subtotal"))

          {

          }

          if (style == "Summary")

         {

          } 

          if (style == "Summary")

         {

          }

          if ((tmp.substring(colon+1,end - start)) == 1 )

          {

          }

          else

          {

          }

          if (style == "ItemCount")

          {

          } 

          else if (style == "Subtotal")

          {

          } 

          else if (style == "Summary")

          {

          }

        }

        if (linecount == 3)  // Product Subtotal

       {

         if ((style == "Subtotal") || (style == "Summary"))

          {

            tmp = cartvalues.substring(start,end);

            colon = tmp.indexOf(":", 0);

            //document.write(tmp.substring(colon+1,end - start));

            document.write(BuyMoreTxt(free_shipping, tmp.substring(colon+1,end - start)));

            if (style == "Summary") 

            {

              document.write("</b>");

            }

            else

            {

            document.write("</a>");

            }

          }

          else if (style == "Detail")

          {

            start1 = start;

            end1 = end;

            document.write("<tr><td class=\"MiniCartHead\">Qty</td>");

            document.write("<td class=\"MiniCartHead\">Product</td>");

            document.write("<td class=\"MiniCartHead\">Price</td></tr>\n");

          }

        }

       if ((linecount > 3) && (style == "Detail"))  // individual products

        {

          tmp = cartvalues.substring(start,end);

          colon = tmp.indexOf(":", 0);

          document.write("<tr>");

          document.write("<td class=\"MiniCartQty\">");

          document.write(tmp.substring(0,colon));

          document.write("</td><td class=\"MiniCartProduct\">");

          colon2 = tmp.indexOf(":", colon+1);

          document.write(tmp.substring(colon2+1,end - start));

          document.write("</td><td class=\"MiniCartPrice\">");

          document.write(tmp.substring(colon+1,colon2));

          document.write("</td></tr>\n");

        }

        start = end;

      }

      else

        break;

    } // end while loop

    //close minicart HTML

    if (style != "Detail")

    {

      document.write("</div>");

    }

    else

    {

      document.write("<tr>");

      document.write("<td class=\"MiniCartSubtotalText\" colspan=\"2\">Subtotal</td>");

      document.write("<td class=\"MiniCartSubtotal\">");

      tmp = cartvalues.substring(start1,end1);

      colon = tmp.indexOf(":", 0);

      document.write(tmp.substring(colon+1,end1 - start1));

      document.write(freeShippingTxt(free_shipping, tmp.substring(colon+1,end1 - start1)));

      document.write("</td>");

      document.write("</tr>");

      document.write("</table>\n");

      document.write("</div>");

    }

  }

}







function formatCurrency(num) {

  num = currencyToNum(num);

  sign = (num >= 0.0);

  num = Math.abs(num);

  num = Math.floor(num*100+0.50000000001);

  cents = num%100;

  num = Math.floor(num/100).toString();

  if(cents<10) {

    cents = "0" + cents;

  }

  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {

    num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));

  }

  return (((sign)?'':'-') + '$' + num + '.' + cents);

}



function currencyToNum(num) {

  num = num.toString().replace(/\$|\,/g,'');

  if (isNaN(num)) {

    num = "0";

  }

  return num;

}



function freeShippingTxt(fs, st) {

  msg = "&nbsp;";

  fs_val = currencyToNum(fs);

  st_val = currencyToNum(st);

  diff = fs_val - st_val;

  if (diff <= 0.0) {

    //msg = "<br>Free Shipping for this order!!";

	msg = "<div class=\"cartShipping\">Free Shipping for this order!!</div>";

  } else {

    msg = "<div class=\"cartShipping\">Free Shipping:</div><div class=\"cartAmount\">" + formatCurrency(diff) + " to go!</div>";

  }

  return msg;

}

function BuyMoreTxt(fs, st) {

  msg = "&nbsp;";

  fs_val = currencyToNum(fs);

  st_val = currencyToNum(st);

  diff = fs_val - st_val;

  if (diff <= 0.0) {

    msg = "<br>You've Earned Free Shipping for this order!!";

  } else {

    msg = "<br>You're  " + formatCurrency(diff) + " Away From FREE Shipping!";

  }

  return msg;

}



var alert_title='Input Restriction';



function limitTextarea(el,maxLines,maxChar){

if(!el.x){

el.x=uniqueInt();

el.onblur=function(){clearInterval(window['int'+el.x])}

}

window['int'+el.x]=setInterval(function(){

var lines=el.value.replace(/\r/g,'').split('\n'),

i=lines.length,

lines_removed,

char_removed;

if(maxLines&&i>maxLines){

alert('You can not enter\nmore than '+maxLines+' lines');

lines=lines.slice(0,maxLines);

lines_removed=1

}

if(maxChar){

i=lines.length;

while(i-->0)if(lines[i].length>maxChar){

lines[i]=lines[i].slice(0,maxChar);

char_removed=1

}

if(char_removed)alert('You can not enter more\nthan '+maxChar+' characters per line')

}

if(char_removed||lines_removed)el.value=lines.join('\n')

},50);

}



function uniqueInt(){

var num,maxNum=100000;

if(!uniqueInt.a||maxNum<=uniqueInt.a.length)uniqueInt.a=[];

do num=Math.ceil(Math.random()*maxNum);

while(uniqueInt.a.hasMember(num))

uniqueInt.a[uniqueInt.a.length]=num;

return num

}



Array.prototype.hasMember=function(testItem){

var i=this.length;

while(i-->0)if(testItem==this[i])return 1;

return 0

};



function set_ie_alert(){

window.alert=function(msg_str){

vb_alert(msg_str)

}

}

function rowOverEffect(object) {
  if (object.className == 'linkTableRow') object.className = 'linkTableRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'linkTableRowOver') object.className = 'linkTableRow';
}

