//<script>
function sendEmail(iEmail) {
	switch (iEmail) {
		case 0:
			sEmail = "info@love4perfume.com"
			break;
		case 1:
			sEmail = "support@love4perfume.com"
			break;
		case 2:
			sEmail = "resellers@love4perfume.com"
			break;
		case 3:
			sEmail = "shopsafe@love4perfume.com"
			break;
		case 4:
			sEmail = "webmaster@love4perfume.com"
			break;
	}
	document.location = "mailto:" + sEmail;
}
function goLetter(sL) { 
	if (sL == "#") sL = "num";
	document.location='Category.asp?CID=' + document.frmQuick.sCID.value + '&sL=' + sL;}
function getFavorites() {
	document.frmFavorite.submit();
}
function switchGender()
{
	var women = document.getElementById('womenLetters');
	var men = document.getElementById('menLetters');
	men.style.display = (women.style.display == 'none') ? 'none' : 'inline';
	women.style.display = (women.style.display == 'none') ? 'inline' : 'none';
}

var sTDStay;
var sImagePath = "\\fragrance//";
// Go to a link
function go(sLink) {document.location = sLink;}
// Trim a string
function trim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { 
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);}
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { 
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);}
   while (retValue.indexOf(" ") != -1) {
      retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length);}
   return retValue;}
// Send form named "frm" to page
function goForm(sPage) {
	document.frm.action = sPage;
	document.frm.submit();}
// Move a <DIV> to a position
var	bXStop = false;
var	bYStop = false;
var tMove;
function moveDivTo(oDiv, iLeft, iTop, iSpeed, iSpeedTop, bVanish) {
	clearTimeout(tMove);
	if (!bXStop || !bYStop) {
		if (!bXStop) oDiv.style.left = parseInt(parseInt(oDiv.style.left) + iSpeed) + 'px';
		if (!bYStop) oDiv.style.top	= parseInt(parseInt(oDiv.style.top) + iSpeedTop) + 'px';
		if (iSpeed > 0) {
			if (parseInt(oDiv.style.left) >= iLeft) bXStop = true;} else {
			if (parseInt(oDiv.style.left) <= iLeft) bXStop = true;}
		if (iSpeedTop > 0) {	
			if (parseInt(oDiv.style.top)>= iTop) bYStop = true;} else {
			if (parseInt(oDiv.style.top) <= iTop) bYStop = true;}	
		var sTimeout =	"moveDivTo(document.getElementById('" + oDiv.id + "'), " + iLeft + ", " + 
						iTop + ", " + iSpeed + ", " + iSpeedTop + ", " + bVanish + ")";
		tMove = setTimeout(sTimeout, 1);} else {
		clearTimeout(tMove);
		oDiv.style.left = iLeft + 'px';
		oDiv.style.top = iTop + 'px';
		if (bVanish) oDiv.style.display = "none";}}
//==============================================================
// Manages the appearance of a DIV from a random location
// outside the page to given X & Y coordinates in a given
// speed
function flashDiv(oDiv, iLeft, iTop, iSpeed, bNotRandom, iFromLeft, iFromTop, bVanish) {

	if (!bNotRandom) {
		with (Math) {
			var iDivLeft = -400 + parseInt(random() * 1900);
			var iDivTop  = -200 + parseInt(random() * 1100);
			
			if (iDivLeft > 0 && iDivLeft < 1100)
				iDivTop =	(-1) * parseInt(random() * 100);
		}
	} else {
		var iDivLeft = iFromLeft;
		var iDivTop = iFromTop;
	}

	oDiv.style.left = iDivLeft + 'px';
	oDiv.style.top = iDivTop + 'px';
	
	var iToGoLeft	= iLeft - iDivLeft;
	var iToGoTop	= iTop - iDivTop;
	var iSpeedTop	= parseInt(iToGoTop / iToGoLeft * iSpeed);
	
	if (iToGoLeft < 0) iSpeed = -iSpeed;
	if (iToGoLeft < 0) iSpeedTop = -iSpeedTop;
	
	bXStop = false;
	bYStop = false;
	
	moveDivTo(oDiv, iLeft, iTop, iSpeed, iSpeedTop, bVanish);
}
// Shows a floating div according to mouse position
function showFloatingDiv(oDiv) {
oDiv.style.left		= window.event.clientX - 280;
oDiv.style.top		= window.event.clientY - 20 + document.body.scrollTop;
oDiv.style.display	= "";}
// Hides a floating div
function hideFloatingDiv(oDiv) {
	oDiv.style.display = "none";
}
// Hides a floating div
function hideDiv(oDiv) {
	oDiv.style.display = "none";
}
// Switches a picture on
function on(oImg) {	var src = String(oImg.src).replace(/_off/, "_on");oImg.src = src;}
// Switches a picture off
function off(oImg) {var src = String(oImg.src).replace(/_on/, "_off");oImg.src = src;}
var oLastImg;
// Switches a picture on and stays on until another is on
function onStay(oImg) {
	if (oImg != oLastImg) {
		var src = String(oImg.src).replace(/_off/, "_on");
		oImg.src = src;
		off(oLastImg);
		oLastImg = oImg;}}
