var quote_data = {"quotes": [
      
        {"author": "Ariel Levine of  Kindergarten", "quote": '"It sounds perfect. It is loud without being squashed, and I can listen to it loudly without hurting my ears, and softly without missing a thing."' },
        {"author": "Evan Coffman - Mixing Engineer", "quote": '"I am very close to these songs and this band so this is the happiest I have been after getting a master back."' },
        {"author": "Trevor Oswalt of East Forest", "quote": '"As usual Nathan provided top notch service and attention to my weird project."' },
        {"author": "Polsia Ryder - Dovecote Records", "quote": '"We are all in awe at how amazing the record sounds AFTER mastering. "' },
        {"author": "Steven Mark - Singer Songwriter", "quote": '"Nathan has a collaborative spirit and a tireless desire to have the client leave happy."' },
        {"author": "Rale Micic - CTA Records", "quote": '"A truly mind blowing, ear pleasing experience!"' },
		{"author": "Eiko Peck of Elco Deck", "quote": '"He has a great understanding of music and the flow and feel of just about any style you may bring in."' },
		
		



	
    ]
};

$(document).ready(function() {
	quoteVar=eval(quote_data);
	quoteCounter=-1;
	$("#login, #login_btn").click(function() {
		$("#l_holder").animate({ top:"-8px" }, 1100);

	});	
	$("#l_close").click(function() { $("#l_holder").animate({ top:"-70px" }, 1100); });
	$("#l_go").click(function() { login(); });
	$("#l_user").keypress(function (e) { if (e.which==13) { login(); }}).click(function() {

		if ($(this).val()=="Username") {
			$(this).val("");
		}
	});
	$("#l_pass").keypress(function (e) { if (e.which==13) { login(); }}).click(function() {
		if ($(this).val()=="password") { $(this).val(""); }

	});
	setInterval(function() {
		$(".q").fadeOut("fast",function() {
			if (++quoteCounter>quoteVar.quotes.length-1) {
				quoteCounter=0;
			}
			$(".author").text(quoteVar.quotes[quoteCounter].author);

			$(".q").text(quoteVar.quotes[quoteCounter].quote);
			$(this).fadeIn("fast");
		});
	}, 5000);
});

function login() {
	$.get("ajax.php",{action: "login", user:$("#l_user").val(),pass:SHA1(SHA1($("#l_pass").val()))}, function(r) {

		r=eval("(" + r + ")");
		if (r['error']==0) {
			createCookie("username", $("#l_user").val(),30);
			createCookie("password", SHA1(SHA1($("#l_pass").val())), 30);

			window.location="/files";
		} else {
			$("#l_holder").animate({backgroundPosition:"(-1px -7px)"}, 200, function() { $("#l_error").text(r['message']).fadeIn(); });

			setTimeout(function() { $("#l_error").fadeOut(); setTimeout(function() { $("#l_holder").animate({backgroundPosition:"(-1px -25px)"}, 200) }, 500); }, 2500);
		}
	});
}

function createCookie(name,value,days) {

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";


}