





		
function Is(){
	var agent=navigator.userAgent.toLowerCase();
	this.major=parseInt(navigator.appVersion);
	this.minor=parseFloat(navigator.appVersion);
	this.nsc=((agent.indexOf('mozilla')!=-1)&&(agent.indexOf('spoofer')==-1)&&(agent.indexOf('compatible')==-1)&&(agent.indexOf('opera')==-1)&&(agent.indexOf('webtv')==-1));
	this.ns=(this.nsc&&(this.major<5));
	this.ns6=(this.nsc&&(this.major>=5));
	this.ie=(agent.indexOf("msie")!=-1) && (agent.indexOf("opera")==-1);
	this.opera=(agent.indexOf("opera")!=-1); 
	this.opera8=(agent.indexOf("opera 8")!=-1); 
	this.mac=(agent.indexOf('mac')!=-1);
	this.safari=(agent.indexOf('safari')!=-1);
  }


function launchinternational(mySelect)
//for the Select a Region dropdown
{
  var myValue = mySelect[mySelect.selectedIndex].value;
  if(myValue != "") {
  window.open(myValue, '_self');
  }
}


//Stylesheet cycler - by Matthew Smith 2005 - matthew.smith@clearblueday.com

function getAllSheets() {
  //if you want ICEbrowser's limited support, do it this way
  	if( !window.ScriptEngine && navigator.__ice_version ) {
	   return document.styleSheets; 
	}
	//Opera 7 seems to return the stylesheets and the embedded stylesheet names so easier using getElementsByName
	if (is.opera && !is.opera8){
	  var Lt = document.getElementsByName("stylesheet");
	}
	else if( document.getElementsByTagName ) {
    //DOM browsers - get link and style tags
		var Lt = document.getElementsByTagName('link');
		} 
	else if( document.styleSheets && document.all ) {
		var Lt = document.all.tags('LINK'), St = document.all.tags('STYLE');
  	} 
  	else { 
  		return []; 
	} 

	for( var x = 0, os = []; Lt[x]; x++ ) {
		//check for the rel attribute to see if it contains 'style'
		//need the title as well to filter out other stylesheets that are not used in this stylesheet change
		if( Lt[x].rel ) { 
			var rel = Lt[x].rel;
			var title = Lt[x].title;
		} 
		else if( Lt[x].getAttribute ) { 
			var rel = Lt[x].getAttribute('rel');
			var title = Lt[x].getAttribute('title');
		} 
		else { 
			var rel = ''; 
			var title = '';
		}
		
    	if((typeof(rel) == 'string' && rel.toLowerCase().indexOf('style') + 1) && (typeof(title) == 'string' && title.toLowerCase().indexOf('macquarie') + 1))   {
      	//fill os with linked stylesheets
	    	os[os.length] = Lt[x];
    	}
  	}

		return os;
	
}






function swapSheet(screenIndex) {
	
	// Create a list of all Macquarie screen style sheets
		var styleArray = new Array();
		styleArray = getAllSheets()
		if (styleArray[0] != ""){
		// Check cycle bounds
			if (screenIndex < 0 || screenIndex > styleArray.length - 1) {
				return -1;
			} 
			else {
			// Disable all style sheets
				for (var i = 0; i <= styleArray.length - 1; i++) {
					if( styleArray[i].title ) {
			     	 styleArray[i].disabled = true;
    				}
				}
				styleArray[parseInt(screenIndex)].disabled = false;
			}
		} 
		else {
			alert('Your browser does not support text resizing.');
			return -1;
		}
}

function cycleUp() {
	var currSheet = (getCookie() == '') ? 1 : parseInt(getCookie()) + 1;
	var res = swapSheet(currSheet);
	if (res != -1) {setCookie(currSheet)};
}

function cycleDown() {
	var currSheet = (getCookie() == '') ? 1 : parseInt(getCookie()) - 1;
	var res = swapSheet(currSheet);
	if (res != -1) {setCookie(currSheet)};
}


function cycleUpOp() {
// these comments are the more straightforward way of doing the same work if we only have two	
//	var currssobj = document.getElementById("MSS1");
//	var newssobj = document.getElementById("MSS2");
//	 currssobj.disabled = true;				
	// newssobj.disabled = false;				
	var styleArray = new Array();
	styleArray = getAllSheets()
	for (var i = 0; i <= styleArray.length - 1; i++) {
		if(styleArray[i].disabled == false){
			//get the index number from the title of the stylesheet - this is the rightmost entry
			var currstylesheetno = parseInt(styleArray[i].title.substr(styleArray[i].title.length-1, 1))
			//increment it by 1
			var gogetstylesheetno =  currstylesheetno + 1
		}
	}
	swapSheet(gogetstylesheetno)
	}

function cycleDownOp() {
	var styleArray = new Array();
	styleArray = getAllSheets()
	for (var i = 0; i <= styleArray.length - 1; i++) {
		if(styleArray[i].disabled == false){
			//get the index number from the title of the stylesheet - this is the rightmost entry
			var currstylesheetno = parseInt(styleArray[i].title.substr(styleArray[i].title.length-1, 1))
			//decrement it by 1
			var gogetstylesheetno = currstylesheetno - 1
		}
	}
	swapSheet(gogetstylesheetno)
}



function recallSheet() {
	if (getCookie() != -1) {swapSheet(parseInt(getCookie()))};
}

function setCookie(sheet) {
	var nextYear = new Date();
	nextYear.setFullYear(nextYear.getFullYear() + 1);
	nextYear.toGMTString();
	nextYear = escape(nextYear);
	//document.cookie = 'sheet=' + sheet + '; expires="' + nextYear + '"; name="sheet"';
	document.cookie = 'sheet=' + sheet + '; name="sheet"';
	
	if (document.cookie.indexOf('sheet') == -1) {
		return -1;
	}
}

function getCookie() {
	
	var cookieText = document.cookie + '';
	var searchVal = 'sheet=';
	var indexStart = cookieText.indexOf(searchVal);
	if (indexStart == -1 ) {
		setCookie(0);
	}
	var indexEnd = (cookieText.indexOf(';', indexStart) != -1) ? cookieText.indexOf(';', indexStart) : cookieText.length;
	return cookieText.substr(indexStart + searchVal.length, indexEnd - searchVal.length);
}
