// JavaScript Document
var idProd_cat='';
var idProd='';
var idCert='';
var arr_cont=new Array(0,0,0,0,0,0,0);

function txt_loadGallery(idT,p1,p2) {
	with (document.form_front) {
		idTesto.value=idT;
	
		var parametri=formCollection(document.form_front,'','');
		
		//verifico se è un video o un'immagine
		var risultato='';
		risultato=getCode_sincrono("/testi/checkMedia.php", parametri, "","");
		//alert(risultato);
		
		if (risultato!='' && !(!risultato)) {
			//è un video
			//alert('video');
			getCode("/testi/00gallery.php", 'gallery_box', parametri, 'play_video("'+risultato+'")','','','');
		} else {
			getCode("/testi/00gallery.php", 'gallery_box', parametri, '','','','');
		}
	}
}

function setLang(mylang) {
	with (document.form_front) {
		idLang.value=mylang;
		action='/lang/00set.php'
		submit();
	}
}

function txt_nav(myPage, p1) {
	//carico lista
	var parametri=formCollection(document.form_front,'','');
	parametri+='&page='+myPage;

	//verifico se è un video o un'immagine
	var risultato=getCode_sincrono("/testi/checkMedia.php", parametri, "","");
	//alert(risultato);
	
	if (risultato!='' && !(!risultato)) {
		//è un video
		//alert('video');
		getCode("/testi/00gallery.php", 'gallery_box', parametri, 'play_video("'+risultato+'")','','','');
	} else {
		getCode("/testi/00gallery.php", 'gallery_box', parametri, '','','','');
	}

	//getCode("/testi/00gallery.php", 'gallery_box', parametri, "","","","");
}

function swapImg(idI, myImg, txt) {
	document.getElementById(idI).src=myImg;
	document.getElementById('nav_txt').innerHTML=txt;
}

function scrollDown(elem) {
	/*alert(document.getElementById("content_text").scrollHeight);
	alert(document.getElementById("content_text").scrollTop);
	alert(document.getElementById("content_text").offsetHeight);*/
	
	var pxScroll=60; //pixel di spostamento
	var mylayer=document.getElementById(elem);
	
	mylayer.scrollTop=mylayer.scrollTop+pxScroll;
}

function scrollUp(elem) {
	var pxScroll=60; //pixel di spostamento
	var mylayer=document.getElementById(elem);
	mylayer.scrollTop=mylayer.scrollTop-pxScroll;
}

function play_video(video) {
	//alert(video);
	var so = new SWFObject("/FLV_player/FLV_player_liquido.swf?auto_start=false&video="+video, "mymovie", "320", "320", "8", "");
	so.addParam("quality", "best");
	so.addParam("wmode", "transparent");
	so.addParam("salign", "t");
	so.write("gall_foto","");
}

function prod_loadMenu(cat,prod,p1) {
	if (idProd_cat!='') {
		document.getElementById('listProd_'+idProd_cat).style.display='none';
		document.getElementById('freccsub01_'+idProd_cat).className='frecciasub_off';
	}

	document.getElementById('freccsub01_'+cat).className='frecciasub_on';
	document.getElementById('listProd_'+cat).style.display='block';
	
	idProd_cat=cat;
	//idProd=prod;
}

function prod_loadContent(prod,p1) {
	if (idProd!='') {
		document.getElementById('prodotto_'+idProd).className='vocesub_off';
		document.getElementById('freccprod_'+idProd).className='frecciasub_off';
	}

	document.getElementById('prodotto_'+prod).className='vocesub_on';
	document.getElementById('freccprod_'+prod).className='frecciasub_on';
	
	with (document.form_front) {
		idProdotto.value=prod;
	
		var parametri=formCollection(document.form_front,'','');

		//verifico se è un video o un'immagine
		var risultato=getCode_sincrono("/prodotti/checkMedia.php", parametri, "","");
		//alert(risultato);
		
		if (risultato!='' && !(!risultato)) {
			//è un video
			//alert('video');
			getCode("/prodotti/00gallery.php", 'gallery_box', parametri, 'play_video("'+risultato+'")','','','');
		} else {
			getCode("/prodotti/00gallery.php", 'gallery_box', parametri, '','','','');
		}
	
		//getCode("/prodotti/00gallery.php", 'gallery_box', parametri, '','','','');
		getCode("/prodotti/00txt.php", 'txt_box', parametri, '','','','');
		
		idProd=prod;
	}
}

function prod_nav(myPage, p1) {
	//carico lista
	var parametri=formCollection(document.form_front,'','');
	parametri+='&page='+myPage;

	//verifico se è un video o un'immagine
	var risultato=getCode_sincrono("/prodotti/checkMedia.php", parametri, "","");
	//alert(risultato);
	
	if (risultato!='' && !(!risultato)) {
		//è un video
		//alert('video');
		getCode("/prodotti/00gallery.php", 'gallery_box', parametri, 'play_video("'+risultato+'")','','','');
	} else {
		getCode("/prodotti/00gallery.php", 'gallery_box', parametri, '','','','');
	}

	//getCode("/prodotti/00gallery.php", 'gallery_box', parametri, "","","","");
}


