
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}



function mailme(tld,domainname,username,displayname){
  domain = ('@' + domainname + '.' + tld);
  if(displayname == ''){displayn = username + domain;}
  else{displayn = displayname;}
  document.write('<a href="mailto:' + username + domain + '" title="' + displayn + '">' + displayn + '</a>');
}



function changeStyle(whichLayer,mode){

	if (document.getElementById){
		// this is the way the standards work
		var thestyle = document.getElementById(whichLayer).style;
	}
	else if (document.all){
		// this is the way old msie versions work
		var thestyle = document.all[whichLayer].style;
	}
	else if (document.layers){
		// this is the way nn4 works
		var thestyle = document.layers[whichLayer].style;
	}

	if(mode=='close'){thestyle.display = "none";}
	else if(mode=='open'){thestyle.display = "block";}
	else if(mode=='openInline'){thestyle.display = "inline";}
	else if(mode=='tabUp'){thestyle.backgroundPosition = "top left";}
	else if(mode=='tabDown'){thestyle.backgroundPosition = "bottom left";}
	else{style2.display = thestyle.display=="block"?"none":"block";}
}

//
// where to buy functions
function refineResults() {
	changeStyle('printOrRefineBar','close');
	changeStyle('refineResultsBar','open');
};
function cancelRefineResults() {
	changeStyle('refineResultsBar','close');
	changeStyle('printOrRefineBar','open');
};
var storeIDList = new Array();

function buildStoreList(FormName, FieldName) {
	if(!document.forms[FormName]) {
		return;
	}
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes) {
		return;
	}
	storeIDList = new Array();
	var totalChecked = 0;
	var masterChecked = false;
	if(objCheckBoxes.length) {
		// build array of store IDs
		for(var i = 0; i < objCheckBoxes.length; i++) {
			if (objCheckBoxes[i].checked) {
				storeIDList.push(objCheckBoxes[i].value);
				totalChecked++;
			}
		}
		if (totalChecked==objCheckBoxes.length){
			masterChecked = true;
		}
	// if there's only one store in our list we can't treat the checkbox object as an array
	} else if (objCheckBoxes.checked) {
		storeIDList.push(objCheckBoxes.value);
		masterChecked = true;
	} 
	document.forms[FormName].elements['masterChkBox'].checked = masterChecked;
	document.forms[FormName].elements['storeList'].value = storeIDList;
	//alert(document.forms[FormName].elements['storeList'].value);
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue) {
	if(!document.forms[FormName]) {
		return;
	}
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes) {
		return;
	}
	if(!objCheckBoxes.length) {
		objCheckBoxes.checked = CheckValue;
	} else {
		// set the check value for all check boxes
		for(var i = 0; i < objCheckBoxes.length; i++) {
			objCheckBoxes[i].checked = CheckValue;
		}
	}
	buildStoreList(FormName, FieldName, CheckValue);
}

function validatePrintForm() {
	if(storeIDList.length==0){
		alert('Please select at least one store for printing.');
		return false;
	} else if (storeIDList.length>5) {
		var agree=confirm("Are you sure you want to print information for "+storeIDList.length+" stores?");
		if (agree) {
			return true;
		} else {
			return false;
		}
	}
}

function productListCollapse(whichStore,collapsed) {
	if (collapsed) {
		var mode = 'close';
	} else {
		var mode = 'open';
	}
	// close or open all lists
	if (whichStore=='all') {
		for (var i=0; i<numStores; i++) {
			changeStyle('productTable'+i,mode);
			if(mode=='close') {
				changeStyle('hideBtn'+i,'close');
				changeStyle('showBtn'+i,'open');
			} else {
				changeStyle('showBtn'+i,'close');
				changeStyle('hideBtn'+i,'open');
			}
		}
	// close a single list
	} else {
		changeStyle('productTable'+whichStore,mode);
		if(mode=='close') {
			changeStyle('hideBtn'+whichStore,'close');
			changeStyle('showBtn'+whichStore,'open');
		} else {
			changeStyle('showBtn'+whichStore,'close');
			changeStyle('hideBtn'+whichStore,'open');
		}
	}
}
// end where to buy functions
//

