function stopFlash(movieName){
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    movie = window[movieName];
  }	else {
    movie =  document[movieName];
  }
   //movie.GotoFrame(1) ;
   if (movie.IsPlaying()) movie.StopPlay();
}
function loaded(){ 	if (getQSParam('pf')==1) self.setTimeout('pagePrint()', 500);}
function getQSParam(name){
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == name) {
return pair[1];
}
}
}
function qbButtonClick(closeTitle, openTitle){
strID= "qbContent";
if (document.getElementById) el = window.document.getElementById(strID);
else if (document.all) el = window.document.all[strID];

if (!closeTitle) var closeTitle = 'Close';
if (!openTitle) var openTitle = 'Search';

btnText = xbGetInnerHTML(window,'qbButton')
elBbtn   =xbGetElement(window,'qbButton') // Info container
btnText = elBbtn.value;

if (btnText==closeTitle){
	//xbSetInnerHTML(window,'qbButton', openTitle)
	elBbtn.value = openTitle;
     xbSetElClass(elBbtn, 'qbButtonClose')
     xbElClose(el);
}
else{
	//xbSetInnerHTML(window,'qbButton', closeTitle)
	elBbtn.value = closeTitle;
     xbSetElClass(elBbtn, 'qbButtonOpen')
     xbElOpen(el);
}
elBbtn.blur();
}
function openMailer(address){	window.location="mailto:" + address; }
function rmOff(){
if (navigator.appName.indexOf("Microsoft")!=-1) {  
document.oncontextmenu = function(){return false} 
if(document.layers) { 
window.captureEvents(Event.MOUSEDOWN); 
window.onmousedown = function(e){ 
if(e.target==document)return false; 
} 
} 
else { 
document.onmousedown = function(){return false} 
}
}
}
function pagePrint(){
if ( window.print ){
if (window.event) window.event.cancelBubble = true;
window.focus();
window.print( );
}
else alert("Sorry! Your browser doesn't support this function.");
}
function openPrintWindow(url, openDlg ){ 
 
	var scW = screen.availWidth ? screen.availWidth : screen.width;	
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	winW=Math.round(scW * .8);
	winH=Math.round(scH * .8);	
	var winL=Math.round(scW-winW)/2;
	var winT=Math.round(scH-winH)/2;
	strOptions= 'height=' + winH +  ',width=' + winW + ',left='+winL+',top='+winT;  
	strOptions += "toolbar=no,"; strOptions += "location=no,"; strOptions += "directories=no,"; 
	strOptions += "status=no,"; strOptions += "menubar=yes,"; strOptions += "scrollbars=yes,"; strOptions += "resizable=no"; 
	winName='Print';
	
	if (!window.winPrint){  
		try{ winPrint = window.open(url,winName,strOptions);}
		catch(e){return(false);}; //window.alert("Popup window blocked " + e.number);}
	} else { // has been defined
		if (winPrint.closed){  
			try{ winPrint.close(); winPrint = window.open(url,winName,strOptions);}
			catch(e){return(false);}; //window.alert("Popup window blocked " + e.number);}
		} else {
			try{ winPrint = window.open(url,winName,strOptions);}
			catch(e){window.alert("Popup window blocked " + e.number); }
		}
	}
	if (winPrint && openDlg ){

       	if ( winPrint.print ){
			if (winPrint.event) winPrint.event.cancelBubble = true;
			winPrint.focus();
			winPrint.print( );
		}
 	}
	return(winPrint);
 
}

