function armList(theBox) {   
  var indStart = theBox.options[theBox.selectedIndex].text.indexOf('|');
  var indStop = theBox.options[theBox.selectedIndex].text.indexOf('|', (indStart+1));
  var indLength = indStop - indStart;
  var newALU = (theBox.options[theBox.selectedIndex].text.split('|', indLength )[1]);
  
  ( document.my_image.src.indexOf('.gif') != -1 ) ? document.my_image.src = '/images/products/' + newALU + '.gif' : document.my_image.src = '/images/products/' + newALU + '.jpg';
  document.my_image.title = newALU;
  document.my_image.parentNode.style.background = 'transparent';
  //document.my_image.parentNode.style.overflow = 'hidden';
  document.my_image.style.marginLeft = 'auto';
  document.my_image.parentNode.style.height = 'auto';
  document.my_image.parentNode.style.width = 'auto';
}

function reWriteLink(theImg) {
if ( theImg.title != 'loaded' ) {  
  if ( theImg.src.indexOf('.gif') != -1 ) {
      var end = theImg.src.indexOf('.gif');
      var newSource = ( theImg.src.substring(0, end) ) + '.jpg';
      theImg.src = newSource;
      theImg.title = 'loaded';
  }
  else if ( theImg.src.indexOf('.jpg') != -1 ) {
      var end = theImg.src.indexOf('.jpg');
      var newSource = ( theImg.src.substring(0, end) ) + '.gif';
      theImg.src = newSource;
      theImg.title = 'loaded';
      
      if ( theImg.parentNode.parentNode.className == 'img_hole' )
        theImg.parentNode.parentNode.style.background = '#fff;';
  }
}
else if ( theImg.parentNode.parentNode.className != 'img_hole' ) {
  theImg.parentNode.style.background = 'transparent url("/images/product_default.gif") center center no-repeat';
  theImg.parentNode.style.overflow = 'hidden';
  theImg.style.marginLeft = '-9999px';
  theImg.parentNode.style.height = '50px';
  theImg.parentNode.style.width = '50px';
}
else {
  theImg.parentNode.parentNode.style.background = '';
  theImg.parentNode.removeChild(theImg);
}
}

//oh boy...

var ajaxRequest;

function makeRequest() { 
  try {
  // Opera 8.0+, Firefox, Safari
  ajaxRequest = new XMLHttpRequest();
  } catch (e){
    // Internet Explorer Browsers
    try{
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e){
        // Something went wrong
        alert("Your browser broke!");
        return false;
      }
    }
  }
}


function discounts( littleSku ) {
  makeRequest();
  
  ajaxRequest.onreadystatechange = function(){
    if(ajaxRequest.readyState == 0){ } //uninitialized

    else if(ajaxRequest.readyState == 1){ } //loading
    
    else if(ajaxRequest.readyState == 2){ } //loaded
    
    else if(ajaxRequest.readyState == 3){ } //interactive

    else if(ajaxRequest.readyState == 4){ //complete
      document.getElementById('update_area').innerHTML = ajaxRequest.responseText;
  
    }
  }
  ajaxRequest.open('GET', '../PDGCommTemplates/ScrappinUnique/mods/mod_discount_hunter.php?sku=' + littleSku, true);
  ajaxRequest.send(null); 
}









var i=0;
var numcols=3;
var colwidth=100/numcols;
function writepdgbr(x){
  i++;

  if((i==1)&&(x==1)){
        document.write("<tr><td width="+colwidth+"% align=left valign=top>");
  }
  else if((i==(numcols*2))&&(x==0)){
           document.write('</td></tr>');
        i=0;
  }
  else if(x==0){
        document.write("</td><td width="+colwidth+"% align=left valign=top>");
  }
}




function FormatCurrency (value) {
  var Precision = 2;

  var valStr = "" + value;
  var valInt = Math.floor(value);
  var valFrac = value - valInt;
  var multiplier = " 1000000000000000000".substring(1,Precision+2);
  var valRoundedFrac = Math.floor (valFrac*multiplier + 0.5);
  valInt = Math.floor (Math.floor (value*multiplier + 0.5) / multiplier);
  var valFracStr = "000000000000000000" + valRoundedFrac;
  valFracStr = valFracStr.substring (valFracStr.length-Precision, valFracStr.length);

  valStr = "$" + valInt + "." + valFracStr;
  return valStr;
}
function FormatEuro (value) {
  var Precision = 2;

  var valStr = "" + value;
  var valInt = Math.floor(value);
  var valFrac = value - valInt;
  var multiplier = " 1000000000000000000".substring(1,Precision+2);
  var valRoundedFrac = Math.floor (valFrac*multiplier + 0.5);
  valInt = Math.floor (Math.floor (value*multiplier + 0.5) / multiplier);
  var valFracStr = "000000000000000000" + valRoundedFrac;
  valFracStr = valFracStr.substring (valFracStr.length-Precision, valFracStr.length);

  valStr = "" + valInt + "." + valFracStr + " EU";
  return valStr;
}




function NewWindow(mypage, myname, w, h, scroll) {
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resiz able'
  win = window.open(mypage, myname, winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}




function resetaddr(){
  document.upsvaladdr.newshipcity.value="";
  document.upsvaladdr.newshipzip.value="";
}
function setnewaddr(){
  if(document.upsvaladdr.newshipcity.value!="")
    document.upsvaladdr.shipcity.value=document.upsvaladdr.newshipcity.value;
  if(document.upsvaladdr.newshipstate.value!="ZZ")
    document.upsvaladdr.shipstate.value=document.upsvaladdr.newshipstate.value;
  if(document.upsvaladdr.newshipzip.value!="")
    document.upsvaladdr.shipzip.value=document.upsvaladdr.newshipzip.value;
}
function selectnewradio(){
  document.upsvaladdr.addrvalselect[1].checked=true;
}
function setnewvalues(){
  if(document.upsvaladdr.addrvalselect[1].checked==true){
    setnewaddr();
  }    
}
function bypassaddrval(){
  document.upsvaladdr.bypassvalidation.value="yes";
  document.upsvaladdr.addrvalselect[0].checked=true;
}
function resetaddrval(){
  document.upsvaladdr.bypassvalidation.value="no";
}

function removeBG( image ) {
  if ( image.parentNode.parentNode.className == 'img_hole') {
    image.parentNode.parentNode.className = 'img_hole clear'
  } 
}