//generic popup function
function popup(u, w, h, n, scroll, loc, resize, tool, menu){
	newwindow = window.open(u, n,'height='+h+',width='+w+',scrollbars='+scroll+',location='+loc+',resizable='+resize+',toolbar='+tool+',menubar='+menu+'');
	if (window.focus) {
		newwindow.focus()
	}
	return false;
}

function validate_form(){

	if (document.theform.last_name.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.theform.last_name.focus();
		return false;
	}
	if (document.theform.email_address.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.theform.email_address.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.theform.email_address.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.theform.email_address.focus();
		return false;
	}
	
	return true;
}


function validate_newsletter_form(){

	if (document.newsletter_form.first_name.value == "")
	{
		alert ("Please fill in the 'First Name'.");
		document.newsletter_form.first_name.focus();
		return false;
	}
	if (document.newsletter_form.last_name.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.newsletter_form.last_name.focus();
		return false;
	}
	if (document.newsletter_form.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.newsletter_form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.newsletter_form.email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.newsletter_form.email.focus();
		return false;
	}
	if (document.newsletter_form.children.value == "")
	{
		alert ("Please select number of 'Children'.");
		document.newsletter_form.children.focus();
		return false;
	}

	return true;
}

function validate_promo_form(){

	if (document.promo_form.first_name.value == "")
	{
		alert ("Please fill in the 'First Name'.");
		document.promo_form.first_name.focus();
		return false;
	}
	if (document.promo_form.last_name.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.promo_form.last_name.focus();
		return false;
	}
	if (document.promo_form.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.promo_form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.promo_form.email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.promo_form.email.focus();
		return false;
	}
	if (document.promo_form.address1.value == "")
	{
		alert ("Please fill in the 'Address1'.");
		document.promo_form.address1.focus();
		return false;
	}
	if (document.promo_form.city.value == "")
	{
		alert ("Please fill in the 'City'.");
		document.promo_form.city.focus();
		return false;
	}
	if (document.promo_form.state.selectedIndex == 0)
	{
		alert ("Please fill in the 'State'.");
		document.promo_form.state.focus();
		return false;
	}
	if (document.promo_form.zip.value == "")
	{
		alert ("Please fill in the 'Zip Code'.");
		document.promo_form.zip.focus();
		return false;
	}
	if (document.promo_form.phone.value == "")
	{
		alert ("Please fill in the 'Phone Number'.");
		document.promo_form.phone.focus();
		return false;
	}
	if (document.promo_form.month.selectedIndex == 0 || document.promo_form.day.selectedIndex == 0 || document.promo_form.year.selectedIndex == 0)
	{
		alert ("Please fill in the 'Birth Date'.");
		document.promo_form.month.focus();
		return false;
	}
	if (document.promo_form.agree.checked == false)
	{
		alert ("Please check 'Agree'.");
		document.promo_form.agree.focus();
		return false;
	}

	return true;
}

function validate_pinktips_form(){

	if (document.pinktips_form.first_name.value == "")
	{
		alert ("Please fill in the 'First Name'.");
		document.pinktips_form.first_name.focus();
		return false;
	}
	if (document.pinktips_form.last_name.value == "")
	{
		alert ("Please fill in the 'Last Initial'.");
		document.pinktips_form.last_name.focus();
		return false;
	}
	if (document.pinktips_form.city.value == "")
	{
		alert ("Please fill in the 'City'.");
		document.pinktips_form.city.focus();
		return false;
	}
	if (document.pinktips_form.state.selectedIndex == 0)
	{
		alert ("Please fill in the 'State'.");
		document.pinktips_form.state.focus();
		return false;
	}
	if (document.pinktips_form.comments.value == "")
	{
		alert ("Please fill in the 'Tip/Story'.");
		document.pinktips_form.comments.focus();
		return false;
	}
	if (document.pinktips_form.comments.value.length > 500)
	{
		alert ("Your 'Tip/Story' is over 500 characters.");
		document.pinktips_form.comments.focus();
		return false;
	}
	return true;
}


