	
	function signInFormSubmit(the_element) {
		document.getElementById("home_sign_in_messages").innerHTML = '<br /><br /><img src="/css/img/loading.gif" /><br /><br /><span style="color:white">Please refresh your browser if this process takes more than a few minutes.</span>';
		$('#home_listen_expanded').slideUp(500, function() {
			setTimeout(function() {
				$('#home_artists_container').fadeOut(1000);
				$('#home_more_container').fadeOut(1000);
				$('#home_sign_in_messages').slideDown(500);
				},200);
				
			
			
			username = document.getElementById("si_username").value;
			password = document.getElementById("si_password").value;
						
			xmlHttp=GetXmlHttpObject();
			var url="/ajax/signin.asp";
			url=url+"?sid="+Math.random();
			url=url+"&susername="+username;
			url=url+"&spassword="+password;

			xmlHttp.onreadystatechange=function() {
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
					if (xmlHttp.responseText == "[FAIL]") {
            apprise("Incorrect log in - either your email address or password has been entered incorrectly");
						document.getElementById("home_sign_in_messages").innerHTML = "<font color='white'>Login failure</font><br /><br />"
						setTimeout(function() {
							$('#home_sign_in_messages').fadeOut(3000);
							//$('#home_sign_in_messages').slideUp(1000);
							$('#home_listen_expanded').slideDown(1000);
						},400);
					} else if (xmlHttp.responseText == "[PREF_REQUIRED]") {
						window.location = "/preferences.asp?update_pref=1";
					} else if (xmlHttp.responseText == "[SUCCESS]") {
            //if ($.browser.safari)
            //  window.location = "/player2.asp?safari=1";
            //else
						window.location = "/player2.asp";
					} else {
						window.location = "/signout.asp";
					}
				}
			}
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			
			
			
		});
		
	}
	
	function signUpFormSubmit(the_element) {


		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(document.getElementById("su_username").value)) {
			alert("please enter a valid email address")
		} else if (!/^[^'"]{4,}$/.test(document.getElementById("su_password").value)) {
			alert("please enter a valid password (4 or more characters and no quotes)")
		} else if (document.getElementById("su_password").value != document.getElementById("su_cpassword").value) {
			alert("passwords do not match")
    } else if (!$('#su_toc').attr('checked')) {
      alert('You must accept the Terms and Conditions before signing up.');
		} else {
	
			document.getElementById("home_sign_in_messages").innerHTML = '<br /><br /><img src="/css/img/loading.gif" /><br /><br /><span style="color:white">Please refresh your browser if this process takes more than a few minutes.</span>';
			$('#signup_container').slideUp(500, function() {
				setTimeout(function() {
					$('#home_sign_in_messages').slideDown(500);
					},200);
					
				username = document.getElementById("su_username").value;
				password = document.getElementById("su_password").value;
				cpassword = document.getElementById("su_cpassword").value;
							
				xmlHttp=GetXmlHttpObject();
				var url="/ajax/signup.asp";
				url=url+"?sid="+Math.random();
				url=url+"&susername="+username;
				url=url+"&spassword="+password;
				url=url+"&scpassword="+cpassword;

				xmlHttp.onreadystatechange=function() {
					if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
						if (xmlHttp.responseText == "[DUPLICATE]") {
							document.getElementById("home_sign_in_messages").innerHTML = "Signup failure - Email already in use<br /><br />"
							setTimeout(function() {
								//$('#home_sign_in_messages').slideUp(1000);
								$('#signup_container').slideDown(1000);
							},400);

						} else if (xmlHttp.responseText == "[SUCCESS]") {
							window.location = "/preferences.asp";
						} else {
							document.getElementById("home_sign_in_messages").innerHTML = xmlHttp.responseText;
						}
					}
				}
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);
				
				
				
			});
		}
	}
	
	function signUpArtistFormSubmit(the_element) {
    var username     = $('#su_username'),
        password     = $('#su_password'),
        confPassword = $('#su_cpassword'),
        bandName     = $('#cu_band_name'),
        address1     = $('#cu_address1'),
        address2     = $('#cu_address2'),
        address3     = $('#cu_address3'),
        postCode     = $('#cu_post_code'),
        county       = $('#cu_county'),
        country      = $('#cu_country'),
        promoCode    = $('#cu_promo_code'),
        genre1       = $('#genre1'),
        genre2       = $('#genre2'),
        genre3       = $('#genre3');

    if (!$('#su_toc').attr('checked')) {
      alert('You must accept the Terms and Conditions before signing up.');
    } else if (!genre1.val()) {
      alert("You must select at least one genre."); 
    } else if (genre1.val() == genre2.val() || genre1.val() == genre3.val()) {
      alert("Each of the three genres should be unique."); 
    } else if (genre2.val() && (genre2.val == genre1.val() || genre2.val() == genre3.val()))  {
      alert("Each of the three genres should be unique.");
    } else if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(username.val())) {
			alert("Please enter a valid email address");
		} else if (!/^[^'"]{4,}$/.test(password.val())) {
			alert("Please enter a valid password (4 or more characters and no quotes)");
    } else if (password.val() != confPassword.val()) {
      alert("Passwords do not match.");
    } else if (!bandName.val()) {
      alert("Please enter an band name.");
    } else if (!address1.val()) {
      alert("Please enter an address.");
    } else if (!postCode.val()) {
      alert("Please enter an post code.");
    } else if (!county.val()) {
      alert("Please enter an county."); 
    } else if (!country.val()) {
      alert("Please enter an country.");
    } else {
      $("home_sign_in_messages").html('<br /><br /><img src="/css/img/loading.gif" /><br /><br /><span style="color:white">Please refresh your browser if this process takes more than a few minutes.</span>');
      $('#signup_container').slideUp(500, function () {
        setTimeout(function () {
          $('#home_sign_in_messages').slideDown(500);
        }, 200);

        var url = "/ajax/signupArtist.asp";
        url += "?id=" + (new Date()).getTime();
        url += "&username=" + username.val();
        url += "&password=" + password.val();
        url += "&bandname=" + bandName.val();
        url += "&address1=" + address1.val();
        url += "&address2=" + address2.val();
        url += "&address3=" + address3.val();
        url += "&postcode=" + postCode.val();
        url += "&promocode=" + promoCode.val();
        url += "&county=" + county.val();
        url += "&country=" + country.val();
        url += "&genre1=" + genre1.val();
        url += "&genre2=" + genre2.val();
        url += "&genre3=" + genre3.val();

        $.get(url, function (res) {
          if (res == "[DUPLICATE]") {
            $('#home_sign_in_messages').html("Signup failure - Email already in use<br /><br >");
            setTimeout(function () {
              $('#signup_container').slideDown(1000);
            }, 400);
          } else if (res == "[SUCCESS]") {
            window.location = "/artists/home.asp";
          } else {
            $("#home_sign_in_messages").html(res);
          }
        });
      });
    }
/*

		if (document.getElementById("su_username").value == "") {
			alert("please enter an email address")
		} else if (document.getElementById("su_password").value == "") {
			alert("please enter a password")
		} else if (document.getElementById("su_password").value != document.getElementById("su_cpassword").value) {
			alert("passwords do not match")
		} else {
	
			document.getElementById("home_sign_in_messages").innerHTML = '<img src="/images/player/loading.gif" /><br /><br />';
			$('#signup_container').slideUp(500, function() {
				setTimeout(function() {
					$('#home_sign_in_messages').slideDown(500);
					},200);
					
				
				
				username = document.getElementById("su_username").value;
				password = document.getElementById("su_password").value;
				cpassword = document.getElementById("su_cpassword").value;
							
				xmlHttp=GetXmlHttpObject();
				var url="/ajax/signupArtist.asp";
				url=url+"?sid="+Math.random();
				url=url+"&susername="+username;
				url=url+"&spassword="+password;
				url=url+"&scpassword="+cpassword;

				xmlHttp.onreadystatechange=function() {
					if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
						if (xmlHttp.responseText == "[DUPLICATE]") {
							document.getElementById("home_sign_in_messages").innerHTML = "Signup failure - Email already in use<br /><br />"
							setTimeout(function() {
								//$('#home_sign_in_messages').slideUp(1000);
								$('#signup_container').slideDown(1000);
							},400);

						} else if (xmlHttp.responseText == "[SUCCESS]") {
							window.location = "/artists/home.asp";
						} else {
							document.getElementById("home_sign_in_messages").innerHTML = xmlHttp.responseText;
						}
					}
				}
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);
				
				
				
			});
		}*/
	}	
		
		function signInArtistFormSubmit(the_element) {
		document.getElementById("home_artist_sign_in_messages").innerHTML = '<br/><br /><img src="/css/img/loading.gif" /><br /><br /><span style="color:white">Please refresh your browser if this process takes more than a few minutes.</span>';
		$('#home_artists_expanded').slideUp(500, function() {
			setTimeout(function() {
				$('#home_artist_sign_in_messages').slideDown(500);
				},200);
				
			
			
			username = document.getElementById("asi_username").value;
			password = document.getElementById("asi_password").value;
						
			xmlHttp=GetXmlHttpObject();
			var url="/ajax/signinArtist.asp";
			url=url+"?sid="+Math.random();
			url=url+"&susername="+username;
			url=url+"&spassword="+password;

			xmlHttp.onreadystatechange=function() {
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
					response = xmlHttp.responseText;
					if (response == "[SUCCESS]") {
						window.location = "/artists/home.asp"
					} else {
            apprise("Incorrect log in - either your email address or password has been entered incorrectly");
            document.getElementById("home_artist_sign_in_messages").innerHTML = "<font color='white'>Login failure</font><br /><br />"
						setTimeout(function() {
							$('#home_artist_sign_in_messages').fadeOut(3000);
							//$('#home_sign_in_messages').slideUp(1000);
							$('#home_artists_expanded').slideDown(1000);
						},400);
					
						
					}
				}
			}
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			
			
			
		});
		
	}


	
	