function openImgWindow(imgURL,imgW,imgH,caption,txFlag,sizeImg){

     var sizeImg = (sizeImg == null) ? true : sizeImg;
	var scW = screen.availWidth ? screen.availWidth : screen.width;
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	scH = scH - 100;
	scW = scW - 20;
	var scrollBars = '';
	var vScrollBarW = (is_ie)? 30: 10;
	var hScrollBarH = 0;
	vScale = scH / imgH;
	if ( vScale < 1 ){
		imgH = Math.round(imgH * vScale);
		imgW = Math.round(imgW * vScale);
		scrollBars = 'scrollbars=yes,';
		vScrollBarW = 20;
	}
	hScale = scW / imgW  ;
	if ( hScale < 1 ){
		imgH = Math.round(imgH * hScale);
		imgW = Math.round(imgW * hScale);
		scrollBars = 'scrollbars=yes,';
		hScrollBarH = 20;
	}
     scrollBars = 'scrollbars=yes,';
	winH=Math.round(imgH)+80+ hScrollBarH;
	winW=Math.round(imgW)+40 + vScrollBarW;
	if ( caption && caption.length > 1 ){
		charsPerLine = winH/12;
		lines=caption.length/charsPerLine;
		winH = Math.round(winH + 40  + (10 * lines));
	}
	winH = ( winH > (scH-20) )? scH-20 : winH;
	winW = ( winW > (scW-20) )? scW-20 : winW;
	winL=Math.round(scW-winW)/2;
	winT=Math.round(scH-winH)/2;
	url='about:blank';
	options= 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=yes,' + scrollBars + 'status=no,menubar=yes,resizable=yes,left='+winL+',top='+winT;

	winName='winImage';
	// Open the window

	if (!window.winImage){
		try{ winImage = window.open(url,winName,options);}
		catch(e){return(false);}; //window.alert("Popup window blocked " + e.number);}
	} else { // has been defined
		if (!winImage.closed){  
			try{ winImage.close(); winImage = window.open(url,winName,options);}
			catch(e){return(false);}; //window.alert("Popup window blocked " + e.number);}
		} else {
			try{ winImage = window.open(url,winName,options);}
			catch(e){window.alert("Popup window blocked " + e.number); }
		}
	}
	if (winImage){
		winImage.focus();
		if(caption){
			arrayTemp = caption.split('|');
			caption = arrayTemp[0];
			text = arrayTemp[1];
		}
		/* BODGE ALERT!! this assumes that the relative part of the path leads to the site's root!! */
		//pos = window.location.lastIndexOf('/pages/');
		// relRoot=window.location.substring(0, pos+3);
		// pos = imgURL.lastIndexOf('../');	relRoot=imgURL.substring(0, pos+3);
		var path = window.location.href;
		pos = path.lastIndexOf('/pages/');
          relRoot=path.substring(0, pos+1);
	 
		html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">\n';
		html+='<html><head>\n';
		html+='<link rel="stylesheet"  href="' + relRoot + 'style/popup.css" type="text/css">\n';
		html+='<title>Image Viewer<\/title><\/head>\n';
		html+='<body>\n';
		if (caption) html+='<p class="pTitle" align="center">'+caption+'<\/p>\n';
		if (txFlag=='1'){	// Transparent overlay
			html += '<center><div  style="width:' + imgW + 'px; height:' + imgH + 'px; margin: 0 0 20px 0;';
			html += 'background-image:url(' + imgURL + ');background-repeat: no-repeat;">';
			txPath= '../../style/images/transparent.gif';
			html += '<img src="'+txPath+'" width="'+imgW+'" height="'+imgH+'" border="0" alt="'+caption+'"\/>';
			html += '</div></center>';
		}
		else {
			if(sizeImg) html+='<center><img src="'+imgURL+'" width="'+imgW+'" height="'+imgH+'" border="0" alt="'+caption+'"\/></center>\n';
			else html+='<center><img src="'+imgURL+'" border="0" alt="'+caption+'"\/></center>\n';
		}
		try{ if(text) html+='<p class="pText" align="center">'+text+'<\/p>\n';}
		catch(e){};
		html+='<center><a href="javascript:window.close();" >Close Window</a></center>\n';
		html+='<\/body><\/html>\n';

		winImage.document.write(html);
		winImage.document.close();
          winImage.focus();
		return (false);	
	}
	else return (true);
}
function openPano(url ){
var scW = screen.availWidth ? screen.availWidth : screen.width;
var scH = screen.availHeight ? screen.availHeight : screen.height;
var winW=800; //scW *.66;
var winH=640; //scH *.66;
var winL=Math.round(scW-winW)/2;
var winT=Math.round(scH-winH)/2;
var strOptions = 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=no,scrollbars=yes,resizable=no,left='+winL+',top='+winT;
var winName='panoViewer';
return (openWindow(url,winName,strOptions));
}
function openDoc(url ){
var scW = screen.availWidth ? screen.availWidth : screen.width;
var scH = screen.availHeight ? screen.availHeight : screen.height;
var winW= scW *.9;
var winH= scH *.9;
var winL=Math.round(scW-winW)/2;
var winT=Math.round(scH-winH)/2;
var strOptions = 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=yes,scrollbars=yes,resizable=no,left='+winL+',top='+winT; 
var winName='winDoc';
return (openWindow(url,winName,strOptions));
}

