
function onImgOver(imgId, imgOverSrc)
{
  document.images[imgId].src = imgOverSrc;
}

function onImgOut(imgId, imgOverSrc)
{
  document.images[imgId].src = imgOverSrc;
}

function onButOver(imgId, imgOverSrc)
{
  document.getElementById(imgId).src = imgOverSrc;
}

function onButOut(imgId, imgOutSrc)
{
  document.getElementById(imgId).src = imgOutSrc;
}

function ShipSameDayWindow(bOverrideSameDayMessage,customerZoneID) 
{
  ShipWindow=window.open('','ShipTime','height=270,width=430,resizable=yes,top=100,left=100');

  var tmp = ShipWindow.document;
  
  tmp.write('<html><head><title>Ship Time</title>');

  tmp.write('</head><body><p style=\"font-family:Verdana;font-size:12px;\"><b>Ship Time</b></p>');

  if (!bOverrideSameDayMessage)
  {
    if(customerZoneID == 3) 
    {
        tmp.write('<p style=\"font-family:Verdana;font-size:12px;line-height:120%\">Items that are designated by "Usually ships within 24 hours" normally leave our facilities on the same business day if the order is placed before 5:00pm EST.</p>');
     }
     else
     {
        tmp.write('<p style=\"font-family:Verdana;font-size:12px;line-height:120%\">Items that are designated by "Usually ships within 24 hours" normally leave our facilities on the same business day if the order is placed before 16:00GMT.</p>');
     }   
  }
  
  tmp.write('<p style=\"font-family:Verdana;font-size:12px;line-height:120%\">Ship time indicates the typical number of business days it takes for your item(s) to leave our facilities but does not include transit time from our facilities to the final destination.</p>');
  
  tmp.write('<p style=\"font-family:Verdana;font-size:12px;line-height:120%\">Orders that contain multiple items with different ship times will be shipped out based on the item with the longest ship time.</p>');
  
  tmp.write("<p><div style=\"font-family:Verdana;font-size:12px;cursor:pointer;color:#000077\" onmouseover=\"this.style.textDecoration='underline'\" onmouseout=\"this.style.textDecoration='none'\" onclick=\"window.open('\/asp\/customerservice\/shipping.asp','','height=678,width=900,scrollbars=yes,resizable=yes,titlebar=yes,toolbar=yes,menubar=yes')\">Shipping FAQ</div>");
  
  tmp.write("<div style=\"font-family:Verdana;font-size:12px;cursor:pointer;color:#000077\" onmouseover=\"this.style.textDecoration='underline'\" onmouseout=\"this.style.textDecoration='none'\" onclick=\"window.open('\/asp\/ship_rates.asp','','height=678,width=900,scrollbars=yes,resizable=yes,titlebar=yes,toolbar=yes,menubar=yes')\">Shipping Rates</div><br/></p>");
  
  tmp.write('</body></html>');

  tmp.close();

}

