// JavaScript Code for World Class Arena Website
// (c) 2002 Doublestruck.
// Developer: John Baptiste

<!--

function MM_maximize() { //v3.0

top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->

// Browser ID Utilities

var gAgent = window.navigator.userAgent;
var gAgentVers = parseInt(gAgent.charAt(gAgent.indexOf("/")+1),10);

function is_explorer()
{
	return gAgent.indexOf("MSIE") > 0;
}
	
function is_aol()
{
	return gAgent.indexOf("AOL") > 0;
}

function is_macnetscape()
{
	if (gAgent.indexOf("Mac") <= 0)
		return false;
	else
		return !(gAgent.indexOf("MSIE") > 0);
}

function is_macie4()
{
	if ((gAgent.indexOf("Mac") > 0) && (gAgent.indexOf("MSIE") > 0) && (gAgentVers < 5))
		return true;
	else
		return false;
}

function is_pcnetscape()
{
	if (gAgent.indexOf("Mac") > 0)
		return false;
	else
		return !(gAgent.indexOf("MSIE") > 0);
}
	

// Flash and Image Utilities

// Check whether Flash is installed on the user's computer and create a cookie with the
// result. The cookie has four possible values which tell other routines what to do when
// asked to insert a Flash movie:
// "img" - write out <IMG> tag instead
// "swf" - write out <EMBED> tag and use a Flash movie
// "mov" - write out <EMBED> tag and use a QuickTime movie (QT4 onwards plays Flash)
// "none" - do nothing, <NOSCRIPT> will handle the image in Netscape 2

var gImageHandling = "";

function check_flash()
{
	var nextYear = new Date();
	
	gImageHandling = "none";
		
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
	{
		// Navigator and Explorer ver 5 onwards
		if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		{
			var desc = navigator.plugins["Shockwave Flash"].description;
			var vers = parseInt(desc.charAt(16));
			if (vers >= 3) gImageHandling = "swf";
		}
	}
			
	if (gImageHandling == "none" && navigator.mimeTypes && navigator.mimeTypes["video/quicktime"] && navigator.mimeTypes["video/quicktime"].enabledPlugin)
	{
		// Navigator and Explorer ver 5 onwards
		var instPlugins = navigator.plugins
		for (var i = 0; i < instPlugins.length; i++)
		{
   			if (instPlugins[i].name.indexOf("QuickTime")>=0)
   			{
				var desc = navigator.plugins[i].name;
				var vers = parseInt(desc.charAt(18));
				if (vers >= 2) gImageHandling = "mov";
				i = instPlugins.length;
	   		}
		}
	}
			
	if (gImageHandling == "none" && navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	   && (navigator.userAgent.indexOf("Windows")>=0 || navigator.userAgent.indexOf("Win32")>=0))
	{
	   	// Explorer on a 32-bit PC
		document.write('<scr' + 'ipt language=VBSc' + 'ript\> \n');
		document.write('dim Obj\n');
		document.write('gImageHandling = "gif"\n');
		document.write('on error resume next \n');
		document.write('Set Obj = CreateObject("ShockwaveFlash.ShockwaveFlash.4")\n');
		document.write('if IsObject(Obj) = True then gImageHandling = "swf" \n');
		document.write('Set Obj = Null \n');
		document.write('</scr' + 'ipt\> \n');
	}
		
	if (gImageHandling == "none" && !(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
	{
		// Anything else, other than Navigator ver 2 which will use <NOSCRIPT>
		gImageHandling = "gif";
	}
	
	// Write out cookie
	nextYear.setFullYear(nextYear.getFullYear() + 1);
	document.cookie = "flashHandling=" +  gImageHandling + "; expires=" + nextYear.toGMTString() + "; domain=nykris.com; path=/";

//	document.write('<p>gImageHandling (cookie)=' + gImageHandling + '</p>');
}



function check_flash_nocookie()
{
	gImageHandling = "none";
		
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
	{
		// Navigator and Explorer ver 5 onwards
		if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		{
			var desc = navigator.plugins["Shockwave Flash"].description;
			var vers = parseInt(desc.charAt(16));
			if (vers >= 3) gImageHandling = "swf";
		}
	}
			
	if (gImageHandling == "none" && navigator.mimeTypes && navigator.mimeTypes["video/quicktime"] && navigator.mimeTypes["video/quicktime"].enabledPlugin)
	{
		// Navigator and Explorer ver 5 onwards
		var instPlugins = navigator.plugins
		for (var i = 0; i < instPlugins.length; i++)
		{
   			if (instPlugins[i].name.indexOf("QuickTime")>=0)
   			{
				var desc = navigator.plugins[i].name;
				var vers = parseInt(desc.charAt(18));
				if (vers >= 2) gImageHandling = "mov";
				i = instPlugins.length;
	   		}
		}
	}
			
	if (gImageHandling == "none" && navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	   && (navigator.userAgent.indexOf("Windows")>=0 || navigator.userAgent.indexOf("Win32")>=0))
	{
	   	// Explorer on a 32-bit PC
		document.write('<scr' + 'ipt language=VBSc' + 'ript\> \n');
		document.write('dim Obj\n');
		document.write('gImageHandling = "gif"\n');
		document.write('on error resume next \n');
		document.write('Set Obj = CreateObject("ShockwaveFlash.ShockwaveFlash.4")\n');
		document.write('if IsObject(Obj) = True then gImageHandling = "swf" \n');
		document.write('Set Obj = Null \n');
		document.write('</scr' + 'ipt\> \n');
	}
		
	if (gImageHandling == "none" && !(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
	{
		// Anything else, other than Navigator ver 2 which will use <NOSCRIPT>
		gImageHandling = "gif";
	}
			
//	document.write('<p>gImageHandling (no cookie)=' + gImageHandling + '</p>');
}



// Insert a Flash movie or fallback GIF into the current page depending upon the setting
// of the imageHandling cookie.

function insert_flash(name, width, height, bgCol)
{
	var imageHandling = document.cookie;
	
	if (imageHandling.indexOf("flashHandling") == -1)
	{
		// No cookie exists - ie cookies are off, so do manual check
		check_flash_nocookie();
		imageHandling = gImageHandling
	}
		
	if (imageHandling.indexOf("none") != -1)
	{
	}
	else if (imageHandling.indexOf("swf") != -1)
	{
		document.write('<embed src="' + name + '.swf"');
		document.write(' swLiveConnect=false width=' + width + ' height=' + height);
		document.write(' loop=false quality=high scale=noborder bgcolor=' + bgCol);
		document.write(' type="application/x-shockwave-flash"\>');
		document.write('</embed\>');
		document.write('<noembed\><img src="' + name + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\></noembed\>');
	}
	else if (imageHandling.indexOf("mov") != -1)
	{
		document.write('<embed src="' + name + '.mov"');
		document.write(' autoplay="true" controller="false" width="' + width + '" height="' + height + '"');
		document.write(' loop=false bgcolor=' + bgCol);
		document.write(' type="video/quicktime"\>');
		document.write('</embed\>');
		document.write('<noembed\><img src="' + name + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\></noembed\>');
	}
	else
	{
		document.write('<img src="' + name + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\>');
	} 
	
}



// Insert a random Flash movie or random fallback GIF into the current page depending upon
// the setting of the imageHandling cookie.

function insert_random_flash(imgPath,width,height,bgCol,numImages)
{
	var imageHandling = document.cookie;
	
	if (imageHandling.indexOf("flashHandling") == -1)
	{
		// No cookie exists - ie cookies are off, so do manual check
		check_flash_nocookie();
		imageHandling = gImageHandling
	}
		
	imgNum = (Math.floor((new Date()).getTime()/10)%numImages) + 1;
	imgNumStr = (new Number(imgNum)).toString();
	if (imgNum < 10) imgNumStr = '0' + imgNumStr;

	if (imageHandling.indexOf("none") != -1)
	{
	}
	else if (imageHandling.indexOf("swf") != -1)
	{
		document.write('<embed src="' + imgPath + imgNumStr + '.swf"');
		document.write(' swLiveConnect=false width=' + width + ' height=' + height);
		document.write(' loop=false quality=high scale=noborder bgcolor=' + bgCol);
		document.write(' type="application/x-shockwave-flash"\>');
		document.write('</embed\>');
		document.write('<noembed\><img src="' + imgPath + imgNumStr + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\></noembed\>');
	}
	else if (imageHandling.indexOf("mov") != -1)
	{
		document.write('<embed src="' + imgPath + imgNumStr + '.mov"');
		document.write(' autoplay="true" controller="false" width="' + width + '" height="' + height + '"');
		document.write(' loop=false bgcolor=' + bgCol);
		document.write(' type="video/quicktime"\>');
		document.write('</embed\>');
		document.write('<noembed\><img src="' + imgPath + imgNumStr + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\></noembed\>');
	}
	else
	{
		document.write('<img src="' + imgPath + imgNumStr + '.gif" width=' + width + ' height=' + height + ' border=0 usemap="#' + name + '"\>');
	} 
	
}




// Insert a random GIF image into the current page depending upon the setting of the
// imageHandling cookie.

function insert_random_image(imgType,imgPath,imgWidth,imgHeight,imgHspace,imgVspace,numImages)
{
	var imgNum,imgNumStr="";
	var imageHandling = document.cookie;
	
	if (imageHandling.indexOf("flashHandling") == -1)
	{
		// No cookie exists - ie cookies are off, so do manual check
		check_flash_nocookie();
		imageHandling = gImageHandling
	}
		
	if (imageHandling.indexOf("none") == -1)
	{
		imgNum = (Math.floor((new Date()).getTime()/10)%numImages) + 1;
		imgNumStr = (new Number(imgNum)).toString();
		if (imgNum < 10) imgNumStr = '0' + imgNumStr;
		document.write('<img src="' + imgPath + imgNumStr + '.' + imgType + '" width=' + imgWidth + ' height=' + imgHeight + ' vspace=' + imgVspace + ' hspace=' + imgHspace + '\>');
	}

}


// Miscellaneous Javascript Utilities

var gPopup = "none";
	
// Open a window in either the topleft or topright screen corner
function openWin(url,name,w,h,loc)
{
	if (loc == 'topright')
	{
		gPopup=window.open(url,'popup','left='+(screen.width.valueOf()-(w+100))+',top=400,width='+w+',height='+h+',toolbar=yes,location=no,status=no,scrollbars=no,resizable=yes')
	}
	else if (loc == 'topleft')
	{
		gPopup=window.open(url,'popup','left=100,top=100,width='+w+',height='+h+',toolbar=yes,location=no,status=no,scrollbars=no,resizable=yes')
	}
}

// Close the popup window if it is open
function closeWin()
{	
	if (gPopup)
	{
		if (!is_macie4())
			{
				if (typeof(gPopup) == "object")
				{
					if (gPopup.closed == false)
					{
						gPopup.close();
					}
					gPopup="none";
				}
			}
		else
			{
				if (typeof(gPopup) == "object")
				{
					gPopup="none";
				}
			}
	}
}

// Change the URL of the main window, even if we are in the popup
function navigateMainWindow(url)
{
	if ((window.name.length >= 5) && (window.name.substring(0,5) == "popup"))
	{
		window.opener.location = url;
	}
	else
	{
		window.location = url;
	}
}

// Open a window for an image with optional caption either the topleft or topright screen corner
function openImageWin(title,imageUrl,imageW,imageH,caption,loc)
{
	var w = imageW+16;
	var h = imageH+16;
	var popupHTML = "";
	
	closeWin();
	   
	var lowerCaption = caption.toLowerCase();
	var captionArray = lowerCaption.split("<br>");
	var numberOfLines = captionArray.length;
	if (caption != "")
	{
		h += 8 + (14 * numberOfLines);
	}
	
	popupHTML += "<html><head><title>"+title+"</title>";
	if (caption != "")
	{

		popupHTML += "<style>";
		popupHTML += "<!--";
		popupHTML += ".small { color: #333; font-size: 10px; line-height: 14px; font-family: Arial, Helvetica, Geneva; }";
		popupHTML += ".body {color: #333; font-size: 11px; line-height: 14px; font-family: Arial, Helvetica, Geneva; }";
		popupHTML += ".body a:link { color: #666; text-decoration: none }";
		popupHTML += ".body a:active { color: #666; text-decoration: underline }";
		popupHTML += ".body a:visited { color: #666; text-decoration: none }";
		popupHTML += ".body a:hover { color: #666; text-decoration: underline }";
		popupHTML += "-->";
		popupHTML += "</style>";
	}
	popupHTML += "</head>";
	popupHTML += "<body bgcolor='#FFFFFF' leftmargin=8 topmargin=8 marhinheight=8 marginwidth=8>";
	popupHTML += "<table cellpadding=0 cellspacing=0 border=0>";
	popupHTML += "<tr><td><img src='" + imageUrl + "' width="+imageW+" height="+imageH+" border=0></td></tr>";
	if (caption != "")
	{
		popupHTML += "<tr><td valign=top align=left><table cellpadding=8 cellspacing=0 border=0><tr><td align=left valign=top class='body'>" + caption + "</td></tr></table></td></tr>";
	}
 	popupHTML += "</table>";
  	popupHTML += "</body></html>";
		
	var x = 0;
	var y = 0;
	
	// open the popup window
	if (loc == 'topright')
	{
		x=(screen.width.valueOf()-(w+100));
		y=100;
	}
	else if (loc == 'topleft')
	{
		x=100;
		y=100;
	}
	else if (loc == 'center')
	{
		x=Math.round((screen.width.valueOf()/2)-(w/2));
		y=100;
	}
	
	var secs = new Date();
		
	if (is_aol())
		{
		w = w+4;
		h = h+4;
		gPopup=window.open('','popup'+secs.getTime(),'width='+w+',height='+h+',toolbar=no,location=no,status=no,scrollbars=no,resizable=no');
		}
	else
		{
		gPopup=window.open('','popup'+secs.getTime(),'left='+x+',top='+y+',width='+w+',height='+h+',toolbar=no,location=no,status=no,scrollbars=no,resizable=no');
		gPopup.moveTo(x,y);
		}

	// write the contents into the window
	gPopup.document.open();
	gPopup.document.write(popupHTML);
	gPopup.document.close();
	gPopup.focus();
}
