  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-2952081-29']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
function isValidEmail(str) { return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);}
$(document).ready(function() {
	$('.logo').flash({
	        src: '/images/logo.swf',
			width: 320,
			wmode: 'transparent',
			height: 100
	}); 
	$("input[type='text'],input[type='password'],textarea").focus(function(){
		$(this).addClass("highlighted")
		if (!$(this).hasClass('changed')){

			$(this).addClass('changed')
				var index = $("input[type='text'],input[type='password'],textarea").index(this);
				window["input"+index] = $(this).val();
				$(this).val("")
		}
	
	})
	$("input[type='text'],input[type='password'],textarea").blur(function(){
		$(this).removeClass("highlighted")
			if ($(this).val()==""){
				var index = $("input[type='text'],input[type='password'],textarea").index(this);		
				$(this).val(window["input"+index])
				$(this).removeClass('changed')
			}
	})

	$("#sign_in a.forgot_password").click(function(e){
		e.preventDefault()
		$('#sign_in').fadeOut("fast", function(){
			$('#forgot_password').fadeIn("fast")
		})	
	})
	$("#sign_in a.change_password").click(function(e){
		e.preventDefault()
		$('#sign_in').fadeOut("fast", function(){
			$("#change_password p").hide()
			$('#change_password').fadeIn("fast")
		})	
	})
	$("#change_password").submit(function(e){
		e.preventDefault()
		if (!$("#new_password").hasClass("changed")){
			alert('Please enter a new password')
			$("#new_password").focus()
			return false;
		}
		var newpassword = $("#new_password").val()
		
		$("#change_password #new_password").fadeOut("fast", function(){			
			$.ajax({
			   type: "POST",
			   url: "/ajax.php?changepassword=true",
			   data: "newpassword="+newpassword,
			   success: function(msg){
					$("#change_password p").html("Your new password is <strong>"+newpassword+"</strong>.");
					$("#change_password p").fadeIn("fast")
			   }
			 });
			
			
		});
		$("#change_password input").fadeOut("fast")
	})
	$("#forgot_password a").click(function(e){
		e.preventDefault()
		$('#forgot_password').fadeOut("fast", function(){
			$('#sign_in').fadeIn("fast")
			$("#forgot_password input").show()
			$("#forgot_password p").hide()
		})	
	})
	$("#change_password a").click(function(e){
		e.preventDefault()
		$('#change_password').fadeOut("fast", function(){
			$('#sign_in').fadeIn("fast")
			$("#change_password input").show()
			$("#change_password p").hide()
		})	
	})
	$("#forgot_password").submit(function(e){
		e.preventDefault()
		$("#forgot_password br").fadeOut()
	
		$("#forgot_password #forgot_email").fadeOut("fast", function(){
			var email = $("#forgot_email").val()
			$.ajax({
			   type: "POST",
			   url: "/ajax.php?forgotpassword=true",
			   data: "email="+email,
			   success: function(msg){
					$("#forgot_password p").html(msg);
					$("#forgot_password p").fadeIn("fast")
					//alert(msg)
			   }
			 });
			
		});
			$("#forgot_password input").fadeOut("fast")
	})
	setInterval("slide()", 3000)

});

function slide(){
		$("#scroll_container ul").animate({"left": "-=290px"}, 1000, function(){
			var first = $("#scroll_container ul li:first").clone()
			$("#scroll_container ul li:first").remove()
			$("#scroll_container ul").append(first)
			$("#scroll_container ul").css("left",0)
		})
		
}
function noSpam(e,domain){
	window.location='mailto:'+e+'@'+domain;
}
