// GLOBAL WEBSITE SCRIPTS


// ----- Browser -----
ie = !(navigator.appName.indexOf("Microsoft") < 0)? true: false
ns = !(navigator.appName.indexOf("Netscape") < 0)? true: false
ns6 = (!document.all && document.getElementById) ? true : false;
ob = ((!ie) && (!ns))? true: false

// ----- STATUS BAR -----

function omsg(txt) {
window.status = txt ;
}

function cmsg() {
window.status = "";
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

// ----- FILENAME -----
function filenameOnly (InString)  {
	LastSlash=InString.lastIndexOf ('/', InString.length-1)
	OutString=InString.substring  (LastSlash+1, InString.length)
	return (OutString);	
}


// ----- MENU ------

function menu(id) {
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
if (ns4) {
if (document.layers[id].visibility == "show") { var txswitch = "hide" }
if (document.layers[id].visibility == "hide") { var txswitch = "show" }
document.layers[id].visibility = txswitch
}
else if (ie4) {
if (document.all[id].style.visibility == "visible") { var txswitch = "hidden" }
if (document.all[id].style.visibility == "hidden") { var txswitch = "visible" }
document.all[id].style.visibility = txswitch
}
else if (ns6) {
objElement = document.getElementById(id);
if (objElement.style.visibility == "visible") { var txswitch = "hidden" }
if (objElement.style.visibility == "hidden") { var txswitch = "visible" }
objElement.style.visibility = txswitch
}
}


function SR_showdate() {
var now = new Date();
var month = now.getMonth() + 1;
var date = now.getDate();
var weekday = now.getDay()
var year = now.getYear();
if (year < 2000) year = year + 1900;
if (weekday==0) {dow="Sunday"}
if (weekday==1) {dow="Monday"}
if (weekday==2) {dow="Tuesday"}
if (weekday==3) {dow="Wednesday"}
if (weekday==4) {dow="Thursday"}
if (weekday==5) {dow="Friday"}
if (weekday==6) {dow="Saturday"}
if (month==1) {monthstring="Jan"}
if (month==2) {monthstring="Feb"}
if (month==3) {monthstring="Mar"}
if (month==4) {monthstring="Apr"}
if (month==5) {monthstring="May"}
if (month==6) {monthstring="Jun"}
if (month==7) {monthstring="Jul"}
if (month==8) {monthstring="Aug"}
if (month==9) {monthstring="Sep"}
if (month==10) {monthstring="Oct"}
if (month==11) {monthstring="Nov"}
if (month==12) {monthstring="Dec"}
if (month==1) {ms="January"}
if (month==2) {ms="February"}
if (month==3) {ms="March"}
if (month==4) {ms="April"}
if (month==5) {ms="May"}
if (month==6) {ms="June"}
if (month==7) {ms="July"}
if (month==8) {ms="August"}
if (month==9) {ms="September"}
if (month==10) {ms="October"}
if (month==11) {ms="November"}
if (month==12) {ms="December"}

document.write(dow + ', ' + date + ' ' + ms + ', ' + year)
}


function my_age() {
var now = new Date();
var month = now.getMonth() + 1;
var date = now.getDate();
var year = now.getYear();
if (year < 2000) year = year + 1900;
if (month < 6) { var age = ((year - 1) - 1981) }
else if ((month == 6) && (date <= 22)) { var age = ((year - 1) - 1981) }
else if ((month == 6) && (date >= 23)) { var age = (year  - 1981) }
else { var age = (year - 1981) }
document.write(age)
}


// ----- DREAMWEAVER SCRIPTS -----
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);

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.0
  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 && document.getElementById) x=document.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];}
}


// ----- QUERY STRINGS -----

function QueryString(key)
{
   var value = "";
   for (var i=0;i<QueryString.keys.length;i++)
     {
	if (QueryString.keys[i]==key)
	{
	value = QueryString.values[i];
	break;
	  }
	}
	return value;
}

function QueryTag(key)
{
   var value = "";
   for (var i=0;i<QueryString.keys.length;i++)
     {
	if (QueryString.keys[i]==key)
	{
	return true;
        break
	  }
     }
}

QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
   var query = unescape(window.location.search.substring(1));
   var pairs = query.split("&");
	
    for (var i=0;i<pairs.length;i++)
    {
    var pos = pairs[i].indexOf('=');
    if (pos >= 0)
	{
	var argname = pairs[i].substring(0,pos);
	var value = pairs[i].substring(pos+1);
        
        for (j = 1; j <= (value.length+1); j++) {
        var value = value.replace("+"," ")
        }

	QueryString.keys[QueryString.keys.length] = argname;
	QueryString.values[QueryString.values.length] = value;		}
     }

}

QueryString_Parse();


// ----- TOP -----

