function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) 
{	var i, j;
	var prompt;
	// empty existing items
	for (i = selectCtrl.options.length; i >= 0; i--) 
	{
		selectCtrl.options[i] = null; 
	}
	prompt = (itemArray != null) ? goodPrompt : badPrompt;
	if (prompt == null) 
	{
		j = 0;
	}
	else 
	{
		selectCtrl.options[0] = new Option(prompt);
		j = 1;
	}
	selectCtrl.options[j] = new Option('Todos');
	selectCtrl.options[j].value = '-1'; 
	j++;
	if (itemArray != null) 
	{
	// add new items
		for (i = 0; i < itemArray.length; i++) 
		{
			selectCtrl.options[j] = new Option(itemArray[i][0]);
			if (itemArray[i][1] != null) 
			{
				selectCtrl.options[j].value = itemArray[i][1]; 
			}
			j++;
		}
	// select first item (prompt) for sub list
		selectCtrl.options[0].selected = true;
	}
}

//si la primera feha es mayor a la segunda da error
function EsFechaMenor(dd,mm,aa,ddh,mmh,aah)
{ if (parseInt(aa,10) > parseInt(aah,10))
	{					//AŅO
        return false;
    }
	else
    {	
	  if (parseInt(aa,10) < parseInt(aah,10)) 
	  {
	  	return true;
	  }
	  else
	  { 
		if (parseInt(mm,10) > parseInt(mmh,10))
		{					 			//MES
			return false;
		}
		else
		{ 
		  if (parseInt(mm,10) < parseInt(mmh,10))
		    { 
			   return true;
			}
			else
			{ 
			if (parseInt(dd,10) > parseInt(ddh,10))
			   {					 			//DIA
				return false;
				}
				else
				{ 
				  if (parseInt(dd,10) < parseInt(ddh,10))
				    {
					  return true;
					}
					else
					{
    			      return true;
					}
				}
			}								
		}
 	 }
							
   }

}


<!-- Begin

// Cookie Functions  ////////////////////  (:)



// Set the cookie.

// SetCookie('your_cookie_name', 'your_cookie_value', exp);



// Get the cookie.

// var someVariable = GetCookie('your_cookie_name');



var expDays = 100;

var exp = new Date(); 

exp.setTime(exp.getTime() + (expDays*24*60*60*1000));



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 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] : null;  

	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" : "");

}



// cookieForms saves form content of a page.



// use the following code to call it:

//  <body onLoad="cookieForms('open', 'form_1', 'form_2', 'form_n')" onUnLoad="cookieForms('save', 'form_1', 'form_2', 'form_n')">



// It works on text fields and dropdowns in IE 5+

// It only works on text fields in Netscape 4.5





function cookieForms() {  

	var mode = cookieForms.arguments[0];

	

	for(f=1; f<cookieForms.arguments.length; f++) {

		formName = cookieForms.arguments[f];

		

		if(mode == 'open') {	

			cookieValue = GetCookie('saved_'+formName);

			if(cookieValue != null) {

				var cookieArray = cookieValue.split('#cf#');

				

				if(cookieArray.length == document[formName].elements.length) {

					for(i=0; i<document[formName].elements.length; i++) {

					

						if(cookieArray[i].substring(0,6) == 'select') { document[formName].elements[i].options.selectedIndex = cookieArray[i].substring(7, cookieArray[i].length-1); }

						else if((cookieArray[i] == 'cbtrue') || (cookieArray[i] == 'rbtrue')) { document[formName].elements[i].checked = true; }

						else if((cookieArray[i] == 'cbfalse') || (cookieArray[i] == 'rbfalse')) { document[formName].elements[i].checked = false; }

						else { document[formName].elements[i].value = (cookieArray[i]) ? cookieArray[i] : ''; }

					}

				}

			}

		}

				

		if(mode == 'save') {	

			cookieValue = '';

			for(i=0; i<document[formName].elements.length; i++) {

				fieldType = document[formName].elements[i].type;

				

				if(fieldType == 'password') { passValue = ''; }

				else if(fieldType == 'checkbox') { passValue = 'cb'+document[formName].elements[i].checked; }

				else if(fieldType == 'radio') { passValue = 'rb'+document[formName].elements[i].checked; }

				else if(fieldType == 'select-one') { passValue = 'select'+document[formName].elements[i].options.selectedIndex; }

				else { passValue = document[formName].elements[i].value; }

			

				cookieValue = cookieValue + passValue + '#cf#';

			}

			cookieValue = cookieValue.substring(0, cookieValue.length-4); // Remove last delimiter

			

			SetCookie('saved_'+formName, cookieValue, exp);		

		}	

	}

}

//PARA ROLLOVER
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
//FIN PARA ROLLOVER
//  End --

//PARA CONVERTIR A MILLAS
function Millas(kil)
{	largo = kil.length;
	mil = kil.substr(largo - 2, 2);
	alert(mil)
	if (mil == 'ML')
		{return 1;}
	else
		{return 0;}
}
//FIN PARA CONVERTIR A MILLAS

//PARA DESPLIEGUE DE LA FECHA DE HOY
function fecha()
{
        today = new Date();
        day = today.getDay();

        if ( day == 0 ) { document.write("Domingo "); }
        if ( day == 1 ) { document.write("Lunes "); }
        if ( day == 2 ) { document.write("Martes "); }
        if ( day == 3 ) { document.write("Mi&eacute;rcoles "); }
        if ( day == 4 ) { document.write("Jueves "); }
        if ( day == 5 ) { document.write("Viernes "); }
        if ( day == 6 ) { document.write("S&aacute;bado "); }

        today = new Date();
        year = today.getYear();
		if ( year <= 200) {year = year + 1900}
        if ( today.getMonth() == 0 ) { month = "Enero" }
        if ( today.getMonth() == 1 ) { month = "Febrero" }
        if ( today.getMonth() == 2 ) { month = "Marzo" }
        if ( today.getMonth() == 3 ) { month = "Abril" }
        if ( today.getMonth() == 4 ) { month = "Mayo" }
        if ( today.getMonth() == 5 ) { month = "Junio" }
        if ( today.getMonth() == 6 ) { month = "Julio" }
        if ( today.getMonth() == 7 ) { month = "Agosto" }
        if ( today.getMonth() == 8 ) { month = "Septiembre" }
        if ( today.getMonth() == 9 ) { month = "Octubre" }
        if ( today.getMonth() == 10 ) { month = "Noviembre" }
        if ( today.getMonth() == 11 ) { month = "Diciembre" }

       document.write( " ", today.getDate(), " de ", month, " ", year);
}

//FIN PARA DESPLIEGUE DE LA FECHA DE HOY

function openNewWindow(url, vent, param)
{
window.open(url,vent,param);	
}