	/*
		To change the number of rotation pages, update the rotationCount
		Add the new item to pages[x] array
		Update the home page count (1 or X) JavaScript on index.html
	*/
	
	// Number of rotation pages 
	var rotationCount = 5;

	// get browser information
	function getBrowserInfo () {
		var browserDetail = new Object();
		var browserUAgent = navigator.userAgent; 

		browserUAgent = browserUAgent.toLowerCase();

		// default
		browserDetail.browserName = "msie";
		
		// get browser name
		if (browserUAgent.search("msie") != -1 || browserUAgent.search("internet explorer") != -1) {
			browserDetail.browserName = "msie";
		}
		else if (browserUAgent.search("firefox") != -1) {
			browserDetail.browserName = "firefox";
		}
		else if (browserUAgent.search("opera") != -1) {
			browserDetail.browserName = "opera";
		}
		else if (browserUAgent.search("safari") != -1) {
			browserDetail.browserName = "safari";
		}
		else if (browserUAgent.search("mozilla") != -1) {
			browserDetail.browserName = "mozilla";
		}
		
		// get screen resolution
		browserDetail.resolutionWidth = screen.width;
		
		return browserDetail;
	}	

	function setWNContentHeight () {
		var browserObj = new Object(getBrowserInfo());
		var wnHeight = "489px";
		var prHeight = "349px";

		// Opera/ Firefox/ Mozilla based browsers
		if (browserObj.browserName == "firefox" || browserObj.browserName == "opera" || browserObj.browserName == "mozilla") {
			if (browserObj.resolutionWidth >= 1280) {
				wnHeight = "444px";
				prHeight = "319px";
			}
			else if (browserObj.resolutionWidth >= 1024) {
				wnHeight = "489px";
				prHeight = "349px";
			}
			// width of 800 or less
			else {
				wnHeight = "609px";
				prHeight = "422px";
			}
		}
		
		// Safari on Windows
		else if (browserObj.browserName == "safari") {
			if (browserObj.resolutionWidth >= 1280) {
				wnHeight = "408px";
				prHeight = "286px";
			}
			else if (browserObj.resolutionWidth >= 1024) {
				wnHeight = "450px";
				prHeight = "314px";
			}
			// width of 800 or less
			else {
				wnHeight = "535px";
				prHeight = "354px";
			}
		}
		
		// Internet Explorer
		else if (browserObj.browserName == "msie") {
			if (browserObj.resolutionWidth >= 1280) {
				wnHeight = "426px";
				prHeight = "301px";
			}
			else if (browserObj.resolutionWidth >= 1024) {
				wnHeight = "471px";
				prHeight = "331px";
			}
			// width of 800 or less
			else {
				wnHeight = "650px";
				prHeight = "479px";
			}
		}

		// set the height style for the what's new and press release sections
		document.getElementById('WNPortletContent').height = wnHeight;
		document.getElementById('PRPortletContent').height = prHeight;
	}	
	
	var slides = new Array();
	var current = 0;
	var hide = 0;

	function Elements(name_of_class){
	    
	    var i = 0;
	    var every_tag = document.all? document.all : document.getElementsByTagName("*"); 
	    slides=[]; //clear out global array
	    for(var j=0; j<every_tag.length;j++){
	       	 
	       	 //alert("POP");
	        if(every_tag[j].className == name_of_class){	            	                 
	                slides[i]=every_tag[j];
	                i++;
	        }
	        
	    } //end for
	
	    
	
	
	}// end Elements
	
	function rotate(){
	    var browserObj = new Object(getBrowserInfo());
	    if( current < slides.length - 1){
	        current = current + 1;
	    }
	    else{
	        current = 0;
	    }
	    /*
	    if (current == 0){
	        hide = slides.length - 1;
	    }
	    else{
	        hide = current - 1;
	    }
	    */
	    /*
	      document.writeln("current is", current);
	    document.writeln("hide is", hide);
	    */
	    
	    //document.writeln("slides is", slides[1]);
	    //document.writeln("prev is", prev);
	    hide=(current==0)? slides.length-1 : current-1;
	    
	    slides[hide].style.display="none";
	    slides[current].style.display="block";   
    }
    var pages=new Array();
    colors=new Array()
    hcolor=new Array();
    lcolor=new Array();
    page_no=new Array();
    opa=new Array();
