	function menu_over(this_ele, this_class) {
		this_ele.className = this_class;
		return true;
	}
	
	function changeBorder(this_ele, this_class) {
		this_ele.className = this_class;
		return true;
	}
	
	function chooseTemplate(){
		window.open('shops/templates/templates_gallery/choose_template.php', "Templates", 'status,menubar=no,scrollbars=yes,resizable,width=800,height=600,screenX=100, screenY=100');
		//window.open('../admin/index.php', 'Templates', 'menubar=no,scrollbars,resizable,width=800,height=700');
	}

	function openWin(this_url, this_name) {
		this_form = document.vendor_app_form;
		if ((this_form.template.selectedIndex != 0) && (this_form.style.selectedIndex != 0)) {
 			this_url = this_url+'?template='+this_form.template.options[this_form.template.selectedIndex].value+'&style='+this_form.style.options[this_form.style.selectedIndex].value
			newWin = window.open(this_url, this_name, 'menubar=no,scrollbars,resizable,width=700,height=500');
			newWin.focus();
			return true;
		} else {
			alert('Choose a template and a style!');
			return false;
		}
	}

	function addToFavorite() { 
		if (window.external) {
		// if the browser is IE open the add favorite window
			external.AddFavorite(location.href, 'Philshop.com - Best of Philippine products')
		// Add the document location and title to the AddFavorite window
		}
		else {
		// Display and alert box for any other browser.
		alert("Sorry, your browser doesn't support this feature." + 
		 "\nPlease use the bookmark feature of your browser to save the location of this page.");
		}
	}
	

	function validateLinkForm(this_form) {
		error_msg = validateText('Store Name' , this_form.store_name.value);
		error_msg = error_msg + validateText('Location' , this_form.url.value);
		error_msg = error_msg + validateText('Store Description' , this_form.store_description.value);
		error_msg = error_msg + validateText('Your Name' , this_form.submitted_name.value);
		error_msg = error_msg + validateEmail('Your Email Address' , this_form.submitted_email.value);
		if(error_msg) {
			displayErrorMsg(error_msg);
			return false;
		} else {
			return true;
		}
	}

	function validateSignUpForm(this_form, this_type) {
		error_msg = validateText('Username', this_form.user_name.value);
		error_msg = error_msg + validateText('First Name', this_form.first_name.value);
		error_msg = error_msg + validateText('Last Name', this_form.last_name.value);
		error_msg = error_msg + validateEmail('Email', this_form.email.value);
		error_msg = error_msg + validateSelect('Birthdate (month)', this_form.birthdate_month.options[this_form.birthdate_month.selectedIndex].value, '');
		error_msg = error_msg + validateSelect('Birthdate (day)', this_form.birthdate_day.options[this_form.birthdate_day.selectedIndex].value, '');
		error_msg = error_msg + validateSelect('Birthdate (year)', this_form.birthdate_year.options[this_form.birthdate_year.selectedIndex].value, '');
		error_msg = error_msg + validateSelect('Sex', this_form.sex.options[this_form.sex.selectedIndex].value, '');
		error_msg = error_msg + validateText('Address 1', this_form.address_1.value);
		error_msg = error_msg + validateSelect('Country', this_form.country.options[this_form.country.selectedIndex].value, '');
		if(this_type == 'add') {
			error_msg = error_msg + validateText('Password', this_form.password.value);
			error_msg = error_msg + validateText('Confirm Password', this_form.password_confirm.value);
			error_msg = error_msg + validatePassword(this_form.password.value, this_form.password_confirm.value);
		} else if(this_type == 'edit' && (this_form.password.value != '' || this_form.password_confirm.value != '')) {
			error_msg = error_msg + validatePassword(this_form.password.value, this_form.password_confirm.value);
		}
		if(error_msg) {
			displayErrorMsg(error_msg);
			return false;
		} else {
			return true;
		}
	}

	function validateVendorForm(this_form, type) {
		error_msg = ''; 
		error_msg = error_msg + validateText('Username', this_form.user_name.value);
		error_msg = error_msg + validateText('Store Name', this_form.store_name.value);
		error_msg = error_msg + validateText('Suggested URL', this_form.url.value);
		error_msg = error_msg + validateText('Store Type', this_form.store_type.options[this_form.store_type.selectedIndex].value);
		error_msg = error_msg + validateText('Contact Person (First Name)', this_form.contact_fname.value);
		error_msg = error_msg + validateText('Contact Person (Last Name)', this_form.contact_lname.value);
		error_msg = error_msg + validateEmail('Contact Person (Email Address)', this_form.contact_email.value);
		error_msg = error_msg + validateText('Address 1', this_form.address_1.value);
		error_msg = error_msg + validateText('City', this_form.city.value);
		error_msg = error_msg + validateText('Country', this_form.country.options[this_form.country.selectedIndex].value);
		error_msg = error_msg + validateText('Zip', this_form.zip.value);
		error_msg = error_msg + validateText('Phone 1', this_form.phone_1.value);
		if (type == 'add') {
			error_msg = error_msg + validateText('Password', this_form.password.value);
			error_msg = error_msg + validateText('Confirm Password', this_form.password_confirm.value);
		} else if (type == 'edit' && (this_form.password.value != '' && this_form.password_confirm.value != '' )) {
			error_msg = error_msg + validatePassword(this_form.password.value, this_form.password_confirm.value);
		}
		if(error_msg != '') {
			displayErrorMsg(error_msg);
			return false;
		} else {
			return true;
		}
 	}

	function validateLoginForm(this_form) {
		error_msg = validateText('Username', this_form.user_name.value);
		error_msg = error_msg + validateText('Password', this_form.password.value);
		if(error_msg) {
			displayErrorMsg(error_msg);
			return false;
		} else {
			return true;
		}
	}	
	
	function validateTellaFriendForm(this_form){
		
		error_msg = "";
		if (this_form.friendemail1.value != '') error_msg = error_msg + validateEmail('Friend\'s Email 1', this_form.friendemail1.value);
		if (this_form.friendemail2.value != '') error_msg = error_msg + validateEmail('Friend\'s Email 2', this_form.friendemail2.value);
		if (this_form.friendemail3.value != '') error_msg = error_msg + validateEmail('Friend\'s Email 3', this_form.friendemail3.value);
		if (this_form.friendemail1.value == '' && this_form.friendemail2.value == '' && this_form.friendemail3.value == '')
		{
			error_msg = error_msg + "Please enter at least 1 email \n";
		}
		error_msg = error_msg + validateEmail('Your Email', this_form.youremail.value);
		error_msg = error_msg + validateText('Your Name', this_form.name.value);
		if(error_msg) {
			displayErrorMsg(error_msg);
			return false;
		} else {
			return true;
		}

	}
	
	//form validation functions
	var re = new RegExp("#([0-9a-fA-F]){6}", "i");
	
	function validateText(this_name, this_value) {
		if(this_value == '' || this_value.search(/^\W+$/) != -1) {
			return this_name+'\n';
		} else {
			return '';
		}
	}
	function validateSelect(this_name, this_value, this_error_choice) {
		if(this_value == this_error_choice) {
			return this_name+'\n';
		} else {
			return '';
		}
	}
	function validateEmail(this_name, this_value) {
		var re = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		if (this_value == '') {
			return this_name+'\n';
		} else if (!re.test(this_value)) {
			return 'Invalid email address on '+this_name+'\n';
		} else {
			return '';
		}
	}	
	function validatePassword(this_passwd, this_cpasswd) {
		var msg='';
		if (this_passwd != this_cpasswd) {
	        msg = 'Password doesn\'t match \n';
		}
		return msg;
	}
	function displayErrorMsg(this_error_msg) {
		this_alert_error_msg = 'Error on the following fields: \n'+this_error_msg;
		alert(this_alert_error_msg);
		return true;
	}