function validate_pink_ecard_form(){

	if (document.ecard_form.recipient_name.value == "")
	{
		alert ("Please fill in the 'Recipient\'s First Name'.");
		document.ecard_form.recipient_name.focus();
		return false;
	}
	if (document.ecard_form.recipient_email.value == "")
	{
		alert ("Please fill in the 'Recipient\'s Email Address'.");
		document.ecard_form.recipient_email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.ecard_form.recipient_email.value)){
		alert ("Please fix the 'Recipient\'s Email Address', it is in an incorrect format.");
		document.ecard_form.recipient_email.focus();
		return false;
	}
	if (document.ecard_form.sender_email.value == "")
	{
		alert ("Please fill in the 'Your Email Address'.");
		document.ecard_form.sender_email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.ecard_form.sender_email.value)){
		alert ("Please fix the 'Your Email Address', it is in an incorrect format.");
		document.ecard_form.sender_email.focus();
		return false;
	}
	if (document.ecard_form.sender_name.value == "")
	{
		alert ("Please fill in the 'Your Name'.");
		document.ecard_form.sender_name.focus();
		return false;
	}
	if (document.ecard_form.message.value == "")
	{
		alert ("Please fill in the 'Message'.");
		document.ecard_form.message.focus();
		return false;
	}
	if (document.ecard_form.message.value.length > 200)
	{
		alert ("Your 'Message' is over 200 characters.");
		document.ecard_form.message.focus();
		return false;
	}
	if (document.ecard_form.ecard.selectedIndex == 0)
	{
		alert ("Please fill in the 'eCard'.");
		document.ecard_form.ecard.focus();
		return false;
	}
	
	return true;
}

function validate_celebrity_form(){

	if (document.celebrity_form.recipient_name.value == "")
	{
		alert ("Please fill in the 'Recipient\'s First Name'.");
		document.celebrity_form.recipient_name.focus();
		return false;
	}
	if (document.celebrity_form.recipient_email.value == "")
	{
		alert ("Please fill in the 'Recipient\'s Email Address'.");
		document.celebrity_form.recipient_email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.celebrity_form.recipient_email.value)){
		alert ("Please fix the 'Recipient\'s Email Address', it is in an incorrect format.");
		document.celebrity_form.recipient_email.focus();
		return false;
	}
	if (document.celebrity_form.sender_email.value == "")
	{
		alert ("Please fill in the 'Your Email Address'.");
		document.celebrity_form.sender_email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.celebrity_form.sender_email.value)){
		alert ("Please fix the 'Your Email Address', it is in an incorrect format.");
		document.celebrity_form.sender_email.focus();
		return false;
	}
	if (document.celebrity_form.sender_name.value == "")
	{
		alert ("Please fill in the 'Your Name'.");
		document.celebrity_form.sender_name.focus();
		return false;
	}
	if (document.celebrity_form.message.value == "")
	{
		alert ("Please fill in the 'Message'.");
		document.celebrity_form.message.focus();
		return false;
	}
	if (document.celebrity_form.message.value.length > 200)
	{
		alert ("Your 'Message' is over 200 characters.");
		document.celebrity_form.message.focus();
		return false;
	}
	
	return true;
}


