var flVer = deconcept.SWFObjectUtil.getPlayerVersion();
var check_iPhone = navigator.userAgent.search('iPhone');
var check_iTouch = navigator.userAgent.search('iPod');

function sizePage()
{
	var f = $("footer");

	var fd = f.getCoordinates();
	
	var ph = fd.top+fd.height;
	var wh = window.getHeight() + 60;
	
	if(ph<wh) f.setStyle('height', fd.height + (wh-ph));

	$('content').setStyle('width',window.getWidth());
	if($('masthead') != null) $('masthead').setStyle('width',window.getWidth());
}

// have page resize on rotation
window.onorientationchange = sizePage;


window.addEvent('domready', function()
{
	var redirecting = false;
	
	// do redirect if browser supports flash and isn't iPhone
	if(flVer["major"] > 0)
	{
		
		$$('html')[0].setStyle("height", "100%");
		$$('html')[0].setStyle("overflow", "auto");
		
		// don't bother if we are home page
		if(sectionID == "home" && (contentID == null || contentID == "" || contentID == undefined || contentID == "undefined")){
		} else {
	
			//check to see if not iPhone!
			if(window.orientation === undefined)
			{
			//Not running on iPhone/iPod or version is less than 1.1.1, check further.
			//run user agent check
				if(check_iPhone < 0 && check_iTouch < 0)
				{
					//var newDeeplink =  pathToRoot + "home/index.html";
					var newDeeplink = "http://www.nike.com/jumpman23/home/index.html";
				
					if(sectionID != null && sectionID != "" && sectionID != undefined && sectionID != "undefined")
					{
						newDeeplink += "#" + sectionID;
						
						if(contentID != null && contentID != "" && contentID != undefined && contentID != "undefined")
						{
							newDeeplink += "?contentID=" + contentID;
							
							if(categoryID != null && categoryID != "" && categoryID != undefined && categoryID != "undefined")
							{
								newDeeplink += "&categoryID=" + categoryID;
							}
						}				
					}

					redirecting = true;
					document.location = newDeeplink;			
				}
			}
		}
	}
	else
	{
		// if no flash and on iPhone/iTouch
		if(window.orientation !== undefined || (check_iPhone >= 0 || check_iTouch >= 0))
		{
			sizePage();
			
			var scrollChange = new Fx.Scroll($(window));
			scrollChange.set(0,1);
						
			var paddingChange = new Fx.Tween(document.body, {
			duration:500, 
			transition: Fx.Transitions.Sine.easeOut
			});
			paddingChange.start('padding-left',window.getWidth(), 0);

		}
		
		var t=setTimeout(function()
		{
			$("loadMask").style.display = "none";
			clearTimeout(t);
		},25);
		
	}

}
);