
// globals
var imageOffFiles = new Array();
var imageOnFiles = new Array();
var imageTagNames = new Array();
var imageOff = new Array();
var imageOn  = new Array();

// browser version
var nn4 = (document.layers);
var ie4 = (document.all);
var nn6 = (document.getElementById && !document.all);
var ie5 = (document.all && document.getElementById);

// mac or not
var agent = navigator.userAgent.toLowerCase();
var mac = (agent.indexOf("mac")!=-1) ? true : false; // true if we're on mac

/*******************************************************************************
	Netscape Resize fix.
*******************************************************************************/
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/*******************************************************************************
	Rollovers
*******************************************************************************/

// functions
// this function loads the images from the temp arrays into the 
// storage arrays
function fnInitRollovers() {
	if (document.images) {
		var currentName = "";
		for (var i = 0; i < imageOnFiles.length; i++) {
			currentName = imageTagNames[i];
			
			imageOff[currentName] = new Image();
			imageOn[currentName] = new Image();
			imageOff[currentName].src = imageOffFiles[i];
			imageOn[currentName].src = imageOnFiles[i];
			
		}
	}
}

// this function adds an image into the temporary arrays
function fnPreloadRollover(onFile, offFile, tagName) {

	var index = imageOffFiles.length;
	imageOffFiles[index] = onFile;
	imageOnFiles[index] = offFile;
	imageTagNames[index] = tagName;
}

// this function sets an input type=image to its rollon image
function fnRollonSub(elm,img) {
	
	if (imageOn[img]) {
		elm.src = imageOn[img].src;
	} else {
		// make sure images have been initialised
		if (imageOn[img]){
			elm.src = imageOn[img].src;
		} else {
			fnInitRollovers();
			if (imageOn[img]){
				elm.src = imageOn[img].src;
			}
		}
	}
}

// this function sets an input type=image to its rolloff image
function fnRolloffSub(elm,img) {
if (imageOff[img]) {
	elm.src = imageOff[img].src;
	}
}

// this function sets an image to its rollon image
function fnRollon(img, layer) {
	// try initialising images if necessary
	if(!imageOn[img])
		fnInitRollovers();
	if (document.images && imageOn[img]) {
		if (layer != null && document.layers && typeof(layer) == 'object') layer.document.images[img].src = imageOn[img].src;
		else if (layer != null && document.layers && typeof(layer) == 'string') eval('document.layers.' + layer + '.document.images[img].src = imageOn[img].src');
		else if (document.images[img])
			document.images[img].src = imageOn[img].src;
	}
	
}

// this function sets an image to its rolloff image
function fnRolloff(img, layer) {
	
	if (document.images && imageOff[img]) {
		if (layer != null && document.layers && typeof(layer) == 'object') layer.document.images[img].src = imageOff[img].src;
		else if (layer != null && document.layers && typeof(layer) == 'string') eval('document.layers.' + layer + '.document.images[img].src = imageOff[img].src');
		else if (document.images[img]) document.images[img].src = imageOff[img].src;
	}
}

/*******************************************************************************
	Modal Dialog controls
*******************************************************************************/

function resizeMediaPlayer(){
    if(is.ns){
        var botY = document.anchors['Bottom'].y;
        var frameHeight = self.innerHeight;
    }
    if(is.ie){
        var botY = document.all['Bottom'].offsetTop;
        var frameHeight = document.body.clientHeight;
    }
    parent.resizeBy(0,botY-frameHeight);
}




/*******************************************************************************
	Popup Window openers
*******************************************************************************/

function fnOpenPopup(passedInfo,passedURL, width, height) {
	var URL =  passedURL + passedInfo;
	if(width == null || width == '')
		var width=500;
	if(height == null || height == '')
		var height=500;

	var popup = fnOpenPositionedWindow(URL, 'pop', width, height, 0, 0, '', 'scrollbars','resizable');
}
	
	


