// JavaScript Document V1.02
<!--
var Prototype = {
	 Version: '1.6.0',	
	 Browser: {
	   IE:     !!(window.attachEvent && !window.opera),
	   Opera: !!window.opera,
	   WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
	   Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
	   MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
	 },
	
	 BrowserFeatures: {
	   XPath: !!document.evaluate,
	   ElementExtensions: !!window.HTMLElement,
	   SpecificElementExtensions:
		 document.createElement('div').__proto__ &&
		 document.createElement('div').__proto__ !==
		 document.createElement('form').__proto__
	 },	
	 ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
	 JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,	
	 emptyFunction: function() { },
	 K: function(x) { return x }
};
function slideShowTrackLink( title )
{
	var s=s_gi("macfluor");
	s.tl(this,'o',title.toLowerCase());
}
function addOpacity(id,step,currentValue,targetValue)
{
	if(step <0 && currentValue<=targetValue || step >0 && currentValue >= targetValue)
	   return;
	currentValue = currentValue + step;
	if(currentValue<=100){
		setOpacity(id,currentValue/100);
		alphaTimer = setTimeout(function(){addOpacity(id,step,currentValue,targetValue);},50);
	}
	else{
		clearTimeout(alphaTimer);
	}
}
function setOpacity(obj,value)
{
   if(Prototype.Browser.IE) {
		obj.filters.alpha.opacity = value*100;
   }
   if(Prototype.Browser.Opera) {
		obj.filters.alpha.opacity = value*100;
   }
   if(Prototype.Browser.WebKit) {
	   obj.style.MozOpacity = value;
	   obj.style.Opacity = value;
   }
   if(Prototype.Browser.Gecko) {
	   obj.style.MozOpacity = value;
	   obj.style.Opacity = value;
   }
   if(Prototype.Browser.MobileSafari) {
	   obj.style.MozOpacity = value;
	   obj.style.Opacity = value;
   }
   if(allowShowButton){
  	 if (obj.id == sl_r.id && value>=1) sl_s.style.height="0px";
  	 if (obj.id== sl_s.id && value>=1) sl_s.style.height= sl_imgHeight+"px";
	}
}
function switchImage(adimages,pos,nextDiv,prevDiv,timespan)
{	
	if(adimages && adimages.length == 0) return;
	var counte = pos;	
	if(counte >= adimages.length)		
	   counte = 0;	
	//load the next image to cach
	var img = new Image();
	img.onload = function(){		
		sl_isloaded = true;
		if(timeover){
			clearTimeout(timer);
			timer = setTimeout(function(){switchImage(adimages,counte,nextDiv,prevDiv,timespan);},timespan);	
			timeover = false;
			sl_isloaded = false
			preload(counte,adimages);
		}			
	}
	img.onerror = function(){			
		sl_isloaded = true;
		if(timeover){
			clearTimeout(timer);
			timer = setTimeout(function(){switchImage(adimages,counte,nextDiv,prevDiv,timespan);},timespan);	
			timeover = false;
			sl_isloaded = false;
			preload(counte,adimages);
		}
	}
	img.src = adimages[counte].Src;
	prevDiv.style.height = sl_imgHeight + "px";
	nextDiv.style.height = sl_imgHeight + "px";
	sl_t.style.height = sl_imgHeight + "px";	
	prevDiv.style.backgroundPosition = "center";	
	nextDiv.style.backgroundPosition = "center";
	sl_t.style.backgroundPosition = "center";
	nextDiv.style.width = "100%";
	nextDiv.style.backgroundImage = "url(" + img.src +")";
	sl_t.style.backgroundImage = "url(" + img.src +")";
	if(!allowShowButton){
		nextDiv.innerHTML="<div class='imageTextContent'>"						
							+"<div class='imageTitle'>"	+ adimages[counte].HomeTitle + "</div>"
							+"<div class='description'><div class='title'>" + adimages[counte].Title + "</div><p>" + adimages[counte].Description + "</p></div>"
							+"</div>";
	}else{
		nextDiv.innerHTML="<div class='imageTextContent'>"						
							+"<div class='imageTitle'>"	+ adimages[counte].HomeTitle + "</div>"
							+"<div class='description'><div class='title'>" + adimages[counte].Title + "</div><p>" + adimages[counte].Description + "</p>"
							+"<img src='/Style Library/images/btnOut.gif' style='cursor:pointer' onclick='onclickImage(false)' onmouseover='overButtonHandler(this)' onmouseout='outButtonHandler(this)'/>"							
							+"</div></div>";

	}
	sl_t.innerHTML = nextDiv.innerHTML;
	addOpacity(prevDiv,-5,100,0);
	addOpacity(nextDiv,5,0,100);   
	var temp = prevDiv;	
	prevDiv = nextDiv;
	nextDiv = temp;
	this.currentpos = counte;
	this.nextDiv = nextDiv;
	this.prevDiv = prevDiv;
	this.timespan = timespan;
	this.adimages = adimages;
	counte++;
	if(!sl_isloaded){
		timeover = true;
	}
	else{
		timer = setTimeout(function(){switchImage(adimages,counte,nextDiv,prevDiv,timespan);},timespan);	
		timeover = false;
		sl_isloaded = false;
		preload(counte,adimages);
	}		
}
function nextImage(){	
	slideShowTrackLink(s.pageName + " | SlideShow | " + "NextButton" );
	clearTimeout(timer);	
	timeover = false;
	sl_isloaded = false	
	currentpos = currentpos+1;
	switchImage(adimages,currentpos,nextDiv,prevDiv,timespan);
	preload(currentpos,adimages);
}
function prevImage(){
	slideShowTrackLink(s.pageName + " | SlideShow | " + "PrevButton" );
	clearTimeout(timer);
	timeover = false;
	sl_isloaded = false	
	if(currentpos==0)
		currentpos = adimages?adimages.length-1:0;
	else
		currentpos = currentpos-1;
	switchImage(adimages,currentpos,nextDiv,prevDiv,timespan);
	preload(currentpos,adimages);
}
function preload(c,images){
	try{
		var m = new Image();
		m.onload = function(){
			sl_imgWidth = m.width;
			sl_imgHeight = m.height;				
		}
		m.onerror = function(){
			sl_imgWidth = m.width;
			sl_imgHeight = m.height;			
		}
		var n = c;
		if(n>=images.length){
			n = 0;
		}
		try{
			m.src = images[n].Src;
		}catch(e){}
	}catch(e){}
}
function onclickImage(byDiv){
	if(!allowShowButton){
		if(isAllowClick){	
			window.location = adimages[currentpos].Url;
			if(window.location.href.toLowerCase().indexOf("projects")!=-1)
				slideShowTrackLink(s.pageName + " | SlideShow | " + adimages[currentpos].Title );
			else slideShowTrackLink(s.pageName + " | SlideShow | " + adimages[currentpos].HomeTitle );
		}	
	}else{
		if(!isAllowClick){
			if(!byDiv)
				window.location = adimages[currentpos].Url;
				if(window.location.href.toLowerCase().indexOf("projects")!=-1)
					slideShowTrackLink(s.pageName + " | SlideShow | " + adimages[currentpos].Title );
				else slideShowTrackLink(s.pageName + " | SlideShow | " + adimages[currentpos].HomeTitle );
		}
	}	
}
function overButtonHandler(evt){
	if(evt.id=="leftbtn"){
		if(jQuery.browser.msie&&jQuery.browser.version<=6)
		{
			evt.src ="/Style Library/images/over_left_ie6.gif";
			jQuery('#leftbtn').css("filter","alpha(opacity=100)");
		}
		else
			evt.src ="/Style Library/images/over_left.png";
	}
	else if(evt.id=="rightbtn"){
		if(jQuery.browser.msie&&jQuery.browser.version<=6)
		{
			evt.src = "/Style Library/images/over_right_ie6.gif";
		 	jQuery('#rightbtn').css("filter","alpha(opacity=100)");
		}
		else 
			evt.src = "/Style Library/images/over_right.png";
	}else{
		evt.src = "/Style Library/images/btnOver.gif";
	}
}
function outButtonHandler(evt){
	if(evt.id=="leftbtn"){
		if(jQuery.browser.msie&&jQuery.browser.version<=6)
		{
			evt.src ="/Style Library/images/normal_left_ie6.gif";
			jQuery('#leftbtn').css("filter","alpha(opacity=30)");
		}
		else
			evt.src ="/Style Library/images/normal_left.png";
	}
	else if(evt.id=="rightbtn"){
		if(jQuery.browser.msie&&jQuery.browser.version<=6)
		{
			evt.src = "/Style Library/images/normal_right_ie6.gif";
		 	jQuery('#rightbtn').css("filter","alpha(opacity=30)");
		}
		else 
			evt.src = "/Style Library/images/normal_right.png";
	}else{
		evt.src = "/Style Library/images/btnOut.gif";
	}
}
//---------------------------------------//
function renderSildeShow(xDoc){
	var sl_imgs = new Array();
  	var xmlDoc = xDoc.documentElement;
	if(xmlDoc != null){
		var northNode = xmlDoc.getElementsByTagName("SlideShow");			
		var title;
		var src;
		var url;
		var description;
		var homeTitle;
		for(var i=0;i<northNode.length;i++){			
			title = northNode[i].getElementsByTagName("SlideImage")[0].getAttribute("Title");
			src = northNode[i].getElementsByTagName("SlideImage")[0].getAttribute("src");			
			if(northNode[i].getElementsByTagName("Url")[0].childNodes[0] == null || northNode[i].getElementsByTagName("Url")[0].childNodes[0] == undefined)	{
				url = "";
			}else{
				url = northNode[i].getElementsByTagName("Url")[0].childNodes[0].nodeValue;				
			}
			if(northNode[i].getElementsByTagName("Description")[0].childNodes[0] == null || northNode[i].getElementsByTagName("Description")[0].childNodes[0]== undefined){
				description = "";
			}else{
				description = northNode[i].getElementsByTagName("Description")[0].childNodes[0].nodeValue;
			}			
			if(northNode[i].getElementsByTagName("HomeTitle")[0].childNodes[0] == null || northNode[i].getElementsByTagName("HomeTitle")[0].childNodes[0] == undefined){
				homeTitle = sl_section;	
			}else{
				homeTitle = northNode[i].getElementsByTagName("HomeTitle")[0].childNodes[0].nodeValue;
			}					
			sl_imgs.push({'Title':title,'Src':src,'Url':url,'Description':description,'HomeTitle':homeTitle});
		}		
		//load the first image load complete or error will begin switchImage
		var loadimg = new Image();
		loadimg.onload = function(){
			initSlideShowDiv(myslideshow,isShowPollButton);
			sl_imgWidth = loadimg.width;
			sl_imgHeight = loadimg.height;								
			switchImage(sl_imgs,0,sl_r,sl_s,delay);
		}
		loadimg.onerror = function(){
			initSlideShowDiv(myslideshow,isShowPollButton);
			switchImage(sl_imgs,0,sl_r,sl_s,delay);
		}
		try{		
			loadimg.src = sl_imgs[0].Src;
		}catch(e){}
	}
}
/**
 * section: url
 * idDiv: slideshow div
 * isShow: show the poll button
 * bClick: allow click image go to the link page
 * allow: use the slide button
 */
