var array = new Array();
var speed =35;
var timer = 5;
	var ie = '';




function whichIe() {
	var ua = navigator.userAgent.toLowerCase();
	if (ua.indexOf("msie 6.") != -1){
		ie = 'ie6';
	}
//	alert(ie);	
	return (ie);
}

// Loop through all the divs in the slider parent div //
// Calculate seach full divs height and set it to a variable //
function slider(target,showfirst) {
  var slider = document.getElementById(target);
  var divs = slider.getElementsByTagName('div');
  var divslength = divs.length;
  for(i = 0; i < divslength; i++) {
    var div = divs[i];
    var divid = div.id;
		//alert(divid);
    if(divid.indexOf("name") != -1) {
      div.onclick = new Function("processClick(this)");
    } else if(divid.indexOf("full") != -1) {
      var section = divid.replace('-full','');
      array.push(section);
			div.maxh = div.offsetHeight+12;
			div.style.display = 'none';
			//alert(divid);
 /*     div.maxh = '200';
			if(divid.indexOf("p-") != -1) {
				div.maxh = '50';
			}*/
			
    } 
  }
	for(i = 0; i < divslength; i++) {
	var div = divs[i];
	var divid = div.id;			
		if(divid.indexOf("list") != -1) {
		//	alert(div);
			div.style.display = 'none';
		}	
	}
	
}

// Process the click - expand the selected full and collapse the others //
function processClick(div) {
  var catlength = array.length;
  for(i = 0; i < catlength; i++) {
    var section = array[i];
    var head = document.getElementById(section + '-name');
    var cont = section + '-full';
    var contdiv = document.getElementById(cont);
			var piece = cont.replace('-full', '-piece');
			//alert(piece);
		clearInterval(contdiv.timer);
    if(head == div && contdiv.style.display == 'none') {
			contdiv.style.height = '0px';
      contdiv.style.display = 'block';
			if(cont.indexOf("p-") == -1) {document.getElementById(piece).style.display = 'none';}
      initSlide(cont,1);
    } else if(contdiv.style.display == 'block') {
			if(cont.indexOf("p-") == -1) {document.getElementById(piece).style.display = 'block';}	
			ie = whichIe();
			if(ie == 'ie6') document.getElementById(cont).style.display = 'none';
			initSlide(cont,-1); 
	
    }
  }
}

// Setup the variables and call the slide function //
function initSlide(id,dir) {
  var cont = document.getElementById(id);
  var maxh = cont.maxh;
  cont.direction = dir;
  cont.timer = setInterval("slide('" + id + "')", timer);
}

// Collapse or expand the div by incrementally changing the divs height and opacity //
function slide(id) {
  var cont = document.getElementById(id);
  var maxh = cont.maxh;	
  var currheight = cont.offsetHeight;
  var dist;
  if(cont.direction == 1) {
    dist = (Math.round((maxh - currheight) / speed));
  } else {
    dist = (Math.round(currheight / speed));
  }
  if(dist <= 1) {
    dist = 1;
  }
  cont.style.height = currheight + (dist * cont.direction) + 'px';
  cont.style.opacity = currheight / cont.maxh;
  cont.style.filter = 'alpha(opacity=' + (currheight * 100 / cont.maxh) + ')';
  if(currheight < 2 && cont.direction != 1) {
    cont.style.display = 'none';
    clearInterval(cont.timer);
  } else if(currheight > (maxh - 2) && cont.direction == 1) {
    clearInterval(cont.timer);
  }
}



function buble_s(name) {
	document.getElementById('ukr').style.display = 'none';
	document.getElementById('rus').style.display = 'none';
	document.getElementById('xo4u').style.display = 'none';
	var buble = document.getElementById('buble');
			buble.style.visibility = 'visible';
			document.getElementById(name).style.display = 'block';
	if (name == 'xo4u') {
	var buble2 = document.getElementById('buble2');
			buble2.style.visibility = 'visible';
}
			
			
	}
function buble_h() {
	var buble = document.getElementById('buble');
			buble.style.visibility = 'hidden';
	var buble2 = document.getElementById('buble2');
			buble2.style.visibility = 'hidden';		
			}
			
