
function swap_font(id)
{
 
  if (id==0) 
	{document.engravefont.src='../images/blank.gif';}
 
  else if (id==1) 
	{document.engravefont.src='../images/demi.gif';}
  
  else if (id==2) 
	{document.engravefont.src='../images/times.gif';}
  
  else if (id==3) 
	{document.engravefont.src='../images/arial.gif';}
  
  else if (id==4) 
	{document.engravefont.src='../images/english.gif';}
  
  else if (id==5) 
	{document.engravefont.src='../images/old.gif';}
  
  else if (id==6) 
	{document.engravefont.src='../images/roman.gif';}
	
}


function ValidEmailAddress(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value in the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !ValidEmailAddress(formField.value)) )
	{
		alert("Please enter a complete email address: your@emailaddress.com");
		formField.focus();
		result = false;
	}
   
  return result;

}

function validNum(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		if (!allDigits(formField.value))
 		{
 			alert('Please enter a number in the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function ValidInt(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var num = parseInt(formField.value);
 		if (isNaN(num))
 		{
 			alert('Please enter a valid quantity');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function validDate(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var elems = formField.value.split("/");
 		
 		result = (elems.length == 3); // should be three components
 		
 		if (result)
 		{
 			var month = parseInt(elems[0]);
  			var day = parseInt(elems[1]);
 			var year = parseInt(elems[2]);
			result = allDigits(elems[0]) && (month > 0) && (month < 13) &&
					 allDigits(elems[1]) && (day > 0) && (day < 32) &&
					 allDigits(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4));
 		}
 		
  		if (!result)
 		{
 			alert('Please enter a date in the format MM/DD/YYYY for the "' + fieldLabel +'" field.');
			formField.focus();		
		}
	} 
	
	return result;
}

function validate_registration(theForm)
{
	
	if (!validRequired(theForm.FIRST_NAME,"first name"))
		return false;
	
	if (!validRequired(theForm.LAST_NAME,"last name"))
		return false;
	
	if (!validRequired(theForm.ADDRESS_1,"address"))
		return false;
		
	if (!validRequired(theForm.CITY,"city"))
		return false;
	
	if (!validRequired(theForm.STATE,"state"))
		return false;
	
	if (!validRequired(theForm.ZIP,"zip"))
		return false;
	
	if (!validEmail(theForm.EMAIL,"e-mail address",true))
		return false;
	
	if (!validRequired(theForm.PASSWORD,"password"))
		return false;
	
	if (!validRequired(theForm.PHONE_1,"daytime phone"))
		return false;
	
	
	return true;
}

function validate_signup(theForm)
{

	if (!validEmail(theForm.EMAIL,"e-mail address",true))
		return false;
	
	return true;
}

function validate_sendtoafriend(theForm)
{
	
	if (!validRequired(theForm.namefriend,"Friend's name"))
		return false;
	
	if (!validRequired(theForm.emailfriend,"Your friend's email"))
		return false;
		
	if (!validRequired(theForm.nameyours,"Your name"))
		return false;
	
	if (!validRequired(theForm.emailyours,"Your email"))
		return false;
		
	return true;
}

function validate_address(theForm)
{
	
	if (!validRequired(theForm.FIRST_NAME,"first name"))
		return false;
	
	if (!validRequired(theForm.LAST_NAME,"last name"))
		return false;
	
	if (!validRequired(theForm.ADDRESS_1,"address"))
		return false;
		
	if (!validRequired(theForm.CITY,"city"))
		return false;
	
	if (!validRequired(theForm.STATE,"state"))
		return false;
	
	if (!validRequired(theForm.ZIP,"zip"))
		return false;
	
	return true;
}

function validate_email(theForm)
{
	
	if (!validEmail(theForm.email,"e-mail address",true))
		return false;
		
	return true;
}

function validate_login(theForm)
{
	
	if (!validEmail(theForm.email,"e-mail address",true))
		return false;
	
	if (!validRequired(theForm.password,"password"))
		return false;
		
	return true;
}

function validate_gc_submit(theForm)
{
	
	if (!validEmail(theForm.GC_EMAIL,"recipient e-mail address",true))
		return false;
	
	if (!validRequired(theForm.GC_NAME,"recipient name"))
		return false;
		
	return true;
}
function validate_qty(theForm)
{
	
	if (!ValidInt(theForm.QTY,"quantity", true))
		return false;
	return true;
}

function validate_search(theForm)
{
	
	if (!validRequired(theForm.search,"search"))
		return false;
	return true;
}

function popup(url, width, height)
{
	
	settings= "toolbar=no,location=no,directories=no,"+"status=no,menubar=no,scrollbars=yes,"+"resizable=0,width="+width+",height="+height;aWindow=window.open(url,"hitched",settings);

}

function CloseUp(v_IMAGE_LARGE)
{
	
	window.open("PopUp.asp?LGIMG="+ v_IMAGE_LARGE,"hitched","status=no,width=450,height=500,top=0,left=0");
}

function CloseUpSmall(v_IMAGE_LARGE)
{
	
	window.open("PopUp.asp?LGIMG="+ v_IMAGE_LARGE,"hitched","status=no,width=200,height=275,top=0,left=0");
}

//	THIS IS THE SCROLLABLE ADJUSTABLE POPUP WINDOW FUNCTION
//	*** EXAMPLE - ADJUSTABLE POPUP WINDOW ***
//	<a href="javascript:scrollAdjustPopUp('index.html','200','200','Name')">PopUp</a>
function scrollAdjustPopUp (url, w, h, name) {
	var winopts = "toolbar=no,location=no,directories=no,status=no,";
	winopts = winopts + "menubar=no,scrollbars=yes,resizable=yes,";
	winopts = winopts + "width=" + w + ",height=" + h; remote = window.open(url,name,winopts);
}
//	THIS SCRIPT REVEALS / HIDES CONTENT
// 	EXAMPLE: 
// 	<a href="javascript:revealThis('ingredients');">Reveal This</a><br>
// 	<div id="ingredients" style="display: none;">Reveal text goes here. Lorem ipsum dolor sit amet...</div>
function revealThis(id) {
if(document.getElementById(id).style.display == "none") {
	document.getElementById(id).style.display = "";
	}
else {
	document.getElementById(id).style.display = "none";
	}
}



function validate_misspettigrew(theForm)
{
	

	if (!validRequired(theForm.nameFirst,"first name"))
		return false;
	
	if (!validRequired(theForm.nameLast,"last name"))
		return false;
		
	if (!validRequired(theForm.city,"city"))
		return false;
	
	if (!validRequired(theForm.state,"state"))
		return false;
	
	if (!validRequired(theForm.zip,"zip"))
		return false;

	if (!validRequired(theForm.areacode,"area code phone number"))
		return false;
	if (!validRequired(theForm.prefixNum,"prefix phone number"))
		return false;
	if (!validRequired(theForm.suffix,"suffix phone number"))
		return false;

	if (!validEmail(theForm.email,"e-mail address",true))
		return false;

	if (!validRequired(theForm.birthMonth,"your birth month"))
		return false;
	if (!validRequired(theForm.birthDay,"your birth day"))
		return false;
	if (!validRequired(theForm.birthYear,"your birth year"))
		return false;

	return true;
}

function validate_bridges(theForm)
{
	

	if (!validRequired(theForm.nameFirst,"first name"))
		return false;
	
	if (!validRequired(theForm.nameLast,"last name"))
		return false;
		
	if (!validRequired(theForm.city,"city"))
		return false;
	
	if (!validRequired(theForm.state,"state"))
		return false;
	
	if (!validRequired(theForm.zip,"zip"))
		return false;

	if (!validRequired(theForm.areacode,"area code phone number"))
		return false;
	if (!validRequired(theForm.prefixNum,"prefix phone number"))
		return false;
	if (!validRequired(theForm.suffix,"suffix phone number"))
		return false;

	if (!validEmail(theForm.email,"e-mail address",true))
		return false;

	if (!validRequired(theForm.birthMonth,"your birth month"))
		return false;
	if (!validRequired(theForm.birthDay,"your birth day"))
		return false;
	if (!validRequired(theForm.birthYear,"your birth year"))
		return false;

	return true;
}


function validate_app(theForm)
{
	if (!validEmail(theForm.email,"e-mail address",true))
		return false;
	return true;
}


function validate_twittergift(theForm)
{

	if (!validRequired(theForm.nameFirst,"name"))
		return false;

	if (!validRequired(theForm.nameLast,"twittername"))
		return false;
	
	if (!validRequired(theForm.zip,"zip"))
		return false;

	if (!validEmail(theForm.email,"e-mail address",true))
		return false;

	if (!validRequired(theForm.birthMonth,"your birth month"))
		return false;
		
	if (!validRequired(theForm.birthDay,"your birth day"))
		return false;
		
	if (!validRequired(theForm.birthYear,"your birth year"))
		return false;

	return true;
}


function validate_sweepstakes(theForm)
{

	if (!validRequired(theForm.nameFirst,"first name"))
		return false;

	if (!validRequired(theForm.nameLast,"last name"))
		return false;
	
	if (!validRequired(theForm.zip,"zip"))
		return false;

	if (!validEmail(theForm.email,"e-mail address",true))
		return false;
	return true;
}


function validate_shadename(theForm)
{
	
	if (!validRequired(theForm.field1,"Suggested Lip Shade Name"))
		return false;
	if (!validRequired(theForm.nameFirst,"Your First Name"))
		return false;
	if (!validEmail(theForm.email,"Your Email Address",true))
		return false;
	if (!validRequired(theForm.field2,"Tell Us Why We Should Pick Your Name"))
		return false;

	return true;
}
function validate_emailonly() {
	if (!validEmail(theForm.email,"e-mail address",true))
		return false;
	return true;
}

//	<span class="questionReveal"><a href="javascript:void(0)" class="questionReveal" onclick="reveal(this)">QUESTION GOES HERE</a><br><br></span>
//	<span class="answerReveal">ANSWER GOES HERE<br><br></span>
function reveal(loc){
		if(document.getElementById){
			var foc=loc.firstChild;
			foc=loc.firstChild.innerHTML?
				loc.firstChild:
				loc.firstChild.nextSibling;
			foc=loc.parentNode.nextSibling.style?
				loc.parentNode.nextSibling:
				loc.parentNode.nextSibling.nextSibling;
			foc.style.display=foc.style.display=='block'?'none':'block';
		}
}

function GetElement(ctrl){
    return document.all ? document.all(ctrl) : document.getElementById(ctrl);    
}



// Browser safe opacity handling function

function setOpacity( value ) {
 document.getElementById("styled_popup").style.opacity = value / 10;
 document.getElementById("styled_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}

function fadeOutMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
 }

 setTimeout('closeMyPopup()', 800 );
}

function closeMyPopup() {
 document.getElementById("styled_popup").style.display = "none"
}

function fireMyPopup() {
 setOpacity( 0 );
 document.getElementById("styled_popup").style.display = "block";
 fadeInMyPopup();
}


