// JavaScript Document
function parametros(url){
	var ret = new Object;
	var pos = url.indexOf("?");
	if(pos > 0) {
		url = url.substring(pos+1,url.length);
		var arraux = url.split("&");
		for(var i = 0; i < arraux.length; i++){
			var biv = arraux[i].split("=");
			ret[biv[0]] = biv[1];
		}
	}
	return ret;
}

function cpopup(url){
	window.open("popup.php?url="+url, "", "location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=1,height=200,width=200");
}

function mensaje_s(txt){
	$('#txtaviso').html(txt);
	$('#txtaviso').stop().animate({top:0},'fast','linear');
}

function mensaje_h(){
	$('#txtaviso').stop().animate({top:-17},'fast','linear');	
}

function cleartxt(obj, txt){
	if(obj.val() == txt){
		obj.val("");	
	}
}

function rewritetxt(obj, txt){
	if(obj.val() == ""){
		obj.val(txt);	
	}
}

function micuenta(x){
	$('#tmicuenta').attr('src','imgs/rr' + x + '.jpg'); 	
	$('[id^="micuenta_"]').hide();
	$('#micuenta_' + x).show();
	$('#cpagina').val(x);
}

function calcular_edad(fecha){
    hoy = new Date()
    var array_fecha = fecha.split("/")

	if (array_fecha.length!=3)
       return false

    if (isNaN(array_fecha[2]))
       return false

    if (isNaN(array_fecha[1]))
       return false

    if (isNaN(array_fecha[0]))
       return false

    if (array_fecha[2] <= 99)
       array_fecha[2] += 1900

    edad = hoy.getFullYear() - array_fecha[2] - 1; //-1 porque no se si ha cumplido aņos ya este aņo

    if (hoy.getMonth() + 1 - array_fecha[1] < 0) //+ 1 porque los meses empiezan en 0
       return edad
    if (hoy.getMonth() + 1 - array_fecha[1] > 0)
       return edad+1

    if (hoy.getUTCDate() - array_fecha[0] >= 0)
       return edad + 1

    return edad
}

function obj(id){
	return $("#" + id);
}
function lnk(l){
	document.location=l;
}
function chgClass(id, newClass){
 obj(id).removeClass().addClass(newClass);
}

function pulldownClick(id){
	var cmd = obj("pull_" + id);
	var block = obj("block_" + id);
	if(cmd.attr("class") == "pulldown"){
		cmd.removeClass().addClass("pulldown_closed");
		block.hide("fast");
	}else{
		$('[id^="pull_"]').removeClass().addClass("pulldown_closed");
		cmd.removeClass().addClass("pulldown");
		$('[id^="block_"]').hide("fast");
		block.show("fast");			
	}
}


