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

function showHide(divID) 
{
	document.getElementById(divID).style.display == 'none' ? document.getElementById(divID).style.display = 'block' : document.getElementById(divID).style.display = 'none';
}

function stripPath(loc)
{
	return loc.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 activate(objectName){
	document.getElementById(objectName).className='hover';
}

function deactivate(objectName){
	document.getElementById(objectName).className='';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function reloadWindow()
{
	window.location=window.location;
	
	return;
}

function closeWindow(Id)
{
	document.getElementById(Id).style.display = "none";
}

// Checks if a field is empty, and if so, resets the input's content to the default value
function checkField( obj, value )
{
	// Match any amount of white spaces
	if( obj.value.match( " " ) || obj.value == "" )
	{
		obj.value = value;
	}
	
	return false;
}

// Clears an input's content
function clearField( obj, value )
{
	if( obj.value == value )
	{
		obj.value = "";
	}
	
	return false;
}

function show2(linkId) {
	var theLink = document.getElementById(linkId);
	var submenu = theLink.nextSibling;
	
	submenu.style.display = 'block';
}
function hide2(linkId) {
	var theLink = document.getElementById(linkId);
	var submenu = theLink.nextSibling;
	
	submenu.style.display = 'none';
}

function hide(divID) {
	document.getElementById(divID).style.display = 'none' ;
}
function show(divID) {
	document.getElementById(divID).style.display ='block' ;
}


/* GALERIE FOTO */
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 + 83 + 'px';
		setCookie(x.style.marginLeft); // update cookie with the position of the slider when moving to left
	}
}

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*83)-503))
	{
		y=parseInt(document.getElementById('gallery_pics').style.marginLeft);
		x.style.marginLeft = y - 83 + 'px';
		setCookie(x.style.marginLeft); // update cookie with the position of the slider when moving to right
	}
}
	
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 = 'anefs_galerie' + "=" + escape(value) + ";expires=" + expire.toGMTString(); // set the cookie
}
	
function getCookie() 
{ // returns the value of a cookie (starfoods_istoric in this case)
	var c_name = 'anefs_galerie'; // 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 */