function popUpWin(thisUrl, thisName, theseParams) {
  remote = open(thisUrl, thisName, theseParams);
}
var remote = null;
function help(f, n, w, h, t) {
  remote = window.open("/helppopup.htm?tab=" + t + "&file=" + f, n, 'width=' + w + ',height=' + h + ',resizable=yes,scrollbars=yes,status=yes');
  if (window.focus) {
    remote.focus()
  }
  if (remote != null) {
    if (remote.opener == null) remote.opener = self;
    window.name = 'store';
  }
}
function change_parent(url) {
  parent.opener.location = url;
  parent.window.close();
}
function forgotPassword(thisUrl, thisName, theseParams) {
  remote = open(thisUrl, thisName, theseParams);
}


/* Free Shipping On Cart */
function showCartFreeShipping() {
  shipWin = open("","shipWin","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=350,height=400");
  strHTML  = "<div style='font-size:8pt'>";
  strHTML += document.getElementById('freeshippingtext').innerHTML;
  strHTML += "</div>";
  shipWin.document.write(strHTML);
}
/* End Free Shipping On Cart */

/* Print Friendly Invoice */
function spawnInvoice(bolPrint) {
  var strHTML  = '';
  var invoiceWin = open("#","invoiceWin","toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,resizable=no,width=800,height=600");

  strHTML += '<script language="JavaScript" src="/custom.js" type="text/javascript"></script>\n';
  strHTML += '<link rel="stylesheet" href="/custom.css" type="text/css">\n';
  strHTML += '<link rel="stylesheet" href="/custom.css" type="text/css">\n';

  strHTML += "<script language='javascript'>\n";
  strHTML += "function printMe() { window.print(); }\n";

  if (bolPrint) {
    strHTML += "window.onload = printMe;\n";
  }

  strHTML += "<\/script>\n";
  strHTML += "<body style='background-color:#FFFFFF;background-image: url();'>";
  strHTML += "<table border='0' width='100%'><tr><td><img src='images/fye-invoice-logo.gif' border='0' /></td></tr></table>";
  strHTML += document.getElementById('invoiceCapture').innerHTML;

  var strPrintUrl = "><a href='javascript:printMe()'>print</a>";

  invoiceWin.document.open();
  invoiceWin.document.write(strHTML.replace(/id="?remove"?(.*)\</g,">&nbsp;<").replace(/id="?swapprintlink"?(.*)span>/g,strPrintUrl));
  invoiceWin.document.write('</body>')
  invoiceWin.document.close();
  var strHTML  = '';
}
/* Print Friendly Invoice */

function showStatus(strMsg) {
  window.status = strMsg;
  return true;
}

/* FAST SERCH CODE */
function setSort(objOptionValue) {
  document.getElementById('pageSort').value = objOptionValue;
  document.fastSearchResultsForm.submit();
}

function filterKeyCodes(evt,flgModule) {
  // Check for the 'Enter Key'
  if (evt.keyCode == 13) {
    if (flgModule == 662) {
      setProfile();
    } else if (flgModule == 189) {
      populateLast();
    } else {
      return true;
    }
  }
}
/* / END FAST SEARCH CODE */

/* ZOOM CODE FOR PRODUCT DEATAIL IMAGE */
function zoomProduct() {
  var objImgDiv    = document.getElementById('imgResize');
  var intImgWidth  = objImgDiv.offsetWidth;
  var intImgHeight = objImgDiv.offsetHeight;
  var intWinW = (intImgWidth < 800) ? intImgWidth : 800;
  var intWinH = (intImgHeight < 600) ? intImgHeight : 600;

  objZoomWindow = window.open('','','toolbar=no,scrollbars=no,resizable=yes,width=' + (intWinW + 4) + ',height=' + (intWinH + 4) + ',top=40,left=20,screenX=20,screenY=40');

  objZoomWindow.document.open();
  objZoomWindow.document.write('<body style="margin:0 0 0 0">');
  objZoomWindow.document.write(objImgDiv.innerHTML);
  objZoomWindow.document.write('</body>');
  objZoomWindow.document.close();

}
/* / END ZOOM CODE FOR PRODUCT DEATAIL IMAGE */

/* SIDE SEARCH  */
flgLastValue = '';

function populateKeyWords(objCaller,evt) {
  var objID = objCaller.id;

  if (flgLastValue != '' && flgLastValue != objID) {
    eval("document.filters." + flgLastValue).value = arrFlags[flgLastValue];
  }

  flgLastValue = objID;

  if (arrFlags[objID]) {
    objCaller.value = objCaller.value.replace(arrFlags[objID], '');
  }

  // Called below as well
  populateLast();

  // Test for 'Enter' Key
  if (evt.keyCode == 13) {
    document.getElementById('viewfdsearch').submit();
  }
}

function populateLast() {
  document.getElementById('keywordTarget').value = eval("document.filters." + flgLastValue + ".value");

  if (flgLastValue == 'Music') {
    document.viewfdsearch.profile.value = 'Music';
    if (useAdvanceSearch == 'T') {
      document.viewfdsearch.searchBy.value = 'ProductName,Artist,GroupMember,|ProductNumber,|UPC';
    }
  }
  if (flgLastValue == 'Movies') {
    document.viewfdsearch.profile.value = 'Movies';
    if (useAdvanceSearch == 'T') {
      document.viewfdsearch.searchBy.value = '|ProductNumber,|UPC';
    }
  }
  if (flgLastValue == 'Games') {
    document.viewfdsearch.profile.value = 'Games';
    if (useAdvanceSearch == 'T') {
      document.viewfdsearch.searchBy.value = '|ProductNumber,|UPC'; 
    }
  }
}
/* / END SIDE SEARCH  */

function checkCompataibilty(url) {
  if (document.all) {
    return true;
  } else {
    if (document.cookie.match(/wmainstructions=read/)) {
      return true;
    } else {
      var objImgDiv    = document.getElementById('ffhelptxt');

      objZoomWindow = window.open('','','toolbar=no,scrollbars=no,resizable=yes,width=640,height=272,top=40,left=20,screenX=20,screenY=40');

      objZoomWindow.document.open();
      objZoomWindow.document.write('<link rel="stylesheet" href="/custom.css" type="text/css" />');
      objZoomWindow.document.write('<link rel="stylesheet" href="/custom.css" type="text/css" />');
      objZoomWindow.document.write('<body style="margin:0 0 0 0;color:#000000">');
      objZoomWindow.document.write(objImgDiv.innerHTML);
      objZoomWindow.document.write('</body>');
      objZoomWindow.document.close();

      return false;
    }
  }
}


// moved from platform
var windw = null;
function openWindow(winpage,winname,w,h,features) {
  var topOffset = 50;
  leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  topPosition = (screen.height) ? (screen.height-h)/2 : 0;
  topPosition = topPosition - topOffset;
  features = 'width='+w+',height='+h+',top='+topPosition+',left='+leftPosition+',' + features;
  windw = window.open(winpage,winname,features)
  if (windw.window.focus){
    windw.window.focus();
  }
}