$(document).ready(function(){
	$("#loginText").click(function(){
		$("#loginText").hide();
		$(".loginArea form").show();
	})
	$("#cancelText").click(function(){
		$("#loginText").show();
		$(".loginArea form").hide();
	})
	
	$('.listViewTable tr:even').addClass("alternateRow");
	
});




$(function(){
	var hideTabs = false;
	// Tabs
	if (!(hideTabs)){
		$('#tabs').tabs();

		// Dialog			
		$('#dialog').dialog({
			autoOpen: false,
			width: 600,
			buttons: {
				"Cancel": function() { 
					$(this).dialog("close"); 
				} 
			}
		});
		
		// Dialog Link
		$('#dialog_link').click(function(){
			$('#dialog').dialog('open');
			return false;
		});
	
		$('.dialogLocation').click(function(){
			$("#ui-dialog-title-dialog").attr("innerHTML","Change Location");
			var newHTML = $("#cityNav").attr("innerHTML");
			$("#dialog").attr("innerHTML",newHTML);
			$('#dialog').dialog('open');
			return false;
		});
	
		// Datepicker
		$('#datepicker').datepicker({
			inline: true
		});
		
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);
		
	}
});







var timer;
function validateEmail() {
	var email1 = document.getElementById('email1').value;
	ajaxpage('/inc/emailvalidate.inc.php?login='+email1,'regValidate3');	
}

function validateRegistration(whichValidate) {
	var email1 = document.getElementById('email1');
	var email2 = document.getElementById('email2');
	var password1 = document.getElementById('password1');
	var password2 = document.getElementById('password2');
	var valField1 = document.getElementById('regValidate1');
	var valField2 = document.getElementById('regValidate2');
	var error1,error2

	if (whichValidate == "email") {
		if (email1.value.length > 0) {
			if (email2.value.length > 0) {
				if (email1.value != email2.value) {
					error1 = "<div style='color:#ff0000;'>Email fields do not match</div>";
				} else {
					error1 = "<div style='color:#00ff00;'>Your email address will be your login</div>";
				}
				valField1.innerHTML = error1;
			}
		}
	} else if (whichValidate == "password") {
		if (password1.value.length > 0) {
			if (password2.value.length > 0) {
				if (password1.value != password2.value) {
					error2 = "<div style='color:#ff0000;'>Password fields do not match</div>";
				} else {
					error2 = "<div style='color:#00ff00;'>Password fields match!</div>";
				}
				valField2.innerHTML = error2;
			}
		}
	}
	if (error1 == "Email fields match!" || error2 == "Password fields match!" ) {
		document.getElementById('regSubmit').disabled = true;
	} else {
		document.getElementById('regSubmit').disabled = false;
	}
}

function submitRegForm() {
	var email1 = document.getElementById('email1');
	var email2 = document.getElementById('email2');
	var password1 = document.getElementById('password1');
	var password2 = document.getElementById('password2');
	var valField1 = document.getElementById('regValidate1');
	//alert(document.form['main'].input['user'].value);
	if (email1.value != '' && email2.value != '' && password1.value != '' && password2.value != '') {
		document.main.submit();
	} else {
		alert("Please fill out all required fields");
	}
}
function startTimer(theEvent) {
	var c = document.getElementById('inpArtist');
	 clearTimeout(timer);
	if (theEvent == 8 && c.value.length < 3) {
		 ajaxpage('resultarea.html', 'resultArea');
	} else {
		timer = setTimeout("callCheckSuggest("+theEvent+")",500); 
	}
}

function callCheckSuggest(whatEvent) {
	if (whatEvent!=13) {
		var c = document.getElementById('inpArtist');
		if (c.value.length > 2) {
			var pass = 'suggest2.php?';
			var temp1 = document.getElementById('inpArtist').value;
				if (temp1 != '') {
					pass = pass + '&s=' + temp1;
				}
	
			ajaxpage(pass, 'suggest1');
	
			document.getElementById('suggest1').style.display = "block";
			timedMsg();
		} else {
			hideResults();
		}
	} else {
		hideResults();
	}
}

function timedMsg()
    {
        //var t=setTimeout("hideResults()",5000)
    }
function insertField(value1,value2) {
        document.getElementById('inpID').value = value1;
        document.getElementById('inpArtist').value = value2;
        document.getElementById('suggest1').style.display = "none";
}

function hideResults() {
	document.getElementById('suggest1').style.display = "none";
}


