/*** COPYRIGHT 2009  BY FDM4 INTERNATIONAL INC. - ALL RIGHTS RESERVED ********/
/*** global.js -- Global JavaScript                                        ***/
/*****************************************************************************/
/*B010301 01/24/12 JKR P14071 Moved getHashParam() and getHashObj().         */
/*B010300 12/19/11 JKR P14258 Email subscription changes.                    */
/*B010201 12/01/11 JZ - Added & to the invalid search term chars.            */
/*B010200 11/17/11 JZ - Added cart hover display override capabilities.      */
/*B010102 09/26/11 JD - IAI: Temp fix for IE8 cart drop down display.        */
/*B010101 09/14/11 JD - Luxx: removed stock display and style code from      */
/*                      detailed drop down.                                  */
/*B010100 08/16/11 JD - Luxx: "detailed" cart drop down.                     */
/*B010007 05/25/11 MS - Updated press page function.                         */
/*B010006 05/25/11 MS - Show color descriptions on "added" to cart.          */
/*B010005 05/19/11 MS - Make AJAX paths relative urls.                       */
/*                    - Make ProductMode check case-insensitive.             */
/*B010004 05/12/11 MS - Added press page pop-up modal function.              */
/*B010003 05/01/11 MS - Email List AJAX fixes.                               */
/*B010002 04/28/11 MS - Minor register/email modal window js changes.        */
/*B010001 04/04/11 MS - Sign In and Email modal window pop-up functions.     */
/*        04/14/11 TV - Add pink circle for shopping cart items.             */
/*B010000 03/03/11 JJD- Cart hover display changes.                          */
/*****************************************************************************/
/* 070010 01/18/11 JB - Removed top references.                              */
/* 070009 12/01/10 JD2- Added validation for floatingAdded.                  */
/* 070008 08/23/10 JB - Added getNoCacheParam,appended to cartRequest.w call.*/
/* 070007 03/10/10 APY- Remove Alert when adding to cart.                    */
/* 070006 02/24/10 APY- Update CartHover logic to split cart / added display.*/
/* 070005 02/23/10 JD2- Only hide the processing display if it exists.       */
/*                      Issue on pages not running through site.w.           */
/* 070004 02/16/10 JD2- Moved ajax functions to site.js. Issues on checkout. */
/*                    - Added getParam function get retrieving query param.  */
/* 070003 02/03/10 APY- Add getHash, showMore and hideMore functions.        */
/* 070002 01/19/10 JD2- Removed 10dev reference.                             */
/*                    - Added clearField and setField functions.             */
/* 070001 01/06/10 JB - Added ajax functions - deprecate ajax-js.i.          */
/* 070000 12/19/09 JB - Added and removed functions/vars for P9134.          */
/*                      Full content of CartHover.js is now contained here.  */
/* 060000 12/11/09 APY- Add setColorCookie function.                         */
/* 050000 04/03/09 JB - Update global.js from the web server.                */
/* 040000 04/23/02 JZ - Added missing image functionality.                   */
/*****************************************************************************/
/* 030100 10/15/01 JZ - Fix enlarge function for Mac IE 5.                   */
/* 030000 09/20/01 JZ - Added enlarge view functionality.                    */
/*****************************************************************************/
/* 020000 08/23/01 JZ - Wip'd to correct version problem.                    */
/*                    - Added blank function.                                */
/* 010102 12/12/00 IAB- Added functions for On Hold Alert                    */
/* 010100 08/22/00 JZ - Added a progress bar function with no time out.      */
/*****************************************************************************/
/* 070000 12/19/09 JB - Added and removed functions/vars for P9134.          */
/* 060000 12/11/09 APY- Add setColorCookie function.                         */
/* 050000 04/03/09 JB - Update global.js from the web server.                */
/* 040000 04/23/02 JZ - Added missing image functionality.                   */
/*****************************************************************************/
/* 030100 10/15/01 JZ - Fix enlarge function for Mac IE 5.                   */
/* 030000 09/20/01 JZ - Added enlarge view functionality.                    */
/*****************************************************************************/
/*** CartHover.js -- Renders order info and provides add-to-cart           ***/
/* 020000 08/23/01 JZ - Wip'd to correct version problem.                    */
/*                    - Added blank function.                                */
/* 010102 12/12/00 IAB- Added functions for On Hold Alert                    */
/* 010100 08/22/00 JZ - Added a progress bar function with no time out.      */
/*****************************************************************************/
// This is a .js file that contains several commonly used javascript functions
var img        = new Image();                                      /* 030000 */
var maxWidth   = 0;                                                /* 030000 */
var maxHeight  = 0;                                                /* 030000 */
var imagePath  = "";                                               /* 030000 */
/********************^ 050000 ^********************/
// xp_progressbar
// Copyright 2004 Brian Gosselin of ScriptAsylum.com
//
// v1.0 - Initial release
// v1.1 - Added ability to pause the scrolling action (requires you to assign
//        the bar to a unique arbitrary variable).
//      - Added ability to specify an action to perform after a x amount of
//      - bar scrolls. This requires two added arguments.
// v1.2 - Added ability to hide/show each bar (requires you to assign the bar
//        to a unique arbitrary variable).
// var xyz = createBar(
// total_width,
// total_height,
// background_color,
// border_width,
// border_color,
// block_color,
// scroll_speed,
// block_count,
// scroll_count,
// action_to_perform_after_scrolled_n_times
// )
var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;
function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action){
if(ie||w3c){
var t='<div id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
t+='<span id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
for(i=0;i<blocks;i++){
t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
t+='"></span>';
}
t+='</span></div>';

document.getElementById("procDiv").innerHTML = t;
var bA=(ie)?document.all['blocks'+N]:document.getElementById('blocks'+N);
bA.bar=(ie)?document.all['_xpbar'+N]:document.getElementById('_xpbar'+N);
bA.blocks=blocks;
bA.N=N;
bA.w=w;
bA.h=h;
bA.speed=speed;
bA.ctr=0;
bA.count=count;
bA.action=action;
bA.togglePause=togglePause;
bA.showBar=function(){
this.bar.style.visibility="visible";
}
bA.hideBar=function(){
this.bar.style.visibility="hidden";
}
bA.tid=setInterval('startBar('+N+')',speed);
return bA;
}}

function startBar(bn){
var t=(ie)?document.all['blocks'+bn]:document.getElementById('blocks'+bn);
if(parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){
t.style.left=-(t.h*2+1)+'px';
t.ctr++;
if(t.ctr>=t.count){
eval(t.action);
t.ctr=0;
}}else t.style.left=(parseInt(t.style.left)+t.h+1)+'px';
}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}
/********************^ 050000 ^********************/
/********************^ 040000 ^********************/
function centreMe(jwindow, height, width)
{
   var screenHeight = screen.height;
   var screenWidth  = screen.width;
   var topLeftx     = Math.round( (screenWidth - width)/2 );
   var topLefty     = Math.round( (screenHeight - height)/2 );
   jwindow.moveTo(topLeftx, topLefty);
}

