	function pageload(hash){  
		var cache_not=Math.random();  
		if(hash){  		
			var1 = hash.split('-');
			var txt;
			if(var1.length  == 2){
				txt = "?id="+var1[1];
			}else if(var1.length  == 3){
				txt = "?id="+var1[1]+"&obs="+var1[2];	
			}else if(var1.length  == 1){
				txt = ""
			}
			
		$("#content").fadeOut(1).load("modulos/" + var1[0]+ ".php"+txt,function(){
				
				$("a[@rel='pag']").click(function(){  
					var hash = this.href;
					hash = hash.replace(/^.*#/, '');  
					$.historyLoad(hash);  
					return false;  
				});
				
				$("input[name='envio']").click(function(){
					if($("input[name='nombre']").val() == ""){
						alert("debe ingresar un nombre");
						$("input[name='nombre']").focus()
					}else{
						if($("input[name='email']").val() == ""){
							alert("debe ingresar un email");
							$("input[name='email']").focus()
						}else{
							if($("input[name='telefono']").val() == ""){
								alert("debe ingresar un telefono");
								$("input[name='telefono']").focus()
							}else{
								$.post('modulos/correo.php',{nombre:$("input[name='nombre']").val(),
												 telefono:$("input[name='telefono']").val(),
												 email:$("input[name='email']").val(),
												 sociedad:$("input[name='sociedad']").val(),
												 mensaje:$("textarea[name='mensaje']").val()},function(data){
													$("input[name='nombre']").val("");	
													$("input[name='telefono']").val("");
													$("input[name='email']").val("");
													$("input[name='sociedad']").val("");
													$("textarea[name='mensaje']").val("");
												});
							}	
						}		
					}									
														
					
					return false;						
				});
				
				$("#btn_bsq").click(function(){
					if($("input[name='nomemp']").val() == ""){
						alert("Debe Ingresar un valor a a buscar");
						$("input[name='nomemp']").focus();
					}else{
						cAR = "-";
						cR = "*";
						vod = $("input[name='nomemp']").val().split(cAR).join(cR);
						hash = "asociados2-1-"+vod;
						$.historyLoad(hash); 
					}
					
					return false;
				});
				
				$("select[name='rubro']").change(function(){
					if($("select[name='rubro']").val() == ""){
						alert("Debe Seleccionar un rubro");
						$("select[name='rubro']").focus();
					}else{
						hash = "asociados3-1-"+$("select[name='rubro']").val();
						$.historyLoad(hash); 
					}
					
					return false;
				});
			}).fadeIn('slow');
			
		}  
		else{
			$("#content").load("modulos/portada.php",function(){
				return false;
			});
		} 
		
	}

$(document).ready(function(){
	
		$.historyInit(pageload);  


		$(".nav")
			.superfish({
				animation : { opacity:"show",height:"show"}
			})
			.find(">li:has(ul)")
				.mouseover(function(){
					$("ul", this).bgIframe({opacity:false});
				})
				.find("a")
					.focus(function(){
						$("ul", $(".nav>li:has(ul)")).bgIframe({opacity:false});
					});
					
		$("#ir_top").hover(function(){
			$("#ir_top img").attr("src","img/btn_ir2.jpg");
		},function(){
			$("#ir_top img").attr("src","img/btn_ir1.jpg");
		});
		

		$("a[rel='menu']").click(function(){  
				var hash = this.href;  
				hash = hash.replace(/^.*#/, '');  
				$.historyLoad(hash);   
		});	
		
		$("a[rel='login']").click(function(){  
				$("input[name='user']").val();
				$("input[name='pass']").val();
				
				if($("input[name='user']").val() == "" || $("input[name='pass']").val() == ""){
					alert("Debe Ingresar Ambos Valores");	
				}else{
					$.post("modulos/login.php",{user:$("input[name='user']").val(),pass:$("input[name='pass']").val()},function(data){
						if(data == 0){
							alert("EL Nombre de Usuario y Clave no Coinciden");
						
						}else{
							top.location.href='cliente/index.php?log=1';//    Q('_'Q)
						}																									
					});
				}
				return false;
			
		});	
		$("a[@rel='none']").click(function(){  
			return false;  
		});
});


	

