/*
_____________
::    botikode    ::
¯¯¯¯¯¯¯¯¯¯¯¯¯
*/

function refresh() {
	location.reload();
}
function lehiostatus(zein) {
	window.defaultStatus="Maquinaria para la Transformación de Fleje y Chapa.";
}

/*
____________________
::      edukiarentzat       ::
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/

function lin_on(ni) { document.getElementById('linehizk').className="line_on"; }
function lin_of(ni) { document.getElementById('linehizk').className="line_of"; }

function f_on(ni) { document.getElementById(ni).className="fover"; }
function f_of(ni) { document.getElementById(ni).className="fout"; }
function contact() { document.getElementById('name').focus(); }
function barne(zein,zer) {
	if (document.getElementById(zein).value==zer) {
		document.getElementById(zein).value="";
	}
}
function kanpo(zein,zer) {
	if (document.getElementById(zein).value=="") {
		document.getElementById(zein).value=zer;
	}
}
function jarritext() {
	document.sarbidea.name.value="erabiltzailea";
	document.sarbidea.fake.value="pasahitza";
	document.getElementById("iru").style.display="none";
}
function passing(){
	if (document.sarbidea.fake.value=="pasahitza") {
		document.getElementById("bit").style.display="none";
		document.getElementById("iru").style.display="block";
		document.sarbidea.pass.focus();
	}
}
function shot(){
	if (document.sarbidea.pass.value=="") {
		x=document.getElementById("bit").style.display="block";
		y=document.getElementById("iru").style.display="none";
	}
}


function menu(zediv){
	x=document.getElementById('sub'+zediv);
	y=document.getElementById("i"+zediv);
	if(x.style.display != "block"){
		x.style.display="block";
		y.src="../../irudi/i.gezion.gif";
	}else{
		x.style.display="none";
		y.src="../../irudi/i.gezioff.gif";
    }
}

function edozeinpic(zeatal,subatal){
	x=document.getElementById("pics");
	zein=Math.floor(Math.random()*6)+1;
	x.src="../irudi/pics/bimg"+zeatal+subatal+"."+zein+".jpg";
	y=document.getElementById("pic"+zein);
	y.className="pictxikion";
}

/*
_____________
::   lehio*pop   ::
¯¯¯¯¯¯¯¯¯¯¯¯¯
*/

function pop(url,name,features, myWidth, myHeight, isCenter) {
	if(window.screen)if(isCenter)if(isCenter=="1") {
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	flop=window.open(url,name,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	flop.focus();
}
function irudipop(zein,title,zab,alt){
    pop('botipop.htm?'+zein+'*'+title, zein, '', zab, alt, 1);
}

/*
____________________
::         utilities         ::
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/
function validame(hizk){
	var form=document.getElementById("contact");
	
	var errores="";
	var nombre=document.getElementById("name");
	var email=document.getElementById("mail");
	var empresa=document.getElementById("enpresa");
	var pais=document.getElementById("herria");
	var telefono=document.getElementById("tel");
	var asunto=document.getElementById("subject");
	var mensaje=document.getElementById("message");
	if(hizk==1) {
		if(email.value=="") errores+="- El email es obligatorio.\n";
		if(empresa.value=="") errores+="- La Empresa es obligatoria.\n";
		if(pais.value=="") errores+="- El País es obligatorio.\n";
		if(telefono.value=="") errores+="- El teléfono es obligatorio.\n";
		/*
		if(nombre.value=="") errores+="- El nombre es obligatorio.\n";
		if(asunto.value=="") errores+="- El asunto es obligatorio.\n";
		if(mensaje.value=="") errores+="- El mensaje es obligatorio.\n";
		*/
	} else if(hizk==2) {
		if(email.value=="") errores+="- E-mail is required.\n";
		if(empresa.value=="") errores+="- Company is required.\n";
		if(pais.value=="") errores+="- Country is required.\n";
		if(telefono.value=="") errores+="- Telephone is required.\n";
		/*
		if(nombre.value=="") errores+="- Name is required.\n";
		if(asunto.value=="") errores+="- Subject is required.\n";
		if(mensaje.value=="") errores+="- Message is required.\n";
		*/
	} else if(hizk==3) {
		if(email.value=="") errores+="- E-mail obligatoire.\n";
		if(empresa.value=="") errores+="- Société obligatoire.\n";
		if(pais.value=="") errores+="- Pays obligatoire.\n";
		if(telefono.value=="") errores+="- Téléphone obligatoire.\n";
		/*
		if(nombre.value=="") errores+="- Prenom obligatoire.\n";
		if(asunto.value=="") errores+="- Sujet obligatoire.\n";
		if(mensaje.value=="") errores+="- Message obligatoire.\n";
		*/
	}
	
	if(errores==""){
		form.submit();
	}else{
		alert(errores);
	}
}

/*
_____________________
::          hizkuntzak       ::
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/

function hizkuntzazein(zein) {
	saveCookie('bonacookie',zein,666);
 }
 function hasera() {
	if (readCookie('bonacookie')){
		deleteCookie('bonacookie');
		window.location="../index.php";
	}else{
		window.location="../index.php";
	}	
 }
function hartuhizkuntza() {
	if (readCookie('bonacookie')){
		hizkuntzaoain=readCookie('bonacookie');
		if (hizkuntzaoain == 1) {
			window.location="web/bonak.php?atal=1&hizk=1";
		} else if (hizkuntzaoain == 2) {
			window.location="web/bonak.php?atal=1&hizk=2";
		} else if (hizkuntzaoain == 3) {
			window.location="web/bonak.php?atal=1&hizk=3";
		}
	}
 }
/*function hizkuntzaldaketa(berria) {
	//saveCookie('bonacookie',berria,666);
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	if (berria==1) {
		hk="?hizk=1";
	} else if (berria==2) {
		hk="en";
	} else if (berria==3) {
		hk="fr";
	}
	nora="../"+hk+"/"+sPage;
	window.location.href=nora;
}*/
function hizkuntzaldaketa(berria) {
	saveCookie('bonacookie',berria,666);
	var sPath = window.location.pathname+window.location.search;
	var sPage = sPath.substring(sPath.lastIndexOf('/')+1);
	var sBerri = sPage.substring(0, sPage.length-1);
	nora=sBerri+berria;
	window.location.href=nora;
	//alert(nora);
}

/*
____________________
::         egutegia         ::
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/

function egutegi(zein) {
	eguna=document.getElementById(zein).value;
	if (eguna) {
		var banaka=eguna.split("-");
		pop('../orokor/egutegia.php?zelai='+zein+'&eguna='+banaka[2]+'&hila='+banaka[1]+'&urtea='+banaka[0]+'&hizk=1', 'egutegia', 'n', '228', '185', '1');
	} else {
		pop('../orokor/egutegia.php?zelai='+zein+'&eguna=0&hila=0&urtea=0&hizk=4', 'egutegia', 'n', '228', '185', '1');
	}
}
function itzuli(zer, zein, end) {
	/*parentform = opener.document.datak;*/
	opener.document.getElementById(zein).value=zer;
	if (zein=="new_start") { opener.document.getElementById('new_end').value=end; };
	window.close();
}


/*
_____________________
::             cookie          ::
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/

function saveCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000))
		var expires = "; expires="+date.toGMTString()
	}
    else expires = ""
    document.cookie = name+"="+value+expires+"; path=/"
}
function readCookie(name) {
	var nameEQ = name + "="
	var ca = document.cookie.split(';')
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length)
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
	}
	return null
}
function deleteCookie(name) {
    saveCookie(name,"",-1)
}

 