$('#registro-de-pagos a').click(function(){
	$(this).toggleClass('active');
	$('.registro-wrap').toggle();
});

$('form#registro div:last-child, aside.col1 ul li:last-child, aside.col2 ul li:last-child').css('border-bottom','none');
$('form#registro div:last-child').css('text-align','right');

var userfield = $('form#login input[type="text"], form#login input[type="password"]')
$(userfield).focus(function() {
	$(this).css('background-image','none');
});

if ($('form#login input[type="text"], form#login input[type="password"]').val().length > 0) {
    $(userfield).css('background-image','none');
}

//$(function(){// on load
//    var userfield = $('form#login input[type="text"], form#login input[type="password"]')
//    userfield.focus(function() {
//        $(this).css('background-image','none');
//    }).each(function() {
//        if ($(this).val()!='') $(this).css('background-image','none');
//    })
//})

$('.error').fadeIn();

function getUrlVars() {
	var vars = {};
	var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		vars[key] = value;
	});
	return vars;
}

var thistab = getUrlVars()["tab"];

$(".tab_content").hide(); //Hide all content
if (thistab == undefined){
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
} else {
	$('#' + thistab).show(); //Show first tab content
	$('.' + thistab).addClass("active"); //Add "active" class to selected tab
}

//On Click Event
$("ul.tabs li").click(function() {

	$("ul.tabs li").removeClass("active"); //Remove any "active" class
	$(this).addClass("active"); //Add "active" class to selected tab
	$(".tab_content").hide(); //Hide all tab content

	var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
	$(activeTab).fadeIn('fast'); //Fade in the active ID content
	return false;
});



//On Click Event
$("ul.tabs li").click(function() {

	$("ul.tabs li").removeClass("active"); //Remove any "active" class
	$(this).addClass("active"); //Add "active" class to selected tab
	$(".tab_content").hide(); //Hide all tab content

	var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
	$(activeTab).fadeIn(); //Fade in the active ID content
	return false;
});

var path = window.location.pathname;
if (path == '/index.php' || path == '/') {
	$('li#inicio a').addClass('active');
}
else if (path == '/empresa.php') {
	$('li#empresa a').addClass('active');
}
else if (path == '/planes.php') {
	$('li#planes a').addClass('active');
}
else if (path == '/ventajas.php') {
	$('li#ventajas a').addClass('active');
}
else if (path == '/contacto.php') {
	$('li#contacto a').addClass('active');
}

$("#registro").validate({
	messages: {
		tipo: "Deposito o transferencia?",
		banco: "Seleccione un banco",
		fecha: "Seleccione una fecha",
		referencia: {
			required: "No. de deposito o transferencia?",
			number: "Solo acepta n&uacute;meros"
		},
		monto: {
			required: "Cual es el monto?",
			number: "Solo acepta n&uacute;meros"
		},
		factura: {
			number: "Solo acepta n&uacute;meros"
		}
	}
});

$("#contactoForm").validate({
	messages: {
		nombre: "Ingrese su Nombre",
		mensaje: "Ingrese su Mensaje",
		telefono: {
			number: "Ingrese un n&uacute;mero de tel&eacute;fono valido"
		},
		email: {
			required: "Ingrese su Email",
			email: "Debe ser tipo: nombre@dominio.com"
		}
	}
});

$("#pago").validate({
	messages: {
		nombre: "Persona encargada de entregar el pago",
		telefono: {
			required: "Ingrese su n&uacute;mero de tel&eacute;fono",
			number: "Ingrese un n&uacute;mero de tel&eacute;fono valido"
		},
		email: {
			required: "Ingrese su Email",
			email: "Debe ser tipo: nombre@dominio.com"
		},
		fecha2: "Seleccione la fecha y hora para pasar recogiendo por el pago",
		ciudad: "Seleccione la ciudad",
		direccion: "Ingrese la direcci&oacute;n donde retirar el pago"
	}
});


$("a.help").easyTooltip({
	tooltipId: "help",
	content: '<strong>Plan Inteligente:</strong> Afiliaci&oacute;n Bs. 399 y domiciliado a la tarjeta de cr&eacute;dito'
});

$('.msg').slideDown(function (){
	$(this).delay(5000).slideUp('fast');
});

$('#pago input#fecha2, #registro input#fecha').datetimepicker({
	ampm: true,
	dateFormat: 'dd/mm/yy',
	timeText: 'Hora:',
	hourText: 'Horas:',
	minuteText: 'Minutos:',
	currentText: 'Ahora',
	closeText: 'Aceptar',
	monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
	dayNames: ['Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado','Domingo'],
	dayNamesShort: ['Lu','Mar','Mier','Jue','Vie','Sab','Dom'],
	dayNamesMin: ['Lu','Mar','Mier','Jue','Vie','Sab','Dom']
});
