// JavaScript Document
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function register_ok() {
	if (document.form_register.mail_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo mail.')
	return false
	}
	var pos = 0;
	var c=0;
	var i = document.form_register.mail_user.value;
	pos = i.indexOf("@");
	if (pos  =='-1') {
	alert('ATTENZIONE !!! - Il campo indirizzo mail non e\' corretto.')
	return false
	}
	if (document.form_register.pwd1_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo password.')
	return false
	}
	var num = document.form_register.pwd1_user.value.length;
	if(num< 6) {
	alert('ATTENZIONE !!! - Il campo password deve essere di almeno 6 caratteri.')
	return false
	}
	if (document.form_register.pwd1_user.value != document.form_register.pwd1_user2.value) {
	alert('ATTENZIONE !!! - Le due password non sono uguali.')
	return false
	}
	if (document.form_register.nome_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo nickname.')
	return false
	}	
	if (document.form_register.provincia_user.value == "%") {
	alert('ATTENZIONE !!! - E necessario selezionare una provincia.')
	return false
	}
	if (document.form_register.cell_prefisso.value == "---") {
	alert('ATTENZIONE !!! - E necessario compilare il campo cellulare.')
	return false
	}
	if (document.form_register.numero_cell.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo cellulare.')
	return false
	}	
	if (document.form_register.eta_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo eta.')
	return false
	}		
	if (!document.form_register.privacy.checked) {
	alert('ATTENZIONE !!! - E necessario accettare l\'informativa sulla privacy.')
	return false
	}
}

function register_ok2() {
	if (document.form_register.mail_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo mail.')
	return false
	}
	var pos = 0;
	var c=0;
	var i = document.form_register.mail_user.value;
	pos = i.indexOf("@");
	if (pos  =='-1') {
	alert('ATTENZIONE !!! - Il campo indirizzo mail non e\' corretto.')
	return false
	}
	if (document.form_register.pwd_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo password.')
	return false
	}
	var num = document.form_register.pwd_user.value.length;
	if(num< 6) {
	alert('ATTENZIONE !!! - Il campo password deve essere di almeno 6 caratteri.')
	return false
	}
	if (document.form_register.pwd_user.value != document.form_register.pwd_user2.value) {
	alert('ATTENZIONE !!! - Le due password non sono uguali.')
	return false
	}
	if (document.form_register.nome_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo nickname.')
	return false
	}	
	if (document.form_register.provincia_user.value == "%") {
	alert('ATTENZIONE !!! - E necessario selezionare una provincia.')
	return false
	}
	if (document.form_register.eta_user.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo eta.')
	return false
	}		
}


function active_ok() {
	if (document.form_active.mail.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo e-mail.')
	return false
	}
	else if (document.form_active.codice.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo codice.')
	return false
	}
}

function pwd_ok() {
	if (document.form_active.mail.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo e-mail.')
	return false
	}
}

function addann_ok() {
	if (document.form_register.id_cat01.value == "%") {
	alert('ATTENZIONE !!! - E necessario selezionare una categoria.')
	return false
	}
	if (document.form_register.id_cat02.value == "%") {
	alert('ATTENZIONE !!! - E necessario selezionare una sottocategoria.')
	return false
	}
	if (document.form_register.titolo_annuncio.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo titolo.')
	return false
	}
	if (document.form_register.testo_annuncio.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo testo.')
	return false
	}	
	if (document.form_register.mail_annuncio.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo mail.')
	return false
	}
	var pos = 0;
	var c=0;
	var i = document.form_register.mail_annuncio.value;
	pos = i.indexOf("@");
	if (pos  =='-1') {
	alert('ATTENZIONE !!! - Il campo indirizzo mail non e\' corretto.')
	return false
	}
	if (document.form_register.prov_annuncio.value == "%") {
	alert('ATTENZIONE !!! - E necessario selezionare una provincia.')
	return false
	}
}

function video_ok() {
	if (document.video_form.video.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo nome video.')
	return false
	}		
	else if (document.video_form.file_download.value == 0) {
	alert('ATTENZIONE !!! - E necessario selezionare un video da caricare.')
	return false
	}		
}

function foto_ok() {
	if (document.foto.img1.value == 0) {
	alert('ATTENZIONE !!! - E necessario compilare il campo foto 01.')
	return false
	}		
	else if (document.video_form.file_download.value == 0) {
	alert('ATTENZIONE !!! - E necessario selezionare un video da caricare.')
	return false
	}		
}

function login_ok() {
	if (document.form_login.mail_user.value == 0) {
		alert('ATTENZIONE !!! - E necessario compilare il campo mail.')
		return false
	}
	else if (document.form_login.pwd_user.value == 0) {
		alert('ATTENZIONE !!! - E necessario compilare il campo password.')
		return false
	}
}

function confirmClose() {
    if (confirm("Sei sicuro di voler eliminare il file?")) {
       location.href="inc/function.php?action=edit_filevideo&id_video=" + document.video_form.id_video.value + "&file_video=" + document.video_form.file_video.value + "&ann=" +  document.video_form.ann.value + "&f=" + document.video_form.f.value;
    }
    else
      alert("Eliminazione annullata."); {
    }
}

var enablepersist="on"

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
selectedItem=cid+"|"+document.getElementById(cid).style.display
}
}

function revivecontent(){
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
contractcontent(selectedComponents[0])
document.getElementById(selectedComponents[0]).style.display=selectedComponents[1]
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
if (typeof selectedItem!="undefined")
document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
getElementbyClass("switchcontent")
if (enablepersist=="on" && getselectedItem()!="")
revivecontent()
}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

