// Master JavaScript Document

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(externalLinks);

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";
    }
}

$(document).ready(function(){
	// Cufon.replace('h1', { fontSize: '34px' });
	// Cufon.replace('h1 span', { fontSize: '16px' });
	
	//video
	var strFlashMessage = "<div id=\"theVideo\"><p>We could not detect an up to date version of the <a href=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\">Flash Player</a> installed on your machine, this site requires flash. You will not be able to view all of the content on this site without the flash player installed.</p></div>";
	
	
	$("#videoHolder").html(strFlashMessage);
	$("#videoHolder").hide();
	$("#video img.close").hide();
	$(".video #videoHolder").show();
	
	$("a.play").click(function() {
		$("#video").addClass("playing");
		$(this).parents().find("a.play").show();
		$(this).hide();
		$(this).parents().find("#videoHolder").show();
		$(this).parents().find("img.close").show();
		var flashvars = {
			//file: "home.flv"
		}; 
		var params = { 
			wmode: "transparent",
			allowfullscreen: true
		};
		var attributes = { 
		}; 
		swfobject.embedSWF("video.swf?" + $(this).attr("rel"), "theVideo", "550", "310", "9.0.0", "", flashvars, params, attributes);												 
		
		location.href = "#header";
		return false;	
	});
	
	$("#video img.close").click(function() {
		$("#video").removeClass('playing');
		$(this).hide();
		$(this).parent().find("#videoHolder").hide();
		$(this).parents().find("a.play").show();
		$(this).parent().find("#videoHolder").html(strFlashMessage);												 
		return false;	
	});
	
	
	
});

function fncVideoAutoClose() {
	$("#video img.close").click(); //auto close player
}