function validate_munchkin_form(){

	if (document.munchkin_form.munchkin_first_name.value == "")
	{
		alert ("Please fill in the Munchkin 'First Name'.");
		document.munchkin_form.munchkin_first_name.focus();
		return false;
	}
	if (document.munchkin_form.munchkin_last_name.value == "")
	{
		alert ("Please fill in the Munchkin 'Last Name'.");
		document.munchkin_form.munchkin_last_name.focus();
		return false;
	}
	if (document.munchkin_form.month.value == "")
	{
		alert ("Please select your Munchkin's Birthday 'Month'.");
		document.munchkin_form.month.focus();
		return false;
	}
	if (document.munchkin_form.day.value == "")
	{
		alert ("Please select your Munchkin's Birthday 'Day'.");
		document.munchkin_form.day.focus();
		return false;
	}
	if (document.munchkin_form.year.value == "")
	{
		alert ("Please select your Munchkin's Birthday 'Year'.");
		document.munchkin_form.year.focus();
		return false;
	}
	if (document.munchkin_form.comments.value == "")
	{
		alert ("Please fill in 'What makes your Munchkin special?'.");
		document.munchkin_form.comments.focus();
		return false;
	}
	if (document.munchkin_form.munchkin_photo.value == "")
	{
		alert ("Please select a photo of your Munchkin to upload.");
		document.munchkin_form.munchkin_photo.focus();
		return false;
	}
	if (document.munchkin_form.first_name.value == "")
	{
		alert ("Please fill in the 'First Name'.");
		document.munchkin_form.first_name.focus();
		return false;
	}
	if (document.munchkin_form.last_name.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.munchkin_form.last_name.focus();
		return false;
	}
	if (document.munchkin_form.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.munchkin_form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.munchkin_form.email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.munchkin_form.email.focus();
		return false;
	}

	return true;
}


function validate_tip_form(){

	if (document.tip_form.first_name.value == "")
	{
		alert ("Please fill in the 'First Name'.");
		document.tip_form.first_name.focus();
		return false;
	}
	if (document.tip_form.last_name.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.tip_form.last_name.focus();
		return false;
	}
	if (document.tip_form.city.value == "")
	{
		alert ("Please fill in the 'City'.");
		document.tip_form.city.focus();
		return false;
	}
	if (document.tip_form.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.tip_form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.tip_form.email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.tip_form.email.focus();
		return false;
	}
	if (document.tip_form.children.value == "")
	{
		alert ("Please select number of 'Children'.");
		document.tip_form.children.focus();
		return false;
	}
	if (document.tip_form.comment.value == "")
	{
		alert ("Please fill in the 'Comments'.");
		document.tip_form.comment.focus();
		return false;
	}
	if (document.tip_form.option1.checked == false)
	{
		alert ("Please you must agree to allow Munchkin to publish your name and tip on the website.");
		document.tip_form.option1.focus();
		return false;
	}

	return true;
}



function validate_question_form(){

	if (document.question_form.first_name.value == "")
	{
		alert ("Please fill in the 'Name'.");
		document.question_form.first_name.focus();
		return false;
	}
	if (document.question_form.email.value == "")
	{
		alert ("Please fill in the 'Email'.");
		document.question_form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.question_form.email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.question_form.email.focus();
		return false;
	}
	if (document.question_form.comment.value == "")
	{
		alert ("Please fill in the 'Question'.");
		document.question_form.comment.focus();
		return false;
	}

	return true;
}


function validate_contact_form(){

	if (document.contact_form.first_name.value == "")
	{
		alert ("Please fill in the 'Name'.");
		document.contact_form.first_name.focus();
		return false;
	}
	if (document.contact_form.last_name.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.contact_form.last_name.focus();
		return false;
	}
	if (document.contact_form.email.value == "")
	{
		alert ("Please fill in the 'Email'.");
		document.contact_form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.contact_form.email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.contact_form.email.focus();
		return false;
	}
	if (document.contact_form.phone.value == "")
	{
		alert ("Please fill in the 'Phone Number'.");
		document.contact_form.phone.focus();
		return false;
	}
	if (document.contact_form.option1.value == "")
	{
		alert ("Please select a Topic.");
		document.contact_form.option1.focus();
		return false;
	}
	if (document.contact_form.comment.value == "")
	{
		alert ("Please fill in the 'Questions/Comments'.");
		document.contact_form.comment.focus();
		return false;
	}

	return true;
}

