/*
_____________
::    botikode    ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function refresh() {
	location.reload();
}
function lehiostatus() {
	window.defaultStatus="Remonte Profesional";
}
window.onload=lehiostatus;
function home(hzk) {
	location.href="index.php?hizk="+hzk;
}

/*
____________________
::      edukiarentzat       ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function over(zein,zer) {
	if (zer==1) {
		document.getElementById(zein).style.background="#F5F5F5";
	} else if (zer==0) {
		document.getElementById(zein).style.background="#FFF";
	}
}
function overadmin(zein,zer) {
	if (zer==1) {
		document.getElementById(zein).style.background="#C00";
		document.getElementById(zein).style.color="#FFF";
	} else if (zer==0) {
		document.getElementById(zein).style.background="#FFF";
		document.getElementById(zein).style.color="#001A33";
	}
}
function irudipop(zein,title,zab,alt){
    pop('botipop.htm?'+zein+'*'+title, zein, '', zab, alt, 1);
}
function txaponoff(zein) {
	if (!zein) {
		document.getElementById('id_txap_0').style.display="none";
	} else {
		document.getElementById('id_txap_'+zein).style.display="block";
	}
}
function aukeratua() {
	x=document.getElementById('new_visible');
	if (x.checked) { 
		document.getElementById('visible').value = 1;
	} else {
		document.getElementById('visible').value = 0;
	}
   return true;	
}
/*
____________________
::          forms           ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function f_on(ni) { document.getElementById(ni).className="fover"; }
function f_of(ni) { document.getElementById(ni).className="fout"; }
function contact() { document.getElementById('nom').focus(); lehiostatus(); }

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="usuario";
	document.sarbidea.fake.value="contraseña";
	document.getElementById("iru").style.display="none";
}
function passing(){
	if (document.sarbidea.fake.value=="contraseña") {
		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 gallery(zein,zer) {
	if (zer==1) {
		document.getElementById('gallery'+zein).className="gallerybordon";
		document.getElementById('galleryover'+zein).style.background="#781F1C";
	} else if (zer==0) {
		document.getElementById('gallery'+zein).className="gallerybordout";
		document.getElementById('galleryover'+zein).style.background="#EBDEDD";
	}
}

/*
____________________
::         utilities         ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

var error=Array("Datos obligatorios","Données obligatoires","Compulsory data");
var izena=Array("Nombre","Prénom","Name");
var mail=Array("e-mail","e-mail","e-mail");
var mezu=Array("Mensaje","Message","Message");
function checkform(hizk) {
	txarto=false;
	mezua=error[hizk-1]+":\n";
	if(document.getElementById('nom').value=="" || document.getElementById('nom').value=="X") {
		mezua=mezua+"\t- "+izena[hizk-1]+"\n"; txarto=true;
		document.getElementById('nomtxt').className="kol0";
	} else {
		document.getElementById('nomtxt').className="kol1";
	} 
	if(document.getElementById('pos').value=="" || document.getElementById('pos').value=="X") {
		mezua=mezua+"\t- "+mail[hizk-1]+"\n"; txarto=true;
		document.getElementById('postxt').className="kol0";
	} else {
		document.getElementById('postxt').className="kol1";
	} 
	/*if(document.getElementById('men').value=="" || document.getElementById('men').value=="X") {
		mezua=mezua+"\t- "+mezu[hizk-1]+"\n"; txarto=true;
		document.getElementById('mentxt').className="kol0";
	} else {
		document.getElementById('mentxt').className="kol1";
	}*/
	if(txarto) { 
		alert(mezua);
		return false; 
	}
}

/*
____________________
::         egutegia         ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

zabal=200;
garai=184;
//function egutegi(zein) {
//	eguna=document.getElementById(zein).value;
//	//alert(eguna);
//	if(zein=="desde") {
//		if (!eguna) {
//			eguna=document.getElementById('hasta').value;
//		}
//	} else {
//		if (!eguna) {
//			eguna=document.getElementById('desde').value;
//		}
//	}
//	var banaka=eguna.split("-");
//	pop('../orokor/egutegia.php?zelai='+zein+'&eguna='+banaka[2]+'&hila='+banaka[1]+'&urtea='+banaka[0]+'&egute=1&hizk=1', 'egutegia', 'n', zabal, garai, '1');
//}
function egutegi(zein) {
	try{
		var eguna=document.getElementById(zein).value;
	}catch(ex){
		var eguna='';	
	}
	if (eguna!='') {
		var banaka=eguna.split("-");
		pop('../orokor/egutegia.php?zelai='+zein+'&eguna='+banaka[2]+'&hila='+banaka[1]+'&urtea='+banaka[0]+'', 'egutegia', 'n', zabal, garai, '1');
	} else {
		pop('../orokor/egutegia.php?zelai='+zein+'&eguna=0&hila=0&urtea=0', 'egutegia', 'n', zabal, garai, '1');
	}
}
function itzuli(zer, zein, end) {
	opener.document.getElementById(zein).value=zer;
	window.close();
}
function egutegi2(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]+'&egute=1&hizk=1', 'egutegia', 'n', zabal, garai, '1');
	}
}

/*
_____________
::   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();
}

/*
_____________________
::          hizkuntzak       ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function hizkuntzazein(zein) {
	saveCookie('dokacookie',zein,666);
}
function hasera() {
	if (readCookie('dokacookie')){
		deleteCookie('dokacookie');
		window.location="../";
	}else{
		window.location="../";
	}	
}
function hartuhizkuntza() {
	if (readCookie('dokacookie')){
		hizkuntzaoain=readCookie('dokacookie');
		if (hizkuntzaoain == 1) {
			window.location="web/index.php?atal=1&amp;hizk=1";
		} else if (hizkuntzaoain == 2) {
			window.location="web/index.php?atal=1&amp;hizk=2";
		}
	} else {
		window.location="web/index.php?atal=1&amp;hizk=1";
	}
}
function hizkuntzaldaketa(berria) {
	saveCookie('dokacookie',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);
}

/*
_____________________
::             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)
}
function hizkuntzazein(zein) {
	saveCookie('boticookie',zein,666);
}

 