
var i=0;
var  m=10;
var flag=0;
var width=0;
var count=0;
var left_column_range=0;
var klasa  = "top-navigation-item";
var content_promotions = new Array();
var content_actual = new Array();
function setTablesLeft(){
	var ilosc=0;
	 ilosc = getElementsByClassName("example_content");
	
	left_column_range=ilosc;
		for(var i=0; i<ilosc; i++){
			if(i==0){
				content_promotions[i] = "1";
			}else{
		content_promotions[i] = "0";
		}
		}

}
function setTablesRight(){
	var ilosc=0;
	 ilosc = getElementsByClassName("example_content");
	ilosc=ilosc-left_column_range;
	
		for(var i=0; i<ilosc; i++){
			if(i==0){
				content_actual[i] = "1";
			}else{
		content_actual[i] = "0";
		}
		}
		
}
function big(lyr) {
     var layer = lyr.substr(5)-1;
     var menu = "menu"+layer;
	 var width = getWidth(menu);
document.getElementById(lyr).style.left=width;    
document.getElementById(lyr).style.display='block';}
//		document.all[lyr].style.height='75px'; }

function small(lyr) {

//document.all[lyr].style.height='0px';
document.getElementById(lyr).style.display='none';
}

function layer(){

var ilosc = getElementsByClassName(klasa);
	
            for(var i=1; i<=ilosc; i++){
			var layer = "Layer"+i;
			var zwrot = document.getElementById(layer);
			
			if(zwrot==null){
			}else{
			document.getElementById(layer).style.display='none';
			}
            }


}

function elementsHiddenLeft(){
for ( i = 0; i < content_promotions.length; i++) {
	if (content_promotions[i]=="1") {
		document.getElementById([i]).style.display = "block";
	}else {
		document.getElementById([i]).style.display = "none"; 
	}
}
for ( i = 0; i < content_actual.length; i++) 
	
 {
	if (content_actual[i]=="1") {
		
		
		document.getElementById([i+m]).style.display = "block";
	}else {
		
		document.getElementById([i+m]).style.display = "none"; 
	}
}

}
function elementsHiddenRight(){
	
	for ( i = 0; i < content_actual.length; i++) 
	{
		if (content_actual[i]=="1") {		
			document.getElementById([i+m]).style.display = "block";
		}else {
			document.getElementById([i+m]).style.display = "none"; 
		}
	}
}
function hideLeft(){
	setTablesLeft();
	elementsHiddenLeft();
}
function hideRight(){
	setTablesRight();
	elementsHiddenRight();
}
function startMenu() {

layer();
var topHeight=countItemsWidth("top-navigation-item");

if(topHeight==640){
	document.getElementById("top_menu").style.width=topHeight+30+"px";
}
else if(topHeight>640){
	var diference= topHeight-640;
	document.getElementById("top_menu").style.width=topHeight+30+"px";
	document.getElementById("top_menu").style.left=document.getElementById("top_menu").offsetLeft-diference+"px";

}
else if((topHeight-1)<640){
	var diference= 640-topHeight+1;
	document.getElementById("top_menu").style.width=topHeight+30+"px";
	document.getElementById("top_menu").style.left=document.getElementById("top_menu").offsetLeft+diference+"px";
}

width=getHeightByClassName("menu_left",100);

if(width>100){
	width=(width-100)+15;
		

	document.getElementById("news_background").style.top=document.getElementById("news_background").offsetTop+width;
	document.getElementById("news").style.paddingTop=width;
	document.getElementById("footer_background").style.top=document.getElementById("footer_background").offsetTop+width;
	
	
}
}
function checkHeight(){
	
 var height=getHeightByClassName("example_content",135);

 if(height>132){
	
	height=height-132; 
	var browser=navigator.appName;
	var nAgt=navigator.userAgent;
	var majorVersion=0;
	if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
		 
		 fullVersion  = parseFloat(nAgt.substring(verOffset+5));
		 majorVersion = parseInt(''+fullVersion);
		}
	
	if(browser =="Microsoft Internet Explorer" && majorVersion =="6"){
		document.getElementById("news_background").style.height=document.getElementById("news_background").offsetHeight+height+"px";
		
		document.getElementById("footer_background").style.top=document.getElementById("footer_background").offsetTop+height+"px";
		
		document.getElementById("news").style.height=document.getElementById("news").offsetHeight+17+"px";
		
		document.getElementById("promotions").style.height=document.getElementById("promotions").offsetHeight+10+"px";
		
		document.getElementById("actual").style.height=document.getElementById("actual").offsetHeight+10+"px";
		

	}else{
	
	 document.getElementById("promotions").style.height=document.getElementById("promotions").offsetHeight+height+"px";
	 document.getElementById("actual").style.height=document.getElementById("actual").offsetHeight+height+"px";
	 document.getElementById("news_background").style.height=document.getElementById("news_background").offsetHeight+height+"px";
	 document.getElementById("footer_background").style.top=document.getElementById("footer_background").offsetTop+height+"px";
	 document.getElementById("news").style.height=document.getElementById("news").offsetHeight+height+"px";
	
	}
	
 }	
}
				

					
function ukryj (content,flaga) {
			for (  i = 0; i < content.length; i++) {
				if (content[i]=="1") {
					if(i>0){
						content[i-1]=1;
						content[i]=0;
					}
				} 
			}
			
			 
			
		  for (  i = 0; i < content.length; i++) {
				if (content[i]=="1") {
					if(flaga=="1"){
						document.getElementById([i+m]).style.display = "block";
					}
					else
					{
						document.getElementById([i]).style.display = "block";
					}
				}else
				{
					if(flaga=="1"){
						document.getElementById([i+m]).style.display = "none";
					}else{
						document.getElementById([i]).style.display = "none"; 
					}
				}
				
			}
		
}

