/*************************************************/
/************ Telémaco Sistemas S.L **************/
/*************************************************/

/******* Funciones envio formulario correo *********/

function isEmail(str)
{
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function chequeo()
{
  vari = isEmail(document.envio.MAILFROM.value);
  if (!vari){
	alert('Su correo electrónico no parece válido.\nIntrodúzcalo en el campo indicado.');
  }
  else document.envio.submit();
}
/*******************************/

/******* Google Maps *********/
function load()
{
  var map = new GMap(document.getElementById("map"));
  map.addControl(new GSmallMapControl());
  map.centerAndZoom(new GPoint(-0.865774, 38.632243), 1);
  map.addOverlay(new GMarker(new GPoint(-0.865774, 38.632243)));  
  
  var infoTabs = [  new GInfoWindowTab("Ubicación", "C/. Maestro Chanzá, 14 entlo.<br>03400 VILLENA (Alicante)<br>Telf: 96 580 21 06 <a href='mailto:info@filateliatorres.com'>info@filateliatorres.com</a>"),  new GInfoWindowTab("Horario", "Mañanas de 10h a 13 h<br>Tardes de 16:30 h a 20 h")];
  
  marker = new GMarker(map.getCenter());
  GEvent.addListener(marker, "click", function(){
    marker.openInfoWindowTabsHtml(infoTabs);
  });
  map.addOverlay(marker);marker.openInfoWindowTabsHtml(infoTabs);  
}
/***************/

/******* Botones cesta *********/
function botones_cesta()
{
  finalizar_on = new Image(110,31);
  finalizar_on.src = "iconos/bt-finalizar-of.jpg";
  finalizar_of = new Image(110,31);
  finalizar_of.src = "iconos/bt-finalizar-on.jpg";
  
  vaciarcesta_on = new Image(110,31);
  vaciarcesta_on.src = "iconos/bt-vaciar-of.jpg";
  vaciarcesta_of = new Image(110,31);
  vaciarcesta_of.src = "iconos/bt-vaciar-on.jpg";  
}

function btn_on(imgbtn)
{
  x = eval(imgbtn + "_on.src");
  document[imgbtn].src = x;
}

function btn_of(imgbtn)
{
  x = eval(imgbtn + "_of.src");
  document[imgbtn].src = x;
}

function cantidad(element, n){
  cant = element.value;
  document.getElementById("producto_"+n).name += ";CANTIDAD="+cant;
}