function openPopup(url, winName,winW, winH){
var scW = screen.availWidth ? screen.availWidth : screen.width;
var scH = screen.availHeight ? screen.availHeight : screen.height;
if (! winW ) var winW=800; //scW *.66;
if (! winH ) var winH=640; //scH *.66;
var winL=Math.round(scW-winW)/2;
var winT=Math.round(scH-winH)/2;
strOptions = 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=yes,scrollbars=yes,resizable=no,left='+winL+',top='+winT;
if (!winName) winName='winInfo';
return (openWindow(url,winName,strOptions));
}
function openDownload(url ){
var scW = screen.availWidth ? screen.availWidth : screen.width;
var scH = screen.availHeight ? screen.availHeight : screen.height;
var winW=640;
var winH=480;	
var winL=Math.round(scW-winW)/2;
var winT=Math.round(scH-winH)/2;
strOptions = 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=no,scrollbars=yes,resizable=no,left='+winL+',top='+winT; 
winName='winDownload';
return (openWindow(url,winName,strOptions));
}
function openFlash(url){
var scW = screen.availWidth ? screen.availWidth : screen.width;
var scH = screen.availHeight ? screen.availHeight : screen.height;
var winW=650; //scW*.8;
var winH=480; //scH*.8;
var winL=Math.round(scW-winW)/2;
var winT=Math.round(scH-winH)/2;
//strOptions = 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=yes,scrollbars=yes,resizable=no,left='+winL+',top='+winT;
strOptions = 'height=' + winH +  ',width=' + winW + ',toolbar=no,directories=no,status=no,' + 'menubar=no,scrollbars=no,resizable=no,left='+winL+',top='+winT;
	return(openWindow(url,'flash',strOptions, winW, winH) );
}
function openWindow(url, winName, strOptions, winW, winH){
var winName='winPop';
 
var scW = screen.availWidth ? screen.availWidth : screen.width;	
var scH = screen.availHeight ? screen.availHeight : screen.height;
if (! winW ) winW=Math.round(scW * .9);
if (! winH) winH=Math.round(scH * .9);	
var winL=Math.round(scW-winW)/2;
var winT=Math.round(scH-winH)/2;
if (! strOptions) strOptions= 'height=' + winH +  ',width=' + winW + ',location=yes,toolbar=yes,directories=yes,status=yes,' + 'menubar=yes,scrollbars=yes,resizable=yes,left='+winL+',top='+winT;  
if (!window.winName){  
 
try{ winName =  window.open(url,winName,strOptions);}
catch(e){return(false);};//window.alert("Popup window blocked " + e.number);}
} else { 
if (!winName.closed){  
try{ winName.close(); winName = window.open(url,winName,strOptions);}
catch(e){return(false);};//window.alert("Popup window blocked " + e.number);}
} else {
try{ winName = window.open(url,winName,strOptions);}
catch(e){return(false);};//window.alert("Popup window blocked " + e.number); }
}
}
if (winName ) winName.focus();
return (false);
}


