//The pixel value of where you want the layer to start (from the top)
lstart=0
//Set this to false if you just want it to go one time
loop=true 
//Set the speed, lower value gives more speed
speed=70
//Set this to how many pixels you want it to go for each step, this also changes the speed.    
pr_step=1
//Browsercheck
	var n = (document.layers) ? 1:0;
	var ie = (document.all) ? 1:0;
//Object constructor
function makeObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
	this.scrollHeight=n?this.css.document.height:eval(obj+'.offsetHeight')
	this.up=goUp
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}
//Makes the layer slide up
function goUp(speed){
	this.scrollHeight = 360
	if( parseInt(this.css.top) >- this.scrollHeight ){
		//alert(1+' '+this.css.top+' '+this.scrollHeight);
		this.css.top=parseInt(this.css.top)-pr_step
		setTimeout(this.obj+".up("+speed+")",speed)
	}else if(loop) {
		//alert(2+' '+this.css.top+' '+this.scrollHeight);
		this.css.top=lstart
		eval(this.obj+".up("+speed+")")
	  }
}

function chk_form_contatti(tipo){
	with(document.contatti2){
		if(
			chk_txt(nome,"Inserisci il tuo nome") &&
			chk_txt(cognome,"Inserisci il tuo cognome") &&
			chk_txt(provincia,"Inserisci il tuo cognome") &&
			chk_txt(cap,"Inserisci il tuo CAP") &&
			chk_txt(localita,"Inserisci la tua localit/comune") &&
			chk_txt(via,"Inserisci la tua via") &&
			chk_txt(num,"Inserisci il tuo numero civico") &&
			chk_txt(abitazione,"Inserisci il tuo numero di casa") &&
			chk_email(email,"Inserisci un email valida") &&
			chk_aut()
		){
			/*if ((tipo==397)||(tipo==398)){
				if(!chk_box(classe,"Scegli una classe")){
					return false;
				} else {
					//alert('ahaha');
					return true;
				}
			} else */if(tipo==160){
				if(
					!chk_txt(accessori1,"Inserisci almeno un accessorio") ||
					!chk_txt(consegna,"Inserisci la data di consegna") ||
					!chk_txt(marca,"Inserisci la marca")||
					!chk_txt(modello,"Inserisci il modello")||
					!chk_txt(cilindrata,"Inserisci la cilindrata")||
					!chk_txt(meccanica,"Inserisci la meccanica")||
					!chk_txt(alimentazione,"Inserisci l'alimentazione")||
					!chk_txt(potenza,"Inserisci la potenza")||
					!chk_txt(accessori,"Inserisci gli accessori presenti")||
					!chk_txt(km,"Inserisci i chilometri") ||
					/* !chk_box(classe,"Scegli una classe") ||*/
					!chk_box(veicolo,"Scegli un tipo di veicolo")
				){
					return false
				} else {
					return true;	
				}
			} else if(tipo==400){
				if(
					!chk_txt(intervento1,"Inserisci almeno un servizio") ||
					!chk_txt(consegna,"Inserisci la data di consegna") ||
					!chk_txt(marca,"Inserisci la marca")||
					!chk_txt(modello,"Inserisci il modello")||
					!chk_txt(cilindrata,"Inserisci la cilindrata")||
					!chk_txt(meccanica,"Inserisci la meccanica")||
					!chk_txt(alimentazione,"Inserisci l'alimentazione")||
					!chk_txt(accessori,"Inserisci gli accessori presenti")||
					!chk_txt(km,"Inserisci i chilometri") 
					/*|| !chk_box(classe,"Scegli una classe")*/
				){
					return false
				} else{
					return true;	
				}			
			} else if(tipo==399){
				if(
						!chk_txt(dal,"Inserisci l'inizio del noleggio") ||
						!chk_txt(al,"Inserisci la fine del noleggio") ||
						!chk_txt(tariffa,"Inserisci la tariffa")
				){
					return false
				} else{
					return true;	
				}
			} else{
				if(
						chk_txt(messaggio,"Inserisci il messaggio")
				){
					return true;
				} else {
					return false;
				}
			}
		
		/////

		}
		return false;
	}
	
}

function chk_txt(o,v){
	if(o.value.search('[a-zA-Z0-9]') == -1){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(v);
		o.focus();
		return false;
	}
	return true;
}

function chk_email(o,d){
	if(o.value.search("^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\\.[a-zA-Z]{2,4}$") == -1){
		alert(d);
		o.focus();
		return false;
	}
	return true;
}

function chk_box(o,d){
	if(!o.checked){
		alert(d);
	    //document.registrazione.focus();
	    return false;
	}else{
	 return true;
	}
}

function chk_aut(){
	if(!document.contatti2.check_privacy.checked){
		alert("E' necessario fornire il proprio consenso");
	    //document.registrazione.focus();
	    return false;
	}else{
	 return true;
	}
}

function non_selezionare(logged){

	if(logged==1 || logged==true){
		return true;	
	}
	else{
	alert('Attenzione, il testo non  selezionabile');
	return false;
	}
	
}

function autozoom(img,i){

	w = 0;
	h = 0;
	
	window.open('autozoom.php?img='+img+'&i='+i,'zoom','width=0,height=0');
}

