$(document).ready(function(){

	$('#donate-form').css('display','none');

	$('.download').click(function () {
		$('#donate-form').slideDown("fast");
	});

	$('#donate-form button.cancel').click(function () {
		$('#donate-form').slideUp("fast");
	});

	$('#donate-form button.agree').click(function () {
		if ($('#donate-form input.terms').attr('checked'))
		{
			window.location.href = "http://apaulodesign.com/widgets/Data-Vu.zip";
		}
		else
		{
			alert("In order to download this widget, you need to click the check box indicating you agree to the terms and conditions.")
		}
	});

	$('#list-submit').click(function() {
		$('#list-submit').attr("disabled","disabled");
		$.get("/widgets/list.php", { email : $('#user-email').attr("value"), optin : "yes" }, function() {
			//$('#list-submit').attr("disabled","");
			//$('#user-email').attr("value",":)");
			$('#mailing-list').hide("normal");
		});
	});

	$("a.fancy-img").fancybox({
		'speedIn'		:	600,
		'speedOut'		:	200,
		'showCloseButton'	:	false,
		'overlayShow'	:	true,
		'overlayColor'	:	'#000',
		'overlayOpacity':	.8,
		'titlePosition'	:	'over',
		'autoScale'		:	false,
		'centerOnScroll':	true,
		'onComplete'	:	function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}
	});

	$(".download-modal").fancybox({
		"speedIn"				:	0,
		"speedOut"				:	0,
		"margin"				:	0,
		"padding"				:	10,
		"autoDimensions"		:	false,
		"width"					:	625,
		"height"				:	420,
		"showNavArrows"			:	false,
		"titleShow"			:	false,
		"overlayShow"			:	true,
		"overlayColor"			:	"#000",
		"overlayOpacity"		:	.4,
	//	"modal"					:	true,		// !hideOnOverlayClick, !hideOnContentClick, !enableEscapeButton, !showCloseButton + overlayShow
		"hideOnContentClick"	:	false,
		"showCloseButton"		:	false,
		"autoScale"				:	false,
		"centerOnScroll"		:	false,
		"href"					:	"#purchase-form"
	});

//http://code.google.com/apis/youtube/player_parameters.html
//http://code.google.com/apis/ajax/playground/?exp=youtube
//http://code.google.com/apis/youtube/youtube_player_demo.html

	$("#video-link").fancybox({
		"href"					:	"http://www.youtube.com/v/hQf3MPKG8SE&hl=en&fs=0&showinfo=0&color1=e0e0e0&color2=ffffff&rel=0&hd=1&cc_load_policy=0&autoplay=1",
	//	"content"					:	"",
		"hideOnContentClick"	:	false,
		"hideOnOverlayClick"	:	false,
		"type"					:	"swf"
		
	});							

});


String.prototype.trim = function () {
	return this.replace(/^\s+|\s+$/g, '');	// faster for short strings that probably don't contain leading/trailing white space
	//return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');	// fastest performance, especially for long strings
}

//unverified
String.prototype.isEmail = function () {
	var rx = new RegExp("\\w+([-+.\Õ]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
	var matches = rx.exec(this);

	return (matches != null && this == matches[0]);
}