function bookmark(){ 
	javascript:window.external.AddFavorite('http://www.fragrance4u.com/', 'fragrance4u.com !!!');
}

function stripBlanks(aString) {
	var newString =aString;
	var blank = " ";

	if(newString.indexOf(blank) != -1)
	{
		var i = 0;
		var j = newString.length - 1;

		for(i = 0; i < newString.length; i += 1)
		{
			if(newString.charAt(i) != blank)
				break;
		}

		if(i != newString.length)
		{
			for(j = newString.length - 1;j > -1; j -= 1)
			{
				if(newString.charAt(j) != blank)
					break;
			}

			newString = newString.substring(i,j);
		}
		else
		{
			// all blanks
			newString = "";
		}
	}

	return newString;
}

function check_form() 	{
	var TheForm;
	TheForm = document.SearchForm;
	if (stripBlanks(TheForm.Keyword.value) == "")
	{
	  	alert("Please enter Fragrance Name to be searched.");
		TheForm.Keyword.focus();
		return false;
	}
	return true;
 }

function check_email() 	{
	var TheForm;
	TheForm = document.ForgetPassword;
	if (stripBlanks(TheForm.email.value) == "")
	{
	  	alert("Please enter your email address.");
		TheForm.email.focus();
		return false;
	}
	return true;
}

function check_order_number()	{
	var TheForm;
     	TheForm = document.OrderStatus;
	if (stripBlanks(TheForm.email.value) == "")
	{
	  	alert("Please enter your email.");
		TheForm.email.focus();
		return false;
	}

     	if (stripBlanks(TheForm.ordernumber.value) == "")
	{
	  	alert("Please enter your order number.");
		TheForm.ordernumber.focus();
		return false;
	}
     	if (isNaN(TheForm.ordernumber.value))
	{
	  	alert("Please check the order number.");
		TheForm.ordernumber.focus();
		return false;
	}

	return true;
}

function check_login() 	{
	var TheForm;
      TheForm = document.login;
      if (stripBlanks(TheForm.email.value) == "")
	{
	  	alert("Please enter Your Email Account.");
		TheForm.email.focus();
		return false;
	}
     
	if(stripBlanks(TheForm.password.value) == "")
	{
	  	alert("Please enter Password.");
		TheForm.password.focus();
		return false;
	}

	if (TheForm.email.value.indexOf("@", 0)  == -1 )
	{
	  	alert("Please Fill In Your correct Email Address.");
		TheForm.email.focus();
		return false;
	}
     return true;
}

function  check_signin() {
     var TheForm;
     TheForm = document.login;
     if(TheForm.action[0].checked) {
      if(stripBlanks(TheForm.email.value) == "")
	{
	  	alert("Please enter Your Email Account.");
		TheForm.email.focus();
		return false;
	}
     
	if(stripBlanks(TheForm.password.value) == "")
	{
	  	alert("Please enter Password.");
		TheForm.password.focus();
		return false;
	}

	if(TheForm.email.value.indexOf("@", 0)  == -1 )
	{
	  	alert("Please Fill In Your correct Email Address.");
		TheForm.email.focus();
		return false;
	}
		return true;
       }
       return true;

}

function clear_register_info() {
	this.document.register.reset();
}

