
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// The following scripts are specific to the Pacific and Asian 
// Studies website. 
// -----------------------------------------------------------
// Created by Spencer Rose, 
// Humanities Computing and Media Centre, 2002.
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


// -----------------------------------------------------------
// JAVASCRIPT STYLESHEET CHOOSER 
// -----------------------------------------------------------

// Set Style Sheet:

function setCSS() {

// browser is capable:
	if (compareBrowser()){

	// SouthEastAsia Exception: colour scheme RED
		if ((getCurrFileName()=='SEA_ProgramInfo.html')||(getCurrFileName()=='SEA_GraduateAchievements.html')||(getCurrFileName()=='SEA_Resources.html')||(getCurrFileName()=='SEA_Activities.html')||(getCurrFileName()=='sea302a_new.html')||(getCurrFileName().indexOf('SEA')!=-1)){window.colour='red'}
		else{window.colour='blue'}

		setColour(window.colour);
	}

 // browser is not capable:
	else{
		document.write('<link rel="stylesheet" type="text/css" href="' + dirTest() + 'css/plainStyle.css" />');
		document.write('<link rel="stylesheet" type="text/css" href="' + dirTest() + 'css/plainMenu.css" />');
	}
}


// ---------------------------------------------
// determine current directory:

function dirTest(){

	var DirName = '';
    var CurrLoc = window.location.pathname;
    var i = CurrLoc.length-1;

    while ((CurrLoc.charAt(i) != '\\')&&(CurrLoc.charAt(i) != '/')){i--;}
	i--;
    while ((CurrLoc.charAt(i) != '\\')&&(CurrLoc.charAt(i) != '/')){
        DirName = CurrLoc.charAt(i) + DirName;
        i--;
    }
	
	for (i=0;i<D.dirs.length ;i++ ){ 
		if (D.dirs[i].label==DirName) {var test=true;}
	}
	if (test){return '../';}
	else { return '';}
}



// ---------------------------------------------
// establish directory object:

var D = new MDir();

function MDir(){this.dirs = new Array();}

MDir.prototype.AddDir=doAddDir;


// ---------------------------------------------
// set directory object properties:

function doAddDir(Label){
	var dir = new labelDir(Label);
	this.dirs[this.dirs.length] = dir;
	}

function labelDir(Label){this.label = Label;}


// ---------------------------------------------
// set colour scheme:

function setColour(colour) {
	document.write('<link rel="stylesheet" type="text/css" href="' + dirTest() + 'css/style_' + colour + '.css" />');
	document.write('<link rel="stylesheet" type="text/css" href="' + dirTest() + 'css/menu_' + colour + '.css" />');
}

function setImageColour() {

	// browser is capable:
	if (compareBrowser()){
		document.images['banner'].src = dirTest() + 'images/banner_' + window.colour + '.gif';
	}

	// browser is not capable:
	else{return}
}

// --------------------------------------------- 
// >>> Enter Directory Changes Here:

// SYNTAX: M.AddDir('### DIRECTORY NAME ###');

// Directory Item:
D.AddDir('faculty');

// Directory Item:
D.AddDir('gradstudents');

// Directory Item:
D.AddDir('courses');

// Directory Item:
D.AddDir('pacificstudies');

// Dirctory Item:
D.AddDir('graduateprogram');
// ---------------------------------------------


// -----------------------------
// Warning Message Toggle
// -----------------------------

function warningMessage() {

// Turn off Warning Message:
		if (compareBrowser()) {
			var warning = document.getElementById('warning');
			if (warning!=null){warning.style.display='none';}
		}
}


// -----------------------------------------------------------
// RANDOM IMAGE GENERATOR
// -----------------------------------------------------------

// --- Generates a Random Number: between 0 and the limit value
function getRandom(limit) {
	
	var randex = parseInt(Math.abs(Math.floor(limit*Math.random())));  // indexed random number
	return randex;
}

// --- Loads random images from image bank: based on random index value
function getImages(){

// The following values are a count of the images in the "images" folder:
	var iconCount = parseInt(13);     // total number of icon images in folder
	var seaCount = parseInt(8);       // total southeast asian images

// Replace default images:

	// SouthEast Asian images exception:
	if ((getCurrFileName()=='SEA_ProgramInfo.html')||(getCurrFileName().indexOf('SEA')!=-1)){
		document.getElementById('icon').src = dirTest() + 'images/icon' + getRandom(seaCount) +'.gif';      // load random SEA icon
	}

	// All other PACAS webpages:
	else {document.getElementById('icon').src = dirTest() + 'images/icon' + getRandom(iconCount) +'.gif';}  // load random icon
}



// -----------------------------
// New Window Opener
// -----------------------------

// --- Opens a New Window:

function winOpen(URL){window.open(URL)}



// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

