//----------------------------------------------- macromedia functions

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_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_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_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);
}

// -------------------------------------------------- niki9 functions


//this function returns a specified parameter from the URL
function getParam(theArgName) {
	sArgs = location.search.slice(1).split('&');
    r = '';
    for (var i = 0; i < sArgs.length; i++) {
        if (sArgs[i].slice(0,sArgs[i].indexOf('=')) == theArgName) {
            r = sArgs[i].slice(sArgs[i].indexOf('=')+1);
            break;
        }
    }
    return (r.length > 0 ? unescape(r).split(',') : '')
}

//this function prints the thumbnails if no particular image has been selected yet
function printThumbnails() {
	document.write("<table width='75%' align='center' cellpadding='5'><tr>")
	for(i=0;i<pics.length;i++) {
		document.write("<td align='center'><a href='"+fileName+"?img="+i+"'><img src='"+pics[i]+"' height='100' border='1'></a></td>");
		if ((i + 1) % columns == 0) {
			document.write("</tr><tr>");
		}
	}
	var extraCells = pics.length % columns;
	for(i=0;i<extraCells;i++) {
		document.write("<td>&nbsp;</td>")
	}
	document.write("</tr></table>");
}


//this function prints the large image that has been selected, as well links back to the index, and to the next and last image
function printImage(img) {
	document.write("<center>");
	document.write("<img src='"+pics[img]+"' border='2' height='600'>");
	document.write("<br><br><a href='"+fileName+"'>Go Back To The Index</a><center>");
	
	var next = img - 1 + 2; 
	var prev = img - 1;
	var printprev = "yes";
	var printnext = "yes";
	if (next == pics.length) printnext = "no";
	if (prev < 0) printprev = "no";
	document.write("<table width='75%' align='center'><tr>");
	if (printprev == "yes") document.write("<td align='left'><a href='"+fileName+"?img="+prev+"'>Previous Image</a></td>");
	if (printnext == "yes") document.write("<td align='right'><a href='"+fileName+"?img="+next+"'>Next Image</a></td>");
	document.write("</tr></table>");
}

//an image swap without restore
function swapImage(imageName, path) {
	document.images[imageName].src = path;
}

// popup with multiple windows & simpler parameters
var popwin = 1;
function popUp(page, width, height) {
	popwin = popwin+1;
	popwin.toString();
	newWindow = window.open(page, popwin, "toolbar=0,menubar=0,width="+width+",height="+height+",status=0,scrollbars=1,alwaysRaised=1,resizable=1");
}

// bookmark this page
function bookmark(urlAddress,pageName) {
	if (window.external) {
		window.external.AddFavorite(urlAddress,pageName);
	} else { 
		alert("Sorry! Your browser doesn't support this function.");
	}
}

//==================================================
// flash detection:
//==================================================

// heavily modified version of original by colin moock
// user defined global: modify to customize the inspection behaviour
var requiredVersion = 4;			// version needed

// system globals
var flash2Installed = false;		// boolean. true if flash 2 is installed
var flash3Installed = false;		// boolean. true if flash 3 is installed
var flash4Installed = false;		// boolean. true if flash 4 is installed
var flash5Installed = false;		// boolean. true if flash 5 is installed
var flash6Installed = false;		// boolean. true if flash 5 is installed
var maxVersion = 6;					// highest version we can actually detect
var actualVersion = 0;				// version the user really has
var hasRightVersion = false;		// boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;				// the version of javascript supported


// check the browser...we're looking for ie/win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.platform.indexOf("Win32") != -1) ? true : false;

// this is a js1.1 code block, so make note that js1.1 is supported.
jsVersion = 1.1;

// write vbscript detection if we're not on mac.
if(isIE && isWin) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n'); 
	document.write('</SCR' + 'IPT\> \n');
}


function detectFlash() {	
	if (navigator.plugins) {	// does navigator.plugins exist?
		if (navigator.plugins["Shockwave Flash 2.0"] 	// yes>> then is Flash 2 
		|| navigator.plugins["Shockwave Flash"]) {		// or flash 3+ installed?

			// set convenient references to flash 2 and the plugin description
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

			// we know the version, now set appropriate version flags
			flash2Installed = flashVersion == 2;		
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion >= 6;
		}
	}
	
	// loop through all versions and set actualVersion to highest detected version
	for (var i = 2; i <= maxVersion; i++) {	
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;
	
	// return true if greater than or equal to required version, else return false.
	if (actualVersion >= requiredVersion) {
		return true;
	} 
	else {
		return false;
	}
}