
var Ano1 = new Array();

function Stup(clickId,parrentId,sliderId,detaliiId,nano_slideSpeed,nano_timer)
{    
    m = new upSliderObject(clickId,parrentId,sliderId,detaliiId,nano_slideSpeed,nano_timer);
    Ano1[clickId] = m;
    m.init();
    m.move();   
}

function Stdow(clickId)
{
    m = Ano1[clickId];
    m.hide();
}

function upSliderObject(clickId,parrentId,sliderId,detaliiId,nano_slideSpeed,nano_timer)
{   
    this.clickId = clickId;
    this.parrentId = parrentId;
    this.sliderId = sliderId;
    this.detaliiId = detaliiId;

    this.nano_timer = nano_timer;
    
    this.clickObj = document.getElementById(clickId);
    this.parrentObj = document.getElementById(parrentId);
    this.contentObj = document.getElementById(sliderId);
    this.detaliiObj = document.getElementById(detaliiId);
    
    this.direction = nano_slideSpeed;
    this.parrentObj.style.display='block';
    this.parrentObj.style.visibility = 'visible';

    this.contentObj.style.top=(this.parrentObj.clientHeight-71) + 'px';
    this.clickObj.style.opacity = 100;
    this.detaliiObj.style.opacity = 100;

    this.setOpId = "";
    this.setOpVal = 0;

    this.t = 0;

    this.statusShow = false;
    this.statusHide = false;
}

upSliderObject.prototype = {
    _this : "",
    init: function() {
        _this =  this;        
    },
    move : function(){
        if(_this.statusHide==false){
        _this.statusShow=true;
        rerunFunction = true;
        // calculate opacity
        opvalue = 100/(_this.contentObj.offsetHeight/_this.direction);
        // ez a fade efektus a szinvaltashoz
        difference = (_this.contentObj.offsetTop - (_this.direction));
        opvalue1 = 0-(Math.round(opvalue)+3);
        //setOpacityValue(clickId,opvalue1);
        _this.setOpId=_this.clickId;
        _this.setOpVal=opvalue1;
        _this.setOpaV();
        //setOpacityValue(detaliiId,opvalue1);
        _this.setOpId=_this.detaliiId;
        _this.setOpVal=opvalue1;
        _this.setOpaV();
        var topPos = difference;
        if(topPos<=0){
            topPos=0;
            rerunFunction = false;
        }
        // ez a mozgas honnat es mihez kepest
        _this.contentObj.style.top = topPos + 'px';
        _this.contentObj.style.offsetTop = topPos;

        if(rerunFunction){
           _this.t = setTimeout(_this.move,_this.nano_timer);
        }else{
            document.getElementById(_this.clickId).style.opacity = 0;
            document.getElementById(_this.detaliiId).style.opacity = 0;
            clearTimeout(_this.t);            
        }
        }
    },    
    hide : function() {
        if(_this.statusShow==true){
        clearTimeout(_this.t);
        _this.statusHide=true;
        rerunFunction = true;
        //calculate opacity
        opvalue = 100/(_this.contentObj.offsetHeight/_this.direction);
        difference = (_this.contentObj.offsetTop + (_this.direction));
        opvalue1 = (Math.round(opvalue)+3);        
        //setOpacityValue(clickId,opvalue1);
        _this.setOpId=_this.clickId;
        _this.setOpVal=opvalue1;
        _this.setOpaV();
        //setOpacityValue(detaliiId,opvalue1);
        _this.setOpId=_this.detaliiId;
        _this.setOpVal=opvalue1;
        _this.setOpaV();
        var topPos = difference;
        if(topPos<=0){
            topPos=0;
            rerunFunction = false;
        }
        if(difference>=(_this.contentObj.offsetHeight-71)){
            topPos = _this.contentObj.offsetHeight-71;
            rerunFunction = false;
        }
        // lekerem az elmentett infokat
        _this.contentObj.style.top = topPos + 'px';
        _this.contentObj.style.offsetTop = topPos;
        if(rerunFunction){
            _this.t = setTimeout(_this.hide,_this.nano_timer);
        }else{
            if(difference>=(_this.contentObj.offsetHeight-71)){
                _this.parrentObj.style.display = '';
                _this.parrentObj.style.visibility = '';
                _this.clickObj.style.visibility = 'visible';
            }
        }
        }
    },
    setOpaV : function() {
        currvalue = document.getElementById(_this.setOpId).style.opacity;
        valuetoset = (currvalue--) + _this.setOpVal;
        //alert(valuetoset);
        document.getElementById(_this.setOpId).style.opacity = valuetoset;
        document.getElementById(_this.setOpId).style.filter = 'alpha(opacity=' + valuetoset + ')';
        if(valuetoset>=0){
            valuetoset = -1;
        }else{
            valuetoset=valuetoset;
        }
        document.getElementById(_this.setOpId).style.zIndex = valuetoset;
    },
    fade : function() {
        topPos=0;
        _this.contentObj.style.top = topPos + 'px';
        _this.contentObj.style.offsetTop = topPos;
        _this.parrentObj.style.display = '';
        _this.parrentObj.style.visibility = '';
        _this.clickObj.style.visibility = 'visible';
        opvalue = 100/(_this.contentObj.offsetHeight/_this.direction);
        difference = (_this.contentObj.offsetTop + (_this.direction));
        opvalue1 = (Math.round(opvalue)+3);
        _this.setOpId=_this.clickId;
        _this.setOpVal=opvalue1;
        _this.setOpaV();
        _this.setOpId=_this.detaliiId;
        _this.setOpVal=opvalue1;
        _this.setOpaV();
        // lekerem az elmentett infokat
        
    }
};

function changeAllZindexOn(){
    changeZindex('lmch', 100);
    changeZindex('lmch2', 100);
    changeZindex('lmch3', 100);
    changeZindex('lmch4', 100);
    changeZindex('lmch5', 100);
}

function changeAllZindexOFF(){
    changeZindex('lmch', -10);
    changeZindex('lmch2', -10);
    changeZindex('lmch3', -10);
    changeZindex('lmch4', -10);
    changeZindex('lmch5', -10);
}

// something else

function setOpacityValue(id,value) {

    currvalue = document.getElementById(id).style.opacity;

    valuetoset = (currvalue--) + value;
    //alert(valuetoset);
    document.getElementById(id).style.opacity = valuetoset;
    document.getElementById(id).style.filter = 'alpha(opacity=' + valuetoset + ')';
    if(valuetoset>=0){valuetoset = -1;}else{
    valuetoset=valuetoset;}
    document.getElementById(id).style.zIndex = valuetoset;
}

function changeZindex(elem, value){
    var zObj = document.getElementById(elem);
    zObj.style.zIndex=value;
    //document.getElementById(elem).style.zIndex=value;
}

