function midatext(mida){
	SetCookie ("lletra",mida);
	history.go(0);
}
function writebig(){
	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/styles/big.css\"/>");
}
function midalletra(){
	mida=GetCookie("lletra");
	if(mida=="2"){
		document.getElementById("mida1").className="";
		document.getElementById("mida2").className="on";
	}
	else{
		document.getElementById("mida1").className="on";
		document.getElementById("mida2").className="";
	}
}
function SetCookie (name, value) { 
	var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : "/";
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" + expires.toGMTString()))+((path == null) ? "" : ("; path=" + path))+((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)  endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
    var alen = arg.length;        
	var clen = document.cookie.length;
    var i = 0;       
	while (i < clen) {        
	     var j = i + alen;
    	 if (document.cookie.substring(i, j) == arg)
    	 return getCookieVal (j);
	     i = document.cookie.indexOf(" ", i) + 1;
         if (i == 0) break;         
	 }
	return null;
}

function toggle(showhide){
	arLayers=toggle.arguments;
	displaycss=(showhide)?"block":"none";
	if(arLayers.length>1){
		for(i=1;i<arLayers.length;i++){
			document.getElementById(arLayers[i]).style.display=displaycss;
		}
	}
}

var dirty = false;
function changeSection(message)
{	
	if(dirty) return confirm(message);
	return true;
}

function set_dirty()
{
	dirty = true;
}

function show_help(page, anchor)
{
	if(anchor != "")
		page += "#" + anchor;
	
	ventana(0, page, 'vHelp');	
}

function ventana(a,pag,nombre){
  aw=screen.availWidth-10;
  switch (a){
	//help
	case 0:
	Vancho=400;Valto=500;
	carac='scrollbars=yes';
	break;
	default:
	Vancho=650;Valto=450;
	carac='scrollbars=yes';
	break;
  }
  xc=(aw-Vancho)/2;
 carac='left='+xc+',top=0,screenX='+xc+',screenY=0,width='+Vancho+',height='+Valto+',status=yes,toolbar=yes,resizable=yes,location=yes,'+carac;
  if(!nombre)nombre='FINESTRA';
  eval(nombre+'=window.open("'+pag+'","'+nombre+'","'+carac+'")');
  eval(nombre+'.focus()');
}

function change_province(oSelect, preffix, provinceValue)
{
	var arOptions = eval(oSelect[oSelect.selectedIndex].value + "_provinces");
	var oSelect = document.getElementById(preffix + "Province");
	
	fill_select(oSelect, arOptions, provinceValue);
}

function init_provinceSelects(preffix, regionValue, provinceValue)
{
	var oRegion = document.getElementById(preffix + "Region");
	var oProvince = document.getElementById(preffix + "Province");
	
	if(regionValue != '')
	{
		var arOptions = eval(regionValue + "_provinces");
		fill_select(oProvince, arOptions, provinceValue);
	}
	else
	{
		oProvince.disabled = true;
	}
}

function fill_select(oSelect, arOptions, value)
{
	oSelect.disabled = false;
	oSelect.length = arOptions.length;
	for( i = 0; i < arOptions.length; i++)
	{
		var selected = (arOptions[i][0] == value) ? true : false;
		
		oSelect.options[i].selected = selected;
		oSelect.options[i].value = arOptions[i][0];
		oSelect.options[i].text  = arOptions[i][1];
	}
}