/*
***
Bizideo main javascript. 
*/
function playMovie(ID, mWidth, mHeight, OffsetLeft, OffsetTop) {
		
		var ajustWidth = 45;
		
		var adjustHeight = 70;
		
		
		if (navigator.appName == 'Microsoft Internet Explorer') {
			
			//need to give IE some more size 
		
			ajustWidth = ajustWidth + 15;
			
			adjustHeight = adjustHeight + 20;
		
		}
		
		
		if (typeof(OffsetLeft) == 'undefined') OffsetLeft = 0;
		
		if (typeof(OffsetTop) == 'undefined') OffsetTop = 0;
		
		if (!($('.colorbox').is('*'))) {//if color box class does not exists in DOM -- add it
		
			$('body').append('<a class="colorbox" href="/main/video/'+ID+'" style="display: none"></a>');
		
		}else{	
			
			//it is in DOM just update the loader url
			$('.colorbox').attr('href', '/main/video/'+ID);
			
		}
		
		
		setTimeout(function() {
		
			$('.colorbox').colorbox({open: true, iframe: true, transition: 'fade', width: (mWidth + ajustWidth), height: (mHeight + adjustHeight), overlayClose: false, OffsetL: OffsetLeft, OffsetT: OffsetTop});
			
			//remove the overlay that dims page -- it inter-fears with flash controls
			$('#cboxOverlay').remove();
			
			$('#cboxIframe').attr('scrolling', 'no');
			
		
		}, 1500);
				
		
}


function playMultiMovie(ID, mWidth, mHeight, OffsetLeft, OffsetTop) {
		
		var ajustWidth = 45;
		
		var adjustHeight = 70;
		
		var theLinks = '<div id="mvControls" style="color: white">';
	 	
		for (x=0; x < ID.length ; x++) {

			theLinks = theLinks +  '<span class="Vbutton" id="'+ID[x]+'"> Video '+(x+1)+' </span>';		
		
		}
		
		
		theLinks = theLinks + '</div>';
		
		
		if (navigator.appName == 'Microsoft Internet Explorer') {
			
			//need to give IE some more size 
		
			ajustWidth = ajustWidth + 15;
			
			adjustHeight = adjustHeight + 20;
		
		}
		
		
		if (typeof(OffsetLeft) == 'undefined') OffsetLeft = 0;
		
		if (typeof(OffsetTop) == 'undefined') OffsetTop = 0;
		
		var ExtraH = 0;
		
		if (!($('.colorbox').is('*'))) {//if color box class does not exists in DOM -- add it
		
			$('body').append('<a class="colorbox" href="/main/video/'+ID[0]+'" style="display: none"></a>');
			
			//alert(ID.length);//debug
			
			if (ID.length > 1) {
				
				
				$("iframe")[0].contents().find('body').append(theLinks);
			
				$('.Vbutton').one('click', function() { var theCurrent = $(this).attr('id'); $('.colorbox').attr('href', '/main/video/'+theCurrent) });
				
				ExtraH = 20;
			}	
			
		}else{	
			
			//it is in DOM just update the loader url
			$('.colorbox').attr('href', '/main/video/'+ID[0]);
			
		}
		
	
		
		setTimeout(function() {
		
			$('.colorbox').colorbox({open: true, iframe: true, transition: 'none', width: (mWidth + ajustWidth), height: (mHeight + adjustHeight + ExtraH), overlayClose: false, OffsetL: OffsetLeft, OffsetT: OffsetTop});
			
			//remove the overlay that dims page -- it inter-fears with flash controls
			$('#cboxOverlay').remove();
			
			$('#cboxIframe').attr('scrolling', 'no');
			
		
		}, 1500);
				
		
}

function closeMovie() {

	if ($('#colorbox').is('*')) {
		
		$.fn.colorbox.close();
	}	
	
}
	
$(function () { //same as doc ready
	
	
	$('#content_wrapper').hide();//hide html content
		
	$('body').append('<div id="overlay" style="width: 100%, height: 800px; background: black"><img src="/rsc/img/Bizideo-Logo_white_full.jpg" width="700" height="192" style="display: block; width: 700px; height: 192px; margin: 200px auto 15px auto" /><p style="text-align: center; font-style: italic; font-size: 60px; letter-spacing: 1px; color: white">Welcome</p></div>');
	
	//$('body').append('<iframe src="/rsc/loader/basic.html" style="display: none"></iframe>');
	
	setTimeout (run_flash, 2500);
		
	function run_flash () {
	
		$('#overlay').fadeOut('slow', function() { 
					
			$(this).hide();
			
			$('body').append('<div id="flash_content"></div>');
			
			$("#flash_content").css({width: '980px', height: '802px', margin: '5px auto' });
			
			
			$("#flash_content").flash({width: 980, height: 802, src: 'rsc/flash/main_cs4.swf', wmode: 'transparent' }, { expressInstall: true});
			
			$("#flash_content").append('<a style="text-align: center; font-size: small" href="#?hasFlash=true">I have Flash!</a>');
			
			});
	
	
	}

	

});