$(document).ready(myOnDomReady);
$(window).load(myDocumentLoad);

var g=
{
	async		: "async.php"
	,debug		: false
	,hasVideo	: false
	,isIE		: false
	,isIE6		: false
	,headerW	: 632
	,headerH	: 174
	,videoPlayer: null
	,mto		: null
	,mtoa		: null
	,clrmto		: function(){if(g.mto) self.clearTimeout(g.mto);g.mto=0;g.mtoa=0;}
};



function RQDebug(s)	{if(g.debug){$('#debug').prepend("<div>"+s+"</div>");}}
function onWindowResize()	{myAdjustLayout();}
function onWindowScroll()	{myAdjustLayout();}

function myOnDomReady()
{
	if(g.debug)
		$('body').append("<div id=\"debug\"><div class=\"content\"></div></div>");

	// browser detection
	g.isIE = jQuery.browser.msie?true:false;
	g.isIE6 = (g.isIE && (jQuery.browser.version.charAt(0)<="6" ))?true:false;

	var vid = $("<video />");
	g.hasVideo	=($(vid).get(0).play && $(vid).get(0).canPlayType) ? true:false;
	RQDebug("hasVideo = "+(g.hasVideo? "true":"false"));
	if(!g.hasVideo)
	{	if($('video source').get(0)) showFlashPlayer();
	}

	// image preloads
	RQPreload('icVimeoOn.gif');
	RQPreload('icFacebookOn.gif');
	RQPreload('icFlickrOn.gif');
	RQPreload('icRSSOn.gif');

	// run slideshow
	RQSlideshowInit();

	// animate menu
	$(".MenuLevel1>li>ul").not(".expanded").hide();
	$(".MenuLevel1>li").each(function(){
		var a =$(this).children("a");
		if(!a.attr('href'))	a.click(function()
			{	g.clrmto(); $(".expanded").slideUp("fast").removeClass("expanded"); $(this).siblings("ul").addClass("expanded").slideDown('fast');
			}).mouseover(function(){ g.clrmto();g.mtoa=this;g.mto=self.setTimeout("autoexpand()",1500); }).mouseout(function(){if(g.mto &&g.mtoa==this )g.clrmto();});
	});
}
function autoexpand()
{	if( g.mtoa && !$(g.mtoa).siblings("ul").is('.expanded') )
		$(g.mtoa).click();
}

function myDocumentLoad()
{

}

function myAdjustLayout()
{	var h=$(document).height();
	$('#footerDiv').css({top:h-20}).show();


}



function showFlashPlayer(url,idDiv)
{
	RQDebug("showFlashPlayer("+url+")");
	if( !idDiv) idDiv ="headerFlashPlayer";
	var params	= {quality:"autohigh",bgcolor:"#ffffff",allowfullscreen:"false",allowscriptaccess:"always",wmode:'transparent'};
	var fv		= {bufferlength:4,controlbar:"none",autostart:"false",repeat:"list",item:0}
	var attrs	= {id:"idPlayer",name:"idPlayer"};
	if(url) fv.file=g.url+url;
	swfobject.embedSWF("Data/Flash/VideoPlayer/player.swf", idDiv, g.headerW, g.headerH, "9", "Data/Flash/expressInstall.swf",fv,params,attrs);


}
function playerReady(obj) 
{	RQDebug("playerReady()");
	var id = obj['id'];
	var version = obj['version'];
	var client = obj['client'];
	g.videoPlayer = $("#"+id).get(0);
};