function launchSlideShow(section,idDiv,isShow,bClick,allow){
	var xmlPath = "/_layouts/css/SlideShowsDataSource.aspx?section="+section;
	if(section=="Project"){
		sl_section  = "Projects";
	}else if(section=="Career"){
		sl_section  = "Careers";
	}else{
		sl_section  = section;
	}
	myslideshow= idDiv;
	allowShowButton  = allow;
	isAllowClick= bClick;	
	isShowPollButton  = isShow;
	var xProvider = new mcoXmlProvider(xmlPath,renderSildeShow);
	xProvider.run();
}
function initSlideShowDiv(idDiv,isShowPollButton){	
	if(isShowPollButton){
		idDiv.innerHTML = '<div id="subdiv3"></div>'
						 + '<div id="subdiv1" onclick="onclickImage(true)"></div>'
						 + '<div id="subdiv2" onclick="onclickImage(true)"></div>'
						 + '<div class="pollbtn">'
						 + '<div class="pollDiv1">'
						 + '<div class="pollDiv2" >'
						 + '<img alt="" id="leftbtn" src='+(jQuery.browser.msie&&jQuery.browser.version<=6? '"/Style Library/images/normal_left_ie6.gif"': '"/Style Library/images/normal_left.png"')
						 +' onclick="prevImage()" onmouseover="overButtonHandler(this)" onmouseout="outButtonHandler(this)"/>'
						 + '<img alt="" id="rightbtn" src='+(jQuery.browser.msie&&jQuery.browser.version<=6? '"/Style Library/images/normal_right_ie6.gif"': '"/Style Library/images/normal_right.png"')
						 +' onclick="nextImage()" onmouseover="overButtonHandler(this)" onmouseout="outButtonHandler(this)"/>'
					     + '</div>'
				         + '</div>'
					     + '</div>';
	}else{
		idDiv.innerHTML = '<div id="subdiv3"></div>'
						 + '<div id="subdiv1" onclick="onclickImage(true)"></div>'
						 + '<div id="subdiv2" onclick="onclickImage(true)"></div>';			     
	}
	sl_r = document.getElementById("subdiv1");
	sl_s = document.getElementById("subdiv2");
	sl_t = document.getElementById("subdiv3");	
	if(jQuery.browser.msie&&jQuery.browser.version<=6)
	{
		jQuery('#leftbtn').css("filter","alpha(opacity=30)");
		jQuery('#rightbtn').css("filter","alpha(opacity=30)");
		
	}
}
var sl_r;
var sl_s;
var sl_t;
var myslideshow;
var nextDiv;
var prevDiv;
var bgDiv;
var currentpos;
var timespan;
var adimages;
var sl_section = "";
var timer;
var timeover = false;
var sl_isloaded = false;
var alphaTimer;
var currentTime=0;
var delay = 8000;
var allowShowButton = false;
var isAllowClick= false;
var isShowPollButton = false;
//below code for store the sreen width and height
//also store the loaded image width;	
var screenWidth = this.window.screen.width;
var screenHeight = this.window.screen.height;
var sl_imgWidth;
var sl_imgHeight;
-->