// JavaScript Document

var menuContent;

function closeMenu() {
	var m=document.getElementById('imgs-menu');
	var gals=document.getElementById('gals-menu');
	var img=document.getElementById('img-container');
	var d=document.getElementById('img-descr');
	var b=document.getElementById('img-btns');
	var bg=document.getElementById('gen-bg');
	
	m.style.width='10px';
	m.style.height='800px';
	img.style.width='890px';
	img.style.height='790px';
	bg.style.height='810px';
	gals.style.display='none';
	d.style.width='689px';
	b.style.width='890px';
	//m.style.padding='0px';
	menuContent=m.innerHTML;
	m.innerHTML='<li class="imgs-li" style="float:right; width:10px; height:62px; padding:2px;"><a href="javascript:openMenu()"><img src="images/spacer.gif" id="open-menu" title="Espandi il menu"/></a><br><a href="javascript:setBackground(\'000000\')"><img src="images/spacer.gif" style="background-color:#000000; width:10px; height:10px; margin-top:4px;"/></a><br><a href="javascript:setBackground(\'ffffff\')"><img src="images/spacer.gif" style="background-color:#ffffff; width:10px; height:10px; margin-top:4px;"/></a><br><a href="javascript:setBackground(\'5e6886\')"><img src="images/spacer.gif" style="background-color:#5e6886; width:10px; height:10px; margin-top:4px;"/></a</li>';
	setCookie('sdvmnclosed',1,2);
}
function openMenu() {
	var m=document.getElementById('imgs-menu');
	var img=document.getElementById('img-container');
	var gals=document.getElementById('gals-menu');
	var d=document.getElementById('img-descr');
	var b=document.getElementById('img-btns');
	var bg=document.getElementById('gen-bg');
	gals.style.display='block';
	img.style.width='760px';
	img.style.height='780px';
	bg.style.height='830px';
	m.style.width='140px';
	m.style.height='790px';
	d.style.width='559px';
	b.style.width='760px';
	m.innerHTML=menuContent;
	setCookie('sdvmnclosed',0,2);
}

function setBackground(color) {
	var m=document.getElementById('imgs-menu');
	var img=document.getElementById('img-container');
	var gic=document.getElementById('global-img-container');
	img.style.backgroundColor='#'+color;
	m.style.backgroundColor=img.style.backgroundColor;
	gic.style.backgroundColor=img.style.backgroundColor;
	
	var t=document.getElementById('img-title');
	var d=document.getElementById('img-descr');
	var pr=document.getElementById('btn-prev-a');
	var nx=document.getElementById('btn-next-a');
	if (color=='ffffff') {
		t.style.color='#5e6886';
		d.style.color='#5e6886';
		pr.style.color='#5e6886';
		nx.style.color='#5e6886';
	} else {
		t.style.color='#f5f5f5';
		d.style.color='#f5f5f5';
		pr.style.color='#f5f5f5';
		nx.style.color='#f5f5f5';
	}
	setCookie('sdvbg',color,2);
}

// gestione cookies
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
	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 "";
}

