///\/\/\\/\/\\/\/\\\/\/\/\/\---- check box pagina di login ----/\/\/\/\/\/\/\/\/\\/\

function SetUserPass(obj)
{
	if(obj.checked == true)
	{
		document.getElementById('txtUsername').value = "Anonimo";
		document.getElementById('txtPassword').value = "Anonimo";
	}
	else
	{
		document.getElementById('txtUsername').value = "";
		document.getElementById('txtPassword').value = "";
		document.getElementById('txtUsername').focus();
	}
}

//\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\\/\/\/\/\/\\/\/\/\/\/\\/\/\/\/\/\/\/\
///\/\/\\/\/\\/\/\\\\---- apertura e ridimensionamento pop-up ----\\/\/\/\/\/\/\/\\/

function resize(obj) {
    var h = document.getElementById(obj).offsetHeight;
    var w = document.getElementById(obj).offsetWidth;
	
	if (h>600)h=600;
	width = w + 50;
	heigth = h + 110;
	resizeTo(width, heigth);
	
	var xp = (screen.width - width)/2;
	var yp = (screen.height - heigth)/2;
	
	this.moveTo(xp,yp);
}

function PopUp(url){
	str_param = "top=200, left=200, height=200, width=200, menubar=no, status=1, location=no, toolbar=0, scrollbars=1, resizable=0";
	window.open(url,'',str_param);
}


function ScrollerPopUp(url){
	str_param = "top=200, left=200, height=200, width=200, menubar=no, status=1, location=no, toolbar=0, scrollbars=1, resizable=0";
	window.open(url,'',str_param);
}

function PopUp800(url){
	str_param = "top=60, left=60, height=650, width=1000, menubar=no, status=1, location=no, toolbar=1, scrollbars=1, resizable=1";
	window.open(url,'',str_param);
}

function PopUp650(url){
	str_param = "top=60, left=60, height=600, width=650, menubar=no, status=1, location=no, toolbar=0, scrollbars=1, resizable=1";
	window.open(url,'',str_param);
}
//\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\\/\/\/\/\/\\/\/\/\/\/\\/\/\/\/\/\/\/\

//\/\/\\\/-------  Prende il testo selezionato da una Text-Area  --------\\/\\//\/\\\

function replaceText(txtSource, ddlDocumento) 
{
	var documento = document.getElementById(ddlDocumento);
	var article = document.getElementById('listArticoli');
	var source = document.getElementById(txtSource);
	
	if ((article.selectedIndex != null) && (article.selectedIndex != -1))
	{
		if(document.selection) 
		{ 
			//IE
			if(document.selection.createRange().text != '')
				document.selection.createRange().text = "$$" + documento.options[documento.selectedIndex].value + "_" + article.options[article.selectedIndex].value + "^^" + document.selection.createRange().text + "||";
			else
				alert("Nessun testo selezionalto!");
		}
		else 
		{ 
			//FF
			var txtArea = document.getElementById(txtSource);
			var startPos = txtArea.selectionStart;
			var endPos = txtArea.selectionEnd;

			strSelection = txtArea.value.substring(startPos, endPos);
			if(strSelection == '')
				alert("Nessun testo selezionalto!");
				
			txtArea.value = txtArea.value.substring(0, startPos) + txtReplace + txtArea.value.substring(endPos, txtArea.value.length);
		}
	}
	else
		alert("Nessun articolo selezionato");
}

//\/\/\/\/\/\/\/\/\\---------Focus--------\/\/\/\/\\/\/\\/
function setFocus(id) {
	document.getElementById(id).focus();
}

//\/\/\/\/\/\/\/\/\\---------Immagine di attesa della ricerca--------\/\/\/\/\\/\/\\/
function Attendi()
{
	if(document.getElementById('RicercaInCorso') != null)
	{
		document.getElementById('RicercaInCorso').style.display = 'inline';
		document.getElementById('RicercaEffettuata').style.display = 'none';
	}
}