// Open a window at a given position on the screen
function fnOpenPositionedWindow(url, name, width, height, x, y, status, scrollbars,resizable, openerName) {
	
	// ie4.5 mac - windows are 2 pixels too short; if a statusbar is used, the window will be an additional 15 pixels short
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("mac")!=-1 && agent.indexOf("msie") != -1 && agent.indexOf("msie 5.0")==-1) {
		height += 2;
		if (status) height += 15;
	}
	
	var properties = 'width=' + width + ',height=' + height + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ((status) ? ',status' : '') + ',scrollbars' + ((scrollbars) ? '' : '=no') + ((resizable) ? ',resizable' : '');
	winReference = window.open(url, name, properties);
	if (openerName) self.name = openerName;
		
	// ie doesn't like giving focus immediately (to new window in 4.5 on mac; to existing ones in 5 on pc)
	setTimeout('if (winReference && !winReference.closed) winReference.focus()', 250);
	return winReference;
}

// Open a window at the center of the screen
function fnOpenCenteredWindow(url, name, width, height, status, scrollbars, openerName) {
	var x = 0;
	var y = 0;
	if (screen) x = (screen.availWidth - width) / 2;
	if (screen) y = (screen.availHeight - height) / 2;
	if (!status) status = '';
	if (!openerName) openerName = '';
	var reference = openPositionedWindow(url, name, width, height, x, y, status, scrollbars, openerName);
	return reference;
}	

// Open a full-screen window (different from IE's fullscreen option)
function fnOpenMaxedWindow(url, name, scrollbars, openerName) {
	var width  = 600;
	var height = 800;
	if (screen) width  = screen.width - 10;
	if (screen) height = screen.height - 30;
	var reference = openPositionedWindow(url, name, width, height, 0, 0, false, scrollbars, openerName);
	return reference;
}

// Open a full-chrome (all GUI elements) window
// This is like using a target="_blank" in a normal link but allows focussing the window
function fnOpenFullChromeWindow(url, name, openerName) {
	winReference = window.open(url, name, 'directories,location,menubar,resizable,scrollbars,status,toolbar');
	if (openerName) self.name = openerName;
	
	// ie doesn't like giving focus immediately (to new window in 4.5 on mac; to existing ones in 5 on pc)
	setTimeout('if (winReference && !winReference.closed) winReference.focus()', 250);
	return winReference;
}

// miscellaneous popups for media player/buylinks etc
function openPopupA(passedInfo) {
	var URL = passedInfo;
	var popup = fnOpenPositionedWindow(URL, 'audio_pop', 452, 366, 0, 0, '', '');
}

function openPopupMediaPlayer(passedInfo){
	var URL = passedInfo;
	
	if (nn4 && mac){	
	var popup = window.open(URL, 'media_pop', 'resizable=no,height=650,width=452,screenX=0,screenY=0');
	}
	 else {
	 var popup = window.open(URL, 'media_pop', 'resizable=yes,height=364,width=452,screenX=0,screenY=0');
	} 
}

function openPopupBuylink(URL) {
	var popup = fnOpenPositionedWindow(URL, 'pop', 365, 500, 0, 0, '', '');
}

function openParentWindow(URL) {
	window.opener.location.href = URL;
	window.close();
}




//---popup.js
function PopUp(url) 

{

var w = 410
var h = 290
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var popUpURL=url + ".htm"

splashWin = window.open("",'x','fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');

	
	splashWin.resizeTo(w,h);
	splashWin.moveTo(winl,wint);
	splashWin.location=popUpURL;
}


function PopitUp(url)
{

	var SizeX=400;
	var SizeY=540;
	var LocationX=5;
	var LocationY=5;
	var popUpURL=url
	var dim = eval('"width=' + SizeX + ',height=' + SizeY + ',top='+ LocationY +',left='+ LocationX +',scrollbars=1,resizable"');

	openwin = window.open(url,"pop",dim);
	self.focus();

}

function fnPopUp(url,w,h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var dim = eval('"width=' + w + ',height=' + h + ',top='+wint+',left='+winl+',scrollbars,resizable"');
Npop = window.open(url,"pop",dim);
}

function fnPopUp2(url,w,h) {
var winl = 5;
var wint = 5;
var dim = eval('"width=' + w + ',height=' + h + ',top='+wint+',left='+winl+',scrollbars,resizable"');
Npop = window.open(url,"pop",dim);
}

function vidPopUp(url,w,h) {
var popUpURL="vidmetdir/" + url
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var dim = eval('"width=' + w + ',height=' + h + ',top='+wint+',left='+winl+',resizable"');
Npop = window.open(popUpURL,"pop",dim);
}

function exitmysite()
{
var popup; 
popup = window.open("popup.htm","popDialog","width=340, height=400");
popup.moveTo(0,0);
popup.focus();

}