function status_write(msg)
{
   window.status = msg;
   return true;
}
/********************v 020000 v********************/
function blank() { return "<html></html>";}
/********************^ 020000 ^********************/
var clickFlag = false;
var onhold = false;                                               /* 010102 */
var OnHoldWindow = null;                                          /* 010102 */

function getClickFlag()
{
   return clickFlag;
}

function checkClickFlag(vWindow)
{
   var isWindow = vWindow;
   if ( (!getClickFlag()) && (!onhold) )
   {
      clickFlag = true;
      brokenHref();
      if ( isWindow != "YES" )
      {
         runProgressBar();
      }
      return true;
   }
   else
   {
     if (OnHoldWindow != null)                                     /* 010102 */
         OnHoldWindow.focus();                                     /* 010102 */
      return false;
   }
}
/**************** 010100 ******************/
function checkClickFlagNoTimeout(vWindow)
{
   var isWindow = vWindow;
   if ( !getClickFlag() )
   {
      clickFlag = true;
      /* removed call to brokenHref() */
      if ( isWindow != "YES" )
      {
         runProgressBar();
      }
      return true;
   }
   else
   {
      return false;
   }
}
/****************^ 010100 ^******************/
var errorFlag;
function brokenHref()
{
   errorFlag = setTimeout("clickFlag = false;",10000);
}

// progress bar stuff below

var i = 0;
var progressBar;
var goForward = true;

function runProgressBar()
{
   i         = 0;
   goForward = true;

   if ( navigator.appName != "Netscape" )
   {
      for (var j=1; j<=50; j++)
      {
         eval("menu.document.all.cell_" + j + ".style.background=\"white\"");
      }
      eval("menu.document.all.progress.style.visibility=\"visible\"");

      progressBar = setInterval("if ( getClickFlag() ) {changeColor();} else {clearInterval(progressBar); eval(  \"menu.document.all.progress.style.visibility='hidden'\"  );}",5);
   }
}

function changeColor()
{
   if ( goForward )
   {
      i++;
      if ( i > 50 )
      {
         i = 50;
         goForward = false;
         for (var j=1; j<=50; j++)
         {
            eval("menu.document.all.cell_" + j + ".style.background=\"white\"");
         }
      }
   }
   else
   {
      i--;
      if ( i < 1 )
      {
         i = 1;
         goForward = true;
         for (var j=1; j<=50; j++)
         {
            eval("menu.document.all.cell_" + j + ".style.background=\"white\"");
         }
      }

   }
   eval("menu.document.all.cell_" + i + ".style.background=\"#cccc99\"");
}
/********************v 030000 v********************/
function enlarge(defWidth, defHeight, largeImage)
{
   imagePath = largeImage;
   maxWidth  = defWidth;
   maxHeight = defHeight;
   img.src   = largeImage;

   if ( !( (navigator.userAgent.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1) ) )
   {
      imageWidth = setInterval("setWidth();", 100);
      stopWidth  = setTimeout("clearInterval(imageWidth); clearTimeout(stopWidth); ", 1000);
   }
   else
      openImage();
}

function setWidth()
{
   if ( img.width != 0 )
   {
      clearInterval(imageWidth);
      clearTimeout(stopWidth);
      openImage();
   }

   if ( (navigator.userAgent.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1))
      openImage();
}

function openImage()
{
   if ( imagePath != "" )
   {
      if ( (navigator.userAgent.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1))
         var large = window.open("", "Enlarge", "width=" + maxWidth + ",height=" + maxHeight + ",resizable=yes");
      else
         var large = window.open("", "Enlarge", "width=" + img.width + ",height=" + img.height + ",resizable=yes");

      if ( large != null )
      {
         large.document.open();
         large.document.writeln('<html>');
         large.document.writeln('<head>');
         large.document.writeln('<title>Enlarged View</title>');
         large.document.writeln('</head>');
         large.document.writeln('<BODY bgcolor="#FFFFFF" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" bottommargin="0">');
         large.document.write('<img src="" name="largepic" border="0"');

         if ( img.width != 0 && img.width != 1 && img.width != null ) /* 030100 */
            large.document.write(' width="' + img.width + '"');

         if ( img.height != 0 && img.height != 1 && img.height != null) /* 030100 */
            large.document.write(' height="' + img.height + '"');

         large.document.write('>');
         large.document.writeln('</body>');
         large.document.writeln('</html>');
         large.document.close();
         large.document.largepic.src = imagePath;
         large.focus();
      }
   }
}
/********************^ 030000 ^********************/
/** APY 4/23/07 - update header shopping bag **/
function set_cart_qty(vNumItems) {
  var strQyt;
  strQyt = vNumItems;
  if(vNumItems == 1) {
    strQyt = strQyt + " item";
  } else {
    strQyt = strQyt + " items";
  }
  if (document.getElementById("cartItems"))                        /* 070010 */
  {
    document.getElementById("cartItems").innerHTML = strQyt;       /* 070010 */
  }
}
/** end APY **/

/********************v JJS v********************/
function ltrim (s) {
  return s.replace( /^\s*/, "" );
}

function rtrim (s) {
   return s.replace( /\s*$/, "" );
}

function trim(s) {
   var temp = s;
   return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}

function echeck(str) {
  var emailRegxp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(str.match(emailRegxp)){
  return true;
}else{
  return false;
}
}