function check_register_info(){
	var TheForm;
	TheForm = document.register;
	if(stripBlanks(TheForm.fname.value) == "")
	{
	  	alert("Please Fill In Your First Name.");
		TheForm.fname.focus();
		return false;
	}
	if(stripBlanks(TheForm.lname.value) == "")
	{
	  	alert("Please Fill In Your Last Name.");
		TheForm.lname.focus();
		return false;
	}

	if (stripBlanks(TheForm.email.value) == "")
	{
	  	alert("Please Fill In Your Email Address.");
		TheForm.email.focus();
		return false;
	}
        
	if (TheForm.email.value.indexOf("@", 0)  == -1 )
	{
	  	alert("Please Fill In Your correct Email Address.");
		TheForm.email.focus();
		return false;
	}

	if (stripBlanks(TheForm.password.value) == "")
	{
		alert("Please enter Password.");
		TheForm.password.focus();
		return false;
	}
	if (stripBlanks(TheForm.password2.value) == "")
	{
	  	alert("Please reenter your Password.");
		TheForm.password2.focus();
		return false;
	}
	if (TheForm.password.value.length < 5 )
	{
	  	alert("Your Password must be of atleast 5 characters.");
		TheForm.password.focus();
		return false;
	}
	if ((TheForm.password.value) !== (TheForm.password2.value))
	{
	  	alert("Entered Password does not match. Reenter Passwords.");
		TheForm.password.focus();
		return false;
	}
	if (stripBlanks(TheForm.challenge.value) == "")
	{
	  	alert("Entered Question in for reminder of password.");
		TheForm.challenge.focus();
		return false;
	}
	if (stripBlanks(TheForm.answer.value) =="")
	{
	  	alert("Entered Answer for reminder of password.");
		TheForm.answer.focus();
		return false;
	}

	if (stripBlanks(TheForm.address1.value) == "")
	{
	  	alert("Please Fill In Your Shipping Address.");
		TheForm.address1.focus();
		return false;
	}
        
	if (stripBlanks(TheForm.city.value) == "")
	{
	  	alert("Please Fill In Your City Name.");
		TheForm.city.focus();
		return false;
	}
	
	if (stripBlanks(TheForm.State.value) == "")
	{
	  	alert("Select State Name.");
		TheForm.State.focus();
		return false;
	}
	if ((stripBlanks(TheForm.zip.value) =="") || (TheForm.zip.value.length < 5))
	{
		alert("Please Fill In Your correct zip code");
		TheForm.zip.focus();
		return false;
	}
	
	if ((stripBlanks(TheForm.phone_ac.value) =="") || (TheForm.phone_ac.value.length < 3 ) || 
			(isNaN(TheForm.phone_ac.value)))

	{
	  	alert("Please Fill In Your valid area code.");
		TheForm.phone_ac.focus();
		return false;
	}

	if ((stripBlanks(TheForm.phone_lc.value) =="") || (TheForm.phone_lc.value.length < 3 ) || 
			(isNaN(TheForm.phone_lc.value)))
	{
	  	alert("Please Fill In Your valid phone number.");
		TheForm.phone_lc.focus();
		return false;
	}

	if ((stripBlanks(TheForm.phone_num.value) =="") || (TheForm.phone_num.value.length < 4 ) || 
			(isNaN(TheForm.phone_num.value)))
	{
	  alert("Please Fill In Your valid phone number.");
		TheForm.phone_num.focus();
		return false;
	}


	return true;
}

function check_delivery_info() {
   var TheForm;
   TheForm = document.deliveryInfo;
   if(TheForm.deliverto[1].checked) {
	if (stripBlanks(TheForm.fname.value) == "")
	{
	  	alert("Please Fill In Your First Name.");
		TheForm.fname.focus();
		return false;
	}
	if (stripBlanks(TheForm.lname.value) == "")
	{
	  	alert("Please Fill In Your Last Name.");
		TheForm.lname.focus();
		return false;
	}

	if (stripBlanks(TheForm.address1.value) == "")
	{
	  	alert("Please Fill In Your Shipping Address.");
		TheForm.address1.focus();
		return false;
	}
        
	if (stripBlanks(TheForm.city.value) == "")
	{
	  	alert("Please Fill In Your City Name.");
		TheForm.city.focus();
		return false;
	}
	
	if (stripBlanks(TheForm.State.value) == "")
	{
	  	alert("Select State Name.");
		TheForm.State.focus();
		return false;
	}
	if ((stripBlanks(TheForm.zip.value) =="") || (TheForm.zip.value.length < 5))
	{
		alert("Please Fill In Your correct zip code");
		TheForm.zip.focus();
		return false;
	}
	  return true;
    }

    return true;
}


