
// ...............................................

// Use for testing that JavaScript and usercontrol is working...
// alert('Your Javascript is working!');

// ...............................................

//---Image Slice-Show Script--- (currently not used, so optional)
function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder').src = whichpic.href;
  if (whichpic.childNodes[0].alt) {
   //document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
document.getElementById('placeholder').alt = whichpic.childNodes[0].alt;
  } else {
   //document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
document.getElementById('placeholder').alt = "";
  }
  return false;
 } else {
  return true;
 }}

// ...............................................

//---PRINT WEB PAGE---
function goPrint() {
    print();
}

// ...............................................


// GLOBAL POPUP WINDOW OBJECT
//var globalWindow;

function closeDialog() {
    window.close();
}

// ............... Popup Checker 2 .................
function Popup(TheURL,WindowName,width,height,top,left)
{
    var leftPosition = 	(screen.width) ? (screen.width-width)/2 : 0;
    var topPosition = 	(screen.height) ? (screen.height-height)/2 : 0;
    if (window.open)
    {
        globalWindow=window.open(TheURL,WindowName,'width='+width+',height='+height+',alwaysLowered=0,top='+topPosition+',left='+leftPosition+',alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=1,scrollbars=0,status=0,titlebar=0,toolbar=0,z-lock=0');
        //globalWindow.focus();
        //globalWindow.onblur = new function(){globalWindow.focus();setInterval('if(!globalWindow.closed)globalWindow.focus();',1000);};
    }
    else
    {
        alert('Alert! This website uses "popups". Please turn off all\nPopup Blockers before viewing this website. Thank You');
    }
    //return false;
}


//---Netscape 4 Reload Script---
// Note: this is turned OFF for now, since support of older Netscape 4 series browsers is not needed
//function reLoadPage(init) {  //reloads the window if Nav4 resized
  //if (init==true) with (navigator) {
    //if ((appName=="Netscape") && (parseInt(appVersion)==4)) {
    //document.is_pgW=innerWidth; document.is_pgH=innerHeight; 
    //onresize=reLoadPage; }}
  //else if (innerWidth!=document.is_pgW || innerHeight!=document.is_pgH) 
    //location.reload();
  //}
// reLoadPage(true);

// ...............................................

// Yet Another Nasty Browser "Sniffer" Script Thingie (another reminder of why I hate JavaScript)...
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
//TEST
//alert(BrowserDetect.browser);


//
// getPageSize()
// Returns array with page width, height and window width, height
// Code from Lightbox 2 (http://www.huddletogether.com/projects/lightbox2/)
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


// ================== DELETE CONFIRMATION ==================
function Delete()
{
	var x = window.confirm('Are you sure you want to delete this file?');
	if (x)
	{
		return true;
	}
	else
	{
		return false;
	}
}

//.......................................................

function ShowHide (ID,isShown)
{
    if (document.getElementById)
    {
        if (document.getElementById(ID))
        {
            if (isShown == 'hide')
            {
                document.getElementById(ID).style.display = 'none';
            }
            else
            {
                document.getElementById(ID).style.display = 'block';
            }
        }
    }
}

