var isDown = true;
var isDown2 = true;
var isDown3 = true;
var isDown4 = true;

function slide1(){
    slideUp = new Fx.Style('upslide1', 'top', { duration: 500	});
    
    $('slideTitle1').addEvent('click', function(){
	    if(isDown){
		    slideUp.start(100)
		    document.getElementById("arrow1").src = '/images/tibcov2/arrow_down.gif';
		    document.getElementById("slidePromo1").style.zIndex = "3";
		    resetSliders(1);
		    isDown = false;
	    }
	    else {
		    slideUp.start(240)
		    isDown = true;
		    document.getElementById("arrow1").src = '/images/tibcov2/arrow_up.gif';
		    setTimeout("document.getElementById('slidePromo1').style.zIndex = '1';",500);
	    }
    })
}

function slide2(){
    slideUp2 = new Fx.Style('upslide2', 'top', { duration: 500	});
	
    $('slideTitle2').addEvent('click', function(){
	    if(isDown2){
		    slideUp2.start(10)
		    
		    document.getElementById("arrow2").src = '/images/tibcov2/arrow_down.gif';
		    document.getElementById("slidePromo1").style.zIndex = "3";
		    document.getElementById("slidePromo2").style.zIndex = "3";
		    // reset the others
		    resetSliders(2);
		    isDown2 = false;
	    }
	    else {
		    slideUp2.start(240)
		    isDown2 = true;
		    document.getElementById("arrow3").src = '/images/tibcov2/arrow_up.gif';
		    setTimeout("document.getElementById('slidePromo1').style.zIndex = '1';document.getElementById('slidePromo2').style.zIndex = '1';",500);
	    }
    })
}

function slide3(){
    slideUp3 = new Fx.Style('upslide3', 'top', { duration: 500	});
	
    $('slideTitle3').addEvent('click', function(){
	    if(isDown3){
		    slideUp3.start(10)
		    
		    document.getElementById("arrow3").src = '/images/tibcov2/arrow_down.gif';
		    document.getElementById("slidePromo3").style.zIndex = "3";
		    // reset the others
		    resetSliders(3);
		    isDown3 = false;
	    }
	    else {
		    slideUp3.start(240)
		    isDown3 = true;
		    document.getElementById("arrow3").src = '/images/tibcov2/arrow_up.gif';
		    setTimeout("document.getElementById('slidePromo2').style.zIndex = '1';document.getElementById('slidePromo3').style.zIndex = '1';",500);
	    }
    })
}

function slide4(){
    slideUp4 = new Fx.Style('upslide4', 'top', { duration: 500	});
	
    $('slideTitle4').addEvent('click', function(){
	    if(isDown4){
		    slideUp4.start(10)
		    
		    document.getElementById("arrow4").src = '/images/tibcov2/arrow_down.gif';
		    document.getElementById("slidePromo4").style.zIndex = "3";
		    // reset the others
		    resetSliders(4);
		    isDown4 = false;
	    }
	    else {
		    slideUp4.start(240)
		    isDown4 = true;
		    document.getElementById("arrow3").src = '/images/tibcov2/arrow_up.gif';
		    setTimeout("document.getElementById('slidePromo3').style.zIndex = '1';document.getElementById('slidePromo4').style.zIndex = '1';",500);
	    }
    })
}

function resetSliders(activeSlider) {
    for (var x = 1; x <= 4; x++) {
        if(x == 1) {
            isDownObj = eval("isDown");
            sliderObj = eval("slideUp");
        }
        else {
            isDownObj = eval("isDown" + x);
            sliderObj = eval("slideUp" + x);
        }
        if(activeSlider != x) {
            sliderObj.start(240);
            slideImgObj = eval("document.getElementById('arrow" + x + "')");
            slideImgObj.src = '/images/tibcov2/arrow_up.gif';
            isDownObj = true;
        }
    }
}
function sendout() {
    docObj = document.getElementById("reference").offsetLeft;
    docObj = docObj + 15;
	
    //for IE
    if (window.ActiveXObject)
        document.getElementById("slidePromo1").style.left = docObj;
    else
        document.getElementById("slidePromo1").style.left = docObj + "px";
    
    docObj = docObj + 232;
    
    if (window.ActiveXObject)
        document.getElementById("slidePromo2").style.left = docObj;
    else
        document.getElementById("slidePromo2").style.left = docObj + "px";
        
    docObj = docObj + 232;
    
    if (window.ActiveXObject)
        document.getElementById("slidePromo3").style.left = docObj;
    else
        document.getElementById("slidePromo3").style.left = docObj + "px";
        
    docObj = docObj + 232;
    
    if (window.ActiveXObject)
        document.getElementById("slidePromo4").style.left = docObj;
    else
        document.getElementById("slidePromo4").style.left = docObj + "px";

}

function startList() {
    if (document.all&&document.getElementById) {
        cssdropdownRoot = document.getElementById("nav");
        var targetArray = new Array();
        var triggerArray = new Array();
        
        for (x=0; x<cssdropdownRoot.childNodes.length; x++) {
            node = cssdropdownRoot.childNodes[x];
            
            if (node.nodeName=="LI") { 
                for (y=0; y<node.childNodes.length; y++) {
                    node2 = node.childNodes[y];
                   
                    if (node2.nodeName=="A") {
                        targetArray[x] = node2;
                    }
                    
                    if (node2.nodeName=="UL") {
                        triggerArray[x] = node2;
                    }
                }
            }
        }
        triggerArray[0].onmouseover=function() {
                targetArray[0].className="over";
        }
        triggerArray[1].onmouseover=function() {
                targetArray[1].className="over";
        }
        triggerArray[3].onmouseover=function() {
                targetArray[3].className="over";
        }
         triggerArray[5].onmouseover=function() {
                targetArray[5].className="over";
        }
        triggerArray[0].onmouseout=function() {
                targetArray[0].className="";
        }
        triggerArray[1].onmouseout=function() {
                targetArray[1].className="";
        }
        triggerArray[3].onmouseout=function() {
                targetArray[3].className="";
        }
         triggerArray[5].onmouseout=function() {
                targetArray[5].className="";
        }
    }
}

jQuery(document).ready(function(){
    slide1();
	slide2();
	slide3();
	slide4();
});