function check_summary_info() {

	alert("It is demo website. No order will be processed.");
	var TheForm;
	TheForm = document.Order;
	if(TheForm.cc_type[4].checked) {
		alert("Our Sales person will instruct you how to pay by PayPal service.");
		return true;
	}

	if (stripBlanks(TheForm.cc_number.value) == "")
	{
	  	alert("Please enter Credit Card Number.");
		TheForm.cc_number.focus();
		return false;
	}
	
	if ((TheForm.cc_number.value.length < 1 ) || (isNaN(TheForm.cc_number.value)) || (!verifycc(TheForm.cc_number.value)))
	{
	  	alert("Please enter correct credit card number.");
		TheForm.cc_number.focus();
		return false;
	}
	if (stripBlanks(TheForm.cc_expmonth.value) == "")
	{
	  	alert("Please enter credit card expiry month.");
		TheForm.cc_expmonth.focus();
		return false;
	}
	if (stripBlanks(TheForm.cc_expyear.value) == "")
	{
	  	alert("Please enter credit card expiry year.");
		TheForm.cc_expyear.focus();
		return false;
	}
	var cal = new Date()
	var mon = cal.getMonth() + 1
	var yr = cal.getFullYear()
	var entmon = TheForm.cc_expmonth.value
	var entyr = TheForm.cc_expyear.value
		
	if (( entyr < yr ) || ((entyr == yr ) && ( entmon < mon )))
	{
	  	alert("Please check credit card expiry date and reenter it.");
		TheForm.cc_expmonth.focus();
		return false;
	}
	
	if (TheForm.cc_name.value == "")
	{
	  	alert("Please enter name on the credit card.");
		TheForm.cc_name.focus();
		return false;
	}


	return false;
}


function clear_feedback_info() {
	this.document.feedback.reset();
}

function check_feedback_info() {
	var TheForm;
	TheForm = document.feedback;
	if (stripBlanks(TheForm.fname.value) == "")
	{
	  	alert("Please Fill In Your First Name.");
		TheForm.fname.focus();
		return false;
	}
	if (stripBlanks(TheForm.lname.value) == "")
	{
	  	alert("Please Fill In Your Last Name.");
		TheForm.lname.focus();
		return false;
	}

	if (stripBlanks(TheForm.email.value) == "")
	{
	  	alert("Please Fill In Your Email Address.");
		TheForm.email.focus();
		return false;
	}
        
	if (TheForm.email.value.indexOf("@", 0)  == -1 )
	{
	  	alert("Please Fill In Your correct Email Address.");
		TheForm.email.focus();
		return false;
	}
	
	if (stripBlanks(TheForm.textarea.value) == "")
	{
	  	alert("Please Fill In Comments.");
		TheForm.textarea.focus();
		return false;
	}
	return true;
}

// Calcalates Shipping

function calculateShipping() {
	newWindow = window.open('calculateshipping.asp', 'a', 'height=310,width=400, resize=no,alwaysRaised=yes');
}



//////////////////////////////////////////////////////
// verifycc(ccnumber)
//
// This function uses a checksum algorithm to check
// the validity of a credit card before it is submitted
// for verification.  It takes a string adds leading
// zeros to the function to make it a 19 digit number.
// Then the index is alternated between 1 and 2 starting
// at 1.  The each digit is multiplied by the corresponding
// index and if the result is greater than 9 subtract 9.
// Total the results of each calculation and divide by 10.
// If the total divides evenly by ten then Ok otherwise 
// fail.  Works for major credit, charge, and debit cards.
//////////////////////////////////////////////////////////
function verifycc(ccnumber) {
		index=1
		sum=0
		lng = ccnumber.length
		addzero = 19 - lng
		for(i=0; i < 19; i++)
		{
			if( addzero > i )
			{
				if( index == 2)
				{
					index = 1
				}else{
					index = 2
				}
			}else{
				num = ccnumber.charAt(i-addzero)
				result = num * index
				if(result > 9)
				{
					result = result - 9
				}
				sum = sum + result 
				if( index == 2)
				{
					index = 1
				}else{
					index = 2
				}
			}			
		}
		sum = sum % 10
		if(sum == 0)
		{
			return true
		}else{
			return false
		}
	}
	
