//*********************************************************************
//***************	FUNZIONI DI UTILITA

//*********************************************************************
//***	openPopup
// apertura popup
openPopup.newWindow=null;
function openPopup(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if((openPopup.newWindow!=null)&&(!openPopup.newWindow.closed)){
		//alert('closing...'+openPopup.newWindow.closed);
		//openPopup.newWindow.close();
		openPopup.newWindow.focus();
		openPopup.newWindow.location=theURL;
	}else{
	 	if(window.screen)if(isCenter)if(isCenter=="true"){
	    var myLeft = (screen.width-myWidth)/2;
	    var myTop = (screen.height-myHeight)/2;
	    features+=(features!='')?',':'';
	    features+=',left='+myLeft+',top='+myTop;
	   }
	 	openPopup.newWindow=window.open(theURL,'',features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
		openPopup.newWindow.opener=window;
		//alert(features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight)
	}
}	//	end function openPoUp
//*********************************************************************

//*********************************************************************
// *** showLayer
//
function showLayer(oDiv, bShow, width, height, hCenter, vCenter, left, top){
	if(bShow){
		var l, t;
		l = (hCenter == true ? (screen.width - width) / 2 : left);
		t = (vCenter == true ? (screen.height - height) / 2 : top);
		
		if(width!=null)	oDiv.style.width = width;
		if(height!=null) oDiv.style.height = height;
		if(l!=null) oDiv.style.left = l 
		if(t!=null) oDiv.style.top = t;
		
		oDiv.style.visibility = 'visible';
	}else{
		oDiv.style.visibility = 'hidden';
	}
}// end showLayer
//*********************************************************************

//*********************************************************************
//***	checkRegular
// utilizzata per verificare il match con una regular expression
function checkRegular(regS,value){
	var re=new RegExp(regS);
	return re.test(value)
}	// end function checkRegular
//*********************************************************************


//*********************************************************************
//*** isEmail
// true - email formalmente valida
// false - email non valida
function isEmail(value){
	return checkRegular('^(.+)@(.+)\.([a-zA-Z]{2,4})$',value);
}	// end function isEmail
//*********************************************************************

//*********************************************************************
//*** isEmpty
// true - valore vuoto o di soli spazi
// false 
function isEmpty(value){
	var s = value.replace(/\s*/,'');
	return (s=='');
}	// end function isEmpty
//*********************************************************************

//*********************************************************************
//*** isInteger
// true - la stringa è un intero
// false 
function isInteger(value){
	return !(isNaN(parseInt(value, 10)));
}	// end function isInteger
//*********************************************************************

//*********************************************************************
//*** isFloat
// true - valore è un numero decimale
// false 
function isFloat(value){
	return !(isNaN(parseFloat(value, 10)));
}	// end function isFloat
//*********************************************************************

//*********************************************************************
//*** getInteger
// true - valore è un numero decimale
// false 
function getInteger(value){
	var i = parseInt(value, 10);
	if(isNaN(i))return 0;
	else return i;
}	// end function getInteger
//*********************************************************************

//*********************************************************************
//*** getFloat
// true - valore è un numero decimale
// false 
function getFloat(value){
	var f = parseFloat(value);
	if(isNaN(f))return 0.0;
	else return f;
}	// end function isFloat
//*********************************************************************

//*********************************************************************
//*** chkSelectedSelect (IN: oggetto select, riferimento per non selezionata)
// true - select selezionata
// false - select non selezionata
function chkSelectedSelect(oSlc,sRef){
	if(oSlc!=null){
		var cSel = oSlc.options[oSlc.selectedIndex].value;
		return cSel!=sRef;
	}else{
		return false;
	}
}	// end function isEmail
//*********************************************************************

function chkRadioSelected(oRdo){
	if(oRdo!=null){
		var bOk = false
		for(var i=0;i<oRdo.length;i++){
			if(oRdo[i].checked){
				bOk = true;
				break;
			}
		}
		return bOk;
	}else{
		return false;
	}
}

function isDateITA(sDta){
	var bRet = false;
	var ss = sDta.split('/');
//	alert(sDta)
	if(ss.length==3){
//		alert(ss[0]);
//		alert(ss[1]);
//		alert(ss[2]);
		var d,m,y;
		d=parseInt(ss[0], 10);
		m=parseInt(ss[1], 10);
		y=parseInt(ss[2], 10);
//		alert(d);
//		alert(m);
//		alert(y);
		if(isNaN(d)||isNaN(m)||isNaN(y)){
			bRet=false;
		}else{
			var dta = new Date(y, m-1, d);
//			alert(dta);
			bRet = ((dta.getDate()==d) && (dta.getMonth()==(m-1)) && (dta.getFullYear()==y))
//			alert(dta.getDate()==d);
//			alert(dta.getMonth()==(m-1));
//			alert(dta.getFullYear());
		}
	}
	return bRet;
}

function apriPhotogallery(gId){
	var loc =  window.location.href;
	var iActo = loc.indexOf('&acto=');
	//alert(loc);
	if (iActo>-1) {
		loc = loc.substring(0, iActo);
	}
	//alert(loc);
	loc = loc + '&acto=photo&keyG=' + gId;
	//alert(loc);
	//window.location = loc;
	return loc;	
}