function pokaz (content,flaga) {

		
                 
			for (  i = 0; i < content.length; i++) {
				
				if (content[i]==1) {
					if(i<content.length-1){
						content[i+1]=1;
						content[i]=0;
						break;
					}
				} 
			}
				
			 
		
		for (  i = 0; i < content.length; i++) {
			if (content[i]=="1") {
					if(flaga=="1"){
						document.getElementById([i+m]).style.display = "block";
					}
					else{
						document.getElementById([i]).style.display = "block";
					}
			}else {
					if(flaga=="1"){
						document.getElementById([i+m]).style.display = "none";
					}
					else{
						document.getElementById([i]).style.display = "none"; 
					}
			}
			
		}
		
}

function getElementsByClassName(findClass) {
	count=0;
	var a=document.body.getElementsByTagName('*');
	for(var i=0; i<a.length; i++) {
	    if(a[i].className==findClass) {
	    	count++;
	        }
	    }        
    return count;
}
function getHeightByClassName(findClass, height) {
	var a=document.body.getElementsByTagName('*');
	for(var i=0; i<a.length; i++) {
	    if(a[i].className==findClass) {
	    	width=a[i].offsetHeight;
	    	if(width>height){
	    	break;
	    	}
	        }
	    }        
    return width;
}
function countItemsWidth(findClass) {
	var a=document.body.getElementsByTagName('*');
	var width=0;
	for(var i=0; i<a.length; i++) {
	    if(a[i].className==findClass) {
	    	width+=a[i].offsetWidth-1;
	    	
	        }
	    }        
    return width;
}
function changeHeightByClassName(findClass,height) {
	var a=document.body.getElementsByTagName('*');
	alert(findClass+getElementById(findClass));
	for(var i=0; i<a.length; i++) {
		
		if(a[i].className==findClass) {
			
			
	    	a[i].style.height=height;
	    	
	    	
	    	
	        }
	    }        
    
}
function getWidth(id){
    var width = 0;

			
			var ilosc = id.substr(4);
				for(var i=1; i<=ilosc; i++){
                     var pomoc ="menu"+i;
						var x = document.getElementById(pomoc).offsetWidth;
					width=width+x;
					
				}
		
		width=width+"px";
	return width;
}
			