// JavaScript Document
$(function(){
	$('#recomienda a').click(function(){
									
		loadSec('recomienda');							
									
	}) 
	
	$('#cont_info').load('secciones/inicio.php');
	
	
	loadMenu();
		
		   
})//end Dom

function loadSec(cualSec){
	
	switch(cualSec){
	   case "quienes":
	         loadQuienes();
	   break;
	    case "metodo":
	         loadMetodo();
	   break;
	   case "diferenciador":
			loadDiferenciador();
	   break;
	   case "socios":
	        loadSocios();
	   break;
	    case "contacto":
	        $('#cont_info').load('secciones/contacto.php');
	   break;
	      case "asesoria":
	        $('#cont_info').load('secciones/contacto.php?exp=true');
	   break;
	     case "recomienda":
	        $('#cont_info').load('secciones/recomienda.php');
	   break;
	}//endSwitch
}//end loadSec

function loadMetodo(){
	
$.ajax({
  
   url: 'secciones/metodologia.php',
  
   success: function(msg){
     $('div#cont_info').html(msg);
	 
   },
   complete: function(success){
   
   var currentBtn ="indi";
   
	
	$('#btn_individual a, #btn_empresa a')
		.css( {backgroundPosition: "0px 0px"} )
		.mouseover(function(){
		if(currentBtn != $(this).attr("id")){
			$(this).css( {backgroundPosition: "0px -19px"} )
		}//end if
		})
		.mouseout(function(){
		if(currentBtn != $(this).attr("id")){
			$(this).css( {backgroundPosition: "0px 0px"} )
		}//end if
		
		}).click(function(){
		
	 		if(currentBtn != $(this).attr("id")){
				 //alert(currentBtn)
				$("#"+currentBtn).css( {backgroundPosition: "0px 0px"} )
				
				
				currentBtn = $(this).attr("id");
				$(this).css({backgroundPosition: "0px -19px"});
				
				switch($(this).attr("id")){
					case"indi":
					//$('#cont_metodo').load('secciones/individual.php');
					loadIndividual();
					break;
					case"emp":
					$('#cont_metodo').load('secciones/empresa.php');
					break;
				}//end Switch
				
		
			}//end if
			
	});	//.click function  
	
	loadIndividual();
   $('#btn_individual a').css( {backgroundPosition: "0px -19px"} )
   }//end function complete
 });//ajax

	
}//end function loadMetodo

function loadQuienes(){
	
$.ajax({
  
   url: 'secciones/quienes.php',
  
   success: function(msg){
     $('div#cont_info').html(msg);
	 
   },
   complete: function(success){
   
   var currentActive ="som";
   
	
	$('#somos a, #valores a, #clientes a')
		.css( {backgroundPosition: "0px 0px"} )
		.mouseover(function(){
		if(currentActive != $(this).attr("id")){
			$(this).css( {backgroundPosition: "0px -19px"} )
		}//end if
		})
		.mouseout(function(){
		if(currentActive != $(this).attr("id")){
			$(this).css( {backgroundPosition: "0px 0px"} )
		}//end if
		
		}).click(function(){
		
	 		if(currentActive != $(this).attr("id")){
				 //alert(currentBtn)
				$("#"+currentActive).css( {backgroundPosition: "0px 0px"} )
				
				
				currentActive = $(this).attr("id");
				$(this).css({backgroundPosition: "0px -19px"});
				
				
				switch($(this).attr("id")){
					case"som":
					//$('#cont_quienes').load('secciones/somos.php');
					 loadSomos();
					break;
					case"val":
					
					$('#cont_quienes').load('secciones/valores.php');
					break;
					case"cli":
					loadClientes();
					break;
				}//end Switch
		
			}//end if	
			
	});	//.click function  
	 loadSomos();
	// $('#cont_quienes').load('secciones/somos.php');
     $('#somos a').css( {backgroundPosition: "0px -19px"} );
	 
   }//end function complete
   
 });//ajax

}//end loadQuienes

