
var container = 'looping_links';
var switch_time = 10000;
var links;
var link = 1; 
var stop = false;

function rotateLinks() {
    
    this.rotate = function(link) {
        if (stop) return; //If the user has hovered over a link then dont loop anymore
        if (link > (links.length)) link = 1;
        plink = (link == 1)? links.length : link - 1;
        
        links[plink-1].removeAttribute('id');
        links[link-1].id = 'curlink';
        get_element('link'.concat(plink)).style.display = "none";
        get_element('link'.concat(link)).style.display = "block";
        get_element('info'.concat(plink)).style.display = "none";
        get_element('info'.concat(link)).style.display = "block";
        
        setTimeout(function() { this.rotate(++link);  }, switch_time);
        
    }
    
    if (!get_element(container)) return;    
    links = get_element(container).getElementsByTagName('li');
    if (links.length <= 1) return;
    setTimeout(function() { this.rotate(++link); },  switch_time);

    
};

function changeLinks() {

    this.change = function(j) {       
    
        //j.onclick = function() {
        j.onmouseover = function() {
        
            stop = true;
            numlink = this.id.replace(/\D+/, '');
            if (numlink != currSwitch) {
                
                li = this.parentNode;
                get_element('curlink').removeAttribute('id');
                links = get_element(container).getElementsByTagName('li');

                for (i=1; i<links.length+1; i++) {
                    if (get_element('link'+i)) get_element('link'+i).style.display = 'none';
                    if (get_element('info'+i)) get_element('info'+i).style.display = 'none';
                }

                get_element('link'.concat(numlink)).style.display = "block";
                get_element('info'.concat(numlink)).style.display = "block";
                currSwitch = numlink;
                li.id = 'curlink';
            }
            
            return false;
            
        }
        
    }  
    
    currSwitch = 1;
        if(!get_element(container)) return;
        j = get_element(container).getElementsByTagName('a');
        for (i=0; i<j.length; i++) {
            if (j[i].className == 'loop') {
                this.change(j[i]);                
            }
        }   
};

function get_element(id) {
    return (document.getElementById)? document.getElementById(id) : document.all[id];
};