startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="li") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;

function columnMatch(id1, id2) 
{
  ob1 = document.getElementById(id1);
  ob1_h = ob1.offsetHeight;
  ob2 = document.getElementById(id2);
  ob2_h = ob2.offsetHeight;
	if (ob1_h > ob2_h)
	{
    ob2.style.height = ob1_h + 'px';
	}
	else if (ob2_h > ob1_h)
	{
    ob1.style.height = ob2_h + 'px';
	}
}

function changeIt(targetElement,id) {
	var x = document.getElementById(id);
	var y = x.getElementsByTagName('li');
	for(var i = 0; i < y.length; i++) {
		var z = y.item(i);
		if (z.className == 'active') {
			z.className = '';
		}
	}
	if (document.getElementById(targetElement)) document.getElementById(targetElement).className = 'active';
}

function show(linkId) {
	var theLink = document.getElementById(linkId);
	var submenu = theLink.nextSibling;
	if (submenu) submenu.style.display = 'block';
}

function hide(linkId) {
	var theLink = document.getElementById(linkId);
	var submenu = theLink.nextSibling;
	if (submenu) submenu.style.display = 'none';
}

/* GALERIE FOTO */
function stripPath(src)
{
	return src.replace(/^(((.+)\/)+)?(([\w\-_]+\.)+\w{3})$/, '$4');
}

function changePic(newSrc,newName)
{
	document.getElementById('bigPic').src=mainWebsiteURL+'custom_images/galerie/full/'+stripPath(newSrc);
	document.getElementById('bigPicName').innerHTML=newName;
}

function move_Left()
{
	var x=document.getElementById('gallery_pics');
	if (parseInt(x.style.marginLeft) < 0)
	{
		y=parseInt(document.getElementById('gallery_pics').style.marginLeft);
		x.style.marginLeft = y + 95 + 'px';
		setCookie(x.style.marginLeft); // update cookie with the position of the slider when moving to left
	}
	setDefaultPosition();
}

function move_Right()
{
	var x=document.getElementById('gallery_pics');
	var linksNumber = x.getElementsByTagName("a").length;
//	alert(linksNumber*83);
	if (Math.abs(parseInt(x.style.marginLeft)) < ((linksNumber*95)-503))
	{
		y=parseInt(document.getElementById('gallery_pics').style.marginLeft);
		x.style.marginLeft = y - 95 + 'px';
		setCookie(x.style.marginLeft); // update cookie with the position of the slider when moving to right
	}
	setDefaultPosition();
}
	
function setCookie(value) 
{ // sets the cookie named starfoods_istoric to a value
	var today = new Date();
	var expire = new Date();
	expire.setTime(today.getTime() + 3600000 * 24 * 999 ); // set expire time after 999 days (never)
	document.cookie = 'wtu_photo_gallery' + "=" + escape(value) + ";expires=" + expire.toGMTString(); // set the cookie
}
	
function getCookie() 
{ // returns the value of a cookie (starfoods_istoric in this case)
	var c_name = 'wtu_photo_gallery'; // the cookie we use to work on
	
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length+1;
			c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}
	
function setDefaultPosition() 
{ // sets the position of the slider to the position kept in the cookie
	var x = document.getElementById('gallery_pics');
	x.style.marginLeft = parseInt(getCookie()) + 'px';
}
/* END GALERIE FOTO */