function version_navegador() {
	navegador = new o_Navegador();
	
	if (navegador.nombre == "Microsoft Internet Explorer" && navegador.version < 6.9) {
		alert("Para usar el Mensajero debes tener un navegador \"Microsoft Internet Explorer 7.0\" o superior.");
		pagina_iexplorer();
		return false;
	}
}

function pagina_iexplorer() {
	abrir('http://www.microsoft.com/spain/windows/internet-explorer/',1,1,1,1,1,1,1,100,100,100,100,1);
}

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

var usuario_logeado = function(usuario){
	jQuery('#form_entrar').attr("disabled","disabled");
	jQuery('#form_usuario').attr("readonly","readonly").val(usuario);
	jQuery('#form_clave').attr("readonly","readonly").val("qwertyuiop");
	jQuery('#form_comentario').removeAttr("readonly");
	jQuery('#form_enviar').removeAttr("disabled");
}

jQuery(document).ready(function(){
	// por eventos
	jQuery('#panel_registrate').click(function () {
		if (version_navegador() == false) { return false; }
		
		jQuery('#siv_modal_container').siv_modal({
			AnchoContenedor: 720,
			AltoContenedor: 270,
			AnchoContenido : 720,
			AltoContenido: 270,
			Opcion: 1
		});
	});
	
	jQuery('#panel_olvide_clave').click(function () {
		if (version_navegador() == false) { return false; }
		
		jQuery('#siv_modal_container').siv_modal({
			AnchoContenedor: 720,
			AltoContenedor: 140,
			AnchoContenido : 720,
			AltoContenido: 140,
			Opcion: 2
		});
	});
	
	jQuery('#form_entrar').click(function () {
		jQuery('#form_entrar').attr('disabled','disabled');
		
		var usuario = jQuery('#form_usuario').val();
		var clave = jQuery('#form_clave').val();
		
		$.post('cvargas_mensajero/php/jquery_php.php', { opcion:3, usuario:usuario, clave:clave }, function(datos){
			jQuery('#cvargas_javascript').html(datos);
		});
	});
	
	jQuery('#form_enviar').click(function () {
		jQuery('#form_enviar').attr('disabled','disabled');
		
		var nick = jQuery('#form_nick').val();
		var comentario = jQuery('#form_comentario').val();
		
		$.post('cvargas_mensajero/php/jquery_php.php', { opcion:7, nick:nick, comentario:comentario }, function(datos){
			jQuery('#cvargas_javascript').html(datos);
		});
	});
	
	// por defecto
	jQuery('#form_usuario').removeAttr("readonly");
	jQuery('#form_clave').removeAttr("readonly");
	
	$.post('cvargas_mensajero/php/jquery_php.php', { opcion:6 }, function(datos){
		jQuery('#cvargas_javascript').html(datos);
	});
	
	var id_registro = getUrlVars()["id_registro"];
	var codigo_confirmacion = getUrlVars()["codigo_confirmacion"];
	if (id_registro != "" && codigo_confirmacion != "") {
		$.post('cvargas_mensajero/php/jquery_php.php', { opcion:9, id_registro:id_registro, codigo_confirmacion:codigo_confirmacion }, function(datos){
			jQuery('#cvargas_javascript').html(datos);
		});
	}
})
