/* LOGIN BOX */

$(document).ready(function(){
	$(".leftfield").addClass('enteremail');
	$(".centerfield").addClass('enterpassword');
	$("#signEmail").attr('href','#');
	$("#signEmail").click(function(){
		$(".methods").hide()
		$(".login").show();
	});
	$(".leftfield").bind("focus click",function(){
		$(".leftfield").removeClass('enteremail')
	});
	$(".centerfield").bind("focus click",function(){
		$(".centerfield").removeClass('enterpassword')
	});
	$(".leftfield").blur(function(){
		var enterPassword = $(".leftfield").val();
		if (enterPassword == '') {
			$(".leftfield").addClass('enteremail')
		} else {
			$(".leftfield").removeClass('enteremail')
		}
	});
	$(".centerfield").blur(function(){
		var enterPassword = $(".centerfield").val();
		if (enterPassword == '') {
			$(".centerfield").addClass('enterpassword')
		} else {
			$(".centerfield").removeClass('enterpassword')
		}
	});	
});


var popupStatus = 0;
function loadPopup(){
	if(popupStatus==0){
		$("#videoLayer").css({
			"opacity": "0.7"
		});
		$("#videoLayer,#videoPopup,embed,#labelPopup").fadeIn("slow");
		popupStatus = 1;
	}
}

function disablePopup(){
	if(popupStatus==1){
		$("#videoLayer,#videoPopup,embed,#labelPopup").fadeOut("slow");
		popupStatus = 0;
	}
}

function centerPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var popupWidth = $("#videoPopup,#labelPopup").width();
	$("#videoPopup,#labelPopup").css({
		"position": "absolute",
		"left": windowWidth/2-popupWidth/2
	});
}

$(document).ready(function(){
	$("#explanation,#labelclick").click(function(){
		centerPopup();
		loadPopup();
	});
	$("#videoClose").click(function(){
		disablePopup();
	});
	$("#videoLayer").click(function(){
		disablePopup();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
});