﻿// Versione File v2.2.0.001 - 29.09.2008
// ---===> Funzioni di interazione con Flex | Inizio <===---//
function modificaValore(objParametri){
	objCampo = eval("document.forms.frmDettagli." + objParametri.nomeCampo);
	objCampo.value = objParametri.testoCampo;
}

function prendiValore(parStrNomeCampo){
	objCampo = eval("document.forms.frmDettagli." + parStrNomeCampo);
	return objCampo.value;
}

function prendiFormattazione(parStrNomeCampo){
	objCampo = eval("document.forms.frmDettagli.ediFormattazione" + parStrNomeCampo);
	return objCampo.value;
}

function newWin(windowUrl, width, height){
	if(width == null){
		width = 800;
	}

	if(height == null){
		height = 600;
	}

	window.open(windowUrl, '', 'toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=auto,width=' + width + ',height=' + height);
}

function nuovaFinestra(parStrIndirizzo, parIntLarg, parIntAlt){
	window.open(parStrIndirizzo, '', 'toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=auto,width=' + parIntLarg + ',height=' + parIntAlt);
}
// ---===> Funzioni di interazione con Flex | Fine <===---//

function countChars(parOggetto, parSpanContantore, parMax){
	var intCaratteriRimanenti = parMax
	intCaratteriRimanenti -= parOggetto.value.length
	document.getElementById(parSpanContantore).innerHTML = intCaratteriRimanenti.toString();
	if(intCaratteriRimanenti < 0){
		parOggetto.value = parOggetto.value.substr(0, parMax);
		alert("Attenzione!\rHai superato il limite massimo di caratteri disponibile.\rSono stati rimossi " + Math.abs(intCaratteriRimanenti) + " caratteri in eccesso.")
	}
	if(parOggetto.value.length > 0){
		parOggetto.form._Invio.disabled = ""
	}
	else{
		parOggetto.form._Invio.disabled = "disabled"
	}
}
// Versione File v2.2.42.001 - 08.12.2008
// ---===> Funzioni di Formattazione | Inizio <===---//
//var formattatore = this;
function Formattatore(taDaFormattare){
    this.campo = document.getElementById(taDaFormattare);
	this.testo = this.campo.value;
	this.G = "grassetto";
	this.S = "sottolineato";
	this.C = "corsivo";
	this.Q = "citazione";
}

Formattatore.prototype.formatta = function(codFormato) {
	this.testo = this.campo.value;
	eval("this." + codFormato + "()")

	if(this.campo.selectionStart){
		this._ffSel();

	var strTestoFormattato = this.testo.substr(0, this.selStart);

	strTestoFormattato += this.codStart;
	strTestoFormattato += this.testo.substr(this.selStart, this.selStop - this.selStart);
	strTestoFormattato += this.codStop;
	strTestoFormattato += this.testo.substr(this.selStop);
	
	this.testo = strTestoFormattato
	this.campo.value = this.testo;
	this.campo.focus();
	this._impostaSelStart(this.selStart + this.codStart.length);
	this._impostaSelStop(this.selStop + this.codStart.length);
//	alert(strTestoFormattato);
	}
	else{
		this._ieSel()
	}

}

Formattatore.prototype.grassetto = function(){
	this.codStart = "[b]";
	this.codStop = "[/b]";
}

Formattatore.prototype.sottolineato = function(){
	this.codStart = "[u]";
	this.codStop = "[/u]";
}

Formattatore.prototype.corsivo = function(){
	this.codStart = "[i]";
	this.codStop = "[/i]";
}

Formattatore.prototype.citazione = function(){
	this.codStart = "[quote]";
	this.codStop = "[/quote]";
}

Formattatore.prototype._ffSel = function() {
	this.selStart = this.campo.selectionStart;
	this.selStop = this.campo.selectionEnd;

	return{ 
        start: this.selStart, 
        stop: this.selStop 
    };
}

Formattatore.prototype._ieSel = function(){
    this.campo.focus();

    var range = document.selection.createRange();
	range.text = this.codStart + range.text + this.codStop;
	//alert(document.selection.createRange().duplicate());
//	range.move("textedit", 2);
/*	this.selStart = range;
	this.selStop = this.campo.selectionEnd;

	return{ 
        start: this.selStart, 
        stop: this.selStop 
    };
	*/
}

Formattatore.prototype._impostaSelStart = function(posizione) {
	this.selStart = posizione;
	this.campo.selectionStart = this.selStart;
}

Formattatore.prototype._impostaSelStop = function(posizione) {
	this.selStop = posizione;
	this.campo.selectionEnd = this.selStop;
}
// ---===> Funzioni di Formattazione | Fine <===---//

function winUpload(parNomeColonna, parPathUpload, parTipoFile, parModulo, parValore){
	window.open("index.aspx?pciOp=upload&pciCampo=pqt" + parNomeColonna + "&pftPath=" + parPathUpload + "&pciTipoFile=" + parTipoFile + "&pciModulo=" + parModulo + "&pftVecchioFile=" + parValore,"","toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=auto,width=600,height=250");
}