var oLastDiv;
// Paging function goes to next page
function pageNext(frmName) {
	with (eval('document.' + frmName)) {
		iPage.value = parseInt(iPage.value) + 1;
		submit();}}
// Paging function goes to previous page
function pagePrevious(frmName) {
	with (eval('document.' + frmName)) {
		iPage.value = parseInt(iPage.value) - 1;
		submit();}}
var iActiveN;
// Open the uploader window
function openUploader(sNotDefault) {
	if (!sNotDefault)
		var y = window.open('/shared/Uploader.asp','Uploader', 'top=250, left=250, width=300, height=300, menubar=0, status=0');
	else
		var y = window.open(sNotDefault,'Uploader', 'top=250, left=250, width=300, height=300, menubar=0, status=0');}
// Open and close static <DIV> of tree
function switchDiv(sDiv) {

	var oDiv = document.getElementById(sDiv);
	var oA   = document.getElementById('A' + sDiv);
	if (oDiv) {oDiv.style.display = (oDiv.style.display == "none") ? "inline" : "none";
		if (oA) oA.innerHTML = (oDiv.style.display == "inline") ? "<img src=" + sImagePath + "minus.gif align=absmiddle>" : "<img src=" + sImagePath + "plus.gif align=absmiddle>";}
	}
// Highlight a category (put it in bold);
var oLastHighlight = "";
function highlight(oA) { 
	if (oLastHighlight != oA) {
		oA.className = (oA.className == "Txt_Blue_15") ? "Txt_Blue_15B" : "Txt_Blue_15";
		oLastHighlight.className = (oLastHighlight.className == "Txt_Blue_15") ? "Txt_Blue_15B" : "Txt_Blue_15";}
	oLastHighlight = oA;}
// Highlight a TD
var oLastHighlightTD = "";
var oLastHighlightA = "";
function highlightTD(oTD, oA) { 
	if (oLastHighlightTD != oTD) {
		oTD.style.backgroundColor = "#8494D7";
		oTD.style.fontWeight = "bold";
		if (oA) oA.style.color = "white";
		if (oLastHighlightTD) {
			oLastHighlightTD.style.backgroundColor = "";
			oLastHighlightTD.style.fontWeight = "normal";
			oLastHighlightA.style.color = "";}}
	oLastHighlightTD 	= oTD;
	oLastHighlightA		= oA;}
// Fly a message
function flyer(str, iSleep, oDiv) {
	if (oDiv == null) {
		var sDiv =	"<DIV  id=flyerDiv style=position:absolute><TABLE width=300 class=Admin_DataTable style=\"border:1px solid lightblue\"><TR><TD class=Data align=center style=\"font-size:18px;height:80px;background-color:lightyellow;\" valign=middle><B>" + str + "</B></TD>" + 
								"</TR></TABLE></DIV>";
		document.write(sDiv);
		var oDiv = flyerDiv;} 
	if (iSleep==null)
		iSleep = 3500;
	var iLeftTo = 	document.body.offsetWidth / 2 - 400 / 2;
	var iTopTo = 	300;
	flashDiv(oDiv, iLeftTo+40, iTopTo, 10, true, -400, iTopTo);
	setTimeout("flashDiv(" + oDiv.id + ", 1500, " + iTopTo + ", 40,  true, " + iLeftTo  + ", " + iTopTo + ", " + true + ");", iSleep);}
// Fly a message
function flyerCustom(iSleep, oDiv, iLeft, iTop, bOneWay) {
	if (iSleep==null)
		iSleep = 3500;
	var iLeftTo = 	iLeft;
	var iTopTo = 	iTop;
	flashDiv(oDiv, iLeftTo+40, iTopTo, 10, true, 200, iTopTo);
	if (!bOneWay)
		setTimeout("flashDiv(document.getElementById('" + oDiv.id + "'), 1500, " + iTopTo + ", 40,  true, " + iLeftTo  + ", " + iTopTo + ", " + true + ");", iSleep);}
