﻿/*! Copr. (c) 2010, 4delite */

var _origHeight;
$(document).ready(function ()
{
	var twitter = $("#twitter");
	if (twitter.length)
	{
		$("#twitter").tweet({
			username: "4delite",
			count: 20,
			loading_text: "loading tweets..."
		});

		$("#btnTweetUp").mousehold(function (i)
		{
			twitter.scrollTop(twitter.scrollTop() - (1 + i / 20));
		}, 20);

		$("#btnTweetDown").mousehold(function (i)
		{
			twitter.scrollTop(twitter.scrollTop() + (1 + i / 20));
		}, 20);
	}
});

function videoComplete()
{
	$("#curtain")
				.animate({ opacity: 0 }, 500, null, function() { $(this).css({ display: "none" }); });

	$("#videoContainer").animate({
		width: 369,
		height: 244,
		top: 38,
		right: 0,
		padding: 0
	}, 500);

	$("#videoCloseLink").fadeOut(100);

	$("#videoLink").fadeIn(350, function()
	{
		var eltPlayer = document.createElement("div");
		$("#videoPlayer").replaceWith(eltPlayer);
		eltPlayer.id = "videoPlayer";
	});
}

function startVideo()
{
	var flashParams = {
		wmode: "opaque",
		bgcolor: "#2A2E31",
		quality: "high",
		allowFullScreen: "true"
	};
	var flashVars = {
		videoSource: "http://vidiwikioke.com/annotated_Susumu.flv",
		videoSkin: "/Flash/4deliteSkinUnderPlayStopSeekFullVol.swf"
	};

	$("#curtain")
				.css({ opacity: 0, display: "block" })
				.animate({ opacity: 0.7 }, 2000);

	$("#videoLink").fadeOut(350);
	$("#videoCloseLink").fadeIn(500);

	$("#videoContainer").animate({
		width: 640 + 50,
		height: 480 + 50,
		top: -130,
		right: ($("#contentBox").width() - (640 + 50)) / 2,
		padding: 25
	}, 500, null, function()
	{
		swfobject.embedSWF(
					"/flash/videocontainer.swf",
					"videoPlayer", "100%", "100%",
					"10.0.0", "/swfobject/expressInstall.swf",
					flashVars, flashParams,
					{ id: "videoPlayer" },
					function(e)
					{
						//$("#videoPlayer").css({ visibility: "visible" });
					}
				);
	});

}

var Recaptcha = {

	challenge_callback: function ()
	{
		$('#' + this.idChallenge).val(RecaptchaState.challenge);
		$('#' + this.idImg).attr('src', 'http://www.google.com/recaptcha/api/image?c=' + RecaptchaState.challenge);
	},

	create: function (idChallenge, idImg)
	{
		this.idChallenge = this.idChallenge || idChallenge;
		this.idImg = this.idImg || idImg;

		var scheme = (document.location.protocol == 'https:' ? 'https' : 'http');
		var url = scheme + "://www.google.com/recaptcha/api/challenge?k=6LfjRAUAAAAAACHVF3rPxYdHq_j507TlQ34a7HHE&ajax=1&cachestop=" + (new Date().getTime());
		$.getScript(url);
	}
};
