// JavaScript Document
/*Funcion para el efecto de hoja doblada*/
$(document).ready(function(){
var isOperBar = false;
//Page Flip on hover
$("#pageflip").hover(function() {
		$("#pageflip img , .msg_block").stop()
			.animate({
				width: '307px', 
				height: '319px'
			}, 500); 
		} , function() {
		$("#pageflip img").stop() 
			.animate({
				width: '50px', 
				height: '52px'
			}, 220);
		$(".msg_block").stop() 
			.animate({
				width: '50px', 
				height: '50px'
			}, 200);
	});
	
	/*Aqui va la fuincionalidad de la SideBar*/
	$("#sideBar").click(function(){
		if(!isOperBar){
			$("#iconsideBar").stop().animate({"left": "+=40px"}, 500);
			$("#contentSideBar").animate({width: '40px'},500);
			$("#realContentSideBar").css('display','inline');
			isOperBar = true;
		}else{
			$("#iconsideBar").stop().animate({"left": "-=40px"}, 500);
			$("#contentSideBar").animate({width: '0px'},500);
			$("#realContentSideBar").css('display','none');
			isOperBar = false;
		}	 
	})
	
	/**/

	
});
/**/

/*validar campos mail*/
function sendMail(){

	var err = 0;
	var text = "";
	var nombre = $("#name").val();
	var er_name = /^([a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s|\.|-)+$/ 
	var company = $("#company").val();
	var phone = $("#phone").val();	
    var email = $("#email").val();
    var way = $("#way").val();
	var comments = $("#comments").val();
	

	if(nombre.length == 0){
		err++;
		text += "- Debes indicar su Nombre.\n";
	}
	
   if(nombre.length != 0){
	
	for(i=0;i<nombre.length;i++){
	  if(nombre.charAt(i) == "0" || nombre.charAt(i) == "1" || nombre.charAt(i) == "2" || nombre.charAt(i) == "3" || nombre.charAt(i) == "4" || nombre.charAt(i) == "5" || nombre.charAt(i) == "6" || nombre.charAt(i) == "7" || nombre.charAt(i) == "8" || nombre.charAt(i) == "9"){

		err++;
		text += "- El campo Nombre solo Acepta Letras.\n";
	  }
    }
   }

	
	if(company.length == 0){
		err++;
		text += "- Debes indicar su Compañia.\n";
	}	

	if(phone.length == 0){
		err++;
		text += "- Debes indicar su Tel&eacute;fono.\n";
	}	
	
	if(email.length == 0){
		err++
		text += "- Debes indicar su Email.\n";
	}else{
		if((email.indexOf('@', 0) == -1) || (email.indexOf('.', 0) == -1)){
			err++;
			text += "- Debes indicar un Email v&aacute;lido.\n";
		}
	}
	if(way == 0){
		err++;
		text += "- Debes indicar la forma de contactarnos.\n";
	}	

	if(comments.length == 0){
		err++;
		text += "- Debes indicar sus Comentarios.\n";
	}	
	
	//VALIDAMOS Verifica lo siguiente:
	if(err != 0){
		jAlert("<div align='center'></div><br /><div align='left'>"+text+"</div>","Verifique lo siguiente",function(){
			
		});
	}else{
		
		$("#btnSend").attr("disabled","disabled");
/*        $("#form").slideUp("slow").hide();
		var loadPage = "<div id='imgLoader' style='width:108px; height:48px;' align='center'><br /><img src='img/ajax-loader-2.gif' /></div>";
        $("#loading").html(loadPage);	*/
		
				// $("#MH").slideDown("slow");




 									$('#overlay').show();
					if(!$('#modal').is(':visible'))
									$('#modal').css('left','-260px')
	<!--				$('#modal').css('left','-260px')-->
							   .show()
							   .stop()
								   .animate({'left':'50%'}, 500);	
								   
								   
								   
				function hide(){
					$('#modal').stop()
							   .animate({'left':'150%'}, 500, function(){
									$(this).hide();
									$('#overlay').hide();
									$('#latest_post').empty();
							   });
				}
				
				/**
				* clicking on the cross hides the dialog
				*/
				$('#modal .close').bind('click',function(){
					hide();
				});	


	$("#name").val('');
	$("#company").val('');
	$("#phone").val('');
    $("#email").val('');
    $("#way").val('');
	$("#comments").val('');
		
			 $("#btnSend").removeAttr("disabled");
		 $.ajax({
		   type: "POST",
		   url: "includers/data/sendMail.php",
		   cache: false,
		   data: "name="+nombre+"&company="+company+"&phone="+phone+"&email="+email+"&way="+way+"&comments="+comments+"",
		   success: function(msg){
			  //alert(msg);

			  /*jAlert("<div align='center'>Usuario Creado!!</div><br />"+text,"Mensaje de Alerta",function(){
			  parent.location.href="index.php";
		      });*/
		
			 
		   }
		 });
	}
}



function send(){

				
					
						   

}

function IsNumber2(e) {
	
    tecla=(document.all) ? e.keyCode : e.which;
    //alert(tecla);
    //48
   // if(tecla<48 || tecla>57)
   //if(tecla!=44 || tecla!=46 || tecla!=48 || tecla!=49 || tecla!=50 || tecla!=51 || tecla!=52 || tecla!=53|| tecla>57)
   if (tecla==8) return true;
   if (tecla==0) return true;
   if (tecla==46) return true;
   //if (tecla==44) return true; ,,,
   if(tecla<48 || tecla>59)
   
   return false;
}


function validaTexto() {
	var nombre = $("#name").val();
	for(i=0;i<nombre.length;i++){
		
    	if(nombre.charAt(i)=="0" || nombre.charAt(i)=="1" || nombre.charAt(i)=="2" || nombre.charAt(i)=="3" || nombre.charAt(i)=="4" || nombre.charAt(i)=="5" || nombre.charAt(i)=="6" || nombre.charAt(i)=="7" || nombre.charAt(i)=="8" || nombre.charAt(i)=="9")
        jAlert("<div align='center'>El campo Nombre solo permite letras</div><br />Es incorrecto:"+nombre,"Verifique",function(){
	    });
		

	}
}












/*buscador*/
function searchWord(){
	var buscador = $("#buscador").val();
	//alert(buscador);
	if(buscador.length == 0){
		var text = "- Debe de ingresar una palabra.\n";
		jAlert("<div align='center'>Verifica lo siguiente:</div><br />"+text,"Mensaje de Alerta",function(){
			
		});
	}else{	
	location.href="index.php?idPage=busqueda&strSearch="+buscador+"";
	}
	//

}
function videoPostal(){

	tb_show(null,"videoP.php?KeepThis=true&amp;TB_iframe=true&amp;height=550&amp;width=850&amp;modal=true",false);

}
function closeTick(){
	self.parent.tb_remove();
}


//donde estamos 

function whereWeAre(){

	//tb_show(null,"modules/whereWeAre?KeepThis=true&amp;TB_iframe=true&amp;height=550&amp;width=850&amp;modal=true",false);

}


