/*-------------------------
Resize
-------------------------*/

// 下記2行を追加
jQuery.noConflict();
var j$ = jQuery;


window.params = {
	div: null,
	movie: null,
	footer: null,
	wrapper: null,
	scrollFixer: null,
	ADJUST: null,
	MINIMUM_WIDTH: 980,
	MINIMUM_HEIGHT: 780
}


jQuery(document).ready(function(){
								
	window.params.div = document.getElementById("top_Flash");
	window.params.footer = document.getElementById("bottom");
	
	//alert(window.params.footer.offsetHeight);
	
	window.params.wrapper = document.getElementById("body");

	// Determine combined height of header / footer
	window.params.ADJUST = window.params.footer.offsetHeight + window.params.wrapper.offsetHeight;

	// Unbind adidas stuff
	jQuery(window).unbind();
	window.onresize = onWindowResize;
	window.onresize();

});

function onWindowResize(e){
	resizeTechfit();
}

function resizeTechfit(dontAskFlash){
	
	// width-height
	var h = jQuery(window).height();
	var w = jQuery(window).width();
	
	//tate-naga
	
/*
.js-h-min {
	height:780px;
}

.js-h-max {
	height:100%;
}

.js-w-min {
	width:980px;
}

.js-w-max {
	width:100%;
}
*/
	
	/*
	jQuery("#top_Flash").removeClass("js-h-min");
	jQuery("#top_Flash").removeClass("js-h-max");
	jQuery("#top_Flash").removeClass("js-w-min");
	jQuery("#top_Flash").removeClass("js-w-max");
		
	jQuery("#topFlash").removeClass("js-h-min");
	jQuery("#topFlash").removeClass("js-h-max");
	jQuery("#topFlash").removeClass("js-w-min");
	jQuery("#topFlash").removeClass("js-w-max");
	
	jQuery("#body").removeClass("js-h-min");
	jQuery("#body").removeClass("js-h-max");
	jQuery("#body").removeClass("js-w-min");
	jQuery("#body").removeClass("js-w-max");
	*/
	
	if(jQuery.browser["msie"]){
	
	//if(h >= w){
	
	
		if(h < 780){
			//jQuery("#body").addClass("js-h-min");
			jQuery("#body").height("780px");
			jQuery("#topFlash").height("780px");//oo
			jQuery("#topFlash").height("780px");//oo
			
					}else{
			//jQuery("#body").addClass("js-h-max");
			jQuery("#body").height("100%");
			jQuery("#topFlash").height("100%");//oo
			jQuery("#topFlash").height("100%");//oo
		}
		
		if(w < 980){
			//jQuery("#topFlash").addClass("js-w-min");
			//jQuery("#body").addClass("js-w-min");
			
			jQuery("#body").width("980px");
			jQuery("#topFlash").width("980px");
			jQuery("#top_Flash").width("980px");//oo
			
		}else{
			//jQuery("#topFlash").addClass("js-w-max");
			//jQuery("#body").addClass("js-w-max");
			
			jQuery("#body").width("100%");
			jQuery("#topFlash").width("100%");
			jQuery("#top_Flash").width("100%");//oo
			
		}
	/*
	}else{
		//yoko-naga
		if(h < 780){
			//jQuery("#top_Flash").addClass("js-h-min");
			jQuery("#top_Flash").height("780px");
		}else{
			//jQuery("#top_Flash").addClass("js-h-max");
			jQuery("#top_Flash").height("100%");
		}
		
		if(w < 980){
			//jQuery("#top_Flash").addClass("js-w-min");
			jQuery("#top_Flash").width("980px");//oo
			jQuery("#topFlash").width("980px");
				
		}else{
			///jQuery("#top_Flash").addClass("js-w-max");
			
			jQuery("#top_Flash").width("100%");//oo
			jQuery("#topFlash").width("100%");
		}
		
	}
	*/
	}else{
	
		if(h < 780){
			jQuery("#body").height(780);

		}else{
			jQuery("#body").height("100%");
		}
		
		if(w < 1024){
			jQuery("#body").width(1024);
		
		}else{
			jQuery("#body").width("100%");
		}
	
	}
	
	/*
	window.params.wrapper.style.height = hoge+"px";
	*/
	
	var div = window.params.div;
	
	/* -- */
	var footerheight = jQuery('#bottom').height() + parseInt(jQuery('#bottom').css('height'), 10) + parseInt(jQuery('#bottom').css('height'), 10);
	var windowheight = jQuery(window).height();
	var wrapper = jQuery('#bottom').height();
	
	//var flashheight = windowheight- footerheight;
	var flashheight = 780;
	
	var _Content = jQuery('#content');



	// mini height

/*
	if (flashheight < 780) {
		div.style.height = window.params.MINIMUM_HEIGHT + "px";
	} else {
		div.style.height = flashheight + "px";
	}



	// min width
	if (w < 980) {
	
		// Set minwidth
		//div.style.width = window.params.MINIMUM_WIDTH + "px";
		jQuery('#body').width(window.params.MINIMUM_WIDTH);
		//jQuery('#bottom').width(window.params.MINIMUM_WIDTH);
	} else {
	
		// Set fullwidth
		//div.style.width = "100%";
		jQuery('#body').width("100%");
		//jQuery('#bottom').width("100%");
	}
*/
	/*
	if(jQuery.browser["msie"]){
		
		if (!dontAskFlash && window.params.movie.getScenePosition) {
			adjustConstraint(window.params.movie.getScenePosition());
		}
		
	}
	*/
	
}

/////////////////////////

function adjustConstraint(config) {
	
	// div content
	var div = window.params.div;
	
	var needsToGrow = config.flashHeight > window.params.MINIMUM_HEIGHT;
	
	var scrollBar = (div.offsetHeight + window.params.ADJUST) > jQuery(window).height()
	
	//taller
	if(needsToGrow) {
		
		// Set minheight
		window.params.MINIMUM_HEIGHT = config.flashHeight;
		
		// Resize
		resizeTechfit(true);
		
	//smaller
	} else {
		
		// If there is a scrollbar, and the flash says it's okay
		if(scrollBar && config.resize) {
			window.params.MINIMUM_HEIGHT = config.flashHeight;
		
			// Resize
			resizeTechfit(true);
		}
	}
}