//==============================================================
// Fly a message from right
function flyerCustomRight(iSleep, oDiv, iLeft, iTop, bOneWay) {
	if (iSleep==null)
		iSleep = 3500;
	var iLeftTo = 	iLeft;
	var iTopTo = 	iTop;
	flashDiv(oDiv, iLeftTo+40, iTopTo, 15, true, document.body.offsetWidth + 10, iTopTo);
	if (!bOneWay)
		setTimeout("flashDiv(document.getElementById('" + oDiv.id + "'), 1500, " + iTopTo + ", 40,  true, " + iLeftTo  + ", " + iTopTo + ", " + true + ");", iSleep);}
function popup(file, width, height, top, left, image)
	{	var str, oWin;
		//str = '" width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', resizable=0, scrollbars=1"';
		str = ' width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', resizable=0, scrollbars=1, status=1';
		(image!=null) ? file = file + '?image=' + image : "" ;
		var ranNum= Math.round(Math.random()*70);
		window.open(file, 'popup' + ranNum, str);}
// Highlights a TD
function onTD(oTD) {
	oTD.style.backgroundImage = 'url("' + sImagePath + 'on_bg.gif")';
	document.getElementById('a' + oTD.id).style.color = "#0D2D50";}
// Off highlights a TD
function offTD(oTD) {
	if (sTDStay != oTD.id) {
		oTD.style.backgroundImage = "";
		document.getElementById('a' + oTD.id).style.color = "";}}
// Highlights a TD with a letter
function onLetterTD(oTD) {oTD.style.backgroundImage = "url(" + letter_bg.src + ")"}
// Off highlights a TD with a letter
function offLetterTD(oTD) {
	if (sTDStay != oTD.id) oTD.style.backgroundImage = "";}
// Change status of order
function updateOrder(oSelect, OID, iOldStatus, sAction) {
	if (oSelect.value.split('~')[1] == 99) {
		if (confirm('Delete order no. ' + OID + '?')) {
			frmOrders.iOID_ToChange.value = OID;
			frmOrders.iStatus.value = oSelect.value;
			frmOrders.action = sAction;
			frmOrders.submit()
		} else
			oSelect.value = OID + "~" + iOldStatus;
	} else {
		if (confirm('Change status of order no. ' + OID + '?')) {
			frmOrders.iOID_ToChange.value = OID;
			frmOrders.iStatus.value = oSelect.value;
			frmOrders.action = sAction;
			frmOrders.submit()
		} else
			oSelect.value = OID + "~" + iOldStatus;	}}
// Check length of keyword string
function checkTxt() {
	with (document.frmSearch) {
		if (Keyword.value != "" && trim(Keyword.value).length < 2) {
			alert("You must enter a keyword of at least 2 letters if you want to search by keyword.");
			Keyword.select();
			Keyword.focus();
			return false;
		} else if (Keyword.value == "" && Price.value == "" && sCID.value == "") {
			alert("You must choose at least one search criteria before searching");
			return false;
		} else if (Keyword.value == "" && (Price.value == "" || sCID.value == "")) {
			alert("If you are not searching with a keyword, you must choose a price range AND a department");
			return false;
		}
		LID.value = "";	}}
// Check Email address
function emailCheck(oField) {
	
	oField.value = Trim(oField.value);
	var bOK = oField.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

	if (bOK)
	   return true;
	else {
   	   alert('Please enter a valid e-mail address. If you have entered it correctly, check if there are any extra spaces before or after the address or any other mistakes.')
	   oField.focus()
	   oField.select()
	   return false;
	}
}

// Check Email address
function emailMultipleCheck(sValues) {

	arrValues = sValues.split("~");

	for (var i=0; i < arrValues.length; i ++) {
	
		sValue = arrValues[i];
		sValue = Trim(sValue);
		var bOK = sValue.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	
		if (bOK) {}
		else {
	   	   alert('Please enter a valid e-mail address for "Email ' + (i+1) + '". If you have entered it correctly, check if there are any extra spaces before or after the address or any other mistakes.')
		   return false;
		}
	}
	return true;
}
// LTrim(string) : Returns a copy of a string without leading spaces.
function LTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}
// RTrim(string) : Returns a copy of a string without trailing spaces.
function RTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;      
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}
// Trim(string) : Returns a copy of a string without leading or trailing spaces
function Trim(str)
{   return RTrim(LTrim(str));}
// Get absolute position X
function getPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
// Get absolute position Y
function getPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

	