/*
file: browser.js
requires: basic.js
author & copyright: Vijay Mahrra &amp; Daniel Bailey <vijay@yoyo.org>
created: 8 August 1999
version: 2.0 12 April 2000
*/

function browser() {
// browser detection
		// OS Platform
	this.win = instr( navigator.userAgent, "Win");	// windows version
	this.mac = instr( navigator.userAgent, "Mac");	// macintosh version
	this.version = parseFloat(navigator.appVersion); // browser version
		// core browser
	this.ie = instr( navigator.userAgent,"MSIE") ? 1 : 0;	// internet explorer
	this.opera = ( instr(navigator.userAgent,"Opera") ) ? 1 : 0; // is opera
	this.mozilla = ( !this.ie && !this.opera && instr(navigator.userAgent,"Mozilla/5") ) ? 1 : 0;  // mozilla
	this.nn = ( !this.ie && !this.opera && !this.mozilla && instr(navigator.appName,"Netscape") ) ? 1 : 0; // is netscape
	this.other = ( !this.nn && !this.ie && !this.mozilla) ? 1 : 0;
		// basic features
	this.images = ( document.images ) ? 1 : 0; // supports images
	this.layers = ( document.layers ) ? 1 : 0; // supports layers
	this.all = ( document.all ) ? 1 : 0; 	// supports document.all notation
		// specific browser version
	this.nn4 = ( this.nn && this.layers ) ? 1 : 0;
	this.nn6 = ( this.nn && this.all ) ? 1 : 0;
	this.ie4 = ( this.ie && this.all ) ? 1 : 0;
	this.ie5 = ( this.ie4 && instr(navigator.appVersion,"5.") ) ? 1 : 0;
	this.ie55 = ( this.ie4 && instr(navigator.appVersion,"5.5") ) ? 1 : 0;
		// dhtml
	this.dhtml = ( this.all || this.layers );
	if( this.dhtml ) {
		this.document = ( this.layers ) ? 'document.' : 'document.all.';
		this.style = (  this.layers ) ? '.' : '.style.';
		this.show = ( this.layers ) ? 'show' : 'visible';
		this.hide = ( this.layers ) ? 'hide' : 'hidden';
	}
} client = new browser();

function upgradeBrowser() {
// directs the user to a download page if their browser is non-DHTML
if( client.dhtml ) return false;
	var t = "This site may not work as intended on your browser.\nDo you want to upgrade to a newer version?";
	if( client.nn )
		confirmURL( "http://www.netscape.com/download/",t,1);
	else if( client.opera )
		confirmURL( "http://www.opera.com/download/",t,1);
	else
		confirmURL( "http://www.microsoft.com/ie/download/",t,1);
return true;
} upgradeBrowser();

function showPlugins() {
// show all plugin name and descriptions
if( client.ie ) return false;
if( !navigator.plugins ) return -1;
	document.write("<table border=1><tr><th>name</th><th>description</th></tr>");
	for( var i=0; i<navigator.plugins.length; i++ ) {
		with( navigator ) {
			writeout("<tr><td>", plugins[i].name, "</td><td>", plugins[i].description, "</td></tr>");
		}
	}
	document.write("</table>");
return true;
}

function showMimeTypes( pluginsOnly ) {
// show details all mimetypes supported by the client or pluginsOnly if arg
// viewing all mimetypes, those supported by plugins will be bold
if( client.ie ) return false;
if( !navigator.mimeTypes ) return -1;
	document.write("<table border=1><tr><th>name</th><th>description</th><th>suffixes</th></tr>");
	for( var i=0; i<navigator.mimeTypes.length; i++ ) {
		with( navigator ) {
			if( pluginsOnly ) {
				if( mimeTypes[i].enabledPlugin != null )
					writeout("<tr><td>", mimeTypes[i].type, "</td><td>", mimeTypes[i].description, "</td><td>", mimeTypes[i].suffixes, "</td></tr>");
			} else {
				document.write("<tr><td>");
				if( mimeTypes[i].enabledPlugin )
				 	writeout("<b>", mimeTypes[i].type, "</b");
				else
					document.write( mimeTypes[i].type );
				writeout("</td><td>", mimeTypes[i].description, "</td><td>", mimeTypes[i].suffixes, "</td></tr>");
			}
		}
	}
	document.write("</table>");
return true;
}

function getPlugin() {
// searches for a plugin by supported file extension in mimetypes as args
// returns true if at least one of the extensions was found
if( client.ie ) return -1;
if( arguments.length == 0 ) return -2;
if( !navigator.mimeTypes ) return -3;
	var j;
	for( var i=0; i< arguments.length; i++ ) {
		for( j=0; j<navigator.mimeTypes.length; j++ ) {
			if( instr(navigator.mimeTypes[j].suffixes, arguments[i]) )
				return true;
		}
	}
return false;
}

// showPlugins();
// showMimeTypes(1);
// getPlugin('qt');

