
var msie = 0;
var opened = 0;

function initialHandling(){

	document.getElementById("aboutClick").onclick = initAbout;
	document.getElementById("worksClick").onclick = initWorks;
	//document.getElementById("techClick").onclick = initTech;
	document.getElementById("gplClick").onclick = initGPL;
	document.getElementById("contactClick").onclick = initContact;
	
	if (location.hash != "")
	{
		var x = location.hash.substr(1).split("#");
		if(x == "about_us" || x == "works" || x == "technologies" || x == "free_scripts" || x == "contact"){
			if(x == "about_us"){ x = "aboutContainer"; }
			else if(x == "works"){ x = "worksContainer"; }
			//else if(x == "technologies"){ x = "techContainer"; }
			else if(x == "free_scripts"){ x = "gplContainer"; }
			else if(x == "contact"){ x = "contactContainer"; }
			setHighContForMSIE7(17,x);
			openContainer(x);
			opened = x;
		}
	}
	
}

	function initAbout(){
	
		closePrevOpenCont(opened);
		setHighContForMSIE7(17,"aboutContainer");
		openContainer("aboutContainer");
		if(opened != 0){opened = "aboutContainer";}
	}
	
	function initWorks(){
	
		closePrevOpenCont(opened);
		setHighContForMSIE7(17,"worksContainer");
		openContainer("worksContainer");
		if(opened != 0){opened = "worksContainer";}
	
	}

	function initTech(){
	
		closePrevOpenCont(opened);
		setHighContForMSIE7(17,"techContainer");
		openContainer("techContainer");
		if(opened != 0){opened = "techContainer";}
	
	}
	
	function initGPL(){
	
		closePrevOpenCont(opened);
		setHighContForMSIE7(17,"gplContainer");
		openContainer("gplContainer");
		if(opened != 0){opened = "gplContainer";}
	
	}
	
	function initContact(){
	
		closePrevOpenCont(opened);
		setHighContForMSIE7(17,"contactContainer");
		openContainer("contactContainer");
		if(opened != 0){opened = "contactContainer";}
	
	}
	
	
//function section	
	
//opening container for MSIE 7
function setHighContForMSIE7( timeOffset , prevOpened ){

var x = navigator;

	if(x.userAgent.indexOf("MSIE 7") > -1){
		if(msie == 0){
			var delay = 0;
			for(var i=0; i<17; i++){
				var topPosition = 50-i;
				delay = delay + timeOffset;
				setTimeout('document.getElementById("container").style.top = "' + topPosition + '%"',delay);
			}
			msie = 1;
		}else if (opened != prevOpened){
			var delay = 0;
			for(var i=0; i<17; i++){
				var topPosition = 34+i;
				setTimeout('document.getElementById("container").style.top = "' + topPosition + '%"',delay);
				delay = delay+20;
				
			}
			
			for(var i=0; i<17; i++){
				topPosition = 50-i;
				delay = delay+15;
				setTimeout('document.getElementById("container").style.top = "' + topPosition + '%"',delay);
				
			}
		}
	}

}

//closeing container for MSIE7
function setLowContForMSIE7( timeOffset  ){

var x = navigator;

	if(x.userAgent.indexOf("MSIE 7") > -1){
		//document.getElementById("container").style.top = "50%";
		for(var i=0; i<17; i++){
				var topPosition = 34+i;
				var delay = timeOffset*i;
				setTimeout('document.getElementById("container").style.top = "' + topPosition + '%"',delay);
		}
	}
}

function closePrevOpenCont( id ){

	//cloesing previously opened window
	if( id != 0){
		var delay = 0;
		var size = 250;
		for (var i=0; i<11; i++){
			delay = delay + 25;
			setTimeout('document.getElementById("'+id+'").style.height = "' + size + 'px"', delay);
			size = size - 25;
		}
		setTimeout('document.getElementById("'+id+'").style.display = "none"', (delay+25));
		
	}

}

function openContainer( id ){

	//opening when something opened previously
	if(opened != 0){
		if(opened != id){
			var delay = 300;
			var size = 0;
			setTimeout('document.getElementById("'+id+'").style.display = "block"', delay);
			setTimeout('document.getElementById("'+id+'").style.height = "0px"', delay);
			for (var i=0; i<11; i++){
				delay = delay + 25;
				size = size + 25;
				setTimeout('document.getElementById("'+id+'").style.height = "' + size + 'px"', delay);
			}
		opened = 1;
		
		//if try to open again this same window - left closed
		} else {
			opened = 0;
			setLowContForMSIE7(20);
			msie = 0;
		}
		
	//opening when everything closed
	}else{
			var delay = 0;
			var size = 25;
			setTimeout('document.getElementById("'+id+'").style.display = "block"', delay);
			setTimeout('document.getElementById("'+id+'").style.height = "0px"', delay);
			for (var i=0; i<11; i++){
				delay = delay + 25;
				setTimeout('document.getElementById("'+id+'").style.height = "' + size + 'px"', delay);
				size = size + 25;
			}
		opened = 1;
	}
		

}
	