function openWin(url, width, height) {
	var win;
	var windowName;
	var params;
	windowName  = "buttons";
	params = "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=1,";
	params += "menubar=0,";
	params += "scrollbars=1,";
	params += "resizable=0,";
	params += "top=50,";
	params += "left=50,";
	params += "width="+width+",";
	params += "height="+height;
	win = window.open(url, windowName, params);
}

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 popSend(url, width, height, reqVars) {
	var win;
	var windowName;
	var params;
	windowName  = "buttons";
	params = "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=1,";
	params += "menubar=0,";
	params += "scrollbars=1,";
	params += "resizable=0,";
	params += "top=50,";
	params += "left=50,";
	params += "width="+width+",";
	params += "height="+height;
	win = window.open(url+"?"+reqVars, windowName, params);
}

function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display=="block"?"none":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display=="block"?"none":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display=="block"?"none":"block";
	}
}


//
// store functions
//



var selected;

function selectRowEffect(object, buttonSelect) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;

// one button is not an array
  if (document.checkout_address.shipping[0]) {
    document.checkout_address.shipping[buttonSelect].checked=true;
  } else {
    document.checkout_address.shipping.checked=true;
  }
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}


function check_form_optional(form_name) {
  var form = form_name;

  var firstname = form.elements['firstname'].value;
  var lastname = form.elements['lastname'].value;
  var street_address = form.elements['street_address'].value;

  if (firstname == '' && lastname == '' && street_address == '') {
    return true;
  } else {
    return check_form(form_name);
  }
}


function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false
	 }

	 return true					
}



function check_community_form() {

  if(document.community.firstname.value == ''){alert('First Name is a required field');document.community.firstname.focus();return false;}
  if(document.community.lastname.value == ''){alert('Last Name is a required field');document.community.lastname.focus();return false;}
  if(echeck(document.community.eemail.value)==false){alert('Email Address is not correct');document.community.eemail.focus();return false;}
  if(document.community.city.value == ''){alert('City is a required field');document.community.city.focus();return false;}
  if(document.community.postal_code.value == ''){alert('Zip Code is a required field');document.community.postal_code.focus();return false;}
  if(document.community.state.value == ''){alert('State is a required field');document.community.state.focus();return false;}

  return true;

}


function returnTrue() {

	return true;

}



function checkFormSend212(url, obj) {

	if (document.promo_form.firstname.value == "") {
	alert("Please enter your first name.");
	document.promo_form.firstname.focus();
	return false; 	
	}	
	
	if (document.promo_form.lastname.value == "") {
	alert("Please enter your last name.");
	document.promo_form.lastname.focus();
	return false; 	
	}
	
	if (document.promo_form.salonname.value == "") {
	alert("Please enter your salon name.");
	document.promo_form.salonname.focus();
	return false;
	}

	if(echeck(document.promo_form.eemail.value)==false){
	alert('Email Address is not correct');
	document.promo_form.eemail.focus();
	return false;
	}

	if (document.promo_form.address.value == "") {
	alert("Please enter your address.");
	document.promo_form.address.focus();
	return false;
	}
	
	if (document.promo_form.city.value == "") {
	alert("Please enter your city.");
	document.promo_form.city.focus();
	return false;
	}

	if (document.promo_form.postal_code.value == "") {
	alert("Please enter your zip code.");
	document.promo_form.postal_code.focus();
	return false;
	}	

	if (document.promo_form.state.value == "") {
	alert("Please enter your state.");
	document.promo_form.state.focus();
	return false;
	}

    var ref = '';
    for(i=0;i<document.promo_form.elements.length;i++){
     if(document.promo_form.elements[i].name == 'referer' && document.promo_form.elements[i].checked){
		ref += document.promo_form.elements[i].value;
	 }
	}
	if (document.promo_form.other_text.value != "") {
		ref += ': ' + document.promo_form.other_text.value;
	}

	document.promo_form.referers.value = ref;

	/* use loop below to get the listbox elements
	var ele = '';
    for(i=0;i<document.promo_form.elements.length;i++){
     ele += '[' + i + ']' + document.promo_form.elements[i].name + '\n';
    }
    alert(ele);
	*/

	/* this is the AJAX section
	var ajaxObj = new XMLHTTP(url);
	
	// lets turn on debugging so we can see what we're sending and receiving
	ajaxObj.debug=1;

	// get all of the form variables
	var form_vars = ajaxObj.getForm(obj);
	
	ajaxObj.call(form_vars, respComplete);
	*/

	return true;
	
}



function respComplete(resp) {
	
	alert('Done!');
	document.getElementById('ajax-results').innerHTML = resp;
	return false;
}




function validate_accesscodeform()
{
	if (document.form.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form.email.value))
	{
		alert ("Please correct your 'Email Address', it is in an incorrect format.");
		document.form.email.focus();
		return false;
	}
	if (document.form.accesscode.value == "")
	{
		alert ("Please fill in the 'Access Code'.");
		document.form.accesscode.focus();
		return false;
	}

	document.form.submit();
	return true;
}


function validate_signupform()
{
	if (document.form.firstname.value == "")
	{
		alert ("Please fill in the 'First Name'.");
		document.form.firstname.focus();
		return false;
	}
	if (document.form.lastname.value == "")
	{
		alert ("Please fill in the 'Last Name'.");
		document.form.lastname.focus();
		return false;
	}
	if (document.form.publication.value == "")
	{
		alert ("Please fill in the 'Publication/venue'.");
		document.form.publication.focus();
		return false;
	}
	if (document.form.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.form.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form.email.value))
	{
		alert ("Please correct your 'Email Address', it is in an incorrect format.");
		document.form.email.focus();
		return false;
	}

	document.form.submit();
	return true;
}


function validate_signupreturningform()
{
	if (document.returningform.email.value == "")
	{
		alert ("Please fill in the 'Email Address'.");
		document.returningform.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.returningform.email.value))
	{
		alert ("Please correct your 'Email Address', it is in an incorrect format.");
		document.returningform.email.focus();
		return false;
	}

	document.returningform.submit();
	return true;
}