	var xmlHttp;
	var xmlHttp_2;
	var opacity = 0;
	var type = "minus";
	var allImages = new Array();
	var count = 0;
	
	
	function showHint() {
		var url="/site/1915/RotateInstitutionLogo.cfm";
		xmlHttp = GetXmlHttpObject(stateChanged);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	} 
	
	function updateHomepage(){
		var url="/site/1915/RotateInstitutionLogo.cfm?homepage=1";
		xmlHttp_2 = GetXmlHttpObject(homepageState);
		xmlHttp_2.open("GET", url , true);
		xmlHttp_2.send(null);
	}
	
	function homepageState(){
		if (xmlHttp_2.readyState == 4 && xmlHttp_2.status == 200 || xmlHttp_2.readyState=="complete") {
			alert(response);
			try {
				image	  = response.getElementsByTagName("img")[0].firstChild.data;
				alert(image);
				width	  = response.getElementsByTagName('width')[0].firstChild.data;
				height 	  = response.getElementsByTagName('height')[0].firstChild.data;
				var myImg = new Image(width, height);
				myImg.src = image;
				image_obj = document.getElementById("main_homepage_image");
				image_obj.src = image;
				image_obj.width = width;
				image_obj.height = height;
			} catch (e){}
		}
	}
	
	function stateChanged() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200 || xmlHttp.readyState=="complete") {
			xmlobject  = xmlHttp.responseXML.documentElement;
			var all = new Array();
			
			for (var iNode = 0; iNode < xmlobject.childNodes.length; iNode++) {
				var node = xmlobject.childNodes.item(iNode);
				for (i = 0; i < node.childNodes.length; i++) {
					var sibling = node.childNodes.item(i);
					for (x = 0; x < sibling.childNodes.length; x++) {
						var sibling2 = sibling.childNodes.item(x);
						all[all.length]  = sibling2.data;
						
						/*
						if(all.length == 5){
							all[6] = new Image(all[5], all[4]);
							all[6].src = all[3];
							
						}
						*/
						//	alert(sibling2.data);
					}
				}
				if(all.length != 0)
					allImages[allImages.length] = all;
				all = new Array();
			}
		}
		if (navigator.userAgent.indexOf("MSIE")>=0){
			setInterval('start_rotate()', 150);
		} else {
			setInterval('start_rotate()', 25);
		}
	}

	function start_rotate() {
		if(opacity == 0){
			len = allImages.length;
			if(count == len){
				count = 0;
			}
			tempArray = allImages[count];

			count++;
			try {
				name = tempArray[0];
				homepage = tempArray[1];
				image = tempArray[3];
				width = tempArray[4];
				height = tempArray[5];
				
				document.getElementById("inst_name").innerHTML	= name;
				document.getElementById("inst_homepage").href	= homepage;
				image_obj = document.getElementById("inst_image");
		
				var myImg = new Image(width, height);
				myImg.src = image;
				image_obj.src = image;
				image_obj.width = width;
				image_obj.height = height;
			} catch (e) {
				return;
			}

			opacity += 1;
			type = "plus";
		
		} else if (opacity == 100 || opacity == 99.99){
			if(opacity == 99.99) {
				opacity = 100;
			}
			opacity -= 1;
			type = "minus";
		}

		theID = "inst_rotate";//"inst_image";
		var object = document.getElementById(theID).style;

		if(type == 'plus'){
			if(opacity > 50){
				opacity += 1;
			} else {
				opacity += 2;
			}
		} else if(type =='minus') {
			if(opacity > 50){
				opacity -= 1;
			} else {
				opacity -= 2;
			}
		}

		if (navigator.userAgent.indexOf("Firefox") != -1) {
			if (opacity == 100) { 
				opacity = 99.99  // This is majorly retarded
			}
	  }
	  
		object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
		object.KhtmlOpacity = (opacity / 100);            // Safari 1.1 or lower, Konqueror
		object.MozOpacity = (opacity / 100);              // Older Mozilla+Firefox
		object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla
	}
	
	function GetXmlHttpObject(handler){ 
		var objXmlHttp=null;
		
		if (navigator.userAgent.indexOf("Opera")>=0) {
			return;
		}
		
		if (navigator.userAgent.indexOf("MSIE")>=0){
			var strName="Msxml2.XMLHTTP";
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
				strName="Microsoft.XMLHTTP";
			} 
			try { 
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler;
				return objXmlHttp;
			} catch(e) {
				return;
			}
		} 
		if (navigator.userAgent.indexOf("Mozilla")>=0) {
			objXmlHttp=new XMLHttpRequest();
			objXmlHttp.onload=handler;
			objXmlHttp.onerror=handler; 
			return objXmlHttp;
		}
	}