function Banner_start(){
	if ( (is_win && (is_ie5up || is_gecko || is_opera5up || is_safari )) || is_safari || is_ff) {
		elTest = xbGetElement(window,this.textID)
		if ( this.firstCall == 1 ) this.firstCall = 0;
		else if ( elTest != null  ){
			xbSetInnerHTML(window,this.titleID,this.titles[this.banIndex]);
			xbSetInnerHTML(window,this.textID,this.text[this.banIndex]);
			this.banIndex++;
			if ( this.banIndex >= this.text.length ) this.banIndex = 0;
		}
		// Set callback
		var pThis = this;
		var f = function(){pThis.start();}
	this.timerID = window.setTimeout(f, this.banDuration * 1000);
	}
}
// ==============================
function Banner() {
	this.banIndex = 1;
	this.titleID='bannerTitle';
	this.textID='bannerText';
	this.titles = new Array();
	this.text = new Array();
	this.banCount=0;
	this.banDuration=5;
	this.firstCall=1;
	this.start = Banner_start;
}
// ==============================
function xbGetElement(win,strID){
	if (document.layers) return (xbGetNS4Element(win, strID))
	if (document.getElementById) return(win.document.getElementById(strID));
	else if (document.all) return( win.document.all[strID]);
}
// ==============================
function xbGetInnerHTML(win,strID){
var el = xbGetElement( win, strID )
if (el){
	if ( ! win.document.layers ){
		if (win.document.getElementById) return( el.innerHTML );
		else if (win.document.all)  return(el.innerHTML );
	}
}
}
// ==============================
function xbElClose(el){
if (document.getElementById || document.all) {
	el.style.visibility = 'hidden';
	el.style.display = 'none';
}
else if (document.layers)  el.visibility = 'hidden';
}
// ==============================
function xbElOpen(el, dispMode){
if (document.getElementById || document.all) {
	el.style.visibility = 'visible';
	if (! dispMode) dispMode='B';
	el.style.display = (dispMode=='B') ? 'block' : 'inline';
}
else if (document.layers)  el.visibility = 'visible';
}
// ==============================
function xbSetInnerHTML(win,strID,strHTML){
var el = xbGetElement( win, strID )
if ( el && ! win.document.layers ){
	if (win.document.getElementById)  el.innerHTML = strHTML;
	else if (win.document.all)  el.innerHTML  = strHTML;
}
}
// ==============================
function xbElHide(el){
if (document.getElementById || document.all) el.style.visibility = 'hidden';
else if (document.layers)  el.visibility = 'hidden';
}
// ==============================
function xbIsVisible(el){
var visible;
if (document.getElementById || document.all) visible = (el.style.visibility == 'visible');
else if (document.layers)   visible = (el.visibility == 'visible');
return(visible);
}
// ==============================
function xbElShow(el){
if (document.getElementById || document.all) {
	el.style.visibility = 'visible';
	el.style.display = 'block';
}
else if (document.layers)  el.visibility = 'visible';
}
// ==============================
function xbSetElClass(el,strClass){
if (el != null){
	if (document.layers ) ; //unsupported in document.layers.X
	else if (document.getElementById) el.className = strClass;
	else if (document.all ) el.className = strClass;
}
}
// ==============================
function setFormFocus(){
var frm = document.forms[0];
var done = false;
	if (document.forms.length == 0) return;
 	for (f = 0; f < frm.elements.length; f++){
 		if (! done){
            	if (frm.elements[f].type){
                 	if ( frm.elements[f].type.substr(0,5) != "selec" && frm.elements[f].type != "hidden" && frm.elements[f].type != "reset" && frm.elements[f].type != "submit" && ! frm.elements[f].disabled && ! frm.elements[f].readOnly){
					frm.elements[f].focus();
	 				done = true;
	 			             }
	  		 }
 		}
 	}
}
// ==============================
function openPlayer(filedesc,filepath, vWidth, vHeight ) {
var winID = 'winMedia'
var newWinOffset = 0 // Position of first pop-up
	// From: http://digitalmedia.oreilly.com/2005/02/23/mp3_embed.html
	winWidth=vWidth+20; winHeight=vHeight+120;
	var scW = screen.availWidth ? screen.availWidth : screen.width;
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	var winL=Math.round(scW-winWidth)/2;
	var winT=Math.round(scH-winHeight)/2;
	PlayWin = window.open('',winID,'width='+winWidth+',height='+winHeight+',top=' + winT +',left=' + winL + ',resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
	PlayWin.focus();

    var winContent = "<HTML>\n<HEAD>\n<TITLE>\n" + filedesc + "</TITLE>\n</HEAD>\n<BODY bgcolor='#FF9900'>\n";
    winContent += "<B style='font-size:14px;font-family:Verdana,sans-serif;line-height:1.5'>" + filedesc + "</B>\n";
	// For IE
    winContent += "<OBJECT width='"+vWidth+"' height='"+vHeight+"'>\n";
    winContent += "<param name='SRC' value='" + filepath + "'>\n";
    winContent += "<param name='AUTOPLAY' VALUE='true'>\n";
    winContent += "<param name='CONTROLLER' VALUE='true'>\n";
    winContent += "<param name='BGCOLOR' VALUE='#FF9900'>\n";
    // For NS & Moz
    if (is_ie ) vHeight += 15; // or we loose teh controller?
    else  vHeight += 60; // or we loose teh controller?
    winContent += "<EMBED SRC='" + filepath + "' AUTOPLAY='TRUE' TARGET='MYSELF' LOOP='FALSE' WIDTH='"+vWidth+"' HEIGHT='"+vHeight+"' CONTROLLER='TRUE' BGCOLOR='#FF9900'></EMBED>";
    winContent += "</OBJECT>\n";

    //winContent += "<p style='font-size:12px;font-family:Verdana,sans-serif;text-align:center'><a href='" + filepath +"'>Download this file</a> <SPAN style='font-size:10px'>(right-click or Option-click)</SPAN></p\n";
    winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onclick='javascript:window.close();'></DIV></FORM>\n";
    winContent += "</BODY>\n</HTML>\n";

    PlayWin.document.write(winContent);
    PlayWin.document.close(); // "Finalizes" new window
    //UniqueID = UniqueID + 1 // newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels lower
}

function contextMenuOff(){
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		document.oncontextmenu = function(){return false}
		if(document.layers) {
		    window.captureEvents(Event.MOUSEDOWN);
		    window.onmousedown = function(e){
			   if(e.target==document)return false;
		    }
		}
	}	
	else document.onmousedown = function(){return false}
	window.oncontextmenu = function(){return false}
}
function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	 document.cookie = name+"="+value+expires+"; path=/";
	//document.cookie = name+"="+value+expires+";
}

