/* Prevent evil form elements from showing through the drop menus */
$(function(){

  $('.TopNav-DropMenu').bgiframe();

});

/* Preload images rollovers for the menu */
if (document.images) { 
  var ShopByPrice_pre = newImage('/images/topnav/shopbyprice-rollover.gif');
  var ShopByOccasion_pre = newImage('/images/topnav/shopbyoccasion-rollover.gif');
  var ShopByCategories_pre = newImage('/images/topnav/shopbycategory-rollover.gif');
  var Sale_pre = newImage('/images/topnav/sale-rollover.gif');
}

// GoLive Generated Rollover Logic
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function rollimage(obj, img) {
	var imgs = obj.getElementsByTagName("IMG");
	for (var i=0; i<imgs.length; i++) {
		imgs[i].src = img;
	}
}

$(function(){
  $('#TopNav-MenuBar > div').hover(function(){
    $(this).addClass('sfhover');
  },function(){
    $(this).removeClass('sfhover');
  });
});


//Check if enter button is pressed. 
 function checkEnterKeyPress(e) {
	if(document.getElementById("email") && document.getElementById("email").value.length > 0) {
		var x = document.getElementById("email");
		var email_value = x.value;
	}
	if (document.getElementById("keyword") && document.getElementById("keyword").value.length > 0) {
		var searchVal = document.getElementById("keyword");
	}
	e = e || window.event;
	var unicode=e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
	if (unicode == 13) {
		if (email_value && email_value.length > 0) {
			goMail();
		}
		if(searchVal.value.length > 0) {
			submitSearch();
		}
	}
 }

//Pass provided email to "Email Sign Up" page
function goMail()
{
  var x = document.getElementById("email");
	email_value = x.value;
	
  if (email_value.length > 0)
  	window.location = "BECEmailSubscribeView?storeId=10051&langId=-1&catalogId=10002&URL=UserAccountView?storeId=10051&langId=-1&catalogId=10002&cm_sp=VersionB-_-Footer-_-Emailsubmit&email1=" + email_value;
}

function submitSearch() {
	var searchVal = document.getElementById("keyword");
	
	if (searchVal.value.length > 0)
	window.location = "view____giftFinder.html?search=" + searchVal.value;	
}

//Easy Entertaining
function GetParamLive(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);
}

function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (i=0;i<array.length;i+=2) {
			img = null; var n = array[i];
			if (d.images) {
				if (d.layers) {img = findElement(n,0);}
				else {img = d.images[n];}
			}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (!img && d.getElementsByName) {
				var elms = d.getElementsByName(n);
				if (elms) {
					for (j=0;j<elms.length;j++) {
						if (elms[j].src) {img = elms[j]; break;}
					}
				}
			}
			if (img) {img.src = array[i+1];}
		}
	}
}
function changeImages() {
	changeImagesArray(changeImages.arguments);
}

var selectedSection;
function selectSection(section)
{
	return true; //Disabled
	
	selectedSection=section;
	for(i=0;i<navImages.length;i++)
	{
		if(navImages[i].key == selectedSection)
		{
			changeImages(navImages[i].name, navImages[i].imgOver);
			break;
		}
	}
}
function sectionSelected(section)
{
	return false; //Disabled
	
	return (section == selectedSection);
}


// Expand/Contract Menu items logic
function expand(id, suff)
{
	var linkEl = document.getElementById(id);
	var contentEl = document.getElementById(id + suff);	
	
	contentEl.style.display = "block";
	linkEl.href = "javascript:contract('"+id+"','"+suff+"')";
}

function contract(id, suff)
{
	var linkEl = document.getElementById(id);
	var contentEl = document.getElementById(id + suff);	
	
	contentEl.style.display = "none";
	linkEl.href = "javascript:expand('"+id+"','"+suff+"')";
}

//Popup
function popup(file, p_width, p_height, sbars, loc, menus, toolb)
{
	var w = p_width;
	var h = p_height;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	
	if (!sbars) sbars = "0";
	if (!loc) loc = "0";
	if (!menus) menus = "0";
	if (!toolb) toolb = "0";
	
	windowprops = "height="+h+",width="+w+",top="+ wint +",left="+ winl +",location="+loc+", scrollbars="+sbars+",menubar="+menus+",toolbar="+toolb+",resizable=0,status=1";
	window.open(file, "Popup", windowprops);
}
 
