// funciones wizard productos  - javascript no intrusivo
// 2007 Raúl Fernández
if (document.getElementById) {

	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
			oldonload();
			func();
		}
	  }
	}
	
	function initWizard() {
		var back=1;
		var pasoBack= document.getElementById('pasoBack')
		if (pasoBack){
			back=pasoBack.value;
		}
		
		var campos = document.getElementsByTagName('input');
		for (var i=0; i<campos.length; i++) {
			if (eval('/volverClick/').test(campos[i].className)) {
				campos[i].onclick=function(){volver(back);}
			}
		}

		
		var filterProduct=document.getElementById('filterProduct');
		if(filterProduct){
			filterProduct.onclick=function(){volverLink(1);}
		}
		var filterBrand=document.getElementById('filterBrand');
		if(filterBrand){
			filterBrand.onclick=function(){volverLink(2);}
		}
		var filterModel=document.getElementById('filterModel');
		if(filterModel){
			filterModel.onclick=function(){volverLink(3);}
		}
		var filterLang=document.getElementById('filterLang');
		if(filterLang){
			filterLang.onclick=function(){volverLink(4);}
		}
	}
	
	function volver(paso){
		document.formWizard.paso.value=paso;
	}
	
	function volverLink(paso){
		document.formWizard.paso.value=paso;
		document.formWizard.submit();
	}
	
 
	addLoadEvent(initWizard);
}