// function to determine the credit card type
function cardtype(ccnumber)
{
	strprefix = ccnumber.substring(0,6)
	if ((strprefix >= "340000") && (strprefix <= "349999"))
        return "American Express"
    else if ((strprefix >= "370000") && (strprefix <= "379999")) 
        return "American Express"
	else if ((strprefix >= "300000") && (strprefix <= "305999"))
        return "Diners Club"
    else if ((strprefix >= "360000") && (strprefix <= "369999"))
        return "Diners Club"
    else if ((strprefix >= "380000") && (strprefix <= "389999"))
        return "Diners Club"
    else if ((strprefix >= "601100") && (strprefix <= "601199"))
        return "Discover"
    else if ((strprefix >= "352800") && (strprefix <= "358900"))
        return "JCB"
    else if ((strprefix >= "400000") && (strprefix <= "405500")) 
        return "VISA"
    else if ((strprefix >= "405501") && (strprefix <= "405554")) 
        return "VISA"
    else if ((strprefix >= "405555") && (strprefix <= "415927")) 
        return "VISA"
    else if ((strprefix >= "415928") && (strprefix <= "415928")) 
        return "VISA"
    else if ((strprefix >= "415929") && (strprefix <= "424603")) 
        return "VISA"
    else if ((strprefix >= "424604") && (strprefix <= "424605")) 
        return "VISA"
    else if ((strprefix >= "424606") && (strprefix <= "427532")) 
        return "VISA"
    else if ((strprefix >= "427533") && (strprefix <= "427533")) 
        return "VISA"
    else if ((strprefix >= "427534") && (strprefix <= "428799")) 
        return "VISA"
    else if ((strprefix >= "428800") && (strprefix <= "428899")) 
        return "VISA"
    else if ((strprefix >= "428900") && (strprefix <= "443084")) 
        return "VISA"
    else if ((strprefix >= "443085") && (strprefix <= "443085")) 
        return "VISA"
    else if ((strprefix >= "443086") && (strprefix <= "471499")) 
        return "VISA"
    else if ((strprefix >= "471500") && (strprefix <= "471699")) 
        return "VISA"
    else if ((strprefix >= "471700") && (strprefix <= "499999")) 
        return "VISA"
    else if ((strprefix >= "500000") && (strprefix <= "540499")) 
        return "MasterCard"
    else if ((strprefix >= "540500") && (strprefix <= "540599")) 
        return "MasterCard"
    else if ((strprefix >= "540600") && (strprefix <= "547205")) 
        return "MasterCard"
    else if ((strprefix >= "547206") && (strprefix <= "548018")) 
        return "MasterCard"
    else if ((strprefix >= "548019") && (strprefix <= "554999")) 
        return "MasterCard"
    else if ((strprefix >= "555000") && (strprefix <= "556999")) 
        return "MasterCard"
    else if ((strprefix >= "557000") && (strprefix <= "557999")) 
        return "MasterCard"
    else if ((strprefix >= "558000") && (strprefix <= "558999")) 
        return "MasterCard"
    else if ((strprefix >= "559000") && (strprefix <= "559900")) 
        return "MasterCard"
	else
        return "Unknown" // Unknown card type
}

//==============================================================================
//	End of JavaScript Functions
//==============================================================================




function validateNumber(field) {
 var valid = "0123456789"
 var ok = "yes";
 var temp;
 for (var i=0; i<field.value.length; i++) {
 temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
if (field.value=="0") ok = "no";
}
 if (ok == "no") {
  alert("Please Enter Valid Number");
  field.focus();
  field.select();
 
   }
 }
 

