function Get_Cookie(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(cookieName, cookieValue, nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)
	             + ";expires="+expire.toGMTString();
}

function sizeFont(size) {
	try {
		switch(size) {
			case 1 :
			case '1':
				document.getElementById('contenedor').style.fontSize = '1em';
				break;
			case 2 :
			case '2':
				document.getElementById('contenedor').style.fontSize = '1.1em';
				break;
			case 3 :
			case '3':
				document.getElementById('contenedor').style.fontSize = '1.2em';
				break;
			case 4 :
			case '4':
				document.getElementById('contenedor').style.fontSize = '1.3em';
				break;
		}
		Set_Cookie('tamanoFuenteNoticia', size, 30);
	} catch(e) {}
}
function familyFont(family) {
	try {
		switch(family) {
			case '1' :
				document.getElementById('contenedor').style.fontFamily = 'Arial';
				break;
			case '2' :
				document.getElementById('contenedor').style.fontFamily = 'Georgia';
				break;
			case '3' :
				document.getElementById('contenedor').style.fontFamily = 'Tahoma';
				break;
			
			case '4' :
				document.getElementById('contenedor').style.fontFamily = 'Verdana';
				break;
			case '5' :
				document.getElementById('contenedor').style.fontFamily = 'Trebuchet MS';
				break;
			default:
				break;
		}
		Set_Cookie('familiaFuenteNoticia', family, 30);
	} catch(e) {}
}
function colorstyle(color) {
	try {
		var estilo = document.getElementById('estilo_color').href;
		var nueva_ruta = estilo.substr(0,Number(estilo.length)-5);

		switch(color) {
			case '1' :
				document.getElementById('estilo_color').href = nueva_ruta+'1.css';
				//document.getElementById('contenedor').value = 'estilo_color1.css';
				//document.write("<span>[<\/span><a class=\"color1\" href=\"#\" onClick=\"document.getElementById('color').value='estilo_color1.css';document.colores.submit();\"><img src=\"{$smarty.const._DIRIMAGES}temas/tema_1.gif\" alt=\"#B6D8FD\"><\/a><span>]<\/span>");
				break;
			case '2' :
				document.getElementById('estilo_color').href = nueva_ruta+'2.css';
				//document.getElementById('contenedor').value = 'estilo_color2.css';
				break;
			case '3' :
				document.getElementById('estilo_color').href = nueva_ruta+'3.css';
				//document.getElementById('contenedor').value = 'estilo_color3.css';
				break;
			case '4' :
				document.getElementById('estilo_color').href = nueva_ruta+'4.css';
				//document.getElementById('contenedor').value = 'estilo_color4.css';
				break;
			case '5' :
				document.getElementById('estilo_color').href = nueva_ruta+'5.css';
				//document.getElementById('contenedor').value = 'estilo_color5.css';
				break;
			default:
				break;
		}
	
		Set_Cookie('estiloColor', color, 30);
	} catch(e) {}
}
function columnstyle(columna) {
	try {
		switch(columna) {
			case '1' :
				var column = '1';
				break;
			case '2' :
				var column = '2';
				break;
			case '3' :
				var column = '3';
				break;
			default:
				break;
		}
		Set_Cookie('estiloColumna', column, 30);
	} catch(e) {}
}
function zonestyle(zona) {
	try {
		switch(zona) {
			case '1' :
				var zone = '1';
				break;
			case '2' :
				var zone = '2';
				break;
			case '3' :
				var zone = '3';
				break;
			case '4' :
				var zone = '4';
				break;
			default:
				break;
		}
		Set_Cookie('estiloZona', zone, 30);
	} catch(e) {}
}

function comienzo()
{
	if (Get_Cookie('tamanoFuenteNoticia') != null) {
		sizeFont(Get_Cookie('tamanoFuenteNoticia'));
	}
	if (Get_Cookie('familiaFuenteNoticia') != null) {
		familyFont(Get_Cookie('familiaFuenteNoticia'));
	}
	if (Get_Cookie('estiloColor') != null) {
		colorstyle(Get_Cookie('estiloColor'));
	}
	if (Get_Cookie('estiloColumna') != null) {
		zonestyle(Get_Cookie('estiloColumna'));
	}
	if (Get_Cookie('estiloZona') != null) {
		zonestyle(Get_Cookie('estiloZona'));
	}
}