function validate_affidavit_form(){

	if (document.munchkin_form.first_name.value == "")
	{
		alert ("Please fill in the 'First Name'.");
		document.munchkin_form.first_name.focus();
		return false;
	}
	if (document.munchkin_form.last_name.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.munchkin_form.last_name.focus();
		return false;
	}
	if (document.munchkin_form.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.munchkin_form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.munchkin_form.email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.munchkin_form.email.focus();
		return false;
	}
	if (document.munchkin_form.address1.value == "")
	{
		alert ("Please fill in the 'Address 1'.");
		document.munchkin_form.address1.focus();
		return false;
	}
	if (document.munchkin_form.city.value == "")
	{
		alert ("Please fill in the 'City'.");
		document.munchkin_form.city.focus();
		return false;
	}
	if (document.munchkin_form.state.selectedIndex == 0)
	{
		alert ("Please fill in the 'State'.");
		document.munchkin_form.state.focus();
		return false;
	}
	if (document.munchkin_form.zipcode.value == "")
	{
		alert ("Please fill in the 'Zip Code'.");
		document.munchkin_form.zipcode.focus();
		return false;
	}

	return true;
}

function isNotZip(theZip){
	// Check for correct zip code
	reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

	if (!reZip.test(theZip)) {
	  //alert("Zip Code Is Not Valid");
	  return true;
	}

	return false;
}

function validate_findRetailer_form(){
	if (isNotZip(document.findRetailer_form.mzdb_zip.value)) // || document.findRetailer_form.mzdb_zip.value == "Zip Code")
	{
		if (document.findRetailer_form.street.value == "" || document.findRetailer_form.street.value == "Street Address" || document.findRetailer_form.city.value == "" || document.findRetailer_form.city.value == "City" || document.findRetailer_form.state.value.length < 2 || document.findRetailer_form.state.value == "State")
		{
			alert ("Please fill in the 'Zip code' or fill in the 'Address', 'City' and 'State'.");
			document.findRetailer_form.mzdb_zip.focus();
			return false;
		}
		else {
			return true;
		}
	}

	return true;
}


function validate_findProduct_form(){

	if (isNotZip(document.findProduct_form.mzdb_zip.value))
	{
		alert ("Please fill in the 'Zip code'.");
		document.findProduct_form.mzdb_zip.focus();
		return false;
	}
	if (document.findProduct_form.pID.value == "")
	{
		alert ("Please select a 'Product'.");
		//document.findProduct_form.pID.focus();
		return false;
	}

	return true;
}


function validate_link_form(){

	if (document.link_form.link.value == "")
	{
		alert ("Please fill in the 'URL'.");
		document.link_form.link.focus();
		return false;
	}

	return true;
}

function validate_wtb_form(){

	if (document.wtb_inc_form.mzdb_zip.value.length < 5 || document.wtb_inc_form.mzdb_zip.value == "Zip Code")
	{
		alert ("Please fill in the 'Zip Code Field'.");
		document.wtb_inc_form.mzdb_zip.focus();
		return false;
	}

	return true;
}

function validate_testimonial_form(){

	if (document.question_form.first_name.value == "")
	{
		alert ("Please fill in the 'First Name Field'.");
		document.question_form.first_name.focus();
		return false;
	}

	return true;
}


function validate_musthave_form(){
	var form = document.getElementById("mhl-form");
	for (i=0; i<form.elements.length; i++){
		if (form.elements[i].type == "checkbox"){
			if(form.elements[i].checked == true){
				form.submit();
				return true;
			}
		}
	}
	alert ("Please select at least one product.");
	return false;
}

function validate_ecard_form(){
	var form = document.getElementById("ecard-form");
	for (i=0; i<form.elements.length; i++){
		if (form.elements[i].type == "textarea"){
			if(form.elements[i].value.length > 25){
				alert('25 characters or less, please.');
				form.elements[i].focus();
				return false;
			}
		}
	}
	return true;
}


