/*contactar.tpl.php*/
function callGoogleMaps(address,texteglobus,div_id){ /*es configura i crida finestra de Google maps*/ 
  var map = null; 
  var geocoder = null;
  
  map = new GMap2(document.getElementById("Gmaps"+div_id)); 
  geocoder = new GClientGeocoder(); 
  if(geocoder){ 
    geocoder.getLatLng( 
      address, 
      function(point) { 
        if (!point) { 
          alert(address + " not found"); 
        }else{ 
          map.setCenter(point, 13); 
          var marker = new GMarker(point); 
          map.addOverlay(marker); 
          /*marker.openInfoWindowHtml(texteglobus);*/ 
        } 
      } 
    ); 
  } 
}
function msgForm(formid)
{
  function formCallback(result, form) {
    window.status = "valiation callback for form '" + form.id + "': result = " + result;
  }

  var valid = new Validation(formid, {useTitles:true,immediate : true, onFormValidate : formCallback});
  Validation.addAllThese([]); 
}

/*seccio.tpl.php*/
function requadre(domini,idreg,prod_id){
			//$('sobrenegre').appear({ duration: 1.5, from: 0, to: 0.7 });
			//$('generalsortint').appear({ duration: 1.5, from: 0, to: 1.0 });
			Effect.Appear('sobrenegre', { duration: 1.5, from: 0, to: 0.6 });
			Effect.Appear('generalsortint', { duration: 1.5, from: 0, to: 1.0 });
			//$('sobrenegre').appear();
		new Ajax.Updater(
			"capaflotantcentre",
			'http://'+domini+'index.php?ajax=popup_dades.php',
			{method: 'post', parameters: 'idreg='+idreg+'&prod_id='+prod_id}
		);		
}
	
function treurerequadre(){
  Effect.Fade('sobrenegre');
  Effect.Fade('generalsortint');
}

/*contactar.tpl.php*/
function msgForm(formid)
{
  function formCallback(result, form) {
    window.status = "valiation callback for form '" + form.id + "': result = " + result;
  }

  var valid = new Validation(formid, {useTitles:true,immediate : true, onFormValidate : formCallback});
  Validation.addAllThese([]); 
}

/*inici.tpl.php*/
function activa(nbbh,total_botons,divimg) //2 següents funcions son per fer la trancicio d'imatges (sciptaculous)
{
  for(var t=1;t<=total_botons;t++) {
    if(t!=nbbh){
	  if($('img'+t).style.display != 'none'){ $('img'+t).fade();$('img'+t).className=divimg; }
	}
  }
  $('img'+nbbh).className='show '+divimg;
  $('img'+nbbh).appear();
  return false;
}

function activaNext(total_botons,divimg)
{
  var canviat = 0;
  for(var c=1;c<=total_botons;c++){
    if($('img'+c).className == "show "+divimg){
      var next = (c == total_botons) ? 1 : c+1;
      if(canviat==0){
        activa(next,total_botons,divimg);
         canviat=1;
      }
    }
  }
}