/*
file: basic.js - basic standalone functions
author & copyright: Vijay Mahrra &amp; Daniel Bailey <vijay@yoyo.org>
created: 29 September 1999
version 1.1: 14 April 2000
*/

function warn() {
// outputs all arguments in an alert message
	if( arguments.length == 0) return false;
	var warnStr="";
	for( var i=0; i<arguments.length; i++)
		warnStr += i+":"+arguments[i] + "\n";
	alert(warnStr);
return true;
}

function writeout() {
// outputs all arguments to the document
	if( arguments.length == 0) return false;
	for( var i=0; i<arguments.length; i++)
			document.write(arguments[i]);
return true;
}

function confirmURL(url,msg){
// changes location if you confirm a message
	if( arguments.length != 2 ) return false;
	if(confirm(msg))
			self.location.href = url;
return true;
}

function instr( s, m ) {
// return true if 'm' is contained in the string 's' else return false
	if( arguments.length != 2) return -1;
	s = s.toLowerCase();
	m = m.toLowerCase();
return ( s.indexOf(m) >-1 ) ? true : false; }

function mkSessionId(x) {
/* generates a random string session_id of 'x' characters
	makes one 8 chars long if invalid argument value */
if( arguments.length != 1 || x < 1) x = 8;
	var SessionID = "", c = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for( i=0; i<x; i++)
	  	SessionID += c.charAt(Math.round(Math.random()*36));
return SessionID;
}
function popUp(url){
// annoying popup window function
	if( arguments.length != 1 ) return false;
	self.name='opener';
	var external = 'remote'+mkSessionId(8); // random window name
	var width = (getWinWidth()) ? getWinWidth() * 0.75 : 300;
	var height = (getWinHeight()) ? getWinHeight() * 0.75 : 300;
	var options = 'location,resizable,scrollbars,status,toolbar,width='+width+',height='+height+',left=50,top=50';
	remote=open(url, external, options);
return true;
}


/*
file: advanced.js - dependent on other functions/html code
author & copyright: Vijay Mahrra &amp; Daniel Bailey <vijay@yoyo.org>
created: 29 September 1999
version 1.1: 14 April 2000
*/

function print() {
// adapted from a usenet post by ulf.norlinger@trio.se
// requires: client.js
    if (client.ie && client.version >=3) {
        var OLECMDID_PRINT = 6,OLECMDEXECOPT_DONTPROMPTUSER = 2, OLECMDEXECOPT_PROMPTUSER = 1;
        var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
        document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
        WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
        WebBrowser1.outerHTML = "";
    }
	else if (client.NN && client.version >=3) { self.print(); }
	else {
		alert("The print function is only available for Netscape and Internet Explorer!");
		return false;
	}
return true;
}

function goButton( url ) {
	if(arguments.length != 1 ) return false;
	document.location.href =  url.options[url.selectedIndex].value;
return true;
}

function getStrType( theStr ) {
// returns a number between 1 and 7 calculated by adding the following:
// 	1 - alphabetic string
// 	2 - numeric
// 	3 - contains charaters from 'allowed' string (optional extra parameter)
// -1 incorrect arguments length
if( arguments.length < 1 || arguments.length > 2 ) return -1;
	allowed = ( arguments.length == 2 ) ? arguments[1] : "";

	var c, r=0, alpha = numeric = legal = false;
	for( var i=0; i<theStr.length; i++ ) {
		c = theStr.charAt(i);
		if ((c >= "A" && c <= "Z") || (c >= "a" && c <= "z") )
			alpha = true;
			else if	(c >= "0" && c <= "9")
				numeric = true;
				else if( allowed != "" && instr(allowed, c) )
					legal = true;
						else return false;
	}
	if ( alpha ) 	r += 1;
	if ( numeric ) 	r += 2;
	if ( legal ) 	r += 4;
return r;
}

function checkFieldLen( formfield, minlength, maxlength, name ) {
	var r = false, f = formfield.value;

	if( f == "" &&  minlength !=0 )
		alert( "'" + name + "' is blank.  You must enter between "+ minlength +" and "+ maxlength +" chracteres.");
	else if( minlength == maxlength && f.length != minlength )
		alert( "'" + name + "' is the wrong size, it should be " + minlength + " characters long only.");
	else if( f.length < minlength )
		alert( "'" + name + "' is too small, it should be at least " + minlength + " characters.");
	else if( f.length > maxlength )
		alert( "'" + name + "' is too long, it should be no more than " + maxlength + " characters.");
	else
		r = true;

	if( !r ) {
		formfield.focus();
		formfield.select()
	}
return r;
}

function checkFieldRange( formfield, minval, maxval, name ) {
	var r = false, f = formfield.value;

	if( f < minval )
		alert( "'" + name + "' is too low.  You must enter a number between "+ minval +" and "+ maxval +".");
	else if( f > maxval )
		alert( "'" + name + "' is too high.  You must enter a number between "+ minval +" and "+ maxval +".");
	else
		r = true;

	if( !r ) {
		formfield.focus();
		formfield.select()
	}
return r;
}

