// header-head.js -- beginning --
var xmlhttp;
var atc_currentpid;
var atc_pushed=0;
var pvid_pushed=0;
<!--
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
function swapDivContents(str,pvid)
{
  var prod_video_div="product_video"+pvid
//  alert(prod_video_div);
//  alert(altVid[0]);
  if (str=='orig')
  { document.getElementById(prod_video_div).innerHTML=origVid[parseInt(pvid)]; }
  else if (str=='alt')
  { document.getElementById(prod_video_div).innerHTML=altVid[parseInt(pvid)]; }
  else
  { document.getElementById(prod_video_div).innerHTML=origVid[parseInt(pvid)]; }
}

function swapAddCartImage(tog)
{ var addCartImageOrig="includes/graphics/btn_addtocart_blue.jpg";
   var addCartImageAlt="includes/graphics/btn_addtocart_grey.jpg";
   var addCartImageName="AddToCart"+atc_currentpid;

  if (tog=='orig')
  { document.getElementById(addCartImageName).src=addCartImageOrig; }
  else if (tog=='alt')
  { document.getElementById(addCartImageName).src=addCartImageAlt; }
}

function stateChangeShopAdd()
{
  var html_resp=xmlhttp.responseText;
  
  html_resp_array=html_resp.split("<|||>");

// if (xmlhttp.readyState==4) alert(validation_resp);
  if ((xmlhttp.readyState==4)&&(html_resp_array[1]!=''))
  { for(i=0;i<altVid.length;i++) { swapDivContents('orig',i);}
    TINY.box.show(html_resp_array[0],0,0,0,0,5);
    swapAddCartImage('orig');
    atc_pushed=0;

//    alert("1: "+html_resp_array[1]);
  }
  else if ((xmlhttp.readyState==4)&&(html_resp_array[1]==''))
  { alert("Unable to contact server.\n\nCheck to make sure you are still\nconnected to the internet."); }
}

function addToShoppingCart(pid)
{
  if (atc_pushed==0)
  { atc_pushed=1;
     atc_currentpid=pid;
     swapAddCartImage('alt');
     xmlhttp=GetXmlHttpObject();
     if (xmlhttp==null)
     {
       alert ("Browser does not support HTTP Request");
       return;
     }
   //  TINY.box.show("#",0,0,0,0);
     var url = "store2/shoppingcart.php";
     url = url+"?shop_action=add&prod="+pid;
   //	alert(url+", "+params);
     xmlhttp.open("GET", url,true);
     xmlhttp.onreadystatechange=stateChangeShopAdd;
     xmlhttp.send(null)
  }
  else
  { alert("We are processing your last click of the 'Add to Cart' button.\n\nPlease wait.\n\nIf this message continues, refresh your browser window. Contact VANITYMARK at 'support@vanitymark.com' if you just can't seem to get past this message or are unable to add this or any other product to your cart."); }
}

function GetXmlHttpObject()
{
  if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
  }
  if (window.ActiveXObject)
  {
  // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
  }
  return null;
}
// header-head.js -- end --