function TopQueryString(key)
{
   var value = "";
   for (var i=0;i<TopQueryString.keys.length;i++)
     {
	if (TopQueryString.keys[i]==key)
	{
	value = TopQueryString.values[i];
	break;
	  }
	}
	return value;
}

function TopQueryTag(key)
{
   var value = "";
   for (var i=0;i<TopQueryString.keys.length;i++)
     {
	if (TopQueryString.keys[i]==key)
	{
	return true;
        break
	  }
     }
}

TopQueryString.keys = new Array();
TopQueryString.values = new Array();

function TopQueryString_Parse()
{
   var query = unescape(top.location.search.substring(1));
   var pairs = query.split("&");
	
    for (var i=0;i<pairs.length;i++)
    {
    var pos = pairs[i].indexOf('=');
    if (pos >= 0)
	{
	var argname = pairs[i].substring(0,pos);
	var value = pairs[i].substring(pos+1);
        
        for (j = 1; j <= (value.length+1); j++) {
        var value = value.replace("+"," ")
        }

	TopQueryString.keys[QueryString.keys.length] = argname;
	TopQueryString.values[QueryString.values.length] = value;		}
     }

}

TopQueryString_Parse();



// ----- Find Position -----

function findPosX(obj)
{
	var curleft = 0;
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curtop += obj.y;
	return curtop;
}


// ----- Move Position -----

function sr_setpos(id, px, t, l) {
  ns4 = (document.layers)? true:false
  ie4 = (document.all)? true:false
  if (ns4) obj = document.layers[id]; 
  if (ie4) obj = document.all[id].style;
  obj.left = (findPosX(px) + l)
  obj.top = (findPosY(px) + t)
}

function sr_setplace(id, l, t) {
  ns4 = (document.layers)? true:false
  ie4 = (document.all)? true:false
  if (ns4) obj = document.layers[id]; 
  if (ie4) obj = document.all[id].style;
  obj.left = l
  obj.top = t 
}

// -- Maximise and Minimise Scripts --

function maximiseWin() {
if (window.screen) {
var mywidth = screen.availWidth;
var myheight = screen.availHeight;
window.moveTo(0, 0);
window.resizeTo(mywidth,myheight);
}
}

function minimiseWin() {
var leftpos = (window.screen.width/2) - (415);
var toppos = (window.screen.height/2) - (320);
window.moveTo(leftpos,toppos);
window.resizeTo(786,591);
}

// -- muppet script --
var muser = '\u006d\u0075\u0070\u0070\u0065\u0074\u0032\u0038\u0030\u0037' ;
var mcsum1 = QueryString('usr');
mcsum2 = 1
for(i = 0; i < mcsum1.length; i++) {
mcsum2 *= mcsum1.charCodeAt(i);
}
if ((QueryString('usr') == muser) && (QueryString('checksum') == mcsum2)) {
var sitex = '\u006d\u0075\u0070\u002e\u0068\u0074\u006d'
window.open(sitex,'Muppet','width=519,height=442')
}

// -- SOUNDS -- 

function playSong(songURL)
{
   if (navigator.appName == "Netscape") {
    document.write('<embed src=\"'+songURL+'\" hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')
   }
   else { 
    document.write('<bgsound src="' + songURL + '" loop=infinite>')
   }
}

function playSongOnce(songURL)
{
   if (navigator.appName == "Netscape") {
    document.write('<embed src=\"'+songURL+'\" hidden="true" border="0" width="20" height="20" autostart="true" loop="false">')
   }
   else { 
    document.write('<bgsound src="' + songURL + '" loop=1>')
   }
}

// --- SCROLL --- 


//THIS IS THE SCROLLBAR SCRIPT
//NOTE THIS WORKS WITH SELF AND PARENT

var H=null;
var speed=1;
var amount=10;
var nF=null;


function scrollme(frame,frameset){

	if (frameset == 'parent')
	{
		nF=parent[frame];
	}

	if (frameset == 'self')
	{
		nF=self[frame];
	}

	nF.document.body.appendChild(nF.document.createElement('<DIV id=iend>'));
    H=nF.iend.offsetTop-nF.document.body.offsetHeight;
}

function movedown(){
	if (nF.document.body.scrollTop!=H){
		nF.document.body.scrollTop+=amount;
		gdown=setTimeout('movedown();', speed);
	}
}

function moveup(){
	if (nF.document.body.scrollTop != 0){
		nF.document.body.scrollTop-=amount;
		gup=setTimeout('moveup();', speed);
	}
}

function stopdown(){
window.status='';
if(nF.document.body.scrollTop!=H){clearTimeout(gdown);}
}

function stopup(){
window.status='';
if(nF.document.body.scrollTop!=0){clearTimeout(gup);}
}
