//Image rotation for banner

function randOrd(){
		return (Math.round(Math.random())-0.4); 
	}

var total_images_loaded = 0;	//count images loaded
									
	
	var int=self.setTimeout("fade(0,1)", 1)
					
	var divs=["image1","image2","image3","image4"];
	divs.sort( randOrd );
	var zindex=0;
	
	function fade(n,diff,opacity){
		id=divs[n];
		opacity=opacity?opacity:(diff<0)?100:0; 
		opacity+=diff;
		if(document.getElementById&&document.all){
			document.getElementById(id).style.filter="alpha(opacity="+opacity+")";
		}else if(document.getElementById&&!document.all){
			document.getElementById(id).style.MozOpacity = opacity/100;
			document.getElementById(id).style.opacity = opacity/100;
		}
			document.getElementById(id).style.visibility="visible";
										
		if(opacity>=99){
			zindex++;
			document.getElementById(id).style.zIndex=zindex;
			setTimeout("fade("+n+",-"+diff+","+opacity+");",3000);
			nn=(n==divs.length-1)?0:n+1;
			setTimeout("fade("+nn+","+diff+");",3000);
		} else if(opacity>0){
			setTimeout("fade("+n+","+diff+","+opacity+");",30);
		}
	}


var active = 0;
var height = 0;
var height2 = 0;
var divHeight = 0;
var IsOpen = 0;
var div = "";
var id= "";

var myTimer;

function toggle_visible(id, Dheight) {
    if(active == 0 && IsOpen == 0) {
	     
       active = 1;
	   div = id;
	   divHeight = Dheight;          
       divPlusOne(id);                
            
    } else if(active == 1 && (id != div) && IsOpen ==1){
		divHeight = Dheight;
		divMinusOne(div);
		divPlusTwo(id);
	} else if(active == 1 && (id != div) && IsOpen ==2){
		divHeight = Dheight;
		divMinusTwo(div);
		divPlusOne(id);
		
	} else if(active == 1 && (id == div) && IsOpen ==1){
        divMinusOne(id);
        active = 0; 	
		IsOpen = 0;	
			            
    } else if(active == 1 && (id == div) && IsOpen ==2){ 
        divMinusTwo(id);		            
        active = 0;	
		IsOpen = 0;
				
    } 
        
}

function divMinusOne(id) {
    if(height >= 10) {
        height = height - 10;
        document.getElementById(id).style.height=height + 'px';
		               
        window.setTimeout('divMinusOne("' + id + '")', 1);               
    } 
	else{
	    document.getElementById(id).style.visibility="hidden"; 
		//close = 1;
	}   
            
} 

function divMinusTwo(id) {
		if(height2 >= 10) {
        height2 = height2 - 10;
        document.getElementById(id).style.height=height2 + 'px';
		               
        window.setTimeout('divMinusTwo("' + id + '")', 1);               
    } 
	else{
	    document.getElementById(id).style.visibility="hidden"; 
	}   
            
} 

function divPlusOne(id) { 
     if(height <= divHeight) {
		document.getElementById(id).style.visibility="visible"; 
        height = height + 10;
        document.getElementById(id).style.height=height + 'px';
		
        window.setTimeout('divPlusOne("' + id + '")', 1);		                    
    }
	else{
		div = id;
		IsOpen = 1;
	}	
}

function divPlusTwo(id) { 
     if(height2 <= divHeight) {
		document.getElementById(id).style.visibility="visible"; 
        height2 = height2 + 10;
        document.getElementById(id).style.height=height2 + 'px';
		
        window.setTimeout('divPlusTwo("' + id + '")', 1);		                    
    }
	else{
		div = id;
		IsOpen = 2;
	}
}