function isNumeric(inNum) {
//CHECK FOR NUMBERS
//ALLOWS -s
var x=inNum
var anum=/(\-)|(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true;
else{
testresult=false;
}
return (testresult);
}
/********************^ JJS ^********************/
/******v APY 01/03/08 v*****/
function getCurrency(vAmt,vCurrency)
{
  var vSymbol = "";
  var vReturnAmt = vAmt.toFixed(2);
  var vReturn = "";

  switch(vCurrency)
  {
    case "CAD":
       vSymbol = "$";
       break;
    case "CA":
       vSymbol = "$";
       break;
    case "USD":
       vSymbol = "$";
       break;
    case "US":
       vSymbol = "$";
       break;
    case "USD":
       vSymbol = "$";
       break;
    case "EUR":
       vSymbol = "&euro;";
       break;
    case "GBP":
       vSymbol = "&pound;";
       break;
  }
  if(vSymbol == "")
    vReturn = vReturnAmt + " " + vCurrency.toUpperCase();
  else
    vReturn = vSymbol + vReturnAmt;
   return vReturn;
}
/******^ APY 01/03/08 ^*****/

/* vv 050000 jb vv */
function isDate(dateStr) {

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
alert("Please enter date as either mm/dd/yyyy or use the calendar.");
return false;
}

month = matchArray[1]; // p@rse date into variables
day = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn`t have 31 days!")
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}
/* ^^ 050000 ^^ */

function findPosX(obj)
 {
  var curleft = 0;
  if(obj.offsetParent)
  while(1)
  {
   curleft += obj.offsetLeft;
  if(!obj.offsetParent)
    break;
  obj = obj.offsetParent;
  }
 else if(obj.x)
  curleft += obj.x;
return curleft;
}

function findPosY(obj)
{
 var curtop = 0;
 if(obj.offsetParent)
 while(1)
 {
  curtop += obj.offsetTop;
  if(!obj.offsetParent)
    break;
  obj = obj.offsetParent;
  }
  else if(obj.y)
    curtop += obj.y;
  return curtop;
}

function checkBlank(vField)
{
     vField.value = rtrim(vField.value);
     vField.value = ltrim(vField.value);
 if (vField.value.length <= 0) return true;
 else return false;
}
/***vv 070000 vv***/
function setColorCookie(vStyleCode,vColorCode){
   setCookie("prodColor",vStyleCode + "," + vColorCode,null,"/",null,null);   /* 070010 */
}
/***^^ 070000 ^^***/
 addToCart = function(vProduct,vColor,vSize,vQty,vType)
{
 document.location.href=siteContent.appPath+"/site.w?sponsor="+siteContent.fdmSponsor+"&frames=no&target=main&location=b2c/product.w&addtocart=yes&product=" + vProduct + "&color" + vProduct + "=" + vColor + "&size" + vProduct + "=" + vSize + "&qty=" + vQty + "&price=" + vSelectedPrice+"&type="+vType;
}

 validateSearchString = function()
{
   var flgStringValid = true;
   var strSearchString = new String(document.wordsearch.textsearch.value);
   if(strSearchString=="")
   {
      alert("Please enter a word or phrase to search for.");
      document.wordsearch.textsearch.focus();
      return false;
   }
   var index;
   var strErrorMsg, strErrorMsgInvalidChars;
   var strArrayOfInvalidChars =
    new Array("\?","&","\/","\\","\@","\(","\)","$","%","!","#");  /* B010201 */
   index = 0;
   while (flgStringValid == true && index < strArrayOfInvalidChars.length)
   {
      if (strSearchString.indexOf(strArrayOfInvalidChars[index]) != -1)
      {
         strErrorMsg = "Were sorry, your search phrase cannot contain the following characters: ";
         strErrorMsgInvalidChars = "";
         for (index = 0; index < strArrayOfInvalidChars.length; index++)
         {
            strErrorMsgInvalidChars = strErrorMsgInvalidChars + "'" + strArrayOfInvalidChars[index] + "'";
            if (index + 1 < strArrayOfInvalidChars.length)
            {
               strErrorMsgInvalidChars = strErrorMsgInvalidChars + ", ";
            }
         }
         alert(strErrorMsg + strErrorMsgInvalidChars);
         flgStringValid = false;
      }
      index++;
   }
   return flgStringValid;
}

 goSearch = function()
{
  if(validateSearchString())
 {
   goReplace(siteContent.appPath + '/olc/word-search.w?search=yes&textsearch=' + document.wordsearch.textsearch.value,'main');  /* 070002 */
  }
  return false;
 }
 vOnLoad = "" ;
 keepDisabled="^";
 enableElements = function(){
   document.getElementById('overlay').style.display = "none";
   document.getElementById('overlay').style.visibility = "hidden";
     for(f=0;f<document.forms.length;f++){
      for(i=0;i<document.forms[f].elements.length;i++){
      if (keepDisabled.indexOf("^"+document.forms[f].name+document.forms[f].elements[i].name+"^") == -1)
   {document.forms[f].elements[i].disabled=false;}
      if (navigator.appName=="Microsoft Internet Explorer" && parseFloat(navigator.appVersion)<=4 && navigator.appVersion.indexOf("MSIE 6") != -1 && (document.forms[f].elements[i].type=="select-one" || document.forms[f].elements[i].type=="select-multiple" || document.forms[f].elements[i].type=="select"))
      {
       document.forms[f].elements[i].style.visibility = "visible";
      }
  }
  }
 }
 hideProcessing = function()
{
   var processDiv = document.getElementById('siteProcess');
   if (!processDiv) return;                                        /* 070005 */
   processDiv.className = "siteProcessNone";
  for(f=0;f<document.forms.length;f++){
   for(i=0;i<document.forms[f].elements.length;i++){
     if (navigator.appName=="Microsoft Internet Explorer" && parseFloat(navigator.appVersion)<=4 && navigator.appVersion.indexOf("MSIE 6") != -1 && (document.forms[f].elements[i].type=="select-one" || document.forms[f].elements[i].type=="select-multiple" || document.forms[f].elements[i].type=="select"))
     {
      document.forms[f].elements[i].style.visibility = "visible";
     }
   }
  }
 }
 showLoginPopup = function()
{
 disableElements("loginPopup");
 if (document.getElementById("loginMsg").offsetWidth > document.getElementById("loginPopup").offsetWidth)
 {
   document.getElementById("loginPopup").style.width  = document.getElementById("loginMsg").offsetWidth  + 50 + "px";
   document.getElementById("loginPopup").style.height = document.getElementById("loginMsg").offsetHeight + 50 + "px";
 }
 else
 {
   document.getElementById("loginPopup").style.width  = document.getElementById("loginMsg").offsetWidth  + 40 + "px";
   document.getElementById("loginPopup").style.height = document.getElementById("loginMsg").offsetHeight + 40 + "px";
 }
 vOnLoad = "moveDialog('loginPopup')";
 moveDialog('loginPopup');
 window.onscroll = function() {eval(vOnLoad);};
}

 hideLoginPopup = function()
{
   document.getElementById("loginPopup").style.display = "none";
   window.onscroll = "";
   document.getElementById('overlay').style.display = "none";
   document.getElementById('overlay').style.visibility = "hidden";
   enableElements();
}

/* vv Old CartHover.js vv */
/******vv 070006 vv******/
var vParams2 = "?frames=no&target=main&sponsor="+fdmSponsor;
var xmlUrl = appPath + "/xml/cartRequest.w" + vParams2; /* 010005 */
var mycart=null;                                                  /* B010100 */
if (siteContent.floatCartMode=="detailed") myCart = new CartDetailed("0"); /* B010100 */
else myCart = new Cart("0");                                      /* B010100 */
var CartShown = false;
var cartTimer, addedTimer;
var vAddedDispTime = 4000;
var boundFloatingAdd = false;
var orderType = "";  /* 010000 */
var vLeft=0;
var vTop=0;
/***vv 010000 vv***/
var vStartLoad = false;
var currTime = new Date();
var currSecs  = (((currTime.getHours() * 60) + currTime.getMinutes()) * 60) + currTime.getSeconds();
var nocache = "&nocache=" + currSecs;
var vProductMode="";
var vCartLabel="";
var vCartMsgSelector=""; /* 010002 */
var vTopScroll=false;    /* 010002 */
/* 070008 - removed nocache var */
/***^^ 010000 ^^***/

function CartLine(style, styleVal, color, colorVal, size, sizeVal, price, qty, tot, image, rowid,available) /* B010000 */ /* B010100 */
{
 this.Style = style;
 this.StyleVal = styleVal;
 this.Color = color;
 this.ColorVal = colorVal;
 this.Size = size;
 this.SizeVal = sizeVal;
 this.Price = price;
 this.Quantity = qty;
 this.LineTotal = tot;
 this.ImagePath = image;                                          /* B010000 */
 this.rowid = rowid;                                              /* B010100 */
 this.available = available;                                      /* B010100 */
}
function AddedItem(style, styleVal, color, size, qty, image,price,rowid,available) /* B010000 */ /* B010100 */
{
 this.Style = style;
 this.StyleVal = styleVal;
 this.Color = color;
 this.Size = size;
 this.Quantity = qty;
 this.ImagePath = image;
 this.Price = price;                                              /* B010000 */
 this.rowid = rowid;                                              /* B010100 */
 this.available = available;                                      /* B010100 */
}

function Cart(subtotal)
{
 if (subtotal.length < 1)
  subtotal = 0.00;

 this.SubTotal  = subtotal;
 this.CartLines  = new Array();
 this.JustAdded  = new Array();
 this.HiddenPages = new Array();
 this.IsLoading  = false;
 /******v 010000 v******/
 if (orderType == "Q")
    this.LoadingMessage = "Loading Wishlist...";
 else
    this.LoadingMessage = "Loading " + vCartLabel + "...";  /* 010000 */
 /******^ 010000 ^******/
 this.ToHtmlStub  = function()
 {
  var ret = '<img src="'+imgPath+'/1by1pix.gif" border="0" id="floatPosition"><a class="bannerLink"  href="#" onclick="'; /* B010000 */
  if (this.CartLines.length < 1)
      ret += "golink('b2c/retail-shop-list.w','main');\">" + vCartLabel;  /* 010000 */ /* B010000 */
  else
  {
   ret += "displayCart();\">" + vCartLabel;  /* 010000 */ /* B010000 */
   var itemTotal = 0;
   for (var i=0; i<this.CartLines.length; i++)
   {
    var tItem = this.CartLines[i];
    if (isNaN(tItem.Quantity))
     itemTotal += 1;
    else
     itemTotal += parseInt(tItem.Quantity);
   }

   if(itemTotal < 10)
    ret += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='headerCont'><div class='headerQty'>&nbsp;&nbsp;" + itemTotal + "&nbsp;</div><div class='shoppingCartCircleSmall'></div></span>"; // TV B010001
   else
    ret += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='headerCont'><div class='headerQty'>&nbsp;&nbsp;" + itemTotal + "&nbsp;</div><div class='shoppingCartCircleLarge'></div></span>"; // TV B010001
  }
  ret += '</a>';
  return ret;
 }
 this.ToHtml  = function()
 {
  if (this.CartLines.length < 1)
  {
   return "<table class=\"cartTable\"><tbody>" +
       "<td class=\"cartCell\">No Items.</td>" +  /* B010000 */
       "</tr></table>";
  }

  var msg = "<i class=\"notch\"></i><i class=\"border-notch notch\"></i><table class=\"cartTable\"><tbody><tr class=\"cartHeader\"><th colspan=\"2\" class=\"cartTitle\"><b>ADDED</b> TO SHOPPING BAG</th></tr>";
  var itemTotal = 0;
  for (var i=0; i<this.CartLines.length; i++)
  {
   var tItem = this.CartLines[i];
   msg += "<tr><td class=\"cartCellImage\">" + tItem.ImagePath + "</td><td class=\"cartCell\">" +  /* B010000 */
       "<a href=\"javascript:golink('b2c/product.w?product=" + tItem.StyleVal + "','main');\">" + tItem.Style + ", " + tItem.Size + ", " + tItem.Color + "</a><div class=\"cartStubPrice\">" +tItem.Price+"</div></td></tr>"; /* B010000 */

   if (isNaN(tItem.Quantity))
    itemTotal += 1;
   else
    itemTotal += parseInt(tItem.Quantity);
  }
  msg += "<tr class=\"cartFooter\"><td colspan=\"2\"><img src=\"" + imgPath + "/checkout/shoppingBag.jpg\" /><a href=\"#\" onclick=\"golink('b2c/retail-shop-list.w','main');\">view bag</a></tbody></table>\n"; /* B010000 */
  return msg;
 }
 this.ErrorMessage = function (msg)
 {
  return "<table class=\"cartTable\"><tbody><tr>" +
      "<td class=\"cartCell\">" + msg + "</td>" + /* B010000 */
      "</tr></table>";
 }
 this.JustAddedHtml = function ()
 {
  // This shouldnt ever really be called when there are no items, however on the off chance it was...
  if (this.JustAdded.length < 1)
  {
   return "<table class=\"cartTable\"><tbody><tr>" +
       "<td class=\"cartCell\">No items were recently added.</td>" + /* B010000 */
       "</tr></table>";
  }

  var msg = "<i class=\"notch\"></i><i class=\"border-notch notch\"></i><table class=\"cartTable\"><tbody><tr class=\"cartHeader\"><th colspan=\"2\" class=\"cartTitle\"><b>JUST ADDED</b> TO SHOPPING BAG</th></tr>";
  for (var i = 0; i<this.JustAdded.length; i++)
  {
   var tItem = this.JustAdded[i];
   msg += "<tr><td class=\"cartCellImage\">" + tItem.ImagePath + "</td><td class=\"cartCell\">" +  /* B010000 */
       "<a href=\"javascript:golink('b2c/product.w?product=" + tItem.StyleVal + "','main');\">" + tItem.Style + ", " + tItem.Size + ", " + tItem.Color + "</a><div class=\"cartStubPrice\">" +tItem.Price+"</div></td></tr>"; /* B010000 */

  }
  msg += "<tr class=\"cartFooter\"><td colspan=\"2\"><img src=\"" + imgPath + "/checkout/shoppingBag.jpg\" /><a href=\"#\" onclick=\"golink('b2c/retail-shop-list.w','main');\">view bag</a></tbody></table>\n"; /* B010000 */
  return msg;
 }
 this.IsHiddenHere = function (page)
 {
  // Loop through HiddenPages array and search the page string for it.
  if (this.HiddenPages.length < 1)
   return false;

  if (page == null)
   page = document.location.href;

  for (var i = 0; i<this.HiddenPages.length; i++)
  {
   var tPage = this.HiddenPages[i];
   // If we find it, return true (that its hidden)
   if (page.toUpperCase().indexOf(tPage.toUpperCase()) >= 0)
    return true;
  }
  return false;
 }
} // Cart()

/******v B010100 v******/

function CartDetailed(subtotal)
{
 if (subtotal.length < 1)
  subtotal = 0.00;

 this.SubTotal  = subtotal;
 this.CartLines  = new Array();
 this.JustAdded  = new Array();
 this.HiddenPages = new Array();
 this.IsLoading  = false;

 if (orderType == "Q")
    this.LoadingMessage = "Loading Wishlist...";
 else
    this.LoadingMessage = "Loading " + vCartLabel + "...";

 this.ToHtmlStub  = function()
 {
  var ret = '<img src="'+imgPath+'/1by1pix.gif" border="0" id="floatPosition"><a class="bannerLink" id="cartDesc" href="#" onclick="'; /* B010200 */
  if (this.CartLines.length < 1)
      ret += "golink('b2c/retail-shop-list.w','main'); return false; \">" + vCartLabel;
  else
  {
   ret += "displayCart(); return false; \">" + vCartLabel;
   var itemTotal = 0;
   for (var i=0; i<this.CartLines.length; i++)
   {
    var tItem = this.CartLines[i];
    if (isNaN(tItem.Quantity))
     itemTotal += 1;
    else
     itemTotal += parseInt(tItem.Quantity);
   }

   ret += ' (' + itemTotal + ')';                                  /* B010200 */

  }
  ret += '</a>';
  return ret;
 }

 /********************v B010200 v********************/
 if (typeof ToHtmlCustomDisplay == "function")
 {
  this.ToHtml = function(){ return ToHtmlCustomDisplay(this.CartLines,this.SubTotal); };
 }
 /********************^ B010200 ^********************/
 else                                                              /* B010200 */
 {
  this.ToHtml  = function()
  {
   if (this.CartLines.length < 1)
   {
    return "<table class=\"cartTable\"><tbody>" +
        "<td class=\"cartCell\">No Items.</td>" +
        "</tr></table>";
   }

   var msg = '<table class="cartTable"><tbody><tr class="cartHeader"><th colspan="2"><a href="javascript:void(0);" onclick="hideCart();">&times;</a></th></tr>';
   var itemTotal = 0;
   for (var i=0; i<this.CartLines.length; i++)
   {
    var tItem = this.CartLines[i];
    msg += cartLineHtml(tItem);
    if (isNaN(tItem.Quantity))
     itemTotal += 1;
    else
     itemTotal += parseInt(tItem.Quantity);
   }

   msg += '</tbody><tfoot><tr class="cartFooter"><td colspan="2"><span class="subtotal">subtotal: $'+subtotal+'</span><div class="footLinks"><a href="#" class="viewBag" onclick="golink(\'b2c/retail-shop-list.w\',\'main\');\">view bag</a><a class="checkoutLink" href="#" onclick="golink(\'b2c/retail-login.w?elocation=b2c/retail-checkout.w\',\'main\');\">checkout</a></div></tfoot></table>\n';

   return msg;

  } // this.ToHtml
 } // else --> not custom ToHtml

 this.ErrorMessage = function (msg)
 {
  return "<table class=\"cartTable\"><tbody><tr>" +
      "<td class=\"cartCell\">" + msg + "</td>" + /* B010000 */
      "</tr></table>";
 }

 /********************v B010200 v********************/
 if (typeof JustAddedHtmlCustomDisplay == "function")
 {
  this.JustAddedHtml = function(){ return JustAddedHtmlCustomDisplay(this.JustAdded,this.SubTotal); };
 }
 /********************^ B010200 ^********************/
 else                                                              /* B010200 */
 {
  this.JustAddedHtml = function ()
  {
   // This shouldnt ever really be called when there are no items, however on the off chance it was...
   if (this.JustAdded.length < 1)
   {
    return "<table class=\"cartTable\"><tbody><tr>" +
        "<td class=\"cartCell\">No items were recently added.</td>" + /* B010000 */
        "</tr></table>";
   }

   var msg = '<table class="cartTable"><tbody><tr class="cartHeader"><th colspan="2"><div class="justAdded">JUST ADDED TO SHOPPING BAG</div><div class="closeCart"><a href="javascript:void(0);" onclick="hideCart();">&times;</a></div></th></tr>';
   for (var i = 0; i<this.JustAdded.length; i++) {
    var tItem = this.JustAdded[i];
    msg += cartLineHtml(tItem);
   }
   msg += '</tbody><tfoot><tr class="cartFooter"><td colspan="2"><span class="subtotal">subtotal: $'+subtotal+'</span><div class="footLinks"><a href="#" class="viewBag" onclick="golink(\'b2c/retail-shop-list.w\',\'main\');\">view bag</a><a class="checkoutLink" href="#" onclick="golink(\'b2c/retail-login.w?elocation=b2c/retail-checkout.w\',\'main\');\">checkout</a></div></tfoot></table>\n';
   return msg;
  }
 } // else --> not custom JustAdded

 this.IsHiddenHere = function (page)
 {
  // Loop through HiddenPages array and search the page string for it.
  if (this.HiddenPages.length < 1)
   return false;

  if (page == null)
   page = document.location.href;

  for (var i = 0; i<this.HiddenPages.length; i++)
  {
   var tPage = this.HiddenPages[i];
   // If we find it, return true (that its hidden)
   if (page.toUpperCase().indexOf(tPage.toUpperCase()) >= 0)
    return true;
  }
  return false;
 }
} // CartDetailed()

function cartLineHtml(tItem) {                                    /* B010101 */

  var html = '';

  /********************v B010200 v********************/

  if (typeof cartLineHtmlCustomDisplay == "function")
   html = cartLineHtmlCustomDisplay(tItem);
  else
   html = '<tr><td class="cartCellImage"><a href="javascript:void(0);" onclick="golink(\'b2c/product.w?product=' + tItem.StyleVal + '\',\'main\');\">'+tItem.ImagePath+'</a></td><td class="cartCell">' +
          '<div class="cartProdLink" style="cursor:pointer;" onclick="golink(\'b2c/product.w?product=' + tItem.StyleVal + '\',\'main\');\"><div class="cartStyleDesc">'+tItem.Style+'</div><div class="colorDesc">Color: '+tItem.Color+'</div><div class="sizeDesc">Size: '+tItem.Size+'</div></div>' + /* B010101 */
          '<div class="cartStubPrice">'+tItem.Price+'</div>'+             /* B010101 */
          '<div class="cartChange"><a href="javascript:void(0);" onclick="golink(\'b2c/retail-shop-list.w\',\'main\');\">Change</a></div>'+
          '<div class="cartRemove"><a href="javascript:void(0);" onclick="removeItem(\''+tItem.rowid+'\');">Remove</a></div>'+
          '</td></tr>';

  /********************^ B010200 ^********************/

  return html;

} // cartLineHtml

function removeItem(rowid) {
  if (confirm("Are you sure you want to remove this from your shopping bag?")) {
    golink('b2c/retail-shop-list.w?mode=delete&id='+rowid,'main');
  }
}

/******^ B010100 ^******/

/* Events */
function cartInitialize()
{
 if(vStartLoad==false)
 loadMyCart();
}

/* Methods */
function loadMyCart(mode,style,color,size,qty,vOrderType) /* 010000 */
{
 myCart.IsLoading = true;
 vStartLoad = true;
 orderType = vOrderType;                                  /* 010000 */
 var realUrl = xmlUrl;

 if (mode == "add") // Add something to cart mode.
 {
  realUrl +=  "&cartMode=add&product=" + style;
  if(color!=null) realUrl += "&color=" + color;
  if(size!=null) realUrl += "&size=" + size;
  realUrl+="&qty=" + qty + "&ordertype=" + vOrderType; /* 010000 */
 }

 $.ajax({
   type: "GET",
   url: realUrl+getNoCacheParam(),                                 /* 070008 */
   dataType: "xml",
   complete: function(data) {
       myCart.IsLoading = false;

       //XML Error Checking
       if (data.responseXML == null) return;
       var cart = data.responseXML.documentElement;
       if (! cart) return; // we got an invalid value back
       vError = cart.attributes.getNamedItem("error").value;
       if(vError.length>0) { alert(vError); return;}
       /******v B010100 v******/
       if (siteContent.floatCartMode=="detailed")
         myCart = new CartDetailed(cart.attributes.getNamedItem("total").value);
       else
         myCart = new Cart(cart.attributes.getNamedItem("total").value);
       /******^ B010100 ^******/
       vProductMode = cart.attributes.getNamedItem("productMode").value.toUpperCase(); /* B010005 */
       vCartLabel = cart.attributes.getNamedItem("cartLabel").value;

       //Set Pages that should not display cartHover
       var hiddenPages = cart.attributes.getNamedItem("hideOnPages");
       if (hiddenPages != null){
        var tArr = hiddenPages.value.split(",");
        for (var i = 0; i< tArr.length; i++){
         myCart.HiddenPages.push(tArr[i]);
        }
       }

       hideCartNow();
       clearTimeout(cartTimer);
       clearTimeout(addedTimer);

       /********************v B010200 v********************/

       if (typeof loadMyCartCustomDisplay == "function")
       {
        loadMyCartCustomDisplay(cart);
        return;
       }

       /********************^ B010200 ^********************/

       /* <cartLine> */
       var cartLines = cart.getElementsByTagName("cartLine");

       for (var i = 0; i<cartLines.length; i++)
       {
        var line = cartLines[i];

        /* <style /> Style */
        var styleEle = line.getElementsByTagName("style")[0];
        var style = styleEle.attributes.getNamedItem("desc").value;
        if(vProductMode=="S"&&styleEle.childNodes[0]!=null)  /* 010000 */
        {
         var styleVal = styleEle.childNodes[0].nodeValue;
         /* <color /> Color */
         var colorEle = line.getElementsByTagName("color")[0];
         var color = colorEle.attributes.getNamedItem("desc").value;
         var colorVal=null;
         var sizeVal=null;
         var size="";
         if(colorEle.childNodes[0]!=null) colorVal=colorEle.childNodes[0].nodeValue;
        /* <size /> Size */
         var sizeEle = line.getElementsByTagName("size")[0];
         if(sizeEle.attributes.getNamedItem("desc")!=null) size = sizeEle.attributes.getNamedItem("desc").value;
         if(sizeEle.childNodes[0]!=null) sizeVal = sizeEle.childNodes[0].nodeValue;
        }
        else if (styleEle.childNodes[0]!=null) {   // 010004
          var styleVal = styleEle.childNodes[0].nodeValue; // 010004
        }
        /* <price /> Item Price */
        var price = line.getElementsByTagName("price")[0].childNodes[0].nodeValue;
        /* <qty /> Quantity */
        var quantity = line.getElementsByTagName("qty")[0].childNodes[0].nodeValue;
        /* <total /> Line Total */
        var lineTotal = line.attributes.getNamedItem("total").value;

        var image = line.getElementsByTagName("image")[0].childNodes[0].nodeValue;  /* B010000 */

        var rowid = line.getElementsByTagName("rowid")[0].childNodes[0].nodeValue;  /* B010100 */
        var available = parseInt(line.getElementsByTagName("available")[0].childNodes[0].nodeValue); /* B010100 */

        myCart.CartLines.push(new CartLine(style, styleVal, color, colorVal, size, sizeVal, price, quantity, lineTotal, image, rowid,available)); /* B010000 */ /* B010100 */
       }
       /* </cartLine> */
       if (orderType != "Q")                                   /* 010000 */
         $("#shopStub").html(myCart.ToHtmlStub());                /* B010000 */

       /* <added> */
       var added = cart.getElementsByTagName("added");
       myCart.JustAdded = new Array();
       if (added.length > 0)
       {
        for (var i = 0; i<added.length; i++)
        {
         var addItem = added[i];
         /* <style /> Style */
         var styleEle = addItem.getElementsByTagName("style")[0];
         var style = styleEle.attributes.getNamedItem("desc").value;

         if(vProductMode=="S"&&styleEle.childNodes[0]!=null)  /* 010000 */
         {
           var styleVal = styleEle.childNodes[0].nodeValue;
           /* <color /> Color -- Unused atm. */
           var colorEle = line.getElementsByTagName("color")[0]; /* B010006 */
           var color = colorEle.attributes.getNamedItem("desc").value; /* B010006 */
           /* <size /> Size */
           if(sizeEle.attributes.getNamedItem("desc")!=null) size = sizeEle.attributes.getNamedItem("desc").value; /* B010100 */
         }
         else if (styleEle.childNodes[0]!=null) {   // 010004
           var styleVal = styleEle.childNodes[0].nodeValue; // 010004
         }
         /* <qty /> Quantity */
         var qty = addItem.getElementsByTagName("qty")[0].childNodes[0].nodeValue;
         var price = addItem.getElementsByTagName("price")[0].childNodes[0].nodeValue;
         /* <image /> Image */
         var imageEle = addItem.getElementsByTagName("image")[0];
         var image = null;
         if (imageEle.childNodes.length > 0)
          image = imageEle.childNodes[0].nodeValue;

         var rowid = addItem.getElementsByTagName("rowid")[0].childNodes[0].nodeValue;    /* B010100 */
         var available = parseInt(addItem.getElementsByTagName("available")[0].childNodes[0].nodeValue);   /* B010100 */

         myCart.JustAdded.push(new AddedItem(style, styleVal, color, size, qty, image,price,rowid,available)); /* B010000 */ /* B010100 */
        }
        // Show the cart display with a message in it.
        displayAddedToCart(myCart.JustAddedHtml());
       }
       /* </added> */

       /***vv 010002 vv***/
       //scroll to top is set
       if (vTopScroll&&$(document).scrollTop() > $("#shopStub").offset().top)
       { $(document).scrollTop($("#shopStub").offset().top); }
       // Show msg in selector element if set
       if (vCartMsgSelector != "")
       { $(vCartMsgSelector).html(qty + " " + style + " added to shopping cart."); }
       /***^^ 010002 ^^***/

   }
 });
}
function floatingAddToCart(style,color,size,qty,vOrderType,vJQSelector) /* 010000 */ /* 010002 */
{
 /******vv 010002 vv******/
 if(vJQSelector){
   $(vCartMsgSelector).html();
   vCartMsgSelector = vJQSelector;
 }
 /******^^ 010002 ^^******/
 loadMyCart("add",style,color,size,qty,vOrderType); /* 010000 */
}
function updateShopStub(){
 // Update the non-cart values now that the cart is built.
 if (myCart.IsLoading)
   $("#shopStub").html(myCart.LoadingMessage);                    /* B010000 */
 else
   $("#floatingCart").html(myCart.ToHtml());                      /* B010000 */
}

function displayAddedToCart(val){
  clearTimeout(addedTimer);
  var $floatingAdded = $("#floatingAddedToCart");
  if ($floatingAdded.length){
     if(boundFloatingAdd==false){
       if ($floatingAdded.mouseenter != undefined) { /* 070009 */
       $floatingAdded.mouseenter(function(){
           clearTimeout(addedTimer);
       });
       } /* 070009 */
       if ($floatingAdded.mouseleave != undefined) { /* 070009 */
        $floatingAdded.mouseleave(function(){
          addedTimer = setTimeout(function() {  $("#floatingAddedToCart").hide(); }, vAddedDispTime);
       });
       } /* 070009 */
       boundFloatingAdd = true;
     }
    //$floatingAdded.html(val).show();
    displayCart(val);

    addedTimer = setTimeout(function() {  $("#floatingAddedToCart").hide(); }, vAddedDispTime);

  }else{
   displayCart(val);
  }

}
function displayCart(val){

 //Return if empty or in hidden list
 if (myCart.IsHiddenHere() || myCart.CartLines.length < 1) return;
 //Clear hide delay timer
 clearTimeout(cartTimer);

 if (! CartShown && myCart.IsLoading == false)
 {
  if (val == null) val = myCart.ToHtml();

  var $floatingCart = $("#floatingCart");
  var $vFloat=$("#floatPosition");
  var $shopStub = $("#shopStub");

  $floatingCart.html(val);

  vFloatPos=$shopStub.position();

  if (siteContent.floatCartMode=="detailed") vFloatPos.top += $shopStub.outerHeight() + 5; /* B010100 */
  else vFloatPos.top += $shopStub.outerHeight() + 25; /* B010100 */

  if (siteContent.floatCartMode=="detailed") vFloatPos.left += $vFloat.outerWidth() + 81; /* 81B010100 */
  else vFloatPos.left += $shopStub.outerWidth() + 115; /* B010100 */

  //Display offscreen to get width/height
  $floatingCart.css("left","-99999px")
               .css("top","-99999px")
               .show(); /* B010000 */                              /* B010102 */
  vFloatPos.left -= $floatingCart.outerWidth();
  $floatingCart.css("top",vFloatPos.top)
               .css("left",vFloatPos.left);

  CartShown = true;
 }
}

//Hide Cart Functions, 1/4 second delay
function hideCart(){
 cartTimer = setTimeout(function() { hideCartNow() }, 250);
}
function hideCartNow(){
 if (CartShown){
  $("#floatingCart").hide();
  CartShown = false;
 }
}

function setTopScroll(vSetting){
 if (vSetting==false||vSetting==true)
   vTopScroll = vSetting;
} /* 010002 */
/******^^ 070006 ^^******/
$(document).ready(function() {
  if(document.getElementById("shopStub")!=null)
     addToCart=floatingAddToCart;
});

/* 070004 - moved ajax functions */

 hideProcessing();

/******v 070002 v******/

function clearField(vField,vText) {
  if (vText != "" && vField.value == vText)
     vField.value = "";
}

function setField(vField,vText) {
  if (vText != "" && vField.value == "")
     vField.value = vText;
}

/******^ 070002 ^******/
/******v 070003 v******/
function getHash(){
  var hashObj = new Array();
  var urlHash = window.location.hash;
  urlHash = urlHash.substring(1,urlHash.length)
  urlHash = urlHash.split("&");
  $(urlHash).each(function(i){
    var nameValue = this.split("=");
    if (nameValue.length == 2)
      hashObj[i] = {"name":nameValue[0],"value":nameValue[1]};
    if (nameValue.length == 1)
      hashObj[i] = {"name":nameValue[0]};
  });
  return hashObj;
}

function showMore(){
  $('#topCopyLower').slideDown();
  $('#topCopyShow').hide();
}
function hideMore(){
  $('#topCopyLower').slideUp();
  $('#topCopyShow').show();
}
/******^ 070003 ^******/
/******v 070004 v******/
function getParam(name) {
  var start=location.search.indexOf("?"+name+"=");
  if (start<0) start=location.search.indexOf("&"+name+"=");
  if (start<0) return '';
  start += name.length+2;
  var end=location.search.indexOf("&",start)-1;
  if (end<0) end=location.search.length;
  var result='';
  for(var i=start;i<=end;i++) {
    var c=location.search.charAt(i);
    result=result+(c=='+'?' ':c);
  }
  return unescape(result);
}

/******^ 070004 ^******/
/********************v 070008 v********************/
function getNoCacheParam() {
  var vCurrTime = new Date();
  var vCurrSecs  = (((vCurrTime.getHours() * 60) + vCurrTime.getMinutes()) * 60) + vCurrTime.getSeconds();
  var vNoCache = "&nocache=" + vCurrSecs;
  return vNoCache;
}
/********************^ 070008 ^********************/


/*********************************v B010001 v**********************************/
function ajaxError(request,url) {

var msg = "";

   // check if AJAX request failed and return error message
   switch(request.status) {
    case 200: msg = ""; break; // OK - Standard response for successful HTTP requests.
    case 401: msg = "Unauthorized. Authentication has failed or not yet been provided."; break;
    case 403: msg = "Forbidden. Server request denied."; break;
    case 404: msg = "Requested URL not found. <br />" + url; break;
    case 408: msg = "Request Timeout. Please try again."; break;
    case 500: msg = "Internal Server Error. Please contact customer service if this error persists."; break;
    case 503: msg = "Service Unavailable. The server is currently unavailable. Please try again later."; break;
    default:  msg = request.status + ": " + request.statusText + ". " +
           "Please contact customer service if this error persists." +
           "<br /><br /> Browser Information: " + navigator.userAgent; break; /* B010007 */
   } // AJAX error messages

return msg;

} // ajaxError

/*****************************************************************************/
/****** vvv B010300 vvv ******/
function emailSubscribe()
{
    var url = appPath + sitePath + "b2c/b2c-subscribe-ajax.w&subscribe=footer&target=main&frames=no&sponsor=" + fdmSponsor + getNoCacheParam();
    var params =  $("#emailSubscribe").serialize();
    var email  = $("#emailSubscribeEmail").val();

    if (!echeck(email))
    {
        $("#emailSubscribeEmail").validationEngine("showPrompt","Please enter a valid email.","","bottomLeft",true);
        return;
    }

    $.post(url + "&" + params, function(responseText, textStatus, XMLHttpRequest)
    {
        var $onlyThisDiv = $("#emailListSubmit", responseText);

        $("#emailSubscribeEmail").validationEngine("showPrompt",$onlyThisDiv,"","bottomLeft",true);
        $("#emailSubscribeContainer").hide();
    }).error(function(x,e)
    {
        error = ajaxError(x, url + "&" + params);
        if (error != "")
            $("#emailSubscribeEmail").validationEngine("showPrompt",error,"","bottomLeft",true);
    }); // $.post
} // emailSubscribe

$('.emailSubscribeEmailformError').live('click', function()
{
    // close error message when you click on it
    $(this).validationEngine('hidePrompt');
    return false;
});
/****** ^^^ B010300 ^^^ ******/
/*****************************************************************************/

function getEmailList() {
 // animated Loading... image
    var preload = '<img src="' + imgPath + '/loading.gif" alt="Loading..." />';

 var url = appPath + sitePath + "b2c/retail-subscription.w" + /* B010005 */
        "&target=main&frames=no&sponsor=" + fdmSponsor + getNoCacheParam();
 var modal = $("#modal_popup");

 if ($("#modal_popup").length == 0) {
   modal = $('<div id="modal_popup" style="display:hidden"></div>').appendTo('body');
    }

 // load external css and scripts
    $.rloader([ {type:'js',src:'/iairetail/jscript/retail-subscription.js'},
                {type:'css',src:'/iairetail/styles/validationEngine.jquery.css'},
                {type:'js',src:'/iairetail/jscript/jquery.validationEngine-en.js'},
          {type:'js',src:'/iairetail/jscript/jquery.validationEngine.js'} ]);

    // show loading animated gif
    modal.html(preload);

 // load remote content of div#emailListContent into div#modal_popup
 modal.load(url + " #emailListContent", function(responseText, textStatus, XMLHttpRequest) {

            // check if AJAX request failed and display to user
               error = ajaxError(XMLHttpRequest, url + " #emailListContent");
      if (error != "") modal.html(error);


     // jQuery UI Dialog widget
     modal.dialog({
      title: "Sign Up For Our Email Newsletter",
      width: 950,
      height: 650,
      modal: true,
         beforeclose: function() {
            if ( $('#retailSub').length > 0 ) { $('#retailSub').validationEngine('hide'); }
         $(this).dialog("destroy");
         }, /* B010003 */
      resizable: true,
                     draggable: false,
         zIndex: 4000
    }); // dialog function


 return false; // prevent browser from following link

 }); // modal.load


} // getEmailList

/*****************************************************************************/


function emailListRequest() {

 var url = appPath + sitePath + "b2c/retail-subscription.w" +  /* B010003 */ /* B010005 */
        "&target=main&frames=no&sponsor=" + fdmSponsor + getNoCacheParam();
 var modal = $("#modal_popup");
 var params =  $("#retailSub").serialize();

    /* B010002 - removed preload */

 $.post(url + "&" + params, function(responseText, textStatus, XMLHttpRequest) {

   var $onlyThisDiv = $("#emailListSubmit", responseText); /* B010003 */

   modal.html($onlyThisDiv);

 }).error(function(x,e) {
    error = ajaxError(x, url + "&" + params);
    if (error != "") modal.html(error);

 }); // $.post

} // registerRequestPopup


/*****************************************************************************/

function getLoginPopup() {
 // animated Loading... image
    var preload = '<img src="' + imgPath + '/loading.gif" alt="Loading..." />';

 var url = appPath + sitePath + "b2c/retail-login-popup.w" + /* B010005 */
        "&target=main&frames=no&sponsor=" + fdmSponsor + getNoCacheParam();
 var modal = $("#modal_popup");

 if ($("#modal_popup").length == 0) {
   modal = $('<div id="modal_popup" style="display:hidden"></div>').appendTo('body');
    }

 // load external css and scripts
    $.rloader([ {type:'js',src:'/iairetail/jscript/retail-login-popup.js'},
                {type:'css',src:'/iairetail/styles/validationEngine.jquery.css'},
                {type:'js',src:'/iairetail/jscript/jquery.validationEngine-en.js'},
          {type:'js',src:'/iairetail/jscript/jquery.validationEngine.js'} ]);

    // show loading animated gif
    modal.html(preload);

 // load remote content of div#loginContent into div#modal_popup
 modal.load(url + " #loginContent", function(responseText, textStatus, XMLHttpRequest) {

            // check if AJAX request failed and display to user
               error = ajaxError(XMLHttpRequest, url + " #loginContent");
      if (error != "") modal.html(error);

     // jQuery UI Dialog widget
     modal.dialog({
      title: "Sign In or Register An Account",
      width: 950,
      height: 600,
      modal: true,
         beforeclose: function() {
                                  $('#loginpopup').validationEngine('hide');
          $('#userprofile').validationEngine('hide');
          $(this).dialog("destroy"); }, /* B010002 */
      resizable: true,
                     draggable: false,
         zIndex: 4000
    }); // dialog function

 return false; // prevent browser from following link

 }); // modal.load


} // getLoginPopup

/*****************************************************************************/

/* B010002 - moved inside of retail-login-popup.js */

/*****************************************************************************/

$(document).ready(function() {
// this section manipulates the header links

  // user is logged in
 if (fdmLoggedIn != "" && fdmLoggedIn != ";") {
  $("#showlogin").hide();
  $("#showlogout").show();
 } else {
  // user is logged out
  $("#showlogin").show();
  $("#showlogout").hide();
 }

 $("#acctLink").click(function() {

  if (fdmLoggedIn != "" && fdmLoggedIn != ";")
   golink('b2c/retail-account.w','main');
  else
   getLoginPopup();

   return false;
 });

 }); /* document.ready */

/*********************************^ B010001 ^**********************************/


/*********************************v B010004 v**********************************/
$('img.press_img_magz').click( function() {
 var url   = $(this).attr('rel');
 var modal = $("#modal_popup");

 if ($("#modal_popup").length == 0) {
   modal = $('<div id="modal_popup" style="display:hidden"></div>').appendTo('body');
    }

    /* B010007 */


 // load external css or scripts
    $.rloader({type:'css',src:'/iairetail/styles/press.css'});

 // load press page into div#modal_popup
 modal.load(url, function(responseText, textStatus, XMLHttpRequest) {

            // check if AJAX request failed and display to user
               error = ajaxError(XMLHttpRequest, url);
      if (error != "") modal.html(error);

     // jQuery UI Dialog widget
     modal.dialog({
      title: "Press",
      width: 950,
      height: 600,
      modal: true,
         beforeclose: function() { $(this).dialog("destroy"); }, /* B010007 */
      resizable: true,
                     draggable: false,
         zIndex: 4000
    }); // dialog function

 return false; // prevent browser from following link

 }); // modal.load

}); // getPressPopup

/*********************************^ B010004 ^**********************************/

/****** vvv B010301 vvv ******/
function getHashObj()
{
    var hashObj = [];
    var urlHash = window.location.hash;
    if(urlHash=="")
        return hashObj;
    urlHash = urlHash.substring(1,urlHash.length).split("&");
    for(var i=0;i<urlHash.length;i++)
    {
        var nameValue = urlHash[i].split("=");
        if(nameValue.length == 2)
        {
            hashObj[ nameValue[0] ] = nameValue[1];
        }
        else if(nameValue.length == 1)
        {
            hashObj[ nameValue[0] ] = nameValue[0];
        }
    }
    return hashObj;
} // getHashObj()

function getHashParam(name)
{
    var paramObj = getHashObj();
    if(typeof paramObj[ name ] !== "undefined")
    {
        return unescape( paramObj[ name ] );
    } else {
        return false;
    }
} // getHashParam()
/****** ^^^ B010301 ^^^ ******/

