function deleteItem(location) {
	var msg = "\nWARNING! This cannot be undone!\n\n";
	if (confirm(msg)) {
		self.location.href=location;
	}else{
		return false;
	}
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}


function check_email_only(f) { // f is the form (passed using the this keyword)
	//alert("yes");
	// check the first email address ( the exclamation means "not" )
	if(!check_email(f.email.value)){
		alert("Invalid email detected");
		// make sure the form is not submitted
		return false;
	} else {
		return true;
	}
}


function check_user_form1(form) { // f is the form (passed using the this keyword)

	if (form.fname.value == "") {
		alert("You need to enter a first name");
		form.fname.focus();
		return false;
		
	}else if (form.lname.value == "") {
		alert("You need to enter a last name");
		form.lname.focus();
		return false;
		
	}else if (form.address1.value == "") {
		alert("You need to enter a street address");
		form.address1.focus();
		return false;
	
	}else if (form.city.value == "") {
		alert("You need to enter a city or town");
		form.city.focus();
		return false;
		
	}else if (form.zipcode.value == "") {
		alert("You need to enter a zip code or postal code");
		form.zipcode.focus();
		return false;

	}else if (form.country.options[form.country.selectedIndex].value == "") {
		alert("You need to enter a country");
		form.country.focus();
		return false;
	
	}else if ((form.day_phone1.value == "")||(form.day_phone2.value == "")||(form.day_phone3.value == "")) {
		alert("You need to enter a phone number");
		form.zipcode.focus();
		return false;
		
	} else if(!check_email(form.email.value)){
		alert("Invalid email, please enter again");
		form.email.focus(); 
		return false;
		
	}else if ((form.amount.value == "")&&(form.classes_id_amount.options[form.classes_id_amount.selectedIndex].value == 0)) {
		alert("You need to enter an amount");
		form.amount.focus();
		return false;
		
	} else {
		return true;
	}	

}


function check_user_form2(form) { // f is the form (passed using the this keyword)
	if (form.card_number.value == "") {
		alert("You need to enter a credit card");
		form.card_number.focus();
		return false;
		
	}else if (form.security_code.value == "") {
		alert("You need to enter a security code");
		form.security_code.focus();
		return false;
		
	}else if (form.bill_fname.value == "") {
		alert("You need to enter a first name");
		form.bill_fname.focus();
		return false;
		
	}else if (form.bill_lname.value == "") {
		alert("You need to enter a last name");
		form.bill_lname.focus();
		return false;
		
	}else if (form.bill_address1.value == "") {
		alert("You need to enter a street address");
		form.bill_address1.focus();
		return false;
	
	}else if (form.bill_city.value == "") {
		alert("You need to enter a city or town");
		form.city.focus();
		return false;
		
	}else if (form.bill_zipcode.value == "") {
		alert("You need to enter a zip code or postal code");
		form.zipcode.focus();
		return false;

	}else if (form.bill_country.options[form.bill_country.selectedIndex].value == "") {
		alert("You need to enter a country");
		form.country.focus();
		return false;
		
	} else if(!check_email(form.bill_email.value)){
		alert("Invalid email, please enter again");
		form.bill_email.focus(); 
		return false;
		
	} else {
		return true;
	}	

}



function check_ecard(form) { // f is the form (passed using the this keyword)
	if (form.name.value == "") {
		alert("You need to enter your name");
		form.name.focus();
		return false;
		
	} else if(!check_email(form.email.value)){
		alert("Invalid email, please enter again");
		form.email.focus(); 
		return false;
		
	}else if (form.sname.value == "") {
		alert("You need to enter the recipient's name");
		form.lname.focus();
		return false;
	
	} else if(!check_email(form.semail.value)){
		alert("Invalid email, please enter again");
		form.semail.focus(); 
		return false;
	} else {
		return true;
	}	

}
// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place

function numbersonly(myfield, e, dec){
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
	    (key==9) || (key==13) || (key==27) )
	   return true;
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	
	else
	   return false;
}

var downStrokeField;

function autojump(fieldName,nextFieldName,fakeMaxLength) {
	var myForm=document.forms[document.forms.length - 1];
	var myField=myForm.elements[fieldName];
	myField.nextField=myForm.elements[nextFieldName];
	
	if (myField.maxLength == null)
	   myField.maxLength=fakeMaxLength;
	
	myField.onkeydown=autojump_keyDown;
	myField.onkeyup=autojump_keyUp;
}

function autojump_keyDown() {
	this.beforeLength=this.value.length;
	downStrokeField=this;
}

function autojump_keyUp(){
	if (
	   (this == downStrokeField) && 
	   (this.value.length > this.beforeLength) && 
	   (this.value.length >= this.maxLength)
	   )
	   this.nextField.focus();
	downStrokeField=null;
}