function DisplayMaxBanner(){
  var ImagesPath;
  var FirstForm;
  var SecondForm;
  var StrMOver;
  var StrMOut;
  StrMOver = "this.className=\'formLinkHover\'";
  StrMOut = "this.className=\'formLink\'";
  FirstForm = getRandomNumber();
  SecondForm = getRandomNumber();

  var CountryCode = readCookie('CountryCode');
  if (readCookie('ImagesPath').length > 0) {
      ImagesPath =  replaceAll( readCookie('ImagesPath'), [["%3A", ":"], [ "%2F", "/" ],["%2E", "."]] );
  }

  if( CountryCode == "FR" )
  {
  document.getElementById('DivBanner').innerHTML = "<table id='Table_01' width='779'   border='0' cellpadding='0' cellspacing='0' valign='top'>" +
          "<tr><td width='4' height='26' background='" + ImagesPath + "/images/art_intl/left_border.gif'></td>" +
          "<td width='43' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='center'>" +
          "<Form name='A" + FirstForm + "' style = 'margin:0px;padding:0px;display:inline;' id = 'A" + FirstForm + "' action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='256009398'><input type='hidden' name='LANG' value='2'><div class='formLink' onclick=document.forms['A" + FirstForm + "'].submit() style='display:inline;'><img src='" + ImagesPath + "/images/art_intl/french.gif' width='24' height='14' border='0'></div></form></td>" +
          "<td width='620' height='26' background='"  + ImagesPath + "/images/art_intl/center.gif' class='TopNavMenuItem'><b>Vous préférez effectuer vos achats en français ? Visitez " +
          "<form name='A" + SecondForm + "' style='margin:0px;padding:0px;display:inline;' id = 'A" + SecondForm + "' + action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='256009398'><input type='hidden' name='LANG' value='2'><div class='formLink' onmouseover = " +  StrMOver + " onmouseout = " +  StrMOut + " onclick=document.forms['A" + SecondForm + "'].submit() style='display:inline;'>allposters.fr</div></form></b></td>" +
          "<td width='36' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='right'>&nbsp;</td><td width='5' height='26' background='" + ImagesPath + "/images/art_intl/right_border.gif'></td></tr></table>";
  }
  else if( CountryCode == "DE" || CountryCode == "AT" )
  {
  document.getElementById('DivBanner').innerHTML = "<table id='Table_01' width='779'   border='0' cellpadding='0' cellspacing='0' valign='top'>" +
          "<tr><td width='4' height='26' background='" + ImagesPath + "/images/art_intl/left_border.gif'></td>" +
          "<td width='43' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='center'>" +
          "<Form name='A" + FirstForm + "' style = 'margin:0px;padding:0px;display:inline;' id = 'A" + FirstForm + "' action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='1631741110'><input type='hidden' name='LANG' value='3'><div class='formLink' onclick=document.forms['A" + FirstForm + "'].submit() style='display:inline;'><img src='" + ImagesPath + "/images/art_intl/germany.gif' width='24' height='14' border='0'></div></form></td>" +
          "<td width='620' height='26' background='"  + ImagesPath + "/images/art_intl/center.gif' class='TopNavMenuItem'><b>Möchten Sie die Seite lieber auf Deutsch anzeigen? Besuchen Sie " +
          "<form name='A" + SecondForm + "' style='margin:0px;padding:0px;display:inline;' id = 'A" + SecondForm + "' + action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='1631741110'><input type='hidden' name='LANG' value='3'><div class='formLink' onmouseover = " +  StrMOver + " onmouseout = " +  StrMOut + " onclick=document.forms['A" + SecondForm + "'].submit() style='display:inline;'>allposters.de</div></form></b></td>" +
          "<td width='36' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='right'>&nbsp;</td><td width='5' height='26' background='" + ImagesPath + "/images/art_intl/right_border.gif'></td></tr></table>";
  }
  else if( CountryCode == "AR" || CountryCode == "CL" || CountryCode == "CO" || CountryCode == "CR" || CountryCode == "DO" || CountryCode == "EC" || CountryCode == "SV" || CountryCode == "MX" || CountryCode == "PE" || CountryCode == "PR" || CountryCode == "ES" || CountryCode == "UY" || CountryCode == "VE" )
  {
  document.getElementById('DivBanner').innerHTML = "<table id='Table_01' width='779'   border='0' cellpadding='0' cellspacing='0' valign='top'>" +
          "<tr><td width='4' height='26' background='" + ImagesPath + "/images/art_intl/left_border.gif'></td>" +
          "<td width='43' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='center'>" +
          "<Form name='A" + FirstForm + "' style = 'margin:0px;padding:0px;display:inline;' id = 'A" + FirstForm + "' action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='859989174'><input type='hidden' name='LANG' value='4'><div class='formLink' onclick=document.forms['A" + FirstForm + "'].submit() style='display:inline;'><img src='" + ImagesPath + "/images/art_intl/spain.gif' width='24' height='14' border='0'></div></form></td>" +
          "<td width='620' height='26' background='"  + ImagesPath + "/images/art_intl/center.gif' class='TopNavMenuItem'><b>¿Prefiere realizar sus compras en español? Visite " +
          "<form name='A" + SecondForm + "' style='margin:0px;padding:0px;display:inline;' id = 'A" + SecondForm + "' + action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='859989174'><input type='hidden' name='LANG' value='4'><div class='formLink' onmouseover = " +  StrMOver + " onmouseout = " +  StrMOut + " onclick=document.forms['A" + SecondForm + "'].submit() style='display:inline;'>allposters.fr</div></form></b></td>" +
          "<td width='36' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='right'>&nbsp;</td><td width='5' height='26' background='" + ImagesPath + "/images/art_intl/right_border.gif'></td></tr></table>";
  }
  else if( CountryCode == "IT")
  {
  document.getElementById('DivBanner').innerHTML = "<table id='Table_01' width='779'   border='0' cellpadding='0' cellspacing='0' valign='top'>" +
          "<tr><td width='4' height='26' background='" + ImagesPath + "/images/art_intl/left_border.gif'></td>" +
          "<td width='43' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='center'>" +
          "<Form name='A" + FirstForm + "' style = 'margin:0px;padding:0px;display:inline;' id = 'A" + FirstForm + "' action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='1245865142'><input type='hidden' name='LANG' value='5'><div class='formLink' onclick=document.forms['A" + FirstForm + "'].submit() style='display:inline;'><img src='" + ImagesPath + "/images/art_intl/italian.gif' width='24' height='14' border='0'></div></form></td>" +
          "<td width='620' height='26' background='"  + ImagesPath + "/images/art_intl/center.gif' class='TopNavMenuItem'><b>Preferisci fare acquisti in italiano? Visita " +
          "<form name='A" + SecondForm + "' style='margin:0px;padding:0px;display:inline;' id = 'A" + SecondForm + "' + action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='1245865142'><input type='hidden' name='LANG' value='5'><div class='formLink' onmouseover = " +  StrMOver + " onmouseout = " +  StrMOut + " onclick=document.forms['A" + SecondForm + "'].submit() style='display:inline;'>allposters.fr</div></form></b></td>" +
          "<td width='36' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='right'>&nbsp;</td><td width='5' height='26' background='" + ImagesPath + "/images/art_intl/right_border.gif'></td></tr></table>";
  }
  else if (CountryCode == "JP" )
  {
  document.getElementById('DivBanner').innerHTML = "<table id='Table_01' width='779'   border='0' cellpadding='0' cellspacing='0' valign='top'>" +
          "<tr><td width='4' height='26' background='" + ImagesPath + "/images/art_intl/left_border.gif'></td>" +
          "<td width='43' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='center'>" +
          "<Form name='A" + FirstForm + "' style = 'margin:0px;padding:0px;display:inline;' id = 'A" + FirstForm + "' action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='2017617078'><input type='hidden' name='LANG' value='6'><div class='formLink' onclick=document.forms['A" + FirstForm + "'].submit() style='display:inline;'><img src='" + ImagesPath + "/images/art_intl/japan.gif' width='24' height='14' border='0'></div></form></td>" +
          "<td width='620' height='26' background='"  + ImagesPath + "/images/art_intl/center.gif' class='TopNavMenuItem'><img src='" + ImagesPath + "/images/art_intl/jp_image1.gif' width='168' height='14' border='0'> " +
          "<form name='A" + SecondForm + "' style='margin:0px;padding:0px;display:inline;' id = 'A" + SecondForm + "' + action='http://affiliates.allposters.com/link/redirect.asp' method='get'><input type='hidden' name='AID' value='2017617078'><input type='hidden' name='LANG' value='6'><div class='formLink' onmouseover = " +  StrMOver + " onmouseout = " +  StrMOut + " onclick=document.forms['A" + SecondForm + "'].submit() style='display:inline;'>allposters.fr</div></form> " +
          "<img src='" + ImagesPath + "/images/art_intl/jp_image2.gif' width='60' height='14' border='0'></b></td>" +
          "<td width='36' height='26' background='" + ImagesPath + "/images/art_intl/center.gif' valign='middle' align='right'>&nbsp;</td><td width='5' height='26' background='" + ImagesPath + "/images/art_intl/right_border.gif'></td></tr></table>";
  }
}

