var side_both1="";
var working= false;

function doSlide_both(id){
	timeToSlide = 50; // in milliseconds
		
	if(side_both1==""){

			obj1 = document.getElementById(id);
			obj1.style.visibility = "hidden";
			obj1.style.display = "block";
			var widthorg = obj1.offsetWidth;
			obj1.style.width = "1px";
			obj1.style.visibility = "visible";
			full1 = Math.ceil(widthorg/timeToSlide)
		
		slideDown_both(obj1,1,widthorg,full1,1);

		side_both1=id;
	}else{
	
		obj1 = document.getElementById(side_both1);
		full1 = Math.ceil(obj1.offsetWidth/timeToSlide)
		
		slideUp_both(obj1,full1,obj1.offsetWidth, id);

		side_both1="";
	}

	
	if((obj1!="" && obj1.style.display == "none")){ // if it's allready hidden we slide it down
			obj1.style.visibility = "hidden";
			obj1.style.display = "block";
			var widthorg = obj1.offsetWidth;
			obj1.style.width="1px";
			obj1.style.visibility = "visible";
			full1 = Math.ceil(widthorg/timeToSlide)
		
		slideDown_both(obj1,1,widthorg,full1,1);
	}
	
}

function slideDown_both(obj1,offset1,full1,px){
	px=1;
	var tmp1 = false;
	
	if(obj1!=''){
		if(offset1 < full1){
			obj1.style.width = offset1+"px";
			offset1=offset1+speedimg*px;
			tmp1 = true;
		} else {
			obj1.style.width = full1+"px"; //If the data inside is updated on runtime you can use auto instead...
			tmp1 = false;
		}
	}
	
	if(tmp1 ){
		setTimeout((function(){slideDown_both(obj1,offset1,full1,px);}),1);
	}else{
		working = false;
	}
}

function slideUp_both(obj1,px1,full1, id){
	px1=1;
	var tmp1 = false;
	
	if(obj1!=''){
		if((obj1.offsetWidth) > 1){
			obj1.style.width = obj1.offsetWidth-speedimg*px1+"px";
			tmp1=true;
		} else {
			tmp1=false;
			obj1.style.display = 'none';
			obj1.style.width=full1+"px"; // we reset the width if we were to slide it back down
		}
	}
	

	if(tmp1){
		setTimeout((function(){slideUp_both(obj1,px1,full1,id);}),1);
	}else{
		if(menunr!=1) document.getElementById('sidemenu'+menunr).style.backgroundImage = "url(images/main/"+menunr+".jpg)";	
		doSlide_both(id);
	}
}