function validate_customer_form(){

	if (document.customer_form.bill_first_name.value == "")
	{
		alert ("Please fill in the 'Billing First Name'.");
		document.customer_form.bill_first_name.focus();
		return false;
	}
	if (document.customer_form.bill_last_name.value == "")
	{
		alert ("Please fill in the 'Billing Last Name'.");
		document.customer_form.bill_last_name.focus();
		return false;
	}
	if (document.customer_form.bill_email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.customer_form.bill_email.focus();
		return false;
	}
	if (document.customer_form.bill_email_confirm.value == "")
	{
		alert ("Please fill in the 'Confirm Email Address'.");
		document.customer_form.bill_email_confirm.focus();
		return false;
	}
	if (document.customer_form.bill_email_confirm.value !== document.customer_form.bill_email.value)
	{
		alert ("The Email Addresses you entered do not match.");
		document.customer_form.bill_email_confirm.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.customer_form.bill_email.value)){
		alert ("Please fix your 'Email Address', it is in an incorrect format.");
		document.customer_form.bill_email.focus();
		return false;
	}
	if (document.customer_form.bill_address1.value == "")
	{
		alert ("Please fill in the 'Billing Address1'.");
		document.customer_form.bill_address1.focus();
		return false;
	}
	if (document.customer_form.bill_city.value == "")
	{
		alert ("Please fill in the 'Billing City'.");
		document.customer_form.bill_city.focus();
		return false;
	}
	if (document.customer_form.bill_phone.value == "")
	{
		alert ("Please fill in the 'Billing Phone Number'.");
		document.customer_form.bill_phone.focus();
		return false;
	}
	if (document.customer_form.bill_state.selectedIndex == 0)
	{
		alert ("Please fill in the 'Billing State'.");
		document.customer_form.bill_state.focus();
		return false;
	}
	if (document.customer_form.bill_zip.value == "" || isNotZip(document.customer_form.bill_zip.value))
	{
		alert ("Please correct the 'Billing Zip Code'.");
		document.customer_form.bill_zip.focus();
		return false;
	}
	if (document.customer_form.shipping_billing.checked == false)
	{
		if (document.customer_form.ship_first_name.value == "")
		{
			alert ("Please fill in the 'Shipping First Name'.");
			document.customer_form.ship_first_name.focus();
			return false;
		}
		if (document.customer_form.ship_last_name.value == "")
		{
			alert ("Please fill in the 'Shipping Last Name'.");
			document.customer_form.ship_last_name.focus();
			return false;
		}
		if (document.customer_form.ship_address1.value == "")
		{
			alert ("Please fill in the 'Shipping Address1'.");
			document.customer_form.ship_address1.focus();
			return false;
		}
		if (document.customer_form.ship_city.value == "")
		{
			alert ("Please fill in the 'Shipping City'.");
			document.customer_form.ship_city.focus();
			return false;
		}
		if (document.customer_form.ship_phone.value == "")
		{
			alert ("Please fill in the 'Shipping Phone Number'.");
			document.customer_form.ship_phone.focus();
			return false;
		}
		if (document.customer_form.ship_state.selectedIndex == 0)
		{
			alert ("Please fill in the 'Shipping State'.");
			document.customer_form.ship_state.focus();
			return false;
		}
		if (document.customer_form.ship_zip.value == "" || isNotZip(document.customer_form.ship_zip.value))
		{
			alert ("Please correct the 'Shipping Zip Code'.");
			document.customer_form.ship_zip.focus();
			return false;
		}
	}
	if (document.customer_form.password.value != "")
	{
		if (document.customer_form.password_repeat.value == "")
		{
			alert ("Please fill in the 'Repeat Password'.");
			document.customer_form.password_repeat.focus();
			return false;
		}
		if (document.customer_form.password_repeat.value !== document.customer_form.password.value)
		{
			alert ("The Passwords you entered do not match.");
			document.customer_form.password_repeat.focus();
			return false;
		}
		if (document.customer_form.password.value.length < 5)
		{
			alert ("Your password must be at least 5 characters long.");
			document.customer_form.password.focus();
			return false;
		}
	}	

	return true;
}