colors[0]='#FFFFFF';
colors[1]='#EEEEEE';
colors[2]='#CCCCCC';
colors[3]='#999999';
colors[4]='#666666';
colors[5]='#333333'
colors[6]='#000000';
opa[0]='0.0';
opa[1]='0.16';
opa[2]='0.32';
opa[3]='0.48';
opa[4]='0.64';
opa[5]='0.8'
opa[6]='1.0';
hcolor[0]='#FFFFFF';
hcolor[1]='#EEEEEE';
hcolor[2]='#CCCCCC';
hcolor[3]='#999999';
hcolor[4]='#666666';
hcolor[5]='#003333';
hcolor[6]='#003366';
lcolor[0]='#FFFFFF';
lcolor[1]='#EEEEEE';
lcolor[2]='#CCCCCC';
lcolor[3]='#999999';
lcolor[4]='#666666';
lcolor[5]='#0000CC';
lcolor[6]='#0000FF';
page_no[0]='Page 1 of ' + rotationCount;
page_no[1]='Page 2 of ' + rotationCount;
page_no[2]='Page 3 of ' + rotationCount;
page_no[3]='Page 4 of ' + rotationCount;
page_no[4]='Page 5 of ' + rotationCount;

pages[0]= '<div class="portletItemRotate" style="margin-top: 5px; text-align:center;float:left"><img id="picture" src="/images/suzeorman.jpg" width="67" height="112" style="" alt="Suze Orman"/><br /><font size="1">Suze Orman</font></div><div class="portletItemRotate" style="margin-top: 5px; margin-left:80px"><a href="http://www.myfdicinsurance.gov/">MyFDICinsurance.gov</a><br/><font size="1">The FDIC\'s national public service campaign designed to help consumers learn about the benefits and limitations of deposit insurance; featuring personal finance expert Suze Orman and a link to EDIE the Estimator.</font></div><br /><div class="portletItemRotate"><a href="http://www.fdicseguro.gov">En Espanol - FDICseguro.gov</a></div>';
pages[1]= '<div class="wnHeaderRotate" style="margin-top:10px;text-align:left; width: 199px;">Consumer Help</div><div class="portletItemRotate" style="margin-top: 5px"><a href="http://www.fdic.gov/edie/">Electronic Deposit Insurance Estimator (EDIE)</a><br/><font size="1">An interactive application that can help you learn about deposit insurance</font></div><div class="portletItemRotate" style="margin-top: 5px"><a href="http://www2.fdic.gov/idasp/main_bankfind.asp">Bank Find</a><br/><font size="1">Search for information about banks</font></div><div class="portletItemRotate" style="margin-top: 5px"><a href="http://www2.fdic.gov/starsmail/index.asp">Customer Assistance Online Form</a><br/><font size="1">Submit questions or complaints</font></div>';
pages[2]= '<div class="portletItemRotate" style="margin-top: 5px; width: 199px; text-align:center;float:left"><img id="picture" src="/images/loanmod.jpg" width="105" height="110" style="" alt="house"/></div><div class="portletItemRotate" style="margin-top: 5px;"><a href="/loanmod/">Loan Modification Programs</a><br/><font size="1">This page is a consolidated look at the loan modification proposals and programs put forth by the FDIC and federal government since May 2008.</font></div><div class="portletItemRotate" style="margin-top: 5px"><a href="http://www.financialstability.gov">FinancialStability.gov</a></div>';
pages[3]= '<div class="portletItemRotate" style="margin-top: 5px; width: 199px; text-align:center;float:left"><img id="picture" src="/images/brochure.jpg" width="73" height="145" style="" alt="foreclosure brochure"/></div><div class="portletItemRotate" style="margin-top: 5px;"><a href="/consumers/loans/prevention/rescue/index.html">Beware of Foreclosure Rescue and Loan Modification Scams</a><br/><font size="1">Tips for avoiding mortgage foreclosure rescue and loan modification scams </font></div>';
pages[4]= '<div class="wnHeaderRotate" style="margin-top:10px;text-align:left; width: 199px;">Consumer Publications</div><div class="portletItemRotate" style="margin-top: 5px"><a href="/consumers/consumer/news/index.html">FDIC Consumer News</a><br/><font size="1">Latest consumer financial news and issues</font></div><div class="portletItemRotate" style="margin-top: 5px"><a href="/deposit/deposits/insured/index.html">Your Insured Deposits</a><br/><font size="1">Comprehensive guide about deposit insurance</font></div><div class="portletItemRotate" style="margin-top: 5px"><a href="/consumers/consumer/moneysmart/index.html">Money Smart</a><br/><font size="1">FDIC\'s financial education program</font></div>';



	var time=8000; //initial time
	var duration=8000;
	var speed=150;
	var blank_between=500;
	var done=1;    
	var curr = 6;
	var index=0;
	var clear=1;
	var ID_TIMEOUT=0;
  
  function linkfade(){
  //var obj=document.getElementById("portletItemRotate").getElementsByTagName("A");
    var obj;
    Elements("portletItemRotate");
  
  if (slides.length>0){
    for (var z=0;z<slides.length;z++){
      obj = slides[z].getElementsByTagName("a");
        if(obj.length>0){
        
            if( getBrowserInfo().browserName != "msie"){
            
                for(var  m=0;m<obj.length;m++){
                    obj[m].style.opacity=opa[curr];
                }
            }
            
            else{
        
                for(var  m=0;m<obj.length;m++){
            
                    obj[m].style.color=lcolor[curr];
                }
            
            }
        }   
    } //end outer for
        
  }
}
  
  
      function imagefade(){
  var obj;
  
  obj=document.all("picture");

  
        obj.style.filter='alpha(opacity='+opa[curr]*100+')';
    

}
  
  
    function wnHeaderfade(){
  //var obj=document.getElementById("portletItemRotate").getElementsByTagName("A");
    Elements("wnHeaderRotate");
  
  if (slides.length>0){         //Should be just one header per slide
  
    if( getBrowserInfo().browserName != "msie"){
            
         slides[0].style.opacity=opa[curr];
               
    }
  
    else{
   
         slides[0].style.color=hcolor[curr];
    }
       
  }
}
  
  
  function Next(){
  
        clearTimeout(ID_TIMEOUT);
        index++;
        done=0;
        time=speed;
        clear=0;
        curr=6;
        document.getElementById("play_pause").innerHTML='<img alt="Pause Button" title="Pause Button" width="31" height="21" src="pause_button.jpg" style="align:center" onmouseover="this.style.cursor=\'pointer\'" onclick="Pau()" />'
        execute();
 }
        
  function Back(){
  
        clearTimeout(ID_TIMEOUT);
        index--;
        done=0;
        time=speed;
        clear=0;
        curr=6;
        document.getElementById("play_pause").innerHTML='<img alt="Pause Button" title="Pause Button" width="31" height="21" src="pause_button.jpg" style="align:center" onmouseover="this.style.cursor=\'pointer\'" onclick="Pau()" />'
        execute();
 }
        
    function Pau(){
  
        document.getElementById("play_pause").innerHTML='<img alt="Play Button" title="Play Button" width="31" height="21" src="play_button.jpg" style="align:center" onmouseover="this.style.cursor=\'pointer\'" onclick="Play()" />'
        
        clearTimeout(ID_TIMEOUT);
        curr=6;
        wnHeaderfade();
        linkfade();
	   
	    
	    if(getBrowserInfo().browserName == "msie" ){
	   
	     
	        document.all("fade_area").innerHTML="<FONT color="+colors[curr]+">"+pages[index].substring(0,pages[index].length)+"</FONT>";
	        document.all("fade_footer").innerHTML="<FONT size="+1+" color="+colors[curr]+">"+page_no[index].substring(0,page_no[index].length)+"</FONT>";
	       //image is on the first slide 
	           if(index==0){
	        imagefade();
	        }
			 if(index==2){
	        imagefade();
	        }
	    }
	    
	    else if( getBrowserInfo().browserName == "firefox" || getBrowserInfo().browserName == "opera"){
	        document.getElementById("fade_area").innerHTML='<div style="opacity:'+opa[curr]+'">'+pages[index]+'</div>';
            document.getElementById("fade_footer").innerHTML='<div style="font-size:1; opacity:'+opa[curr]+'">'+page_no[index]+'</div>';	        
	    }
        
        done=1;
	    clear=1;
	    time=duration;
       
      
 }
  
  function Play(){
    document.getElementById("play_pause").innerHTML='<img alt="Pause Button" title="Pause Button" width="31" height="21" src="pause_button.jpg" style="align:center" onmouseover="this.style.cursor=\'pointer\'" onclick="Pau()" />'
    execute();
  }
  
	function fade_in(){
	
	if(getBrowserInfo().browserName == "msie" ){
	  
	document.all("fade_area").innerHTML="<font color="+colors[curr]+">"+pages[index].substring(0,pages[index].length)+"</font>";
	document.all("fade_footer").innerHTML="<font size="+1+" color="+colors[curr]+">"+page_no[index].substring(0,page_no[index].length)+"</font>";

	       //fade image on slide 0, 2, and 3
	    if(index==0 || index==2 || index==3){
	        imagefade();
	    } 
	}
	
	else if( getBrowserInfo().browserName == "firefox" || getBrowserInfo().browserName == "opera"){
	document.getElementById("fade_area").innerHTML='<div style="opacity:'+opa[curr]+'">'+pages[index]+'</div>';
	document.getElementById("fade_footer").innerHTML='<div style="font-size:1; opacity:'+opa[curr]+'">'+page_no[index]+'</div>';
		//alert(document.getElementById("fade_cell").outerHTML);
	}
	
	wnHeaderfade();
	linkfade();
	
	
	if(curr<colors.length-1){
	    curr++;
	    done = 0;
	    time=speed;
	}
	else{
	    done=1;
	    clear=1;
	    time=duration;
	}
	
	    execute();
	}
	
	function fade_out(){
	    
	    if(getBrowserInfo().browserName == "msie" ){
	          
	        document.all("fade_area").innerHTML="<font color="+colors[curr]+">"+pages[index].substring(0,pages[index].length)+"</font>";
	        document.all("fade_footer").innerHTML="<font size="+1+" color="+colors[curr]+">"+page_no[index].substring(0,page_no[index].length)+"</font>";

	       //image is on the first slide 
	          if(index==0 || index==2 || index==3){
	            imagefade();
	            }
	    }
	    
	    else if( getBrowserInfo().browserName == "firefox" || getBrowserInfo().browserName == "opera"){
	        document.getElementById("fade_area").innerHTML='<div style="opacity:'+opa[curr]+'">'+pages[index]+'</div>';
            document.getElementById("fade_footer").innerHTML='<div style="font-size:1; opacity:'+opa[curr]+'">'+page_no[index]+'</div>';	        
		//alert(document.getElementById("fade_cell").outerHTML);
	    }
	    
	    wnHeaderfade();
	    linkfade();
	   
	    
	    if(curr >0){
	        curr--;
	        done=1;
	        time=speed;
	    }
	    
	    else{
	        done=0;
	        time=blank_between;
	        index++;
	        clear=1;
	    }
	    
	    execute();
	    
   }

    function execute(){
    
        if(!done){

// Change the compare value to the number of page rotations        
            if(index>=rotationCount){
                   index=0;
            }
            
            if(index<0){
                    index=rotationCount - 1;
            }
        
                if(clear){
                    clearTimeout(ID_TIMEOUT);
                    clear=0;
                }
                
                ID_TIMEOUT=setTimeout("fade_in()",time);
        }
        
        if(done){
        
               if(clear){
                    clearTimeout(ID_TIMEOUT);
                    clear=0;
               }
               
               ID_TIMEOUT=setTimeout("fade_out()",time);
        }
        
   }
	    
function something(){

   Elements("portletTableRotate");
   setInterval("rotate()", 2000);
 
}
