function login_validation(theform){
	var useremail;
	var email = theform.Email;
	var pass = theform.Password;

	useremail=isEmail(email.value);

	if (useremail==false) {
		alert("Please enter your proper username/email address.");
		email.focus();
		return false;
	}

	if (pass.value=="") {
		alert("Please enter your password.");
		pass.focus();
		return false;
	}
}

function storeregistration(theform){
	var invalid = " "; // Space is an invalid character
	var useremail;
	var email = theform.UserName;
	var pwd1 = theform.Password1;
	var pwd2 = theform.Password2;
	var store = theform.StoreName;
	var fname = theform.FirstName;
	var lname = theform.LastName;
	var address = theform.Address1;
	var city = theform.City;
	var state = theform.State;
	var zip = theform.Zip;
	var country = theform.Country;
	var opttheme = valButton(theform.optTheme)

	useremail=isEmail(email.value);
	
	if (useremail==false) {
		alert("Please enter your proper email address eg, (johndoe@aol.com).");
		email.focus();
		return false;
	}

	if (pwd1.value==""){
		alert("Password cannot be blank.");
		pwd1.focus();
		return false;
	}

	if (pwd2.value==""){
		alert("Password confirmation cannot be blank.");
		pwd2.focus();
		return false;
	}

	if (pwd1.value!=pwd2.value) {
		alert("Password and password confirmation doesnt matched.");
        pwd1.focus();
		return false;
	}

	if (store.value==""){
		alert("Store name cannot be blank.");
		store.focus();
		return false;
	}
	else if(store.value.indexOf(invalid) > -1){
		alert("Spaces are not allowed in store name.");
		store.focus();
		return false;
	}

	if (fname.value==""){
		alert("FirstName cannot be blank.");
		fname.focus();
		return false;
	}

	if (lname.value==""){
		alert("LastName cannot be blank.");
		lname.focus();
		return false;
	}

	if (address.value==""){
		alert("Address cannot be blank.");
		address.focus();
		return false;
	}

	if (city.value==""){
		alert("City cannot be blank.");
		city.focus();
		return false;
	}

	if (state.value==""){
		alert("State cannot be blank.");
		state.focus();
		return false;
	}

	if (zip.value==""){
		alert("Zip code cannot be blank.");
		zip.focus();
		return false;
	}

	if (opttheme==null){
		alert("Please select your preferred store theme.");
		return false;
	}
}

function switchImage(imgURL){
	if (imgURL.indexOf("/_attachments/") > -1){
		document.getElementById("imgPic").src=imgURL;
		///document.getElementById("zoom").href=imgURL;
		document.getElementById("imgZoom").href=imgURL;
		//alert(document.getElementById("imgzoom").href);
		//alert(document.getElementById("imgPic").src);
	}
	else{
		//document.getElementById("imgPic").src="images/large/"+imgURL.replace("tiny", "large");
		document.getElementById("imgPic").src=imgURL.replace("tiny", "large");
		imgURL = imgURL.replace("_img", "");
		//document.getElementById("zoom").href="images/large/"+imgURL.replace("_tiny", "");
		///document.getElementById("zoom").href=imgURL.replace("_tiny", "");
		//document.getElementById("imgzoom").href="images/large/"+imgURL.replace("_tiny", "");
		document.getElementById("imgZoom").href=imgURL.replace("_tiny", "");
		//alert(document.getElementById("imgzoom").href);
		//alert(document.getElementById("imgPic").src+"\n\n"+imgURL);
	}
}

//Sets new color in rows,buttons in Mouse Over/Mouse Out event========
function ChangeButtonColor(tID, mBGColor, mFColor){
    tID.style.background = mBGColor;
    tID.style.color = mFColor;
}

function RestoreButtonColor(tID, mBGColor, mFColor){
    tID.style.background = mBGColor;
    tID.style.color = mFColor;
}

function ChangeRowColor(tID, mBGColor, mFColor){
    document.getElementById(tID).style.background = mBGColor;
    document.getElementById(tID).style.color = mFColor;
}

function RestoreRowColor(tID, mBGColor, mFColor){
    document.getElementById(tID).style.background = mBGColor;
    document.getElementById(tID).style.color = mFColor;
}
//End of set new color in rows,buttons in Mouse Over/Mouse Out event===

//Universal delete confirmation box//
function doDelete(msg, loc){
	var Selection = confirm(msg);
	if (Selection)
		if (loc != ""){
			window.location.href = loc;
			return true;
		}
	else
		return false;
}

function validatezipcode(theform){
	var country = theform.Country;
	var zip = theform.PostalCode;

	//if (country.selectedIndex==0){
	//	alert("Please select your preferred shipping country from the list.");
	//	country.focus();
	//	return false;
	//}

	if (zip.value==""){
		alert("Recipient's zip code cannot be blank.");
		zip.focus();
		return false;
	}
}

function validatepromotion(theform){
	var promocode = theform.PromotionCode;

	if (promocode.value==""){
		alert("Coupon code cannot be blank.");
		promocode.focus();
		return false;
	}
}
