﻿var i = 0;
var active = "";
var active2 = "";
var action;
var infoBox = new Array(5);



function slide_dropdown(boxId) {
    objId = "box_" + boxId;
    obj = document.getElementById(objId);
    slide_out2(obj);
}





function slide_out(box) {
    //alert("slider: " + action);
    box_id = box.id;
    part = box_id.split("_");
    box_id = part[1];
    sliderbox_id = "sliderbox_" + box_id;

    if (infoBox[box_id].state == 0) {
        window.clearInterval(active);
        i=0;
        window.clearInterval(active);
        active = window.setInterval("posplus_box(infoBox[box_id].height)",1);
        height = infoBox[box_id].height;
        box.style.backgroundImage="url(http://www.montafon.at/Design/images/ibox_header_down_gold.jpg)";
        //alert("sliding out");
    } else {
        if (infoBox[box_id].state == 2) {
            showDropDown2('Karten-dropdown', active, active2);
            slide_out2(box);
            return(true);
        }
        i=40;
        active = window.setInterval("posminus_box(infoBox[box_id].height)",1);
        box.style.backgroundImage="url(http://www.montafon.at/Design/images/ibox_header_up_gold.jpg)";
    }
}
function slide_out2(box) {
    box_id = box.id;
    part = box_id.split("_");
    box_id = part[1];
    sliderbox_id = "sliderbox_" + box_id;
    h = document.getElementById(sliderbox_id).style.height.split("px");
    //alert(infoBox[box_id].state);
    if ( infoBox[box_id].state != 2) {
        i=infoBox[box_id].height;
        window.clearInterval(active);
        active2 = window.setInterval("posplus2_box(infoBox[box_id].maxheight)",1);
        height = infoBox[box_id].height;
        box.style.backgroundImage="url(http://www.montafon.at/Design/images/ibox_header_down_gold.jpg)";
    } else {
        i=infoBox[box_id].maxheight;
        active2 = window.setInterval("posminus2_box(infoBox[box_id].height)",1);
        box.style.backgroundImage="url(http://www.montafon.at/Design/images/ibox_header_up_gold.jpg)";
    }
}
function posplus_box(height) {
    i = i + 10;
    document.getElementById(sliderbox_id).style.height=height * Math.sin(4*i/100)+"px";
    document.getElementById(sliderbox_id).style.filter="alpha(opacity=" + 2.5 * i + ")";
    document.getElementById(sliderbox_id).style.MozOpacity = 2.5 * i/100;
    if(i >= 40) {
        window.clearInterval(active);
        infoBox[box_id].state = 1;
		active="";
    }
}
function posplus2_box(height) {
    i = i + 40;
    //alert("h=" + i);
    document.getElementById(sliderbox_id).style.height= i + "px";
    document.getElementById(sliderbox_id).style.filter="alpha(opacity=" + 2.5 * i + ")";
    document.getElementById(sliderbox_id).style.MozOpacity = 2.5 * i/100;
    if(i >= infoBox[box_id].maxheight) {
        window.clearInterval(active2);
        infoBox[box_id].state = 2;
        //alert("ende");
		active2 = "";
		return(true);
    } 
}
function posminus_box(height) {
    i = i - 10;
    document.getElementById(sliderbox_id).style.height=height * Math.sin(4*i/100)+"px";
    document.getElementById(sliderbox_id).style.filter="alpha(opacity=" + 2.5 * i + ")";
    document.getElementById(sliderbox_id).style.MozOpacity = 2.5 * i/100;
    if(i <= 0) {
        infoBox[box_id].state = 0;
        document.getElementById(sliderbox_id).style.MozOpacity = 0;
        window.clearInterval(active);
		active="";
    }
    
}
function posminus2_box(height) {
    i = i - 40;
	if (i <= infoBox[box_id].height) {
		i = infoBox[box_id].height;
	}
    document.getElementById(sliderbox_id).style.height= i + "px";
    document.getElementById(sliderbox_id).style.filter="alpha(opacity=" + 2.5 * i + ")";
    document.getElementById(sliderbox_id).style.MozOpacity = 2.5 * i/100;
    if(i <= infoBox[box_id].height) {
        infoBox[box_id].state = 1;
        window.clearInterval(active2);
		active2="";
        //document.getElementById(sliderbox_id).style.MozOpacity = 0;
        //document.getElementById(sliderbox_id).style.filter="alpha(opacity=0)";
    }
    
}