function espandiFigli(parRigaAssoluta){

	if (document.all) {
		objFrame = document.getElementById("frameFigliRiga" + parRigaAssoluta)
		objEtichetta = document.getElementById("etiRigaFigli" + parRigaAssoluta)
		if(objFrame.style.pixelHeight > 0){
			objFrame.style.height = 0;
			objEtichetta.innerHTML = '<a href="javascript:espandiFigli(' + parRigaAssoluta + ')"">+</a>';
			objFrame.src = "";
		}
		else{
			objFrame.src = "/nous2/moduli/modulo_figli.aspx?pciModulo=art&pflIdCanale=0." + parRigaAssoluta + "&pfpIdCanale=2";
			objFrame.style.height = 10;
		//	alert(objFrame.document.body.scrollHeight);
		//	objFrame.style.height = objFrame.document.body.scrollHeight;
			objEtichetta.innerHTML = '<a href="javascript:espandiFigli(' + parRigaAssoluta + ')"">-</a>';
		}
	} 
}

function dimensionaPagina(parFrame){
	var objFinestra = parFrame
	var objPadre = objFinestra.parent
	
	if(objPadre.document.getElementById(objFinestra.name).style.pixelHeight == 0){
//				alert("Maggiore: " + objFinestra.name);
			objFinestra = objFinestra.parent;
			objPadre = objFinestra.parent;
		while(objFinestra != top){
			if(objPadre != parFrame){
//				alert(objPadre.name);
				objPadre.document.getElementById(objFinestra.name).style.height = objFinestra.document.body.scrollHeight
			}
			objFinestra = objFinestra.parent;
			objPadre = objFinestra.parent;
		}
	}
	else{
		while(objFinestra != top){
			if(objPadre != parFrame){
//				alert(objPadre.name);
				objPadre.document.getElementById(objFinestra.name).style.height = objFinestra.document.body.scrollHeight
			}
			objFinestra = objFinestra.parent;
			objPadre = objFinestra.parent;
		}
	}
}

function overBox(parTesto, parOp, parOggetto)
{
	var strVisibile
	var objLivelloOverBox

	objLivelloOverBox = document.all.tags('div')['overBox'].style
	if(parOp == 1){
		strVisibile = "visible"
		objLivelloOverBox.left = event.screenX
		objLivelloOverBox.top = event.screenY// - (screen.height - screen.availHeight)

		//alert(document.all.tags('div')[parOggetto.toString()].style.screenX)
		//alert(document.getElementById(parOggetto).style.top)
	//	alert(event.screenY - (screen.height - screen.availHeight))
	}
	else{
		strVisibile = "hidden"
	}

	objLivelloOverBox.visibility = strVisibile;
}

js_ns = (navigator.appName=="Netscape");
js_ie = (navigator.appName == "Microsoft Internet Explorer");
js_ver = parseInt(navigator.appVersion);
js_ie4 = navigator.userAgent.indexOf('MSIE 4') > 0;
js_ie5 = navigator.userAgent.indexOf('MSIE 5') > 0;
js_ns4 = (js_ns&&parseInt(navigator.appVersion)==4);
js_ns5 = (js_ns&&parseInt(navigator.appVersion)==5);
js_v5 = (js_ie5||js_ns5);

var IE = document.all?true:false
var js_timerid = '';

function js_p0()
{
	var i,args=js_p0.arguments;

	//	parametro mode:
	//		0x0
	//		0x1	buy
	//		0x2	void
	//		0x4	big
	//		0x8	know
	//
	i = 0;
	t = args[i++];
	mode = args[i++];
	img = args[i++];
	if(img.charAt(0) != "/"){
		img = "/" + img
	}
	d = '<div id="listpopup"><div class="img"><img src="';
	d += img;
	d += '" class="nmt"></div><div class="txt">';
	for (; i<args.length; i+=2)
	{
		k = args[i];
		v = args[i+1];
		if ( k == "Titolo" || k == "Title" )
			d += '<div class=titolo>'+v+'</div>';
		else if ( k == "Prezzo" || k == "Price" )
			d += '<div class=prezzo>'+k+': '+v+'</div>';
		else if ( k == "Attori" || k == "Actors" || k == "Regista" || k == "Director" || k == "Autore" || k == "By" || k == "Editore" || k == "Publisher" )
			d += '<div class=act>'+k+': '+v+'</div>';
		else if ( k != "" )
			d += '<div class=pubblico>'+k+': <B>'+v+'</B></div>';
		else
			d += v+'';
	}
	d += '</div></div>';

	if (IE) { // grab the x-y pos.s if browser is IE
		x = event.clientX + document.body.scrollLeft;
		y = event.clientY + document.body.scrollTop;
	} else {  // grab the x-y pos.s if browser is NS
		//x = t.offsetLeft;
		//y = t.offsetTop;
		//alert("NS")
		x = getX(t)
		y = getY(t);
	} 

	js_scheda(mode,x,y,img,d)
	return 1;
}

