// JavaScript Document
	
	function jsNews(id, idPlus, fileType, action){
		if(confirm("Sei sicuro di voler eliminare?")){
		window.location = 'adminNewsEXEC.asp?sOp='+action+'&id='+id+'&fileType='+fileType+'&idPlus='+idPlus;
		}
	}
	function jsNewsFiles(id, idPlus, action){
		if(confirm("Sei sicuro di voler eliminare?")){
		window.location = 'adminNewsFileEXEC.asp?sOp='+action+'&id='+id+'&idPlus='+idPlus;
		}
	}
	
	/**********************************************************************
	   Evidenziazione Links nelle pagine
	***********************************************************************/
	function HighlightVisitedLink(){
		var obj = document.getElementsByTagName('a');
		if (document.links || obj){
			for (var i=0; i < obj.length ;i++) {
				if (parseInt(jsInstr(obj[i].href, getCurrentLocation() )) > 0) {
					obj[i].style.color = '#FF0000';
				}
			}
		}
	}
	
	function getCurrentLocation(sStrLocation){
		var currentLocation, nStart, nEnd
		currentLocation = document.location.toString();
		nStart = currentLocation.lastIndexOf("\/")
		currentLocation = Mid(currentLocation, nStart, 1000);
		nEnd = jsInstr(currentLocation, '.' )+1;
		return Mid(currentLocation, 0, nEnd);
	}

	function jsInstr(strSearch, charSearchFor){
		var s = strSearch.indexOf(charSearchFor);
		return(s);
	}

	function Mid(str, start, len){
			if (start < 0 || len < 0) return "";
			var iEnd, iLen = String(str).length;
			if (start + len > iLen)
					iEnd = iLen;
			else
					iEnd = start + len;

			return String(str).substring(start,iEnd);
	}
	/**********************************************************************
	   END Evidenziazione Links nelle pagine
	***********************************************************************/

	function isDateString(dateStr) {
		var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
		var matchArray = dateStr.match(datePat); // is the format ok?
		var TipoDiErrore = '';
		if (matchArray == null) {
			return false;
		}
	   day = matchArray[1]; // parse date into variables
	   month = matchArray[3]; 
	   year = matchArray[5];
		if (month < 1 || month > 12) { // check month range
			return false;
		}
		if (day < 1 || day > 31) {
			return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			return false;
		}
		if (month == 2) { // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day > 29 || (day==29 && !isleap)) {
				return false;
			}
		}
		return true; // date is valid
	}
	
	/**********************************************************************
	   Controllo se campo passato è un anno valido compreso fra 1900 e oggi
	***********************************************************************/
	function isYear (s) {
			var d;
			d = new Date();
			var yyyy = d.getFullYear()
			if ((notNull(s)) && (notBlank(s)) && (isSize(s, 4)) && (!isNaN(s)) && (isInRange(s, 1900, yyyy)) ) { 
				return true; 
			} else { 
				return false;
			}
	}
	
	function Trim(stringa) {
	   reTrim=/\s+$|^\s+/g;
	   return stringa.replace(reTrim,"");
	}
	
	function confirmLink( sMessage, sUrl ) {
		//alert( sMessage+'\n'+sUrl );
		if (confirm(sMessage)) window.navigate(sUrl);
	}

	function ShowHideElement( sObjectId ) {
		var oObj = document.getElementById(sObjectId);
		if (oObj.style.display=='') { oObj.style.display='none' }
		else { oObj.style.display='' }
	}
	
	function todayDate(){
	   var d, s = "";          
	   d = new Date();
	   var giorno, mese, anno;
	   giorno = d.getDate();
	   if (giorno.toString().length <= 1) {
		giorno = '0' + giorno;
	   }  
	   mese = d.getMonth() + 1;
	   if (mese.toString().length <= 1) {
		mese = '0' + mese;
	   }  
	   anno = d.getYear();
	   
	   s += giorno + "/";                   
	   s += mese + "/";            
	   s += anno;                         
	   return(s);                               
	}
	
	function calendarOnClick(obj){
		if (notBlank(obj.value)) {
			if (!isDateString(obj.value)) {
				obj.value = todayDate();
			}
		}
	}
	
	// sostituisce , con .
	function replaceComma( obj ){
	   var r, re;                    
	   var ss = obj.value;
	   re = new RegExp(",");
	   obj.value = ss.replace(re, ".");    
	   return(obj.value);                   
	}

	function moveCheckedValues(obj1, obj2){
		obj2.value = '';
		if (obj1.length != undefined) {
			for (var i=0; i < obj1.length ;i++) {
				if (obj1(i).checked) obj2.value += obj1(i).value + ",";
			}
		} else {
			if (obj1.checked) obj2.value += obj1.value + ",";
		}
	}
	function openPopupStd( url, dimx, dimy, sScroll) {
		dimwidth = dimx;
		dimheight = dimy;
		x = (800 - dimwidth)/2, y = (600 - dimheight)/2;
		if (screen) {
			x = (screen.availWidth - dimwidth)/2;
			y = (screen.availHeight - dimheight)/2;
		}
		finestra1 = window.open(url,'','location=no,status=no,scrollbars='+sScroll+',resizable=no,width='+dimwidth+',height='+dimheight+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
		finestra1.focus();
	}
	
	
	String.prototype.Replace = function(s1, s2){
		return this.split(s1).join(s2);
	}
	
	function replaceHtmlSpecialChars(str) {
		var sHtml = str;
		return sHtml.Replace("’","'").Replace("“","\"").Replace("”","\"").Replace("–", "-").Replace("€", "&euro;").Replace("&", "&amp;");
	}
    
	function txtValida(oForm, oObj){
	  if (oForm.bEnabled.checked == true){
		document.getElementById(oObj).innerText = "SI";
	  }else{
		document.getElementById(oObj).innerText = "NO";
	  }
    }

	function textCounter(field, countfield, maxlimit) {
		if (field.value.length > maxlimit) { // if too long...trim it!
			field.value = field.value.substring(0, maxlimit);
			// otherwise, update 'characters left' counter
		} else { 
			countfield.value = maxlimit - field.value.length;
		}
	}

	function maximizeWindow(){
		window.moveTo(0,0);
		window.resizeTo(screen.width,screen.height);
	}