 
var min_flash_version = 9.0;

var swf_file = "at-risk_HS_trailer_2.21.swf";
var swf_width = 720;
var swf_height = 350;
var moduleContentMovie;

var container = "atrisk-trailer-container";
var mid = "atrisk-trailer-movie";

var showTrailerU = function(){
//	if (swfobject.hasFlashPlayerVersion(min_flash_version)) {

	  // removeTrailer();
		//console.log('c');
		
		var c = document.getElementById("mid");
		if (!c) {
			var d = document.createElement("div");
			d.setAttribute("id", mid);
			document.getElementById(container).appendChild(d);
		}

		
		var att = { data:swf_file, width:swf_width, height:swf_height, backgroundColor: '#ffffff' };
		var par = { WMode: 'transparent', flashvars:"allowScriptAccess=sameDomain", allowFullScreen: 'true', scale: "noScale" };
		
		var d = swfobject.createSWF(att, par, mid);
		
		
		document.getElementById(container).appendChild(d);
		document.getElementById(mid).style.display = 'block';


		//swfobject.createSWF(swf_file, mid, "300", "120", "9.0.0", "expressInstall.swf");
//	}
	
};
var removeTrailer = function(){
var sos = jQuery('.swfmovie');
		sos.show();
	$('#box').animate({top: '-800px', height: '20px', alpha: 0}, function(evt){
		
		try{
			document.getElementById(mid).style.display = 'none';
			swfobject.removeSWF(mid);
		} catch(err){}
		
	});
	
	
	swfobject.embedSWF("_swf/scrolling seq.swf", "homevideo", "480", "255", "9.0.0");
}


var showPlayerU = function(){
	
	swfobject.removeSWF("homevideo");
	
	jQuery('<div/>', {
		id: 'homevideo'		
	}).appendTo('#homevideowrap');

	
	
	
	if($.browser.msie && $.browser.version=="6.0") {
	
		window.open('trailer-home.php','','toolbars=no,width=890,height=550,resizable=yes');


	
	} else {
	
	
		var l = ($(window).width() /2) -(720/2);
		var sos = jQuery('.swfmovie');
		sos.hide();
		
		document.getElementById('box').style.left = l + 'px';
	  	document.getElementById('box').style.display = 'block';

		 $('#overlay').fadeIn('fast',function(){
		   
		   
		   $('#box').animate({'top':'160px', left: l+'px', width: '720px', height: '350px'},500, function(evt){
				//$('#atrisk-trailer-movie').animate({'height': '450px', width: '650px'});
				showTrailerU();
			});
		});
	}
}


function showDemo(){

	var d = document.createElement("iframe");
	d.setAttribute("id", "atrisk-demo");
	document.getElementById(container).appendChild(d);
	
	d.src="demo/launch.html";
	
	d.style.width = '1020px';
	d.style.height = '650px';
}

function launchOverlayDemo(){
	
	var l = ($(window).width() /2) -(1020/2);
		
	document.getElementById('box').style.left = l + 'px';
	  
	 $('#overlay').fadeIn('fast',function(){
	   
	   
	   $('#box').animate({'top':'10px', left: l+'px', width: '1020px', height: '650px'},500, function(evt){
		//	$('#atrisk-trailer-movie').innerHTML = "asdasD";
			showDemo();
		});
	});
}



$(function() {
	
	$('#play-atrisk-trailer').click(showPlayerU);
	
	$('#boxclose').click(function(){
		$('#box').animate({'top':'-500px' },500,function(){
			removeTrailer();
			$('#overlay').fadeOut('fast');
		});
	});

});

