/*
	common.js
	Common JavaScript functions used throughout the Nike Basketball V3 sites
*/

<!--

// ------------------ Flash detect ---------------------------

	// detect browser
	Netscape = navigator.appName == "Netscape";
	MSIE = navigator.appName == "Microsoft Internet Explorer";
	Opera = navigator.userAgent.indexOf("Opera") > -1;
	Unknown = !(Netscape || MSIE || Opera);
	
	// detect platform
	Win = navigator.userAgent.indexOf("Win") > -1;
	Mac = navigator.userAgent.indexOf("Mac") > -1;
	Other = !(Win || Mac);
	
	// now extract version numbers
	if (Netscape) {
		NetscapeVer = parseFloat(navigator.appVersion);
	} else if (MSIE) {
		n = navigator.userAgent;
		MSIEVer = n.substr(n.indexOf("MSIE ")+("MSIE ").length, 4);
		MSIEVer = parseFloat(MSIEVer); 
		// converts it into a floatint point number
	
		if (Opera) {
			OperaVer = n.substr(n.indexOf("Opera ")+("Opera ").length, 4);
			OperaVer = parseFloat(OperaVer);
		}
	}
	
  	var g_plugin = 0;
	var browserType = 0;  // Not IE 
	
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] &&    
	    navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
	
		var version_check = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0); 
		var flash_ver = parseInt(version_check.description.substring(version_check.description.indexOf(".")-1))
	
		if (navigator.plugins && navigator.plugins["Shockwave Flash"] && flash_ver > 5 )
			g_plugin = 1;
	} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
		&& (navigator.userAgent.indexOf("Windows 95")>=0 
		|| navigator.userAgent.indexOf("Windows 98")>=0 
		|| navigator.userAgent.indexOf("Windows NT")>=0)) {
					
			document.write('<SCRIPT LANGUAGE=VBScript> \n');
			document.write('on error resume next \n');
			document.write('if ( g_plugin <= 0 ) then g_plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
	
			document.write('</SCRI');
			document.write('PT> \n');
			
			browserType = 1;  // IE      
	}
	

// functions

function resizeThisToFull() {
	
	//if ((Win && Netscape) || Opera || Unknown || Mac) {
	if (!(MSIE && Win)) {

		window.moveTo(0,0);
	
		if (document.all) {
			window.resizeTo(screen.availWidth,screen.availHeight);
		} else if (document.layers || document.getElementById) {
			if (window.outerHeight < screen.availHeight || window.outerWidth < screen.availWidth) {
				window.outerHeight = screen.availHeight;
				window.outerWidth = screen.availWidth;
			}
		}
		
	}

}


// over writes the function in the global common file, to be used for the regional sites
function gotoOtherSite( link, useCookie, referral ) {

	// useCookie is a string, if it is null, we are just going to another site.
	// if it is "true" we set the cookie to the new site,
	// if it is "false" we clear the cookie
	if ( useCookie == "true" ) {
		setCookie(cookieName, link,"/");
	} else if ( useCookie == "false" ) {
		setCookie(cookieName, "","/");
	}
	
	if ( link.indexOf("?") > -1 ) {
		link = link + "&ref=" + referral;
	} else {
		link = link + "?ref=" + referral;
	}
	
	if( cmdebug && cmdebug !=null && cmdebug== "yes" ) {
		link += "&cmdebug=yes" ;
		alert("in debug mode link= "+ link) ;
	}
	
	// switch
	if (top.opener == null || top.opener.closed) {
		var features = "menubar=yes,location=yes,directories=yes,resizable=yes,scrollbars=yes,status=yes,width=750,height=550";
		mainWindow = window.open(link, "_new", features);
		mainWindow.focus();
	} else {
		top.opener.location.href = link;
		top.opener.focus();
	}
	top.close();
}


function openTvcmLebrons(){
	var url='/basketball/v4/features/lebron3/cm/cm1.html';
	var name='tvcmLebron';
	w=350;
	h=270;
	extra=0;
	if(extra == "0") { extra = "scrollbars=0"; }
    	if(extra == "1") { extra = "scrollbars=1"; }
	str='height='+h+',width='+w+','+extra;
	if(parseInt(navigator.appVersion)>3)
		str+=',left='+((screen.width-8) -w)/2+',top='+parseInt((screen.height -h)/3);
	win=window.open(url,name,str);
	//parent.window.location.href = url;
	
}


//-->