//Popup Paths
var popupPath = "/include/fomcSavings-details.html";
var popupPath1206 = "/include/popup-details1206.html";
var popupPath1207 = "/include/popup-details1207.html";
var popupPath1208 = "/include/popup-details1208.html";
var popupPathDASHER = "/include/popup-detailsDASHER.html";
var popupPathRUDOLPH = "/include/popup-detailsRUDOLPH.html";
var popupPathMERRY = "/include/popup-detailsMERRY.html";
var popupPathPRANCER = "/include/popup-detailsPRANCER.html";
var popupPathPRANCER2 = "/include/popup-detailsPRANCER2.html";
var popupPathFROSTY = "/include/popup-detailsFROSTY.html";
var popupPathACK = "/include/popup-detailsACK.html";
var popupPathVAL = "/include/popup-detailsVAL.html";
var popupPath50Off = "/include/popup-details50Off.html";
var popupPathSPREE = "/include/popup-detailsSPREE.html";
var popupPathHOPPY = "/include/popup-detailsHOPPY.html";
var popupPathEAS = "/include/popup-detailsEAS.html";
var popupPathSPRING = "/include/popup-detailsSPRING.html";
var popupPathDAISY = "/include/popup-detailsDAISY.html";
var popupPathCHARMS = "/include/popup-detailsCHARMS.html";
var popupPathBLOOM = "/include/popup-detailsBLOOM.html";
var popupPathBRIGHT = "/include/popup-detailsBRIGHT.html";
var popupPathSWEET = "/include/popup-detailsSWEET.html";
var popupPathMOTHER = "/include/popup-detailsMOTHER.html";
var popupPathDAD = "/include/popup-detailsDAD.html";
var popupPathD20 = "/include/popup-detailsD20.html";
var popupPathShip = "/include/popup-ship.html";
var popupPathPEARSHIP = "/include/popup-detailsPearShip.html";
var popupPathMP2 = "/include/popup-detailsMP2.html";
var popupPathMS5 = "/include/popup-detailsMS5.html";
var popupPathNP2 = "/include/popup-detailsNP2.html";
var popupPathNS5 = "/include/popup-detailsNS5.html";
var popupPathPEARSHIP2 = "/include/popup-detailsPEARSHIP.html";
var popupPath3PEARS = "/include/popup-details3PEARS.html";
var popupPathFREEDEL = "/include/popup-detailsFreeDel.html";
var popupPathOFF50DEL = "/include/popup-detailsOff50Del.html";
var popupPathSAVESHIP = "/include/popup-detailsSaveShip.html";
var popupPathFreeDel = "/include/popup-detailsFreeDel.html";
var popupPathOff50Del = "/include/popup-detailsOff50Del.html";
var popupPathSaveShip = "/include/popup-detailsSaveShip.html";
var popupPathCZ1 = "/include/popup-detailsCZ1.html";
var popupPathCZ2 = "/include/popup-detailsCZ2.html";
var popupPathDBLREWARD = "/include/popup-detailsDBLREWARD.html";
var popupPathDBLREWARDB2B = "/include/popup-detailsDBLREWARDB2B.html";
var popupPathFALL = "/include/popup-detailsFALL.html";
var popupPathYAMS = "/include/popup-detailsYAMS.html";
var popupPathEARLY = "/include/popup-detailsEARLY.html";
var popupPathCYBER = "/include/popup-detailsCYBER.html";
var popupPathSAVE25 = "/include/popup-detailsSAVE25.html";
var popupPathBLITZEN = "/include/popup-detailsBLITZEN.html";
var popupPathCLUBSHIP = "/include/popup-detailsCLUBSHIP.html";
var popupPathGIVE = "/include/popup-detailsGIVE.html";
var popupPathSHIPFREE = "/include/popup-detailsSHIPFREE.html";
var popupPathTPO = "/include/popup-detailsTPO.html";
var popupPathCUPID = "/include/popup-detailsCUPID.html";
var popupPathTELEFLORA = "/include/popup-detailsTELEFLORA.html";
var popupPathFEBFREE = "/include/popup-detailsFEBFREE.html";
var popupPathSHIP = "/include/popup-detailsSHIP.html";
var popupPathSHIP2 = "/include/popup-detailsSHIP2.html";
var popupPathTAX20 = "/include/popup-detailsTAX20.html";
var popupPathTENOFF = "/include/popup-detailsTENOFF.html";
var popupPathTOWER = "/include/popup-detailsTOWER.html";
var popupPathVASE = "/include/popup-detailsVASE.html";
var popupPathOFFER = "/include/popup-detailsOFFER.html";
var popupPathBIRTHDAY = "/include/popup-detailsBIRTHDAY.html";