/*
_____________
::    botikode    ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function refresh() {
	location.reload();
}
function lehiostatus() {
	window.defaultStatus="Todo Retales";
}

/*
____________________
::      edukiarentzat       ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function hasi() {
	alert(ikusiCookie('todoret'));
	if (ikusiCookie('todoret')){
		hizkuntzaoain=ikusiCookie('todoret');
	} else {
		gordeCookie('todoret','1',666);
		hizkuntzaoain=1;
	}
	window.location="web/index.php?hizk="+hizkuntzaoain;
}

function maquipic(zein,id,taul) {
	irudibox=document.getElementById('maquirudi');
	if(zein==1) {
		irudibox.style.background="url('../irudi/prods/"+taul+"/img_"+id+".jpg') center center no-repeat";
	} else {
		irudibox.style.background="url('../irudi/prods/"+taul+"/img_"+id+"."+zein+".jpg') center center no-repeat";
	}
}
function actvr(zer) {
	txtbox=document.getElementById('spactvr');
	if(zer==1) {
		txtbox.innerHTML="ACTIVAR";
	} else if(zer==-1) {
		txtbox.innerHTML="DESACTIVAR";
	} else {
		txtbox.innerHTML="MIS ANUNCIOS";
	}
}
function nerealdaketa() {
	var sPath = window.location.pathname+window.location.search;
	var sPage = sPath.substring(sPath.lastIndexOf('/')+1);
	if(sPage.indexOf('?')==-1) {
		nora=sPage+'?n=1';
	} else {
		nora=sPage+'&n=1';
	}
	window.location.href=nora;
}

/*
____________________
::         utilities         ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

var error=Array("Dato(s) obligatorio(s)","Dades obligatories","Dades obligatories","Compulsory data");
var pro=Array("PRODUCTO","Nom","Nom","Name");
var col=Array("COLOR","e-mail","e-mail","e-mail");
function checkform(hizk,atal) {
	txarto=false;
	mezua=error[hizk-1]+":\n";
	if(document.getElementById('pro').value==0) {
		mezua=mezua+" --  "+pro[hizk-1]+"\n"; txarto=true;
	} 
	if(atal==1) {
		if(document.getElementById('col').value=="0") {
			mezua=mezua+" --  "+col[hizk-1]+"\n"; txarto=true;
		} 
	} 
	if(txarto) { 
		alert(mezua);
		return false; 
	}
}
var prov=Array("PROVINCIA","Nom","Nom","Name");
function checkprov(hizk) {
	txarto=false;
	mezua=error[hizk-1]+":\n";
	if(document.getElementById('prov').value==0) {
		mezua=mezua+" --  "+prov[hizk-1]+"\n"; txarto=true;
	} 
	if(txarto) { 
		alert(mezua);
		return false; 
	}
}

/*
____________________
::          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.user.value="e-mail";
	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";
	}
}

/*
____________________
::         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]+'', 'egutegia', 'n', '266', '250', '1');
	} else {
		pop('../orokor/egutegia.php?zelai='+zein+'&eguna=0&hila=0&urtea=0', 'egutegia', 'n', '160', '160', '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();
}

/*
_____________________
::             cookie          ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function gordeCookie(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 ikusiCookie(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) {
  gordeCookie(name,"",-1)
}

/*
_____________________
::          hizkuntzak       ::
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
*/

function hizkuntzazein(zein) {
	gordeCookie('todoret',zein,666);
}
function hasera() {
	if (ikusiCookie('todoret')){
		deleteCookie('todoret');
	}	
	window.location="../";
}
function hartuhizkuntza() {
	if (ikusiCookie('todoret')){
		hizkuntzaoain=ikusiCookie('todoret');
		window.location="web/index.php?hizk="+hizkuntzaoain;
//	} else { 
//		window.location="web/index.php?hizk=1";
	}
}
function hizkuntzaldaketa(berria) {
	gordeCookie('todoret',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);
}

