	var selected_item_list = null;
// RED

	function valida_perfil()
	{
		var ok1 = valida_fecha();
		var ok2 = valida_acepta();
		if (ok2 != true || ok1 != true) {return false;}
	}
	function valida_fecha(){
		var fec = document.getElementById('FechaNacP').value;
		var ok = isDate(fec);
		
		if (ok == true) {document.getElementById('advice-fecha').style.display = 'none'; return true;}
		else {document.getElementById('advice-fecha').style.display = 'block'; return false;}
	}
	function valida_acepta()
	{
		if (document.getElementById('AceptaCondicionesP').checked == true) {document.getElementById('advice-acepta').style.display = 'none'; return true;}
		else {document.getElementById('advice-acepta').style.display = 'block'; return false;}
			
	}
	
	altura=0;
	function forzarFoco(){if (parent.getFoco()==1){focus(); parent.clearFoco();}}
	function checkAltura()
	{
		try{if (parent.getAltura()!=altura)	{scroll_red();	altura=parent.getAltura(); /* document.location.href = document.location.href;*/}}
		catch(err) { }
		setTimeout('checkAltura();', 500);	
	}
	function cambia_altura(){altura=0;}
	
	var altura_contenedor = parent.alto_frame();
/*
	function makeScrollbar_red(content,scrollbar,handle, horizontal, ignoreMouse){
 			
			var altura_contenedor = parent.alto_frame();
			altura_contenedor = altura_contenedor - 42;
			var altura_texto = document.getElementById('contenido_frame').offsetHeight;
			document.getElementById('contenedor_frame').style.height = altura_contenedor + "px";

			if ( altura_texto > altura_contenedor)
			{
				document.getElementById('scrollbar_red').style.height = altura_contenedor + "px"; document.getElementById('handle_red').style.height = 20 + "px"; 
				document.getElementById('scrollbar_red').style.width = "10px"; document.getElementById('handle_red').style.width = "14px";
				var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
				var slider = new Slider(scrollbar, handle, { steps: steps, mode: (horizontal?'horizontal':'vertical'), onChange: function(step){ var x = (horizontal?step:0); var y = (horizontal?0:step); content.scrollTo(x,y); } }).set(0);
				if( !(ignoreMouse) ){ $$(content, scrollbar).addEvent('mousewheel', function(e){	e = new Event(e).stop(); var step = slider.step - e.wheel * 30;	 slider.set(step);	}); }
				$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
			}
			else { document.getElementById('scrollbar_red').style.width = "0px"; document.getElementById('handle_red').style.width = "0px"; document.getElementById('scrollbar_red').style.height = "0px"; document.getElementById('handle_red').style.height = "0px";}
			
	}
	*/

	function scroll_red(){ 
		//makeScrollbar_red( $('contenedor_frame'), $('scrollbar_red'), $('handle_red') ); 
		altura_contenedor = parent.alto_frame();
		altura_contenedor = altura_contenedor - 42;
		document.getElementById('contenedor_frame').style.height = altura_contenedor + "px";
	};
	function altura(i) {
	//		alert(document.getElementById('contenedor_frame').style.height); 
	//		document.getElementById('contenedor_frame').style.height = i + "px"; 
	//		alert(document.getElementById('contenedor_frame').style.height);
	}
	

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){ return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); }
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	
//	var strMonth=dtStr.substring(0,pos1)
//	var strDay=dtStr.substring(pos1+1,pos2)
//	var strYear=dtStr.substring(pos2+1)

	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
//		alert("The date format should be : mm/dd/yyyy")
//		alert("La fecha introducida no es correcta")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
//		alert("La fecha introducida no es correcta")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
//		alert("La fecha introducida no es correcta")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
//		alert("La fecha introducida no es correcta")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
//		alert("La fecha introducida no es correcta")
		return false
	}
return true
}

