//
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var HEIGHT_MIN = 560;
var HEIGHT_MAX = 1500;
if ( navigator.userAgent.indexOf('Mac') != -1 ) {
	HEIGHT_MAX = HEIGHT_MAX - 50;
}
var WIDTH_MIN = 960;
var footerHeight = 35;

var allowResize = true;
var resizeInterval;
function resizeWindow(){
	clearInterval(resizeInterval);
	//top.window.moveTo(0,0);
	var footer = MM_findObj("footer");
	var flashcontent = MM_findObj("flashcontent");
	var flashHeight = getFlashHeight();
	var flashWidth = getFlashWidth();
	//footer.style.top = (getFlashHeight()) + 'px';
	//flashcontent.style.width = flashWidth + 'px';
	flashcontent.style.height = flashHeight+'px';
	//alert(flashHeight);
	/*if (document.all) {
		top.window.resizeTo(screen.availWidth, screen.availHeight);
	} else if (document.getElementById || document.layers) {
		if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}*/
	allowResize = true;
	top.window.onresize = onResizeEvent;
}
function onResizeEvent() {
	clearInterval(resizeInterval);
	resizeInterval = setInterval("resizeWindow()",200);
}
function resizeFooter(param_flashMaskWidth_int, paramFlashTotalWidth_int){
	var footer = MM_findObj("footer");
	var flashcontent = MM_findObj("flashcontent");
	var flashTop = 0;
	var windowHeight = getWindowHeight();
	footer.style.width = (param_flashMaskWidth_int) + 'px';
	if (document.all)	{
		footer.style.width = (param_flashMaskWidth_int + 5) + 'px';
	}
	footer.style.left = Math.round((paramFlashTotalWidth_int - param_flashMaskWidth_int) / 2) + 'px';
	//
	if(windowHeight >= HEIGHT_MAX + footerHeight){
		flashTop = Math.round(Math.abs(windowHeight - HEIGHT_MAX - footerHeight) / 2);
		if(flashTop < 15){
			flashTop = 0;
		}
	}
	flashcontent.style.top = flashTop + 'px';
	footer.style.top = (getFlashHeight() + flashTop) + 'px';
	footer.style.display = "block";
	//alert("footer.style.top=" + footer.style.top);
}

function getFlashWidth() {
	var flashWidth = getWindowWidth();
	if(flashWidth < WIDTH_MIN) {
		flashWidth = WIDTH_MIN;
	}
	return flashWidth;
}
function getFlashHeight() {
	var flashHeight = getWindowHeight();
	if(flashHeight > HEIGHT_MAX) {
		flashHeight = HEIGHT_MAX;
	} else if (flashHeight < HEIGHT_MIN){
		flashHeight = HEIGHT_MIN - footerHeight;
	} else {
		flashHeight -= footerHeight;
	}
	return flashHeight;
}
function getWindowHeight() {
	var windowHeight;
	if (document.all)	{
		windowHeight = document.body.offsetHeight;
	} else {
		windowHeight = window.innerHeight;
	}
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth;
	if (document.all)	{
		windowWidth = document.body.offsetWidth - 29;
	} else {
		windowWidth = window.innerWidth;
	}
	return windowWidth;
}
function openFacebookShare(param_sweetspot, param_lang) {
	//alert("param_sweetspot : "+param_sweetspot+" :: param_lang : "+param_lang);
	openPopupWindow("http://www.facebook.com/sharer.php?u=http://www.nike.com/nikeacg/share/facebook/"+param_lang+"/"+param_sweetspot+".html","facebook","height=380, width=680, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, directories=no, status=no");
}

function openPopupWindow(url, name, param) {
	//'height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no'
	window.open (url, name, param);
}

function terms() {
	//'height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no'
	//alert("terms");
	window.open ("terms/terms-conditions.html", "Terms and Conditions", "toolbar=0","status=0","width=200", "height=100", "scrollbars=1", "resizable=no");
}


//
