/* Author: Coloring Book Studio
*/

/*******************MEDIA HANDLER*******************/

function addVideo(targetDIV,sourceVid,sourceImg,autoFlag,holderWidth,holderHeight) {
	if ($.flash.available) {
		//console.log('$.flash.available');
		$("#"+targetDIV).flash({
								swf:'swf/videoPlayer.swf',
								width: holderWidth,
								height: holderHeight,
								allowFullScreen: true,
								allowscriptaccess: true,
								wmode: 'transparent',
								allowScriptAccess:'sameDomain',
								quality:'high',
								swLiveConnect:true,
								flashvars: {
											vidPath:sourceVid,
											posterPath:sourceImg,
											autoPlayFlag:autoFlag
											}
								});	
	} else {
		 var embedVid = '<div class="video-js-box">'+
						'<video class="video-js" width="'+holderWidth+'" height="'+holderHeight+'%" controls poster='+sourceImg+'>'+
						'<source src='+sourceVid+' type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' />'+
						'<img src='+sourceImg+' width="'+holderWidth+'" height="'+holderHeight+'" alt="Poster Image" title="No video playback capabilities." />'+
						'</video>'+
						'</div>';
		$("#"+targetDIV).html(embedVid);
	}
}

/*******************FOOTER HANDLER*******************/

var footerTextArray = new Array("");

function buildFooter(id) {
	var footerOutput = "";
	switch (id) {
	case 0:
		footerOutput = footerTextArray[id];
	break;
	case 1:
		footerOutput = '';
	break;
	}
	$('#site-footer').html(footerOutput);
}


/******************* PAGE BUILD FUNCTIONS*******************************/

function loadHome() {
		VideoJS.setupAllWhenReady();
		addVideo("vidHolder","../vids/STORY_2.f4v","images/story_2_poster.jpg",false,800,450);
	}


/******************* SITE INITIALIZE*******************************/



/*******************DOM READY HANDLER*******************/
function onResize() {
		var value1, value2;
		var stageWidth = $(window).width();
		var stageHeight = $(window).height();
		if (stageHeight < 720) {
			value1 = 15;
		} else {
			var value1 = (stageHeight - 720)/2;
		}
		if (stageWidth < 1020) {
			value2 = 15;
		} else {
			var value2 = (stageWidth - 1020)/2;
		}
  		$('#site-container').css('top',value1+'px');	
  		$('#site-container').css('left',value2+'px');	
	}

var currentSection = 'home';
$(document).ready(function() {
	
	loadHome();
	onResize();
	
	
	/*____________ INIT FONTS ______________*/
		if(!jQuery.browser.msie){
			Cufon.replace('#page_bottom');
			Cufon.replace('#main-nav');
			Cufon.replace('h1');
			Cufon.replace('h2');
			Cufon.replace('#site-footer');
		}
	
	// Event handlers

	$(window).resize(function() {onResize();});
	//$('.wrapper').css('display','visible');
});


