function newCookie(name,value,days){
	var days = 100;

	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/"; 
}
function readCookie(name){
	var nameSG = name + "="; var nuller = '';

	if (document.cookie.indexOf(nameSG) == -1) return nuller;

	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(nameSG) == 0) return c.substring(nameSG.length,c.length); 
	}
	return null; 
}
function eraseCookie(name){
	newCookie(name,"",1);
}
function toMem(){
	newCookie('theEmail', document.getElementById('log_email').value);
	newCookie('thePsswd', document.getElementById('log_pass').value);	 
	newCookie('theCity', document.getElementById('sel_index_ciudades').value);
}
function eraseCookie(name){
  newCookie(name,"",1);
}
function remCookie(){
	try {
		var theEmail = readCookie("theEmail");
		var thePsswd = readCookie("thePsswd");
		var theCity = readCookie("theCity");

		document.getElementById('log_email').value = theEmail;
		document.getElementById('log_pass').value = thePsswd;
		selectciudades=document.getElementById('sel_index_ciudades')		
		selectciudades.selectedIndex=theCity;
		if (theEmail != ''){
			document.getElementById('remember_me').checked = true;
		}
	} catch(err){}
}

function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
			if (oldonload) {oldonload();} func();
		}
	}
}
addLoadEvent(function(){remCookie();});