function validate_login_form(){

	if (document.login_form.email.value == "")
	{
		alert ("Please fill in the 'Email'.");
		document.login_form.email.focus();
		return false;
	}
	
	if (document.login_form.password.value == "")
	{
		alert ("Please fill in the 'Password'.");
		document.login_form.password.focus();
		return false;
	}

	return true;
}

function validate_password_form(){

	if (document.password_form.email.value == "")
	{
		alert ("Please fill in the 'Email'.");
		document.password_form.email.focus();
		return false;
	}

	return true;
}

function validate_payment_form(){
	
	if (document.payment_form.cc_type.selectedIndex == 0)
	{
		alert ("Please fill in the 'Card Type'.");
		document.payment_form.cc_type.focus();
		return false;
	}
	if (document.payment_form.cc_name.value == "")
	{
		alert ("Please fill in the 'Name on Card'.");
		document.payment_form.cc_name.focus();
		return false;
	}
	if (document.payment_form.cc_number.value == "")
	{
		alert ("Please fill in the 'Card Number'.");
		document.payment_form.cc_number.focus();
		return false;
	}
	if (document.payment_form.cc_month.selectedIndex == 0)
	{
		alert ("Please fill in the 'Expiration Month'.");
		document.payment_form.cc_month.focus();
		return false;
	}
	if (document.payment_form.cc_year.selectedIndex == 0)
	{
		alert ("Please fill in the 'Expiration Year'.");
		document.payment_form.cc_year.focus();
		return false;
	}
	if (document.payment_form.cc_code.value == "")
	{
		alert ("Please fill in the 'Code'.");
		document.payment_form.cc_code.focus();
		return false;
	}

	return true;
}

/*
function toggleLayer(whichLayer,mode){

	if (document.getElementById){
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
	}
	else if (document.all){
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
	}
	else if (document.layers){
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
	}

	if(mode=='close'){style2.display = "none";}
	else if(mode=='open'){style2.display = "block";}
	else{style2.display = style2.display=="none"?"block":"none";}

	alert('close!');
}
*/

function toggleLayer(layerStyle,layerClass,mode){

	if (document.getElementById){
		// this is the way the standards work
		if(layerClass){var thisLayer = document.getElementById(layerClass);}
		else{var thisLayer = document.getElementById(layerStyle).style;}
	}
	else if (document.all){
		// this is the way old msie versions work
		if(layerClass){var thisLayer = document.all[layerClass];}
		else{var thisLayer = document.all[layerStyle].style;}
	}
	else if (document.layers){
		// this is the way nn4 works
		if(layerClass){var thisLayer = document.layers[layerClass];}
		else{var thisLayer = document.layers[layerStyle].style;}
	}

	if(layerClass){
		if(mode=='close'){thisLayer.className = 'block-hide';}
		else if(mode=='open'){thisLayer.className = 'block-show';}
		else{thisLayer.className = thisLayer.className=="block-hide"?"block-show":"block-hide";}
	}
	else{
		if(mode=='close'){thisLayer.display = "none";}
		else if(mode=='open'){thisLayer.display = "block";}
		else{thisLayer.display = thisLayer.display=="block"?"none":"block";}
	}

}


function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}



function switchLayers(onLayer,offLayer) {
	
	var split_onLayers = onLayer.split(",");
	var split_offLayers = offLayer.split(",");

	var thisLayer = '';

	for(i=0; i<split_offLayers.length; i++){
		thisLayer = trim(split_offLayers[i]);
		if(thisLayer!=''){
			toggleLayer(thisLayer,'','close');
		}
	}

	for(i=0; i<split_onLayers.length; i++){
		thisLayer = trim(split_onLayers[i]);
		if(thisLayer!=''){
			toggleLayer(thisLayer,'','open');
		}
	}

}

