function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} 
else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}


function setOpacity(obj, opacity) {
 // var browserName=whichBrs();
 if (whichBrs() != "Safari") {
	  opacity = (opacity == 100)?99.999:opacity;
	  obj.style.filter = "alpha(opacity:"+opacity+")";
	  obj.style.KHTMLOpacity = opacity/100;
	  obj.style.MozOpacity = opacity/100;
	  obj.style.ChromeOpacity = opacity/100;
	  obj.style.opacity = opacity/100;
	} 
	else
	{
  	  opacity =0;
	  obj.style.filter = "alpha(opacity:"+opacity+")";
	  obj.style.KHTMLOpacity = opacity/100;
	  obj.style.MozOpacity = opacity/100;
	  obj.style.opacity = opacity/100;
	}
	
}
	

function fadeIn(objId,opacity) 
{// var browserName = whichBrs();
  if (whichBrs() != "Safari") 
  { 
   if (document.getElementById) 
       {
 		   obj = document.getElementById(objId);
		   if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10; 
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		  }
	   }
  }
 Else 
 {
   if (document.getElementById) 
     {
	   obj = document.getElementById(objId);
	    if (opacity <= 100) {
	    	setOpacity(obj, opacity);
		   // opacity += 10; 
			 window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
         }
	   }
     }

}
 
function fadeEm() {
	
	var Images = {
		i: 0,
		urls: ["ani_rad1.jpg", "ani_rad2.jpg",
			   "ani_occ1.jpg", "ani_occ2.jpg",
			   "ani_envir1.jpg", "ani_envir2.jpg",
			   "ani_train1.jpg", "ani_train2.jpg",
			   "ani_tech1.jpg", "ani_tech2.jpg"],
	clicks: ["", "",
				 "", "",
				 "", "",
				 "", "",
				 "", ""], 
	/* if the header page height changes need to adjust height in this function */

		GetTimeoutFn: function(i) {
			return function() {
				if (Images.i > 0)
				{  	
				 if (whichBrs() != "Safari") 
				 { document.getElementById('rotate-img').style.background="url(images/" + Images.urls[i - 1] + ")" ; }
				 else document.getElementById('rotate-img').style.background="url(images/" + Images.urls[i - 0] + ")" ;
		 
				 document.getElementById('rotate-img').style.height="160px";
				} 
				else {
					document.getElementById('rotate-img').style.background="url(images/" + Images.urls[i] + ")"; 
					document.getElementById('rotate-img').style.height="160px";
				}
				document.getElementById('ani2').src = 'images/' + Images.urls[i];
				Event.stopObserving('ani2', 'click');
				Event.observe('ani2', 'click', function(e) {
					window.location = Images.clicks[i];
				});
				setOpacity(document.getElementById('ani2'),0);
				fadeIn('ani2',0);
			};
		}
	};
	
	for (Images.i; Images.i < Images.urls.length; Images.i++) {
		setTimeout(Images.GetTimeoutFn(Images.i), Images.i * 3500);
	}
	
	setTimeout("fadeEm()", (Images.urls.length + 1) * 3500); 
}


function toggleElement(e) {
	$(e).style.display = ( $(e).style.display=='none') ? "inline" : "none";
	window.scroll(0, 500); 
}

