// 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 = '#288fd3';
				}
			}
		}
	}
	
	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);
	}
	
	//funzioni Store Locator
	function openPopupStd( url,sNome, 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,sNome,'location=no,status=no,scrollbars='+sScroll+',resizable=no,width='+dimwidth+',height='+dimheight+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
		if (finestra1) finestra1.focus();
	}       
	
	function fireHTMLEvent(obj,eventType) 
	{ 
		if(typeof obj.fireEvent != "undefined") 
			obj.fireEvent(/^on/.test(eventType) ? eventType : "on" + eventType) 
		else 
		{ 
			var evt = document.createEvent("HTMLEvents"); 
			evt.initEvent(eventType.replace(/^on/,""),true,true) 
			obj.dispatchEvent(evt); 
		} 
	}

	
	///Tooltip text
	function toolTipText(sStore, sAddress, sAddress2, sCAP, sCitta, sStato)
	{
		var text = '<table border="0" cellspacing="0" cellpadding="2" style="background-color:#005e9c; color:#FFFFFF; border:1px solid #f3e939; text-align:left">';
		text +='<tr><td><img src="../images/googleMaps/tool.gif" /></td></tr>';
    text +='<tr><td><strong>'+sStore+'</strong></td></tr>';
    if(sAddress!='') text +='<tr><td>'+sAddress+'</td></tr>';
    if(sAddress2!='') text +='<tr><td>'+sAddress2+'</td></tr>';
    if(sCitta!='' || sCAP!='') text +='<tr><td>'+sCAP+' '+sCitta+'</td></tr>';
    if(sStato!='') text +='<tr><td>'+sStato+'</td></tr>';
    text +='</table>';
    return text;
	}
	
	function genericToolTipText(sText)
    {
      var text = '<table border="0" cellspacing="0" cellpadding="2" style="background-color:#005e9c; color:#FFFFFF; border:1px solid #f3e939">';
			text +='<tr><td><img src="../images/googleMaps/tool.gif" /></td></tr>';
			text +='<tr><td align="left">'+sText+'</td></tr></table></td></tr>';
			text +='</table>';
			return text;
    }
	
	
	function PDIToolTipText(sText)
	{
		var text = '<table width="5" class="toolTipPDI">';
		text +='<tr><td  height="35" align="center" valign="top" background="images/toolTip/pdi.gif"><table width="200" border="0" cellpadding="0" cellspacing="0">';
		text +='<tr><td align="left">'+sText+'</td></tr></table></td></tr></table>';
		return text;
	}
    
	function elementsShowHideObject(objSender, objShowHide)
	{
		var oObj = document.getElementById(objShowHide);
		if(objSender.src.indexOf("images/ico/ico_plus.gif")>0)
		{
			objSender.src ="images/ico/ico_minus.gif";
		}
		else
		{
			objSender.src ="images/ico/ico_plus.gif";
		}
		if( oObj.style.display=="none")
		{
			 oObj.style.display="";
		}
		else
		{
				oObj.style.display="none";
		}
	}