function cert_loadContent(cert,p1) {
	if (idCert!='') {
		document.getElementById('freccsub01_'+idCert).className='frecciasub_off';
	}

	document.getElementById('freccsub01_'+cert).className='frecciasub_on';/**/

	
	with (document.form_front) {
		idCertificato.value=cert;
	
		var parametri=formCollection(document.form_front,'','');

		//verifico se è un video o un'immagine
		var risultato=getCode_sincrono("/certificati/checkMedia.php", parametri, "","");
		//alert(risultato);
		
		if (risultato!='' && !(!risultato)) {
			//è un video
			//alert('video');
			getCode("/certificati/00gallery.php", 'gallery_box', parametri, 'play_video("'+risultato+'")','','','');
		} else {
			getCode("/certificati/00gallery.php", 'gallery_box', parametri, '','','','');
		}
	

		//getCode("/certificati/00gallery.php", 'gallery_box', parametri, '','','','');
		getCode("/certificati/00txt.php", 'txt_box', parametri, '','','','');
		
		idCert=cert;
	}
}

function cert_nav(myPage, p1) {
	//carico lista
	var parametri=formCollection(document.form_front,'','');
	parametri+='&page='+myPage;

	//verifico se è un video o un'immagine
	var risultato=getCode_sincrono("/certificati/checkMedia.php", parametri, "","");
	//alert(risultato);
	
	if (risultato!='' && !(!risultato)) {
		//è un video
		//alert('video');
		getCode("/certificati/00gallery.php", 'gallery_box', parametri, 'play_video("'+risultato+'")','','','');
	} else {
		getCode("/certificati/00gallery.php", 'gallery_box', parametri, '','','','');
	}
	//getCode("/certificati/00gallery.php", 'gallery_box', parametri, "","","","");
}


function checkLogin() {
	var strErr='';
	
	with (document.form_front) {
		if (username.value=='' || psw.value=='') strErr+=err_insert;
		
		if (strErr!='') {
			alert(strErr);
		} else {
			//controllo account
			parametri=formCollection(document.form_front,'','');
			
			var risultato=getCode_sincrono("/areariservata/checkLogin.php", parametri, "","");
			
			//alert(risultato);
			if (risultato=="OK") {
				action='/areariservata/download.php';
				submit();
			} else if (risultato=="KO") {
				alert(err_notfound);
			} else {
				alert(err_general);
			}

		}
	}
}

function conct_loadTxt() {
	with (document.form_front) {
		nome.value=form_nome;
		cognome.value=form_cognome;
		azienda.value=form_azienda;
		email.value=form_email;
		tel.value=form_tel;
		oggetto.value=form_oggetto;
		messaggio.value=form_msg;
	}
}

function cont_activefield(cosa) {
	//alert(''+cosa);
	with (document.form_front) {
		switch (cosa) {
			case 0:
				if (nome.value==form_nome) nome.value='';
			break;
			case 1:
				if (cognome.value==form_cognome) cognome.value='';
			break;
			case 2:
				if (azienda.value==form_azienda) azienda.value='';
			break;
			case 3:
				if (email.value==form_email) email.value='';
			break;
			case 4:
				if (tel.value==form_tel) tel.value='';
			break;
			case 5:
				if (oggetto.value==form_oggetto) oggetto.value='';
			break;
			case 6:
				if (messaggio.value==form_msg) messaggio.value='';
			break;
		}
	}
}

function cont_disactivefield(cosa) {
	//alert(''+cosa);
	with (document.form_front) {
		switch (cosa) {
			case 0:
				if (nome.value=='') nome.value=form_nome;
			break;
			case 1:
				if (cognome.value=='') cognome.value=form_cognome;
			break;
			case 2:
				if (azienda.value=='') azienda.value=form_azienda;
			break;
			case 3:
				if (email.value=='') email.value=form_email;
			break;
			case 4:
				if (tel.value=='') tel.value=form_tel;
			break;
			case 5:
				if (oggetto.value=='') oggetto.value=form_oggetto;
			break;
			case 6:
				if (messaggio.value=='') messaggio.value=form_msg;
			break;
		}
	}
}

function contactSend() {
	var strErr='';
	with (document.form_front) {
		if (nome.value==form_nome || nome.value=='') strErr+=form_err_nome+'\n';
		if (cognome.value==form_cognome || cognome.value=='') strErr+=form_err_cognome+'\n';
		if (azienda.value==form_azienda || azienda.value=='') strErr+=form_err_azienda+'\n';
		if (email.value==form_email || email.value=='') strErr+=form_err_email+'\n';
		if (tel.value==form_tel || tel.value=='') strErr+=form_err_tel+'\n';
		if (oggetto.value==form_oggetto || oggetto.value=='') strErr+=form_err_oggetto+'\n';
		if (messaggio.value==form_msg || messaggio.value=='') strErr+=form_err_msg+'\n';
		
		if (strErr!='') {
			alert(strErr);
		} else {
			var parametri=formCollection(document.form_front,'','');
			getCode("/contatti/send.php", 'txt_box04', parametri, '','','','');
		}
	}
}

function zoom(cosa,p1) {
	elem=document.getElementById('txt_txt');
	if (elem.style.fontSize=='') elem.style.fontSize='10px';
	
	
	if (cosa=='+1') {
		if (parseInt(elem.style.fontSize)<16) elem.style.fontSize=(parseInt(elem.style.fontSize)+1)+'px';
	} else if (cosa=='-1') {
		if (parseInt(elem.style.fontSize)>10) elem.style.fontSize=(parseInt(elem.style.fontSize)-1)+'px';
	}
	
}

