	/*
		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 = 4;

	// 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;


// Take note of which slides have images and check for them in the Pau, fade_in, and fade_out functions where the image_fade function is called based on which slide is current
pages[0]= '<div class="wnHeaderRotate" style="margin-top:11px;text-align:left;">A Safe, Affordable and Feasible Template for Small-Dollar Loans</div><br /><div style="align:left"><img id="picture" src="fdicsdl2.gif" align="left"></div><div class="portletItemRotate" style="padding-left:18px;margin-bottom:5px;"><font size="2"><div style="padding-left:78px;"><ul><li>The small-dollar loan pilot resulted in a template of essential elements for safe, affordable, and feasible small-dollar loans.</li><li>The template is replicable - it is relatively simple to implement and requires no particular technology or other major infrastructure investment.</li><li>The template could help banks better adhere to existing regulatory guidance regarding offering alternatives to fee-based overdraft protection programs.</li></ul></font></div></font></div>';
pages[1]= '<div class="wnHeaderRotate" style="margin-top:11px;text-align:left;">Lessons Learned</div><br /><div style="align:left"><img id="picture" src="fdicsdl2.gif" align="left"></div><div class="portletItemRotate" style="padding-left:18px;margin-bottom:5px;"><font size="2"><div style="padding-left:78px;"><ul><li>A dominant business model emerged: most pilot bankers indicated that small dollar loans were a useful business strategy for developing or retaining long-term relationships with consumers.</li><li>Long-term support from a bank\'s board of directors and senior management was most important for programmatic success.</li><li>Loan terms of 90 days or more and streamlined but solid underwriting were the most important product elements.</li></ul></font></div>';
pages[2]= '<div class="wnHeaderRotate" style="margin-top:11px;text-align:left;">Pilot Results</div><br /><div style="align:left"><img id="picture" src="fdicsdl2.gif" align="left"></div><div class="portletItemRotate" style="padding-left:18px;margin-bottom:5px;"><font size="2"><div style="padding-left:78px;"><ul><li>The pilot concluded with twenty-eight <a href="participants.html">(28) volunteer banks</a> with total assets ranging from $28 million to nearly $10 billion.</li><li>Participating banks made more than 34,400 small-dollar loans with a principal balance of $40.2 million. </li><li>Small-dollar loan default rates were in line with default rates for similar types of unsecured loans.</li></ul></font></div>';
pages[3]= '<div class="wnHeaderRotate" style="margin-top:11px;text-align:left;">Next Steps</div><br /><div style="align:left"><img id="picture" src="fdicsdl2.gif" align="left"></div><div class="portletItemRotate" style="padding-left:18px;margin-bottom:5px;"><font size="2"><div style="padding-left:78px;"><ul><li>The FDIC is working with the banking industry, consumer and community groups, nonprofit organizations, other government agencies, and others to research and pursue strategies that could prove useful in expanding the supply of small-dollar loans.</li></ul></font></div>';




	var time=11000; //initial time
	var duration=11000;
	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 
	         // from when there was an image on the first slide
	         if(index==0 || index==1 || 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>';	        
	    }
        
        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 2 and 4
	    if(index==0 || index==1 || 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>";

	      //fade image on slide 2 and 4
	          if(index==0 || index==1 || 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);
 
}

