function innerFlash(){

	$('#main').css('display', 'block');
	$('#main-media').media({
		version: '8,0', width: '100%', height: '100%', autoplay: true, src: 'swf/site.swf',	caption: false,
		attrs: { id: 'flashSite'},
		params: {
			allowScriptAccess: 'sameDomain',
			bgColor:CONFIG.bgColor,
			quality: 'high'
		},
		flashvars:CONFIG.flashVars
	});	
}

if (isMobile()) {
	if(CONFIG.mobile){
		window.location.href = CONFIG.mobile;
	}	
	
} else{		
	
	var temp =CONFIG.flashVersion.split(",");
	temp[1]=temp[1]?temp[1]:0
	temp[2]=temp[2]?temp[2]:0
	
	if (!DetectFlashVer(temp[0], temp[1], temp[2])) {
		if(CONFIG.noFlash){
			window.location.href =CONFIG.noFlash;
		}
	 }else {
		 $(document).ready(function(){
				if (isNewWindow()) {
					if (window.opener) {
						innerFlash();
						window.opener.location.href = CONFIG.urlSplash;
						var windowWidth = window.outerWidth || document.documentElement.clientWidth;
						var windowHeight = window.outerHeight || document.documentElement.clientHeight;
						window.moveTo((screen.width / 2) - (windowWidth / 2 + 4), (screen.height / 2) - (windowHeight / 2 + 30));
					} else {
						var maxW = screen.availWidth > CONFIG.maxWidth? CONFIG.maxWidth : screen.availWidth - 8;
						var maxH = screen.availHeight > CONFIG.maxHeight ? CONFIG.maxHeight : screen.availHeight - 33;
						callOpen(window.location.href, maxW, maxH);
                              window.location.href = CONFIG.urlSplash;
					}
				}else{
					innerFlash();
				}
			});
			
		}
	 
 }

function isMobile(){
	if (screen.width < 400){
		return true;
	}
}

function isNewWindow(){	;
	if (screen.width >= CONFIG.maxWidth || screen.width <= CONFIG.minWidth){
		return true;
	}
}

function callOpen(openPage, width, height){	
	void window.open(openPage, CONFIG.pageName, "'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,left=0,top=0,width="+width+",height="+height+ "'");	
}
