var mytimeout;

function light(id)
{
	var myElement = document.getElementById(id);
	myElement.style.backgroundColor = '#FFE187';
}

function unlight(id)
{
	var myElement = document.getElementById(id);
	myElement.style.backgroundColor = 'transparent';
}

function unlight_m(id)
{
	var myElement = document.getElementById(id);
	myElement.style.backgroundColor = '#F3FBE9';
}


function validateDate(strValue) {
  var objRegExp = /^\d{2}(\-|\/|\.)\d{2}\1\d{4}$/
  var intDay;
  if(!objRegExp.test(strValue))
    return false; 
  else{
    var strSeparator = strValue.substring(2,3)
    var arrayDate = strValue.split(strSeparator);
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
	if (arrayDate[0].substr(0,1)=='0') { intDay = parseInt(arrayDate[0].substr(1,1)) } else { intDay = parseInt(arrayDate[0]); }
    if(arrayLookup[arrayDate[1]] != null) {
      if(intDay <= arrayLookup[arrayDate[1]] && intDay != 0)
        return true;
    }
    var intMonth = parseInt(arrayDate[1]);
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0)
          return true;
       }
  }
  return false;
}



var offsetfromedge=10;
var dockarray=new Array();
var dkclear=new Array();

function dockit(el, duration){ 
	if (!document.all) return; 
	this.source=document.all? document.all[el] : document.getElementById(el); 
	this.source.height=this.source.offsetHeight; 
	this.docheight=truebody().clientHeight; 
	this.duration=duration; 
	this.pagetop=0; 
	this.elementoffset=this.getOffsetY(); 
	dockarray[dockarray.length]=this; 
	var pointer=eval(dockarray.length-1); 
	var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);'; 
	dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress; 
	eval(dynexpress); 
} 

dockit.prototype.getOffsetY=function(){ 
	var totaloffset=parseInt(this.source.offsetTop); 
	var parentEl=this.source.offsetParent; 
	while (parentEl!=null){ 
	totaloffset+=parentEl.offsetTop; 
	parentEl=parentEl.offsetParent; 
} 
return totaloffset; 
} 

function dockornot(obj){ 
	obj.pagetop=truebody().scrollTop; 
	if (obj.pagetop>obj.elementoffset) {
		obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge-25;
	} 
	else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) 
	{
			obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge-25; 
	}
	else
	{
	obj.source.style.top=-25; 
	}
} 

function truebody(){ 
return (document.compatMode!="BackCompat")? document.documentElement : document.body;
} 

function showMenu() {
	clearTimeout(mytimeout)
	var obj=document.getElementById('tendina_ext');
	if (obj) obj.style.visibility = 'visible';	
	mytimeout = setTimeout(hideMenu, 1500);
}

function hideMenu() {
	var obj=document.getElementById('tendina_ext');
	if (obj) obj.style.visibility = 'hidden';	
}

function flashX() {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,22,0" id="head" width="162" height="185">' +
		        '<param name="movie" value="\/img\/banner\/banner_pine_natale.swf">' +
		        '<param name="bgcolor" value="#FFFFFF">' +
		        '<param name="quality" value="high">' +
		        '<param name="wmode" value="transparent">' +
		        '<param name="allowscriptaccess" value="samedomain">' +
		        '<embed' +
		         ' type="application\/x-shockwave-flash"' +
		         ' pluginspage="http:\/\/www.macromedia.com\/go\/getflashplayer"' +
		         ' name="\/flash\/f_head001.swf"' +
		         ' width="162" height="185"' +
		         ' src="\/img\/banner\/banner_pine_natale.swf"' +
		         ' bgcolor="#FFFFFF"' +
		         ' quality="high"' +
		         ' wmode="transparent"' +
		         ' swliveconnect="true"' +
		         ' allowscriptaccess="samedomain">' +
		         '<noembed>' +
		         '<\/noembed>' +
		        '<\/embed>' +
		      '<\/object>');
}

function flashX2() {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,22,0" id="head" width="468" height="60">' +
		        '<param name="movie" value="\/img\/banner\/banner_468x60.swf">' +
		        '<param name="bgcolor" value="#FFFFFF">' +
		        '<param name="quality" value="high">' +
		        '<param name="wmode" value="transparent">' +
		        '<param name="allowscriptaccess" value="samedomain">' +
		        '<embed' +
		         ' type="application\/x-shockwave-flash"' +
		         ' pluginspage="http:\/\/www.macromedia.com\/go\/getflashplayer"' +
		         ' name="\/flash\/f_head001.swf"' +
		         ' width="468" height="60"' +
		         ' src="\/img\/banner\/banner_468x60.swf"' +
		         ' bgcolor="#FFFFFF"' +
		         ' quality="high"' +
		         ' wmode="transparent"' +
		         ' swliveconnect="true"' +
		         ' allowscriptaccess="samedomain">' +
		         '<noembed>' +
		         '<\/noembed>' +
		        '<\/embed>' +
		      '<\/object>');
}

function openB(foto) { 
	msg=open("","Ingrandimento"," width=100,height=100,toolbar=0,menubar=0,scrollbars=0,resizable=0,top=150,left=150"); 
	d=msg.document; 
	d.write("<head><SCRIP"+"T>")
	d.write("function ridimensiona(){")
	d.write("window.resizeTo(") 
	d.write("document.im1.width+30,") 
	d.write("document.im1.height+70);")
	d.write("}</SCRIP"+"T></head>") 
	d.write("<body topmargin=0 leftmargin=0 scroll=no>") 
	d.write("<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td align=center valign=middle><img src='\/public\/eventi\/"+foto+"_big.jpg' name='im1' onLoad='javascript:ridimensiona()' onclick='javascript:window.close()'></td></tr></table>") 
	d.write("</body>"); 
	d.close(); 
	msg.focus(); 
}