function js_ss(msg)
{
        window.status=msg;
        if ( navigator.userAgent.indexOf("Mozilla/2.0") == -1 )
        {
                if ( js_timerid != '' )
                        clearTimeout(js_timerid);
                if ( document.links[0].onmouseout == null )
                        js_timerid = setTimeout("js_cs()",3000);
        }
        return true;
}

function js_scheda(mode,x,y,img,d)
{
	w = 100;
	h = 10;	/* estimated */
	if ( x > w+20 )
		x -= w;
	if ( js_ie )
		{ dim = document.body.clientHeight; scr = document.body.scrollTop; }
	else
		{ dim = window.innerHeight; scr = window.pageYOffset; }
	if (js_ns4) {
		if ( scheda )
			scheda.document.close();//un pomeriggio per questa riga!!
		scheda=new Layer(w);
		scheda.width=w;
		//scheda.height=h;
		if ( y+h-scr > dim )
		{
			y -= h;
		}
		scheda.top=y;
		scheda.left=x;
		scheda.clip.width=w;
		//scheda.clip.height=h;
		//scheda.bgColor="red";
		//scheda.document.clear();
		scheda.document.write(d);
		scheda.visibility="show";
	} else if (js_ie4) {
		;
	} else if (document.createElement && document.body.style) {
		scheda = document.getElementById("scheda");
		ftime = 0;
		if ( !scheda )
		{
			//scheda.removeNode(true);
			//scheda = null;
			scheda=document.createElement("DIV");
			scheda.id = 'scheda';
			ftime = 1;
		}
		scheda.style.position="absolute";
		scheda.style.width=w+"px";
		scheda.innerHTML=d;
		scheda.style.left=x+"px";
		scheda.style.top=y+"px";
		if ( ftime )
			document.body.appendChild(scheda);
		scheda.style.display = '';
		if ( js_ns5 )
		{
			if ( y+scheda.offsetHeight-scr > dim )
			{
				y -= scheda.offsetHeight;
				scheda.style.top=y+"px";
			}
		} else {
			if ( y+scheda.clientHeight-scr > dim )
			{
				y -= scheda.clientHeight;
				scheda.style.top=y+"px";
			}
		}
	}
}

function js_close_scheda()
{
	if (js_ns4) {
		if ( scheda )
			scheda.visibility = "hidden";
	} else if (!js_ie4 && document.createElement && document.body.style) {
		t = document.getElementById("scheda");
		if ( t )
			t.style.display = 'none';
	}
}

function getX(obj) {
	if (obj.x) return obj.x
		if (obj.offsetLeft || obj.offsetParent) {
			var x = obj.offsetLeft
			while (obj = obj.offsetParent) x += obj.offsetLeft
				return x
		}
	return 0
}

function getY(obj) {
	if (obj.y) return obj.y
		if (obj.offsetTop || obj.offsetParent) {
			var y = obj.offsetTop
			while (obj = obj.offsetParent) y += obj.offsetTop
				return y
		}
	return 0
}

// Pezzi per Nous2

function impostaFocus(){
	if(document.forms[0]){
		eval("document.forms[0]." + document.forms[0].pnnCampoAttivo.value + ".focus()");
	}
}

function alternaValore(parIdOggetto, parAttributo, parValore, parAlternativo){
	parOggetto = document.getElementById(parIdOggetto)
	if(eval("parOggetto.style." + parAttributo) == parValore || eval("parOggetto.style." + parAttributo) == ""){
		eval("parOggetto.style." + parAttributo + " = '" + parAlternativo + "'");
	}
	else{
		eval("parOggetto.style." + parAttributo + " = '" + parValore + "'");
	}
}

function alternaValorePro(parOggetto, parAttributo, parValore, parAlternativo){
	if(eval("parOggetto." + parAttributo) == parValore || eval("parOggetto." + parAttributo) == ""){
		eval("parOggetto." + parAttributo + " = '" + parAlternativo + "'");
	}
	else{
		eval("parOggetto." + parAttributo + " = '" + parValore + "'");
	}
}

function impostaValore(parIdOggetto, parAttributo, parValore){
	parOggetto = document.getElementById(parIdOggetto)
	eval("parOggetto.style." + parAttributo + " = '" + parValore + "'");
}

function alternaSrc(parIdOggetto, parAttributo, parValore, parAlternativo){
	parOggetto = document.getElementById(parIdOggetto)
	if(eval("parOggetto." + parAttributo + ".indexOf('" + parValore + "')") > 0 || eval("parOggetto." + parAttributo) == ""){
		eval("parOggetto." + parAttributo + " = '" + parAlternativo + "'");
	}
	else{
		eval("parOggetto." + parAttributo + " = '" + parValore + "'");
	}
}

