$( document ).ready( function () {
	
	var params = {
		quality: "high",
		scale: "noscale",
		wmode: "window",
		allowscriptaccess: "always",
		bgcolor: "#FFFFFF"
	};
	var flashvars = {
		
	};
	var attributes = {
		id: "video_player",
		name: "video_player"
	};
	
	$( '#player' ).click( function ( e ) {
		swfobject.embedSWF("uploads/video/video_player.swf", "video_player", "559", "315", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	} );

	$("#email_form input[type='text']").focus(function() {
		if ($(this).val() == "Please enter your email") {
			$(this).val('');
		}
	});
	$("#email_form input[type='text']").blur(function() {
		if ($(this).val() == ""){
			$(this).val('Please enter your email');
		}
	});

	$('#btn_send').click(function(e) {
		e.preventDefault();
		var email =  $('#email').val();
		send_mail( email,
			function(mail, status) {
				if (mail.is_sent) {
					$( '#email' ).val( 'Mail sent successfully.' ).css( { color: 'green' } );
				} else {
					$( '#email' ).val( 'Error: Mail not sent. ' + mail.error ).css( { color: 'red' } );
				}
			}
		);
	});
	
	var send_mail = function( email, callback) {
		$.getJSON('websource/mail.php?email='+encodeURIComponent(email), function(mail, status) {
			if (typeof(callback)=='function' && callback != null) {
				callback(mail, status);
			}
		});
	};

} );