//.......................................................
// This Internet Explorer "hack" below allows the media player popup to play the video and audio files without the ugly messages created from the Eolas patent issue with Microsoft
        function WriteMediaCode(theUrl,theMime,theAttribute)
        {
            // always detect if IE as causes issues in other agents
            if (BrowserDetect.browser == "Explorer")
            {
                document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
                document.write("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"><head></head><body style='width:100%;height:100%;margin:0;padding:0;text-align:center;'>\n");
                document.write("<div id=\"divactivex1\" class=\"hidefromnetscape4\" style='width:100%;height:100%;margin:0;padding:0;text-align:center;'>\n");
                document.write("<object id=\"objectactivex1\" name=\"objectactivex1\" data=\"" + theUrl + "\" type=\"" + theMime + "\" standby=\"Loading Media...\" title=\"\" " + theAttribute +" style='width:100%;height:100%;margin:0;padding:0;text-align:center;'>\n");
                document.write("<param name=\"url\" value=\"" + theUrl + "\" />\n");
                document.write("<param name=\"href\" value=\"" + theUrl + "\" />\n");
                document.write("<param name=\"filename\" value=\"" + theUrl + "\" />\n");
                document.write("<param name=\"src\" value=\"" + theUrl + "\" />\n");
                document.write("<param name=\"qtsrc\" value=\"" + theUrl + "\" />\n");

                document.write("<param name=\"AutoSize\" value=\"true\" />\n");
                document.write("<param name=\"AnimationAtStart\" value=\"true\" />\n");
                document.write("<param name=\"AllowScan\" value=\"true\" />\n");
                document.write("<param name=\"AllowChangeDisplaySize\" value=\"true\" />\n");
                document.write("<param name=\"AutoRewind\" value=\"true\" />\n");
                document.write("<param name=\"Balance\" value=\"false\" />\n");
                document.write("<param name=\"BaseURL\" value=\"\" />\n");
                document.write("<param name=\"BufferingTime\" value=\"0\" />\n");
                document.write("<param name=\"CaptioningID\" value=\"\" />\n");
                document.write("<param name=\"ClickToPlay\" value=\"false\" />\n");
                document.write("<param name=\"CursorType\" value=\"false\" />\n");
                document.write("<param name=\"CurrentPosition\" value=\"true\" />\n");
                document.write("<param name=\"CurrentMarker\" value=\"false\" />\n");
                document.write("<param name=\"DefaultFrame\" value=\"\" />\n");
                document.write("<param name=\"DisplayBackColor\" value=\"false\" />\n");
                document.write("<param name=\"DisplayForeColor\" value=\"16777215\" />\n");
                document.write("<param name=\"DisplayMode\" value=\"0\" />\n");
                //These are: 0 (default size), 3 (full screen), and 4 (fit to size).
                document.write("<param name=\"DisplaySize\" value=\"0\" />\n");
                document.write("<param name=\"Enabled\" value=\"true\" />\n");
                document.write("<param name=\"EnableContextMenu\" value=\"true\" />\n");
                document.write("<param name=\"EnablePositionControls\" value=\"true\" />\n");
                document.write("<param name=\"EnableFullScreenControls\" value=\"false\" />\n");
                document.write("<param name=\"EnableTracker\" value=\"true\" />\n");
                document.write("<param name=\"InvokeURLs\" value=\"true\" />\n");
                document.write("<param name=\"Language\" value=\"true\" />\n");
                document.write("<param name=\"Mute\" value=\"false\" />\n");
                document.write("<param name=\"PlayCount\" value=\"1\" />\n");
                document.write("<param name=\"PreviewMode\" value=\"0\" />\n");
                document.write("<param name=\"Rate\" value=\"1\" />\n");
                document.write("<param name=\"SAMILang\" value=\"\" />\n");
                document.write("<param name=\"SAMIStyle\" value=\"\" />\n");
                document.write("<param name=\"SAMIFileName\" value=\"\" />\n");
                document.write("<param name=\"SelectionStart\" value=\"true\" />\n");
                document.write("<param name=\"SelectionEnd\" value=\"true\" />\n");
                document.write("<param name=\"SendOpenStateChangeEvents\" value=\"true\" />\n");
                document.write("<param name=\"SendWarningEvents\" value=\"true\" />\n");
                document.write("<param name=\"SendErrorEvents\" value=\"true\" />\n");
                document.write("<param name=\"SendKeyboardEvents\" value=\"false\" />\n");
                document.write("<param name=\"SendMouseClickEvents\" value=\"false\" />\n");
                document.write("<param name=\"SendMouseMoveEvents\" value=\"false\" />\n");
                document.write("<param name=\"SendPlayStateChangeEvents\" value=\"true\" />\n");
                document.write("<param name=\"ShowCaptioning\" value=\"false\" />\n");
                document.write("<param name=\"ShowControls\" value=\"true\" />\n");
                document.write("<param name=\"ShowVideoControls\" value=\"true\" />\n");
                document.write("<param name=\"ShowDisplay\" value=\"false\" />\n");
                document.write("<param name=\"ShowGotoBar\" value=\"false\" />\n");
                document.write("<param name=\"ShowPositionControls\" value=\"true\" />\n");
                document.write("<param name=\"ShowStatusBar\" value=\"false\" />\n");
                document.write("<param name=\"ShowTracker\" value=\"true\" />\n");
                document.write("<param name=\"TransparantAtStart\" value=\"false\" />\n");
                document.write("<param name=\"VideoBorderWidth\" value=\"false\" />\n");
                document.write("<param name=\"VideoBorderColor\" value=\"false\" />\n");
                document.write("<param name=\"VideoBorder3D\" value=\"false\" />\n");
                document.write("<param name=\"Volume\" value=\"25\" />\n");
                document.write("<param name=\"WindowlessVideo\" value=\"0\" />\n");
                document.write("<param name=\"Controller\" value=\"true\" />\n");
                document.write("<param name=\"Target\" value=\"myself\" />\n");
                document.write("<param name=\"CanScan\" value=\"true\" />\n");
                document.write("<param name=\"scale\" value=\"aspect\" />\n");
                document.write("<param name='controls' value='ImageWindow,ControlPanel' />\n");
                document.write("<param name='nolabels' value='false' />\n");
                document.write("<param name='reset' value='false' />\n");
                document.write("<param name='autogotoURL' value='true' />\n");
                
                document.write("<param name=\"Autoplay\" value=\"true\" />\n");
                document.write("<param name=\"autostart\" value=\"1\" />\n");
                document.write("<param name=\"AutoStart\" value=\"1\" />\n");
                
                //document.write("<param name=\"Autoplay\" value=\"false\" />\n");
                //document.write("<param name=\"autostart\" value=\"0\" />\n");
                //document.write("<param name=\"AutoStart\" value=\"0\" />\n");

                document.write("<span class=\"objectalert\">\n");
                document.write("<strong>Alert!</strong> Sorry, your browser does not have the required Media Player for this file type. Try opening the file directly using the following link: <a href=\"" + theUrl + "\" type=\"" + theMime + "\" title=\"click to open the video file in a new window\" target=\"_blank\">play</a>\n");
                document.write("</span>\n");

                document.write("</object>\n");
                document.write("</div>\n");
                document.write("</body></html>\n");
            }
        }