/*
SOLFX Demo Box - created by sunKING Interactive Group. http://www.sunking.com
*/	

function skBox(){
	var skY = 575;
	var skX = 930; 
	var boxContents = "";
	
	$('.skBox').click(function(){		
		openBox('body',this.href);
		return false;
	});
	
	function openBox(con,fsrc){
		var string;
		if(fsrc.indexOf("height=")>-1){
			string = fsrc.substring(fsrc.indexOf("height="));
			if(string.indexOf("&")>-1){	
				skY = parseInt( string.substring(7,string.indexOf("&")) ,10);
			}else{	
				skY = parseInt( string.substring(7) ,10);
			}
		}if(fsrc.indexOf("width=")>-1){
			string = fsrc.substring(fsrc.indexOf("width="));
			if(string.indexOf("&")>-1){
				skX = parseInt( string.substring(6,string.indexOf("&")) ,10);
			}else{
				skX = parseInt( string.substring(6) ,10);
			}
		}
		
		boxContents = "<div class='skB_window'>";
		boxContents += "<div class='inner' style='width:"+skX+"px;height:"+skY+"px;left:-"+Math.round((skX/2)+15)+"px;top:-"+Math.round(skY/2 - 80)+"px;'>";
		boxContents += "<a href='#close' class='skB_closeButton' style='display:block;height:0;top:0px;'>Close</a>";
		if(fsrc.indexOf('sunglass031209_hsfl_hi-2.flv') > -1 ) {
			boxContents += "<h1 class='videoTitle'>Our Vision</h1>";
		}
		boxContents += "<div id='shieldSideLink' style='width:"+skX+"px;height:"+skY+"px;'></div>";
		boxContents += "</div>";
		boxContents += "</div><div id='skB_overlay'></div>";	
		
		$(con).append(boxContents);
		
		string = "?file=";
		fsrc = fsrc.substring(fsrc.indexOf(string)).substring(string.length);
		
		showContent(fsrc);

		$('.skB_closeButton, #skB_overlay').click(function(){
			$('#skB_overlay ').remove();
			$('.skB_window').fadeOut(400, function(){
				$('.skB_window').remove();	
				//document.body.style.overflow="visible";
				//document.body.style.height="auto"; 
			});
			return false;
		});
	}
	
	function showContent(fsrc){
		$("a:eq(0)")[0].focus();
		//document.body.style.overflow="hidden";
		//document.body.style.height="100%"; 
		$('.skB_window').fadeIn(600,function(){
			if(fsrc.match('.flv&slate=') && fsrc.match('player.swf?')){
				var flash = "";
				flash += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="960" height="485" title="SolFX Demo">';
				flash += '<param name="movie" value="'+fsrc+'" />';
				flash += '<param name="quality" value="high" />';
				flash += '<param name="wmode" value="transparent" />';
				flash += '<param name="scale" value="noscale" />';
				flash += '<embed src="'+fsrc+'" quality="high" wmode="transparent" scale="noscale" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="960" height="485"></embed>';
				flash += '</object>';
				$('#shieldSideLink')[0].innerHTML = flash;
			}else{
				$('#shieldSideLink').flash({
					src: fsrc,
					width: 926,
					height: 569,
					scale: 'noscale',
					wmode: 'transparent'
				}, {expressInstall: true});
			}
			$(".skB_closeButton").animate({height: "33px",top: "-33px"}, 200 );		
		 });
	}
}
