/* DOM構築後に実行 */
__contH = 0;
__winH  = 0;
var strUA = "";
strUA    = navigator.userAgent.toLowerCase();
__thisBgPlay = 0;
__thisBgPlayWindow = 0;

$(function() {
	swfMovie = (navigator.appName.indexOf("Microsoft") != -1) ? bgFlash : document.bgFlash;
	$("#mvSWF,form").hover(
	function(){bgSwfStop()	},
	function(){bgSwfPlay()	}
	);	
/**
	
	$('#bgTex').hover(
		function(){
			$(this).mousemove( function(e) { 
				mouseY = e.pageY;
				if(mouseY <100){
					bgSwfStop();
				}
				else{
					bgSwfPlay();
				}
			});
		},
		function(){
			bgSwfStop();		
		}
	);
	**/
	
/*
	$("#bgTex").mousemove( function(e) { 
		mouseY = e.pageY;
		if(mouseY <20){
			bgSwfStop();
		}
		else{
			bgSwfPlay();
		}
	}); 
/*	
	$("body").mouseover( function(e) { 
		mouseY = e.pageY;
		if(mouseY <50){
			bgSwfStop();
		}
	});
	
	$("body").mouseleave( function(e) { 
		mouseY = e.pageY;
		if(mouseY <50){
			bgSwfStop();
		}
	}); 	
	*/
	

	
	jQuery.event.add(window, "load", function(){
		var documentHeight    = $(document).height();
		var windowHeight    = $(window).height();		
		var containerHeight    = $('#mainContainer').height();
		__contH = containerHeight;
		__winH  = windowHeight;
		//フッター縦幅調整
		if(windowHeight>containerHeight){
			$('#mainContainer').height(windowHeight);
		}
		else{
			$('#mainContainer').height(containerHeight);
		}
	});
	$(window).bind('resize',wresize);	
	
	 $("#newsBacknumber").change(onSelectChange); 
	
});

function bgSwfStop(){
	__thisBgPlay = 0;
	swfMovie.SetVariable("_level0.movieFlg",0);
}

function bgSwfPlay(){
	__thisBgPlay = 1;
	swfMovie.SetVariable("_level0.movieFlg",1);
}

function bgSwfStopWindow(){
	__thisBgPlayWindow = 0;
	swfMovie.SetVariable("_level0.movieFlg",0);
}

function bgSwfPlayWindow(){
	__thisBgPlayWindow = 1;
	swfMovie.SetVariable("_level0.movieFlg",1);
}

function onSelectChange(){  
 var _h = $('#newsBacknumber').val();
 if(_h != 'none'){
	window.location.href = _h;
 }
}  

/*リサイズを検出したら実行*/
function wresize(e){
	swfMovie = (navigator.appName.indexOf("Microsoft") != -1) ? bgFlash : document.bgFlash;
	var windowWidth    = $(window).width();
	var windowHeight    = $(window).height();		
	var containerWidth    = $('#mainContainer').width();
	var containerHeight    = $('#mainContainer').height();	
	
	
	if(windowWidth<containerWidth){
		$("#bgFlash").width(containerWidth);
	}
	else{
		var l = (windowWidth - containerWidth)/2;
		$("#bgFlash").width(windowWidth);
	}
	if(__winH < windowHeight){
		$("#bgFlash").height(windowHeight);
	}
	else{
		$("#bgFlash").height(__winH);
	}
	
	if(windowHeight<__contH){
		$('#mainContainer').height(__contH);
	}
	else{
		$('#mainContainer').height(windowHeight);
		
	}
	swfMovie.SetVariable("_level0.wH",$("#bgFlash").height());
	swfMovie.SetVariable("_level0.wW",$("#bgFlash").width());	
}