/*
file: screen.js
author & copyright: Vijay Mahrra &amp; Daniel Bailey <vijay@yoyo.org>
created: 29 September 1999
*/

function getColorDepth() {
// gets the screen colour depth in bits
	if( !client.dhtml ) return false;
	var colorDepth = (client.nn4) ? screen.pixelDepth : screen.colorDepth;
	return colorDepth;
}
function getWinWidth() {
// gets the browser width
	if( !client.dhtml ) return false;
	var width = (client.nn4) ? window.innerWidth : document.body.offsetWidth;
	return width;
}
function getWinHeight() {
// gets the browser height
	if( !client.dhtml ) return false;
	var height = (client.nn4) ? window.innerHeight : document.body.offsetHeight;
	return height;
}
function setWin(width,height) {
// sets the browser display area
	if( !client.dhtml || arguments.length != 2 ) return false;
	window.resizeTo(width,height);
}

/*
file: cookies.js
author & copyright: Vijay Mahrra &amp; Daniel Bailey <vijay@yoyo.org>
created: 2 March 2000
*/

/*
	sets a cookie, defaults: expires +1 month, domain from url, path is /
	returns: false if invalid argument length, 	-1 if cookie name is not valid
*/
function setCookie( n, v, e, p, d, s ) {
	if(arguments.length < 2 || arguments.length > 6) return false;
	if( n == "" ) return -1;  								// invalid name
	if( !e ) { e = new Date; e.setMonth(e.getMonth()+1); }  // expire next month
		// build document cookie string
	document.cookie = n + '=' + escape(v) +
			';expires=' + e.toGMTString() +
			';path=' + ((p) ? p : "/") +
			';domain=' + ((d) ?  d : location.host) +
			((s) ?  ';secure=' + "1" : "");
return true;
}

/*
	gets a cookie
	returns: false if invalid argument length, -1 there are no cookies set
	-2 the cookie name requested was blank, -3 if the cookie doesn't exist
*/
function getCookie( n ) {
	if( arguments.length !=1 ) return false; // invalid arguments
	if( document.cookie == "" ) return -1;  // no cookies exist
	if( n == "" ) return -2;  				// blank name
	s = document.cookie.indexOf( n+"=" );
		if( s == -1 ) return -3; 	// named cookie doesn't exist
	e = document.cookie.indexOf( ";", s);
		if( e == -1 ) e = document.cookie.length;	// it was the last cookie
return unescape(document.cookie.substring( (s+n.length+1), e ));
}

/*
	deletes a cookie, uses the url domain and path / if none specified
	returns -1 if cookie name was blank, -2 if cookie doesn't exist
*/
function delCookie( n,p,d ) {
	if(arguments.length < 1 || arguments.length > 3) return false;	// invalid args
	if( n == "" ) return -1;  		// empty cookie name
	if( getCookie(n) == -3 ) return -2;
	document.cookie = n + '=;' +
			';path=' + ((p) ? p : "/") +
			';domain=' + ((d) ?  d : location.host)	+
			';expires=Thu, 06-May-76 07:30:00 GMT';
return true;
}

/*
	deletes multiple cookies for a given domain and path
	uses the url domain and path / if none specified
*/
function delCookies( p,d ) {
	if(arguments.length < 3 ) return false;	// invalid args
	for( i=3; i<arguments.length; i++ )
		alert( delCookie( arguments[i], p, d ) );
return true;
}

// JavaScript Netscape Error Suppression
function stopError() { return true; }
window.onerror = stopError;

/* Executed OnLoad */
function site_onLoad() {
}

/* Executed OnUnLoad */
function site_onUnLoad() {
}

// Tickets Popup Window

function opentixWindow() {
popupWin = window.open('/lost/tickets.php', 'adsl', 'scrollbars=yes,width=450,height=570,resizable=yes,status=yes')      
        }

		function opentix2Window() {
popupWin = window.open('/lost/tickets2.php', 'adsl', 'scrollbars=yes,width=450,height=570,resizable=yes,status=yes')      
        }

		function opentix3Window() {
popupWin = window.open('/lost/tickets3.php', 'adsl', 'scrollbars=yes,width=450,height=570,resizable=yes,status=yes')      
        }
		
		function opentix4Window() {
popupWin = window.open('/lost/tickets4.php', 'adsl', 'scrollbars=yes,width=450,height=570,resizable=yes,status=yes')      
        }
		
		function opentix5Window() {
popupWin = window.open('/lost/tickets5.php', 'adsl', 'scrollbars=yes,width=450,height=570,resizable=yes,status=yes')      
        }

		function opentix6Window() {
popupWin = window.open('/lost/tickets6.php', 'adsl', 'scrollbars=yes,width=450,height=570,resizable=yes,status=yes')      
        }







