var multiFeatureTimer;

_initialize = function(){
    if($$(".hp_rotating-feature")){
	
		//rotate
        itemlength = $$(".hp_rotating-feature .feature").length-1;
        if(itemlength > 0)
            multiFeatureTimer = setTimeout("_rotate(1)",6000);
			
		//attach hover event
		$$(".hp_rotating-feature .feature").each(function(item) {
			Event.observe(item,'mouseover', function(e){
				item.childNodes[0].style.display = "block";
			});    
			Event.observe(item,'mouseout', function(e){
				item.childNodes[0].style.display = "none";
			});    		
		}); 		
	}
}

Event.observe(window, 'load', _initialize, false);

_rotate = function(cnt){
    itemlength = $$(".hp_rotating-feature .feature").length-1;
	
    if(cnt<itemlength){
        _rotationControl(cnt);
        cnt++;
        multiFeatureTimer = setTimeout("_rotate("+cnt+")",6000);
    } else if(cnt == itemlength){
        _rotationControl(cnt);
        multiFeatureTimer = setTimeout("_rotate(0)",6000);
    }

}

_rotationControl = function(id){
    //turn off all but chosen one
    $$(".hp_rotating-feature .feature").each(function(item) {
        item.style.display = "none";
       
        if(item.id == id)
            item.style.display = "block";
    });  
}

