//*****************************************************************************
//
// Additions to and over-rides of the Mullen javascript functions.
//
//****************************************************************************
var submitted = false;

function changeImage(which,whichImage){ 
    document.getElementById(which).src = whichImage;
}

function showCover() {
    var cvr = document.getElementById("cover");
    cvr.style.display = "block";
}

function formatMoney(amt) {
    var amtInPennies = parseInt((amt + 0.004) * 100.0);
    var pennies = amtInPennies % 100;
    var dollars = parseInt(amtInPennies / 100);
    if(pennies == 0) {
        pennies = "00";
    } else if(pennies < 10) {
        pennies = "0" + pennies;
    }
    return dollars + "." + pennies;
}


//
// No longer referenced, but it's available to return to exclusive filtering.
//
function changeSortFilter(select, nonPriceIds) {
    var ids = nonPriceIds.split(":");
    var selId = select.id;
    for(i = 0; i < ids.length; i++) {
        var curId = ids[i];
        if(curId.length > 0 && curId != selId) {
            var curSel = document.getElementById(curId);
            if(curSel != null) {
                curSel.selectedIndex = 0;
            }
        }
    }
    select.form.submit();
}

var curSubNavDiv;
var timed;

function changeImageHome(whichImage, topDiv, subDiv) {
    hideSubNav();
    curSubNavDiv = subDiv;
    document.getElementById(subDiv).style.display = 'block';
    document.getElementById(topDiv).src=whichImage;
  
}

function changeImageHomeCA(whichImage, topDiv, subDiv) {
    hideSubNavCA();
    curSubNavDiv = subDiv;
    document.getElementById(subDiv).style.display = 'block';
    document.getElementById(topDiv).src=whichImage;
  
}

function changeImageHomeOut(whichImage, topDiv, subDiv) {
    curSubNavDiv = "";
    document.getElementById(topDiv).src=whichImage;
    mytime = setTimeout("closeNav('" + subDiv + "')",1000);
}

function changeImageHomeOutCA(whichImage, topDiv, subDiv) {
    curSubNavDiv = "";
    document.getElementById(topDiv).src=whichImage;
    mytime = setTimeout("closeNav('" + subDiv + "')",1000);
}

function closeNav(which) {
    if(curSubNavDiv != which) {
        document.getElementById(which).style.display = 'none';
    }
}

function setSubNav(which){
    curSubNavDiv = which;
}

function changeRibbonImage(whichImage, which, dir){
    ribbonDiv = dir;
    document.getElementById(which).src = whichImage;
  
}
function changeRibbonImageOut(image, imageId, catId){
    ribbonDiv="";
    curSubNav="";
    document.getElementById(imageId).src = image;
    mytime = setTimeout("closeRibbon('" + catId + "')",2000);
}

function closeRibbon(which) {
    if(ribbonDiv != which && curSubNav!= which) {
        document.getElementById(which).style.display = "none";
    }
}

function delayedClose(elem) {
    mytime = setTimeout("closePopUp('" + elem + "')",10000);
}

function changeImageFitGuide(which,whichImage){
    document.getElementById(which).src = whichImage;
}

function addLoadEvent(func) {
  var oldOnLoad = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldOnLoad) {
        oldOnLoad();
      }
      func();
    }
  }
}

function replaceAmps(s) {
	return s.replace(/&amp;/g, "&");
}

function autoCompleteOff(id){ 
    document.getElementById(id).setAttribute('autocomplete','off');
} 