// JavaScript Document
<!--



function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function mailto(ad,domini)
{
   mailurl = "mailto:" + ad + "@" + domini;
   window.location = mailurl;
}

function producteveure(opcio,foto){
	if (opcio!=document.getElementById('HTipo').value){		
		Effect.BlindUp(document.getElementById('HTipo').value);
		var el = document.getElementById('Menu'+document.getElementById('HTipo').value); 
		imagen1=new Image
		imagen1.src=el.src.split("_on").join("");
		el.src=imagen1.src;
		var el2 = document.getElementById('Menu'+opcio);
		imagen2=new Image
		imagen2.src="img/"+foto+"_on.jpg";
		el2.src=imagen2.src;
		document.getElementById('HTipo').value=opcio;
		Effect.BlindDown(opcio);
	}	
}


function contacteveure(){
	if (document.getElementById('Hvisible').value=='N'){
		Effect.BlindDown('Vsector');
		document.getElementById('Hvisible').value='S';
	}else{
		Effect.BlindUp('Vsector');
		document.getElementById('Hvisible').value='N';
	}
}

function comprovarregistre(){
	
	if ((document.getElementById('Email').value =="") || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('Email').value))){
		xajax_error('raemail');
		//alert('Email Incorrecta repasa les dades');
		document.getElementById('email').focus();
      	return (false);
	}	
	//alert('Correcte');
	return false;

}

function solsector(nom,id){
	
document.getElementById('divsector').innerHTML =nom+' <input type="button" value="+" onclick="Effect.BlindDown(\'divmostrarsector\');Effect.Squish(\'divsector\');Effect.Squish(\'divproblema\');Effect.Squish(\'divmostrarproblema\');\" />';
Effect.Squish('divmostrarsector');
Effect.Appear('divsector');	
xajax_assignarproblema(id);
//document.getElementById('divmostrarproblema').style.backgroundColor='#CCCCCC';
}

function solproblema(nom,id){
	
alert('En Construccio');
}
 

function MostrarFerreteria(id){	
//alert(document.getElementById('filas'+id).value); num filas
//alert(document.getElementById('T'+document.getElementById('fila'+id+'0').value).value); si es diferent a 0 mostrar


	//variable per saber si el titol s'ha de mostrar
	var titol;
	
	
	if (document.getElementById('V'+id).value=='+'){
		titol="false";
		//si aquesta variable esta a 0 vol dir que tots els divs estan amagats
		if (document.getElementById('HVisible').value!='0'){
			titol="true";
			for(i=0;i<document.getElementById('filas'+document.getElementById('HVisible').value).value;i++){
				//controlem que s'amaguin els de valor =0
				if (document.getElementById('T'+document.getElementById('fila'+document.getElementById('HVisible').value+i).value).value==0){
					Effect.BlindUp('div'+document.getElementById('HVisible').value+i);
				}else{					
					titol="false";
				}		
			}
			if (titol=="true"){Effect.BlindUp('titol'+document.getElementById('HVisible').value);}
		
			document.getElementById('V'+document.getElementById('HVisible').value).value='+';
			Effect.BlindDown('titol'+id);
			for(i=0;i<document.getElementById('filas'+id).value;i++){
				if (document.getElementById('T'+document.getElementById('fila'+id+i).value).value==0){
					Effect.BlindDown('div'+id+i);
				}		
			}		
		}else{
			Effect.BlindDown('titol'+id);
			for(i=0;i<document.getElementById('filas'+id).value;i++){
				
					Effect.BlindDown('div'+id+i);
					
			}			
		}		
		document.getElementById('V'+id).value='-';		
		document.getElementById('HVisible').value=id;
	}else{
		titol="false";
		for(i=0;i<document.getElementById('filas'+id).value;i++){
			if (document.getElementById('T'+document.getElementById('fila'+id+i).value).value==0){
				Effect.BlindUp('div'+id+i);
			}else{
				titol="true";
			}
		}	
		if (titol=="false"){Effect.BlindUp('titol'+id);}
		//Effect.BlindUp('Mostrar'+id);
		document.getElementById('V'+id).value='+';
		document.getElementById('HVisible').value='0';
	}
}

function mesmenysferr(codi,des,preu,valor){
	if (valor=='-'){
		if (document.getElementById('T'+codi).value>0){
			if (document.getElementById('T'+codi).value==1){
				xajax_eliminarlinia(codi);
			}else{				
				xajax_afegirliniacomanda(codi,des,preu,'-1',document.getElementById('Hescalat').value);
			}
			document.getElementById('T'+codi).value--;
		}
		
	}else{
		if (valor=='+'){
			document.getElementById('T'+codi).value++;
			xajax_afegirliniacomanda(codi,des,preu,'1',document.getElementById('Hescalat').value);
		}	
	}
	
}
function cuantitatferr(codi,des,preu) {
	if (IsInt(document.getElementById('T'+codi).value,'false')){
		if (document.getElementById('T'+codi).value<0){
			document.getElementById('T'+codi).value='0';
			xajax_error('verroni');
			//alert('El Valor introduit es erroni');
			document.getElementById('T'+codi).focus();
		}
	}else{
		document.getElementById('T'+codi).value='0';
		xajax_error('verroni');
		//alert('El Valor introduit es erroni');
		document.getElementById('T'+codi).focus();
	}
	//alert('correcta');
	if (document.getElementById('T'+codi).value==0){
	xajax_eliminarlinia(codi);	
	}else{
	xajax_assignarcuantitat(codi,des,preu,document.getElementById('T'+codi).value,document.getElementById('Hescalat').value);
	}
}
function IsInt( numstr, allowNegatives ) {
// Return immediately if an invalid value was passed in
if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")
return false;

// Default allowNegatives to true when undefined or null
if (allowNegatives+"" == "undefined" || allowNegatives+"" == "null")
allowNegatives = true;

var isValid = true;

// convert to a string for performing string comparisons.
numstr += "";

// Loop through string and test each character. If any
// character is not a number, return a false result.
// Include special case for negative numbers (first char == '-').
for (i = 0; i < numstr.length; i++) {
if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || (numstr.charAt(i) == "-"))) {
isValid = false;
break;
} else if ((numstr.charAt(i) == "-" && i != 0) ||
(numstr.charAt(i) == "-" && !allowNegatives)) {
isValid = false;
break;
}

} // END for

return isValid;
} // end IsInt




function mostramenu(){
	if (rcmenu.style.display=='none'){
		Effect.BlindDown('rcmenu');	
	}else{
		Effect.BlindUp('rcmenu');	
	}
}

//-->
