﻿var heightContent=new Array();
var StatusContent=new Array("Closed","Closed");
var closeTimer=null;
function openContent(content,index){
 if(StatusContent[index]=="Closed"){
    setVisible(content);
    if(heightContent[index]!=null && heightContent[index]!=0){
  
    }
    else{
        StatusContent[index]="Opening";
        heightContent[index]=0;
        closeTimer=setTimeout("openingContent('"+content+"',"+index+");",50);
    }
  }
}
function closeContent(content,index){
//    if(window.event)
//      imgObj = window.event.srcElement;
//    else
//      imgObj = ev.target;
////if (imgObj.className == "MPestanyes") {
    if(StatusContent[index]=="Opening" || StatusContent[index]=="Opened"){
    
        if(heightContent[index]!=0){
            StatusContent[index]="Closing";
            closeTimer=setTimeout("closingContent('"+content+"',"+index+");",500);
        }
    }
 //}
}
function closingContent(content,index){
 if(StatusContent[index]=="Closing"){
    heightContent[index]=heightContent[index]-10;
    document.getElementById(content).style.height=heightContent[index]+"px";
    if(heightContent[index]>0){
    closeTimer=setTimeout("closingContent('"+content+"',"+index+");",50);
    }
    else{
    StatusContent[index]="Closed";
    setInvisible(content);
    }
 }
}
function changingContent(content){
  setInvisible(content);
}
function openingContent(content,index){
 if(StatusContent[index]=="Opening"){
    heightContent[index]=heightContent[index]+10;
    document.getElementById(content).style.height=heightContent[index]+"px";
    if(heightContent[index]<130){
    closeTimer=setTimeout("openingContent('"+content+"',"+index+");",50);
    }
    else{
      StatusContent[index]="Opened";
    }
 }
}
// cancel close timer
function cancelCloseTime(index)
{
	if(closeTimer)
	{
		window.clearTimeout(closeTimer);
		closeTimer = null;
		StatusContent[index]="Opened";
	}
}
function setVisible(content){
    document.getElementById(content).style.display="block";
    document.getElementById(content).style.visibility="visible";
}

function setInvisible(content){
    document.getElementById(content).style.display="none";
    document.getElementById(content).style.visibility="hidden";
}

function setLeftPestanyes(){
if(document.getElementById("MPestanyaIdioma")!=null&&document.getElementById("MPestanyaLogin")!=null){
 var posLeft=document.getElementById("MPestanyaIdioma").offsetLeft+getLeftWrapper();
 document.getElementById("MPestanyaIdioma").style.left=posLeft+"px";
 posLeft=document.getElementById("MPanelIdioma").offsetLeft+getLeftWrapper();
 document.getElementById("MPanelIdioma").style.left=posLeft+"px";
 posLeft=document.getElementById("MPestanyaLogin").offsetLeft+getLeftWrapper();
 document.getElementById("MPestanyaLogin").style.left=posLeft+"px";
 posLeft=document.getElementById("MPanelLogin").offsetLeft+getLeftWrapper();
 document.getElementById("MPanelLogin").style.left=posLeft+"px";
}
}

function getLeftWrapper(){
return document.getElementById("wrapping").offsetLeft;
}
