/* layers script */
function MM_findObj(n, d) {
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { 
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}
/* layers script */

function MM_openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
}

/* preload images */
function simplePreload(){
  	 var args = simplePreload.arguments;
  	 document.imageArray = new Array(args.length);
  	 for(var i=0; i<args.length; i++)
  	 {
    	 document.imageArray[i] = new Image;
    	 document.imageArray[i].src = args[i];
  	 }
}
/* preload images */

/* menù script */
var bV=parseInt(navigator.appVersion);
NS4=(document.layers)?true:false;
IE4=(document.all)?true:false;
ver4=(NS4 || IE4)?true:false;

function expandIt(){return}
function expandAll(){return}


isExpanded=false;
function reDo(){window.location.reload()}

function getIndex(el) {
	ind=null;
	for (i=0; i<document.layers.length; i++) {
		whichEl=document.layers[i];
		if (whichEl.id==el) {
			ind=i;
			break;
		}
	}
	return ind;
}

function arrange() {
	nextY=document.layers[firstInd].pageY + document.layers[firstInd].document.height-10;
	for (i=firstInd+1; i<document.layers.length; i++) {
		whichEl=document.layers[i];
		if (whichEl.visibility != "hide") {
			whichEl.pageY=nextY;
			nextY += whichEl.document.height-10;
		}
	}
}

function initIt(){
	if (NS4) {scrollTo(0,pageYOffset-30)
		for (i=0; i<document.layers.length; i++) {
		whichEl=document.layers[i];
			if (whichEl.id.indexOf("Child") != -1) {
				whichEl.visibility="hide";
				whichEl.isExpanded=false;
			}
		}
	arrange();
	setTimeout("window.onresize=reDo",1000)
	} else {
		tempColl=document.all.tags("DIV");
		for (i=0; i<tempColl.length; i++) {
			if (tempColl(i).className == "child") {
				tempColl(i).style.display="none";
				tempColl(i).isExpanded=false;
			}
		}
	}
}

function expandIt(el) {
	if (!ver4) return;
	if (IE4) {expandIE(el)} else {expandNS(el)}
}

function expandIE(el) { 
	whichEl=eval(el + "Child");
	whichIm=event.srcElement;
	if (whichEl.style.display == "none") {
		whichEl.style.display="block";
		whichEl.isExpanded=true;
	}
	else {
		whichEl.style.display="none";
		whichEl.isExpanded=false;
	}
}

function expandNS(el) {
	whichEl=eval("document." + el + "Child");
	if (whichEl.visibility == "hide") {
		whichEl.visibility="show";
		whichEl.isExpanded=true;
	}
	else {
		whichEl.visibility="hide";
		whichEl.isExpanded=false;
	}
	arrange();
}

function showAll() {
	for (i=firstInd; i<document.layers.length; i++) {
		whichEl=document.layers[i];
		whichEl.visibility="show";
	}
}

function expandAll(isBot) {
	if (NS4) {
		for (i=firstInd; i<document.layers.length; i++) {
		whichEl=document.layers[i];
			if (whichEl.id.indexOf("Child") != -1) {
				whichEl.visibility=(isExpanded)?"hide":"show";
				whichEl.isExpanded=(isExpanded)?false:true;
			}
		}
		arrange();
		if (isBot && isExpanded) scrollTo(0,document.layers[firstInd].pageY);
	} else {
		divColl=document.all.tags("DIV");
		for (i=0; i<divColl.length; i++) {
			if (divColl(i).className == "child") {
				divColl(i).style.display=(isExpanded)?"none":"block";
				divColl(i).isExpanded=(isExpanded)?false:true;
			}
		}
	}
	isExpanded=!isExpanded;
}

if (NS4) {
	firstEl="elOneParent";
	firstInd=getIndex(firstEl);
	document.layers[firstInd].pageY-=10;
	showAll();
	arrange();
}

window.onload=initIt;
/* menù script */

/* clock script */ 
var timerID = null 
var timerRunning = false 

function stopclock(){ 
    if(timerRunning) 
        clearTimeout(timerID) 
    timerRunning = false 
} 

function startclock(){ 
    stopclock() 
    showtime() 
} 

function showtime(){ 
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var timeValue = "" + hours;
    timeValue  += ((minutes < 10) ? ":0" : ":") + minutes;
    timeValue  += ((seconds < 10) ? ":0" : ":") + seconds;
    document.clock.face.value = timeValue;
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;
} 
/* clock script */ 

/* function delete rows */
function delete_row(menu, page, id) {
	if ( confirm("Sei sicuro di voler continuare?") ){
		location.href = "index.php?menu="+menu+"&page="+page+"&action=5&id="+id;
	}
}

function delete2_row(menu, page, id, lang, action, type) {
	if ( confirm("Sei sicuro di voler continuare?") ){
		location.href = "index.php?menu="+menu+"&page="+page+"&id="+id+"&lang="+lang+"&action="+action+"&type="+type;
	}
}

/* function active rows */
function active_row(menu, page, action, id, active) {
	location.href = "index.php?menu="+menu+"&page="+page+"&action="+action+"&id="+id+"&active="+active;
}

function active_row2(menu, page, action, id, active, type ) {
	location.href = "index.php?menu="+menu+"&page="+page+"&action="+action+"&id="+id+"&active="+active+"&type="+type;
}


/* function check forms data */
function check_all() {
	if ( check_field() ) {
		document.MyForm.submit();
	}
}
/* function check forms data */

/* function open pop-up */
function openWindow(mypage,myname,w,h,resizable){ 
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0; 
	settings = 'resizable='+resizable+',height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;
	win = window.open(mypage,myname,settings) 
	if(win.window.focus){
		win.window.focus();
	} 
}
/* function open pop-up */

/* function open editor */
function openEditor(mode,form,field){ 
	openWindow('../editor/index.php?mode='+mode+'&form='+form+'&field='+field+'','editor','790','571','yes');
}
/* function open editor */

/* function open file manager */
function openFile(folder,field,mode,changeImg,type){ 
	openWindow('../upload/fileLoad.php?pathFolder='+folder+'&field='+field+'&mode='+mode+'&changeImg='+changeImg+'&type='+type+'','file','790','571','yes');
}
/* function open file manager */

/* function correct date */
function areCharsInList(s,list) {
	var i,c;
	for (i=0;i<s.length; i++) {
		c = s.charAt(i);
	if (list.indexOf(c) == -1)
		return false;
	}
return true;
}

function isDate(str){
	if(str.length!=10){
		return false;
	}
	if(str.charAt(2)!='/' || str.charAt(5)!='/'){
		return false;
	}
	if( !areCharsInList(str.substring(0,2)+str.substring(3,5)+str.substring(6,10), '1234567890') ){
		return false;
	}
	if(str.substring(3,5)>12){
		return false;
	}
	if(str.substring(0,2)>31){
		return false;
	}
return true;
}
/* function correct date */