function loadIndividual(){
	$.ajax({
	
		url:'secciones/individual.php',
		
		success:function(msg){
			$('#cont_metodo').html(msg);
		},
		
		complete:function(success){

			 loadswfInd();
			
		}//end complete
	
		   
	});//end Ajax
	
}//end loadIndividual

function loadSomos(){
	$.ajax({
	
		url:'secciones/somos.php',
		
		success:function(msg){
			$('#cont_quienes').html(msg);
		},
		
		complete:function(success){
			 $('#btn_cobertura a').click(function(){
												  
				 loadCobertura();
				 
	          });
			
		}//end complete
	
		   
	});//end Ajax
	
}//end loadSomos

function loadCobertura(){
	$.ajax({
	
		url:'secciones/cobertura.php',
		
		success:function(msg){
			$('#cont_quienes').html(msg);
		},
		
		complete:function(success){
			
			 $('#btn_back a').mouseover(function(){
			      $(this).css( {backgroundPosition: "0px -21px"} )
			
		     }).mouseout(function(){
			      $(this).css( {backgroundPosition: "0px 0px"} )
			
		     }) 
			 .click(function(){
				loadSomos();
				 
	          });
			
			 loadSWF();
			
		}//end complete
	
		   
	});//end Ajax
	
}//end loadCobertura

function loadDiferenciador(){
	$.ajax({
	
		url:'secciones/diferenciador.php',
		
		success:function(msg){
			$('div#cont_info').html(msg);
		},
		
		complete:function(success){
			 loadSWfDIF()
			
		}//end complete
	
		   
	});//end Ajax
	
}//end loadDiferenciador


function loadClientes(){
	$.ajax({
	
		url:'secciones/clientes.php',
		
		success:function(msg){
			$('#cont_quienes').html(msg);
		},
		
		complete:function(success){
			loadSwfClientes();
			
		}//end complete
	
		   
	});//end Ajax
	
}//end loadClientes



function loadSocios(){
	$.ajax({
	
		url:'secciones/socios.php',
		
		success:function(msg){
			$('#cont_info').html(msg);
		},
		
		complete:function(success){
			loadSwfSocios();
			
		}//end complete
	
		   
	});//end Ajax
	
}//end loadClientes



function paginacion(num){
	// $('#cont_info').load('secciones/noti.php?pagina='+num);
	 
	 
	 $.ajax({
		
				url:'secciones/noti.php?pagina='+num,
				
				success: function(msg){
					
				 $('#cont_info').html(msg)
				 
				},
				
				complete:function(success){
	
				$('.boton').click(function() {
						
						if($(activo).attr('id') != ""){
							
							$(activo).next().slideToggle('normal');
						
						};
						
						if($(this).attr('id') == $(activo).attr('id')){
							
							activo="";
							
						}else{
							
							$(this).next().slideToggle('normal',function(){showVdo(); showText();});

							 activo=this;	
 
							};

						return false;
				});//END CLICK CLASS BOTON
					
		   }//END COMPLETE
		})//END AJAX
	 
}

function sentTo(){
	$.ajax({
				type: "POST",
				url: "secciones/mail.php",
				data: "nombre="+document.formulario.name.value+"&correo="+document.formulario.mail.value+"&telefono="+document.formulario.phone.value+"&asunto="+document.formulario.asuntos.value+"&mensaje="+document.formulario.message.value,
				
				success: function(datos){

					document.formulario.name.value = "";
					document.formulario.mail.value = "";
					document.formulario.phone.value = "";
					document.formulario.message.value = "";
					
					$('#msg').html(datos);
					
			  }
		});

}
function Reset(){
	if(document.getElementById("msg").innerHTML != ""){
	    document.getElementById("msg").innerHTML = "";
	}
}



function sentToFriend(){
	$.ajax({
				type: "POST",
				url: "secciones/sendFriend.php",
				data: "tunombre="+document.recAmigo.yourname.value+"&tucorreo="+document.recAmigo.yourmail.value+"&nombreAmigo="+document.recAmigo.nameFriend.value+"&mailAmigo="+document.recAmigo.mailFriend.value,
				success: function(datos){
					
					
					document.recAmigo.yourname.value = "";
					document.recAmigo.yourmail.value = "";
					document.recAmigo.nameFriend.value = "";
					document.recAmigo.mailFriend.value = "";

					
					$('#msg').html(datos);
					
			  }
		});

}


