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

function refresh() {
	location.reload();
}
function lehiostatus() {
	window.defaultStatus="CASTMOL";
}
window.onload=lehiostatus;

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

function jarritxt() {
	document.getElementById('hzk1').innerHTML='PRODUKTU GARAPENA ETA SERIE MOTZAK'; 
	document.getElementById('hzk2').innerHTML='DESARROLLO DE PRODUCTO Y SERIES CORTAS';
	document.getElementById('hzk3').innerHTML='PRODUIT DEVELOPPEMENT ET COURT SERIES';
	document.getElementById('hzk4').innerHTML='PRODUCT DEVELOPMENT AND SHORT SERIES';
}
function hizku(zein, zer) {
	//opener.document.getElementById(zein).value=zer;
	hizkun=document.getElementById('hzk'+zein);
	if (zer==1) {
		if (zein==1) {
			hizkun.innerHTML='&raquo;&nbsp;EUSKARA';
		} else if (zein==2) {
			hizkun.innerHTML='&raquo;&nbsp;CASTELLANO';
		} else if (zein==3) {
			hizkun.innerHTML='&raquo;&nbsp;FRANÇAIS';
		} else if (zein==4) {
			hizkun.innerHTML='&raquo;&nbsp;ENGLISH';
		}
	} else if (zer==0) {
		jarritxt();
	};
}

/*
____________________
::          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="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";
	}
}
var error=Array("Beharrezko datuak","Datos obligatorios","Données obligatoires","Compulsory data");
var izena=Array("Izena","Nombre","Prénom","Name");
var mail=Array("e-posta","e-mail","e-mail","e-mail");
var mezu=Array("Mezua","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="kolr";
	} else {
		document.getElementById('nomtxt').className="kol0";
	} 
	if(document.getElementById('pos').value=="" || document.getElementById('pos').value=="X") {
		mezua=mezua+"\t- "+mail[hizk-1]+"\n"; txarto=true;
		document.getElementById('postxt').className="kolr";
	} else {
		document.getElementById('postxt').className="kol0";
	} 
	if(document.getElementById('men').value=="" || document.getElementById('men').value=="X") {
		mezua=mezua+"\t- "+mezu[hizk-1]+"\n"; txarto=true;
		document.getElementById('mentxt').className="kolr";
	} else {
		document.getElementById('mentxt').className="kol0";
	}
	if(txarto) { 
		alert(mezua);
		return false; 
	}
}


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

function egutegi(zein) {
	eguna=document.getElementById(zein).value;
	if (eguna!='fin' && eguna!='inicio') {
		var banaka=eguna.split("-");
		pop('../orokor/egutegia.php?zelai='+zein+'&eguna='+banaka[2]+'&hila='+banaka[1]+'&urtea='+banaka[0]+'', 'egutegia', 'n', '228', '185', '1');
	} else {
		pop('../orokor/egutegia.php?zelai='+zein+'&eguna=0&hila=0&urtea=0', '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();
}
function map(zein, hizkuntza) {
	poblacio=document.getElementById(zein).value;
	pop('../orokor/map.php?hizk='+hizkuntza, 'mapa', 'n', '654', '502', '1');
}
function hartumap() {
	selekta=opener.document.getElementById('pobla');
	zein=selekta.value;
	if (zein>0) {
		document.getElementById('dot'+zein).src='../irudi/mapointon.gif';
		document.getElementById('pobla'+zein).className='poblover';
	}
}
function itzulimap(zein) {
	selekta=opener.document.getElementById('pobla');
	selekta.value=zein;
	window.close();
}

/*
_____________
::   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);
}
/*
_____________________
::          hizkuntzak       ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

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

 
