// BOTIKAJAX v 1.0

// Formularioa kargatzeko
function loadForm(name,email,tipo1,tipo2,tipo3,runom,ruurl,rudes,dur_h,dur_m,dific,desni,dista,circu,err) {
  var xmlHttp;
  try { // Gehiengoarentzat
    xmlHttp=new XMLHttpRequest();
  }
  catch (e) { // Internet Explorer-entzat
    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
      try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (e) { alert("Your browser does not support AJAX!"); return false; }
    }
  }
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById('idForm').innerHTML=parseScript(xmlHttp.responseText);
			// Input-etan klikatzean testua desagertzeko
			$("form").find("input, textarea").toggleVal();
			// H2 "z" sifr-ak aktibatzeko
			sIFR.replace(chaparral, {
				selector: 'h2.z span.sifr',
				css:[
					'.sIFR-root { color: #409398; font-size: 30px; }',
					'a { text-decoration: none; }',
					'a:link { color: #409398; }',
					'a:hover { color: #6AC7CC; }'
				],
				thickness: -120,
				wmode: 'transparent',
				fixHover: true,
				useStyleCheck: true
			});
			// Laguntzak aktibatzeko
			addHelp();
		}
	}
	xmlHttp.open("GET",jsroot+"botika/forms/naturalForm.php?name="+name+"&email="+email+"&tipo1="+tipo1+"&tipo2="+tipo2+"&tipo3="+tipo3+"&runom="+runom+"&ruurl="+ruurl+"&rudes="+rudes+"&dur_h="+dur_h+"&dur_m="+dur_m+"&dific="+dific+"&desni="+desni+"&dista="+dista+"&circu="+circu+"&err="+err,true);
	xmlHttp.send(null);
}

// Formularioa bidaltzeko
function sendForm() {

	var name = document.getElementById('name').value;
	if(name==jsname) { name=''; }
	var email = document.getElementById('email').value;
	if(email==jsemail) { email=''; }
	
	var tipo1 = document.getElementById('trekking').checked;
	if(tipo1) { tipo1=1; } else { tipo1=0; }
	var tipo2 = document.getElementById('roadBike').checked;
	if(tipo2) { tipo2=1; } else { tipo2=0; }
	var tipo3 = document.getElementById('mountainBike').checked;
	if(tipo3) { tipo3=1; } else { tipo3=0; }
	var runom = document.getElementById('routeName').value;
	if(runom==jsrunom) { runom=''; }
	var ruurl = document.getElementById('routeURL').value;
	if(ruurl==jsruurl) { ruurl=''; }
	var rudes = document.getElementById('routeDescription').value;
	if(rudes==jsrudes) { rudes=''; }
	var circu = document.getElementById('routeCircu').checked;
	if(circu) { circu=1; } else { circu=0; }
	var onartua = document.getElementById('acceptTerms').checked;
	if(onartua) { onartua=1; } else { onartua=0; }
	
	var dur_h = document.getElementById('routeHours').value;
	var dur_m = document.getElementById('routeMinutes').value;
	var dific = document.getElementById('routeDifficulty').value;
	var desni = document.getElementById('routeLevel').value;
	var dista = document.getElementById('routeDistance').value;
	//var circu = document.getElementById('circular').checked;
	
  var xmlHttp;
  try { // Gehiengoarentzat
    xmlHttp=new XMLHttpRequest();
  }
  catch (e) { // Internet Explorer-entzat
    try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
      try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (e) { alert("Your browser does not support AJAX!"); return false; }
    }
  }
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById('idForm').innerHTML=parseScript(xmlHttp.responseText);
			// Input-etan klikatzean testua desagertzeko
			$("form").find("input, textarea").toggleVal();
			// Laguntzak aktibatzeko
			addHelp();
			// H2 "z" sifr-ak aktibatzeko
			sIFR.replace(chaparral, {
				selector: 'h2.z span.sifr',
				css:[
					'.sIFR-root { color: #409398; font-size: 30px; }',
					'a { text-decoration: none; }',
					'a:link { color: #409398; }',
					'a:hover { color: #6AC7CC; }'
				],
				thickness: -120,
				wmode: 'transparent',
				fixHover: true,
				useStyleCheck: true
			});
		}
	}
	xmlHttp.open("GET",jsroot+"botika/forms/naturalFormSend.php?name="+name+"&email="+email+"&tipo1="+tipo1+"&tipo2="+tipo2+"&tipo3="+tipo3+"&runom="+runom+"&ruurl="+ruurl+"&rudes="+rudes+"&dur_h="+dur_h+"&dur_m="+dur_m+"&dific="+dific+"&desni="+desni+"&dista="+dista+"&circu="+circu+"&onartua="+onartua,true);
	xmlHttp.send(null);
}

