function openWindow(id){
	window.open("download.php?id="+id);	
}
function validate_forgot_passwordfrm() {
		if (document.forgot_passwordfrm.username.value=='' && document.forgot_passwordfrm.email.value=='') {
			alert("Please Enter Username Or Email");
			document.forgot_passwordfrm.username.focus();
			return false;
		}
}
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
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){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
}
function validate_upgradefrm(){
	if (document.upgradefrm.plan.value=='') {
		alert("Please Select Memberhip Plan");
		document.upgradefrm.plan.focus();
		return false;
	}
	if (document.upgradefrm.period.value=='') {
		alert("Please Select Plan Period");
		document.upgradefrm.period.focus();
		return false;
	}
}
function validate_registerfrm(usertype){
	
	if (document.registerfrm.username.value=='') {
		alert("Please Enter Username");
		document.registerfrm.username.focus();
		return false;
	}
	if (document.registerfrm.password.value=='') {
		alert("Please Enter Password");
		document.registerfrm.password.focus();
		return false;
	}
	if (document.registerfrm.password.value != document.registerfrm.confirm_password.value) {
		alert("Confirm Password and Password does not match");
		document.registerfrm.confirm_password.focus();
		return false;
	}
	var f = document.registerfrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if (document.registerfrm.firstname.value=='') {
		alert("Please Enter Firstname");
		document.registerfrm.firstname.focus();
		return false;
	}
	if (document.registerfrm.lastname.value=='') {
		alert("Please Enter Lastname");
		document.registerfrm.lastname.focus();
		return false;
	}
	if (document.registerfrm.address.value=='') {
		alert("Please Enter Address");
		document.registerfrm.address.focus();
		return false;
	}
	if (document.registerfrm.city.value=='') {
		alert("Please Enter City");
		document.registerfrm.city.focus();
		return false;
	}
	if (document.registerfrm.state.value=='') {
		alert("Please Enter County");
		document.registerfrm.state.focus();
		return false;
	}
	if (document.registerfrm.country.value=='') {
		alert("Please Select Country");
		document.registerfrm.country.focus();
		return false;
	}
	if (document.registerfrm.zipcode.value=='') {
		alert("Please Enter Postcode");
		document.registerfrm.zipcode.focus();
		return false;
	}
	if ( usertype == "artist" ) {
		if (document.registerfrm.plan.value=='') {
			alert("Please Select Memberhip Plan");
			document.registerfrm.plan.focus();
			return false;
		}
		if (document.registerfrm.period.value=='') {
			alert("Please Select Plan Period");
			document.registerfrm.period.focus();
			return false;
		}
	}
	if (document.registerfrm.confirm_text.value=='') {
		alert("Please Enter Text shown in image");
		document.registerfrm.confirm_text.focus();
		return false;
	}
}
function validate_edit_profile_frm(){
	var f = document.edit_profile_frm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if (document.edit_profile_frm.firstname.value=='') {
		alert("Please Enter Firstname");
		document.edit_profile_frm.firstname.focus();
		return false;
	}
	if (document.edit_profile_frm.lastname.value=='') {
		alert("Please Enter Lastname");
		document.edit_profile_frm.lastname.focus();
		return false;
	}
	if (document.edit_profile_frm.address.value=='') {
		alert("Please Enter Address");
		document.edit_profile_frm.address.focus();
		return false;
	}
	if (document.edit_profile_frm.city.value=='') {
		alert("Please Enter City");
		document.edit_profile_frm.city.focus();
		return false;
	}
	if (document.edit_profile_frm.state.value=='') {
		alert("Please Enter County");
		document.edit_profile_frm.state.focus();
		return false;
	}
	if (document.edit_profile_frm.country.value=='') {
		alert("Please Select Country");
		document.edit_profile_frm.country.focus();
		return false;
	}
	if (document.edit_profile_frm.zipcode.value=='') {
		alert("Please Enter Postcode");
		document.edit_profile_frm.zipcode.focus();
		return false;
	}
	if (document.edit_profile_frm.plan.value=='') {
		alert("Please Select Memberhip Plan");
		document.edit_profile_frm.plan.focus();
		return false;
	}
	if (document.edit_profile_frm.period.value=='') {
		alert("Please Select Plan Period");
		document.edit_profile_frm.period.focus();
		return false;
	}
}
function validate_contactfrm() {
	if (document.contactfrm.name.value=='') {
		alert("Please Enter Name");
		document.contactfrm.name.focus();
		return false;
	}	
	var f = document.contactfrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if (document.contactfrm.subject.value=='') {
		alert("Please Enter Subject");
		document.contactfrm.subject.focus();
		return false;
	}	
	if (document.contactfrm.message.value=='') {
		alert("Please Enter Message");
		document.contactfrm.message.focus();
		return false;
	}	
}
function validate_loginfrm() {
	if (document.loginfrm.username.value=='') {
		alert("Please Enter Username");
		document.loginfrm.username.focus();
		return false;
	}
	if (document.loginfrm.password.value=='') {
		alert("Please Enter Password");
		document.loginfrm.password.focus();
		return false;
	}
}
function validate_top_loginfrm() {
	if (document.loginfrm.login_username.value=='') {
		alert("Please Enter Username");
		document.loginfrm.login_username.focus();
		return false;
	}
	if (document.loginfrm.login_password.value=='') {
		alert("Please Enter Password");
		document.loginfrm.login_password.focus();
		return false;
	}
}
function validate_change_passwordfrm(){
	if (document.change_passwordfrm.old_password.value=='') {
		alert("Please Enter Old Password");
		document.change_passwordfrm.old_password.focus();
		return false;
	}
	if (document.change_passwordfrm.new_password.value=='') {
		alert("Please Enter New Password");
		document.change_passwordfrm.new_password.focus();
		return false;
	}
	if (document.change_passwordfrm.new_password.value != document.change_passwordfrm.confirm_new_password.value) {
		alert("Confirm New Password and Confirm New Password does not match");
		document.change_passwordfrm.confirm_new_password.focus();
		return false;
	}
}
function validate_upload_photo_frm(){
	if (document.upload_photo_frm.image.value=='') {
		alert("Please Select Photo to Upload");
		document.upload_photo_frm.image.focus();
		return false;
	}
}
function validate_art_frm() {
	if (document.art_frm.art_image.value=='') {
		alert("Please Select Photo");
		document.art_frm.art_image.focus();
		return false;
	}
	if (document.art_frm.title.value=='') {
		alert("Please Enter Title");
		document.art_frm.title.focus();
		return false;
	}
	if (document.art_frm.category.value=='') {
		alert("Please Select Category");
		document.art_frm.category.focus();
		return false;
	}
	if (document.art_frm.price.value=='') {
		alert("Please Enter Price");
		document.art_frm.price.focus();
		return false;
	}
}
function validate_edit_art_frm() {
	if (document.art_frm.title.value=='') {
		alert("Please Enter Title");
		document.art_frm.title.focus();
		return false;
	}
	if (document.art_frm.category.value=='') {
		alert("Please Select Category");
		document.art_frm.category.focus();
		return false;
	}
	if (document.art_frm.price.value=='') {
		alert("Please Enter Price");
		document.art_frm.price.focus();
		return false;
	}
}
function validate_contact_artist_frm() {
	if (document.contact_artist_frm.firstname.value=='') {
		alert("Please Enter First Name");
		document.contact_artist_frm.firstname.focus();
		return false;
	}
	if (document.contact_artist_frm.lastname.value=='') {
		alert("Please Enter Last Name");
		document.contact_artist_frm.lastname.focus();
		return false;
	}
	var f = document.contact_artist_frm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if (document.contact_artist_frm.telephone.value=='') {
		alert("Please Enter Telephone Number");
		document.contact_artist_frm.telephone.focus();
		return false;
	}	
	if (document.contact_artist_frm.art_id.value=='') {
		alert("Please Select Image");
		document.contact_artist_frm.art_id.focus();
		return false;
	}
	if (document.contact_artist_frm.comment.value=='') {
		alert("Please Enter Enquiry/Comments");
		document.contact_artist_frm.comment.focus();
		return false;
	}
	if (document.contact_artist_frm.confirm_text.value=='') {
		alert("Please Enter Text shown in image");
		document.contact_artist_frm.confirm_text.focus();
		return false;
	}
}