/*
_____________
::    botikode    ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function refresh() {
	location.reload();
}
window.onload=lehiostatus;
function lehiostatus() {
	window.defaultStatus="The Matt Harding Project";
}

/*
____________________
::      edukiarentzat       ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function songs(zein){
	for(var i = 1; i <= 11; i++) {
		x=document.getElementById('song'+i).style.display="none";
	}
	x=document.getElementById('song'+zein).style.display="block";
}

var cd1=new Array("Lovin'_In_My_Baby's_Eyes","Hey_Baby","You_are_mine","Lovely_Lady");
var cd2=new Array("Foolish_Heart","Big_City","Jesus_And_The_Devil","There_You_Will_Find_Me");
var cd3=new Array("She_Don't_Know","There_Must_Be_Love","Shanghai","Hello_Africa");
var abestiak=new Array(cd1,cd2,cd3);
function mptree(zein,cd){
	abestia=abestiak[cd-1][zein-1];
	pop("http://www.mattharding.com/media/audio/"+abestia+".mp3",'botika','n','355','105','1');
}

var argazkiak=new Array("matt01","matt02","matt03","matt04","matt05","matt06","front");
function cazenave(zein){
	argazkia=argazkiak[zein-1];
	window.open ("http://www.mattharding.com/media/high/"+argazkia+".jpg","high_resolution");
}

/*
____________________
::          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";
	}
}

/*
____________________
::         utilities         ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

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="kol0";
	} else {
		document.getElementById('nomtxt').className="kol3";
	} 
	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="kol3";
	} 
	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="kol3";
	}
	if(txarto) { 
		alert(mezua);
		return false; 
	}
}

/*
____________________
::         egutegia         ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function egutegi(zein) {
	eguna=document.getElementById(zein).value;
	if (eguna!='') {
		var banaka=eguna.split("-");
		pop('egutegia.php?zelai='+zein+'&eguna='+banaka[2]+'&hila='+banaka[1]+'&urtea='+banaka[0]+'', 'egutegia', 'n', '228', '185', '1');
	} else {
		pop('egutegia.php?zelai='+zein+'&eguna=0&hila=0&urtea=0', 'egutegia', 'n', '228', '185', '1');
	}
}
function itzuli(zer, zein) {
	opener.document.getElementById(zein).value=zer;
	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();
}

/*
_____________________
::          hizkuntzak       ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function jarrizkuntz(zein) {
	saveCookie('mattkie',zein,666);
	//window.location="web/index.php?hizk="+zein;
}
function hasera() {
	if (readCookie('mattkie')){
		deleteCookie('mattkie');
		window.location="../";
	}else{
		window.location="../";
	}	
}
function hartuhizkuntza() {
	if (readCookie('mattkie')){
		hizkuntzaoain=readCookie('mattkie');
		window.location="web/index.php?hizk="+hizkuntzaoain;
	}
	//alert(readCookie('mattkie'));
}
function hizkuntzaldaketa(berria) {
	saveCookie('mattkie',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);
}

 