function readCookie(name){
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function replaceAll( str, replacements ) {

  for ( i = 0; i < replacements.length; i++ ) {
    var idx = str.indexOf( replacements[i][0] );

    while ( idx > -1 ) {
      str = str.replace( replacements[i][0], replacements[i][1] );
      idx = str.indexOf( replacements[i][0] );
    }
  }
      return str;
}

function getRandomNumber() {
  var FormNumber;
  FormNumber = Math.round(100000 * Math.random());
  return FormNumber;
}

function launchStudio(pURL, pParameters, qs_sessionid, glbCustomerZoneID, sAltLink){
   var winPop;
   var newWindow = false;
   var mTop = 10;
   var mLeft = 10;
   //if (screen.width >= 1024) {
      var WindowName="FrameStudio" + new Date().getTime();
      winPop = window.open(pURL + "?" + pParameters + "&ui=" + qs_sessionid + "&customerzoneid=" + glbCustomerZoneID,WindowName,'toolbar=no,location=no,status=no,statusbar=no,menubar=no,height=678,width=900,scrollbars=no,resizable=no,top=' + mTop + ',left=' + mLeft);
      if (winPop){
         if (winPop.focus){
            winPop.focus()
         }
      }else{
         window.location.href = "/FrameStudio/error.asp?error=popup&" + pParameters + "&ui=" + qs_sessionid;
      }
   //}else{
      //document.location.href = sAltLink;
   //}
}
