function chk_form(frm){
	
	for(var i = 0; i < frm.elements.length; i++){
		
		switch(frm.elements[i].required){
			case 'TEXT':
				if(!chk_txt(frm.elements[i],frm.elements[i].msg)) return false;
			break;
			case 'DATE':
				if(!chk_date(frm.elements[i],frm.elements[i].msg)) return false;
			break;
			case 'EMAIL':
				if(!chk_email(frm.elements[i],frm.elements[i].msg)) return false;
			break;
			case 'CHECK':
				if(!chk_checkbox(frm.elements[i],frm.elements[i].msg)) return false;
			break;
			case 'RADIO':
				if(!chk_radiobutton(frm.elements[i],frm.elements[i].msg)) return false;
			break;
		}
	}
	
}

function chk_date(o,v){
	
	if(o.value.search("^[0-9]{2}/[0-9]{2}/[0-9]{4}$") == -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_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_checkbox(o,m){
	if(!o.checked){
		alert(m);
	    o.focus();
	    return false;
	}else{
	 	return true;
	}
}

function chk_radiobutton(o,m){
	//alert(o.checked)
	if(!o.checked){
		alert(m);
	    o.focus();
	    return false;
	}else{
	 	return true;
	}
}

//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 go_stop(){
	//
}
function non_selezionare(){
	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');
}

