
$(function() {
	$("#closeContact").click(function() {
		$("#contact").fadeToggle(700);
	});
});


//////////////////////////////////////////////////////////////////////////////////////////
// Initializes the external links on all pages

window.onload = externalLinks;

//////////////////////////////////////////////////////////////////////////////////////////
// Contact popup toggle

jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

$(function() {
	$("#contactButton").click(function() {
		$("#contact").fadeToggle(700);
	});
});

//////////////////////////////////////////////////////////////////////////////////////////
// XHTML Strict compliant external link script

function externalLinks() {
	if (! document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i < anchors.length; i++) {
			var anchor = anchors[i];
			if ( anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
				anchor.target = "_blank";
		}
}

//////////////////////////////////////////////////////////////////////////////////////////
// This toggles the ON/OFF states for the Video questions

function updateVideo(q,v) {

$("#q1").removeClass("questionActive");
$("#q2").removeClass("questionActive");
$("#q3").removeClass("questionActive");
$("#q4").removeClass("questionActive");
$("#q5").removeClass("questionActive");

$("#" + q).addClass("questionActive");

drawVideo(v);
timeout = setTimeout("startVideo()", 1000);
}

//////////////////////////////////////////////////////////////////////////////////////////

function drawVideo(v) {

	var path = "../flv/" + v + ".flv";
	
	var flashVars = {
		videoPath: path
		}
		
	var params = {
		align: "top", 
		salign: "top", 
		scale: "noscale",
		wmode: "transparent"
	}
	
	swfobject.embedSWF('swf/cga_player.swf', "flashVideoPlayer", '275', '280', "9.0.0", "", flashVars, params, {id:"flashVideoPlayer"});
}

//////////////////////////////////////////////////////////////////////////////////////////

var timeout;

function startVideo(){
	clearTimeout(timeout);
	getVideoPlayer("flashVideoPlayer").startPlayer();
}

function getVideoPlayer(playerId){
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[playerId];
	} else {
		return document[playerId];
	}
}