function getMyID(layerID) {
	if (document.getElementById){
		// this is the way the standards work
		return document.getElementById(layerID);
	}
	else if (document.all){
		// this is the way old msie versions work
		return document.all[layerID];
	}
	else if (document.layers){
		// this is the way nn4 works
		return document.layers[layerID];
	}
}

function switchSelects(onLayer,targetLayer) {
	if (document.getElementById){
		// this is the way the standards work
		var newElement = document.getElementById(onLayer);
		var targetElement = document.getElementById(targetLayer);
	}
	else if (document.all){
		// this is the way old msie versions work
		var newElement = document.all[onLayer];
		var targetElement = document.all[targetLayer];
	}
	else if (document.layers){
		// this is the way nn4 works
		var newElement = document.layers[onLayer];
		var targetElement = document.layers[targetLayer];
	}

	targetElement.innerHTML = newElement.innerHTML;

}

function oldSkool_rollon(image1)
{
	
	if(document.images) {
		var imageOn = new Image();
		imageOn.src = image1;
	}

	if (document.images){
		document.images.imageOn.src = image1;
	}


}

function oldSkool_rolloff(image2)
{
	if(document.images) {
		var imageOff = new Image();
		imageOff.src = image2;
	}

	if (document.images) {
		document.images.imageOff.src = image2;
	}
}

function toggleSubs(id){
	
	var ul = document.getElementById(id);
	ul.style.display = "block";
	
}


// Peter
function ChildrenOnChange(what)
{
	totalchildren = what.options[what.selectedIndex].value;

	var innerdiv = 'newbirth_area';
	//var sHTML = document.getElementById('birth1').innerHTML;

	// clear all elements if exist
	document.getElementById('newbirth_area').innerHTML = "";

	if(totalchildren > 1) {
		for(i = 1; i < totalchildren; i++)
		{
			addElement();
		}
		//document.getElementById(innerdiv).innerHTML = sHTML;
	}
}


function openWin2(url, width, height) {
	var win;
	var windowName;
	var params;
	windowName  = "buttons";
	params = "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=0,";
	params += "menubar=0,";
	params += "scrollbars=1,";
	params += "resizable=1,";
	params += "top=50,";
	params += "left=50,";
	params += "width="+width+",";
	params += "height="+height;
	win = window.open(url, windowName, params);
}


function addElement() {
	var sHTML = document.getElementById('birth1').innerHTML;

	var ni = document.getElementById('newbirth_area');
	var numi = document.getElementById('theValue');
	var num = (document.getElementById('theValue').value -1)+ 2;
	numi.value = num;
	var newdiv = document.createElement('div');
	var divIdName = 'my'+num+'Div';
	newdiv.setAttribute('id',divIdName);
	newdiv.innerHTML = sHTML;
	ni.appendChild(newdiv);
}

function removeElement(divNum) {
	var d = document.getElementById('newbirth_area');
	var olddiv = document.getElementById(divNum);
	d.removeChild(olddiv);
}

// Peter
function reloadMotm(what)
{
	var month = what.options[what.selectedIndex].value;
	window.location='motm.php?mID=' + month;
}


function validate_poll(what) {
	for (var i = 0; i < what.answer.length; i++) {
		if (what.answer[i].checked)
		return true;
	}
	alert("Please select at least one of the 'Poll Options'.");
	return false;
}


// Peter - AJAX Poll

   var http_request = false;
   function makeRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            document.getElementById('poll_answers').innerHTML = result;
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
      var getstr = "id=" + document.getElementById("poll_id").value + "&";
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         
      }
      makeRequest('submit_poll.php', getstr);
   }

	function formToggleChecks(target, self){
		targetForm = document.getElementById(target);
		for (i=0; i<targetForm.elements.length; i++){
			if (targetForm.elements[i].type == "checkbox"){
				if(self.checked == true){
					targetForm.elements[i].checked = true;
				}else{
					targetForm.elements[i].checked = false;
				}
			}
		}
	}