// Settaggio iniziale


window.onload = function()
{
	ParseAnchors()
}

function ParseAnchors()
{
	var myAnchors = document.body.getElementsByTagName("a");
	for (var i=0;i<=myAnchors.length-1;i++)
	{
		if (myAnchors[i].getAttribute("onclick")!=null)
		{
			if (window.location.href.indexOf("/fr/")>-1)
			{
				myAnchors[i].title += " ( Ouvre une nouvelle fenêtre )";
			}
			else
			{
				myAnchors[i].title += " ( Apre una nuova finestra )";
			}
		}
	}
}

function InizializeCharCount(type) {
	
	if(window.panControls != null) {	
		switch(type) {
		
			case "Pubblicazione":
				window.charTitolo.innerText = window.document.forms[0].txtTitolo.value.length;
				window.charSottotitolo.innerText = window.document.forms[0].txtSottotitolo.value.length;			
				window.charTesto.innerText = window.document.forms[0].txtTesto.value.length;
				window.charLuogo.innerText = window.document.forms[0].txtLuogo.value.length;
				break;	
				
			case "Apparto":
				window.charTitolo.innerText = window.document.forms[0].txtTitolo.value.length;
				window.charTesto.innerText = window.document.forms[0].txtTesto.value.length;
				break;	

		}
	}

}

// Conteggio caratteri
function CharCount(idControl, idLabel, maxlenght) {
	
	var textCtrl = eval("window.document.forms[0]." + idControl);
	var lbl = eval("window." + idLabel);	
		
	if(textCtrl.value.length >= maxlenght) {	
		lbl.style.color = "#ff0000";
		if(textCtrl.value.length > maxlenght) {	
			textCtrl.value = textCtrl.value.substring(0,(textCtrl.value.length - (textCtrl.value.length - maxlenght)));
		}
	} else {
		lbl.style.color = "";
	}
	// Aggiorno il contatore
	lbl.innerText = textCtrl.value.length;			
}




// ************************************************************************************
// Calendario
// ************

// Visualizza il calendario
// Type: 1 = dd/MM/yyyy
//       2 = dd/MM
//       3 = yyyy
function OpenCalendar(RootWeb)
{

	// Definisco la posizione della finestra
	var Pos_Left = ((screen.availWidth / 2) - 120);
	var Pos_Top = ((screen.availHeight / 2) - 130);
	var Percorso = RootWeb + '/it/calendario';
	// Apro la finestra popup
	window.open(Percorso,
		'popupcal', 
		'width=337,height=335,left=' + Pos_Left + ',top=' + Pos_Top);
}


// Settaggio della data
function SetDate(FormName, IDControl, newDate)
{
	/*eval('var theform = document.' + FormName + ';');
	theform.elements[IDControl].value = newDate;	*/
	document.getElementById(IDControl).value = newDate;
}
// ************************************************************************************

// Chiude la finestra
function CloseWindow() {				
	self.close();				
}

// ****************************************************************************************

function apriVtrip() {
	var urlVtrip = 'http://www.comune.aosta.it/vtrip/tour.htm';
	window.open(urlVtrip,'VirtualTour','width=775,height=740,toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}