function readCookie(name){
	var ca = document.cookie.split(';');
	var nameEQ = name + "=";
	for(var i=0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}
function flashFix(){
theObjects = document.getElementsByTagName("object");
for (var i = 0; i < theObjects.length; i++) {
	theObjects[i].outerHTML = theObjects[i].outerHTML;
	}
}
function paSetThumbHScrollPos(el){
	var intX = el.scrollLeft;
	createCookie(  'paHScrollX' , intX);
	document.cookie = 'paHScrollX=' + intX ;
}

function paGetThumbHScrollPos(elName){
	myVal = readCookie ('paHScrollX' );
	if(myVal)document.getElementById(elName).scrollLeft=myVal;
}

function elVisible(blockID){
var state;
     el = xbGetElement(window,blockID);
     if (document.layers) state = el.visibility ;
     else state = el.style.visibility;
	return( (state=='visible')? true: false);
}

 
vdsTimer=null;
vdsTop=0;

var agt=navigator.userAgent.toLowerCase();
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_gecko = (agt.indexOf('gecko') != -1);
var is_moz = (agt.indexOf('mozilla') != -1);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
var is_safari = (agt.indexOf("safari")!=-1);
var is_ff = (agt.indexOf("firefox")!=-1);	
var is_win = (agt.indexOf("win")!=-1);
var is_mac = (agt.indexOf("mac")!=-1);


window.onload=loaded;
/* Fixes IE Hourglass on mous-over */
try { document.execCommand("BackgroundImageCache", false, true);} 
catch(err) {}