/*---------------------------
     CARGAMOS LA GALERIA
------------------------------*/
function loadPic(cualpic){
	
	alert(cualpic);
	
	$('.holder_pic').replaceWith('<div class="holder_pic"></div>');
	
     //$('#holder_pic').css("display","block");
	
	  var img = new Image();
	  
	  // wrap our new image in jQuery, then:
	  $(img)
		// once the image has loaded, execute this code
		.load(function () {
		  // set the image hidden by default    
		 //$(this).hide();
		
		  // with the holding div #loader, apply:
		  $('.holder_pic')
		    .css("display","block")
			// remove the loading class (so no background spinner), 
			//.removeClass('loading')
			// then insert our image
			.append(this);
		
		  // fade our image in to create a nice effect
		  $(this).fadeIn();
		})
		
		// if there was an error loading the image, react accordingly
		.error(function () {
		  // notify the user that the image could not be loaded
		}).attr('src', 'ADMIN/'+cualpic);
		
	
}





var currentId = "";
var currentVdo = "";
var activo="";

function loadSem(idSem){
	
		$.ajax({
		
				url:'secciones/sem.php?id_sem='+idSem,
				
				success: function(msg){
					
				 $('#cont_info').html(msg)
				 
				},
				
				complete:function(success){
				
					
				$('.boton').click(function() {
						
						if($(activo).attr('id') != ""){
							
							$(activo).next().slideToggle('normal');
							
						
						
						};
						
						if($(this).attr('id') == $(activo).attr('id')){
							
							activo="";
							
						}else{
							
							$(this).next().slideToggle('normal',function(){showVdo(); showText();});
							 
							
							 activo=this;	
							 
								 
							};
							
					
						
						return false;
				});//END CLICK CLASS BOTON
					
			
				   if(nota && nota != ""){
					
					  sub_activo=activarMenu(nota);
					  currentId = nota;
					  activo = sub_activo;
					  showVdo();
					  showText();
					  
				   }//end if nota
		   }//END COMPLETE
		})//END AJAX


}//END LOADSEM
/*
window.onload=function(){
		$("div#mlateral-contenido").height($("div#derecha").height());
	}
*/
//////////////////////////////////////////////////////////////////////////////////////
/// para activar el menu de la pagina que estoy viendo
//////////////////////////////////////////////////////////////////////////////////////
function activarMenu(sec){
	
	if(sec!="none"){
		
		$('#sec'+sec).next().slideToggle('normal');
		
		return $("#sec"+sec+".boton");
		
	}
}

function idVdo(id){
	
	if(currentId != ""){
	   $('#myVdo'+currentId).hide();
	}
	currentId = id;
	
}

function showVdo(){
		
	$('#myVdo'+currentId).show("slow");
	
	currentVdo = $('#myVdo'+currentId);
	
}

function showText(){
		
		$('.cont_texto').css( {visibility: "visible"});
	
}




var currentIdNot = "";
var activoNot="";

function loadNot(idNot){
	
		$.ajax({
		
				url:'secciones/noti.php?id_not='+idNot,
				
				success: function(msg){
					
				 $('#cont_info').html(msg)
				 
				},
				
				complete:function(success){
				
					
				$('.boton').click(function() {
						
						if($(activoNot).attr('id') != ""){
							
							$(activoNot).next().slideToggle('normal');

						};
						
						if($(this).attr('id') == $(activoNot).attr('id')){
							
							activoNot="";
							
						}else{
							
							$(this).next().slideToggle('normal',function(){ showText();});

							 activoNot=this;	

							};
						
						return false;
				});//END CLICK CLASS BOTON
					
			
				   if(noti && noti != ""){
					  sub_activoNot=activarMenu(noti);
					  currentIdNot = noti;
					  activoNot = sub_activoNot;
					  showText();
					  
				   }//end if nota
		   }//END COMPLETE
		})//END AJAX


}//END LOADSEM