/*Google Analytics (BEGIN)*/
/*<script type="text/javascript">*/

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25038342-1']);
  _gaq.push(['_setDomainName', '.gob.ve']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
/*</script>*/
/*Google Analytics (END)*/

var addthis_config = {
          services_compact: 'facebook, twitter,  digg '
}
		
jQuery(document).ready(function() {
		
// Carrucel                
                jQuery('#galeria_carrucel').jcarousel();
                if($("#reproductor2").length!=0){
                            $('#video').jcarousel();
                } 
                
                $("#mycarousel, #mycarousel2").jcarousel();	        
				//Alerta 
                  $(".submitComentario").click(function(){                
                	jAlert("Lo siento, debes estar logueado para dejar un comentario");		
                })

				//Articulos relacionados
                $(".articulosRelacionadosCont a.closeArticulosRelacionados").click(function(){
                        $(".articulosRelacionadosCont").fadeOut();
                        return false;
                });
                
                
                 $(".BarraArticulos a").toggle(
                     function () {
                                $(".articulosRelacionadosCont").fadeIn();
                                return false;
                     },
                     function () {
                                $(".articulosRelacionadosCont").fadeOut();
                                return false;
                     }
                   );
                
			// Recupera contrasena
                
           $("#recuperaContrasena").click(function(){
                                $("#recuperaContrasenaCont").fadeIn();
                                return false
              })                     
                $("#recuperaContrasenaCont a").click(function(){
                                $("#recuperaContrasenaCont").fadeOut();
                                return false
                })

 // Datepicker        
 /*       if($(".accordionBusqueda").length!=0){
                $('#dateDesde,#dateHasta').datepicker($.datepicker.regional['es']);
                $('#dateDesde,#dateHasta').datepicker({
                inline: false
                });
	} */    
          
//footer
                  $(".masPie").hide();
                
                $(".cerrarPie").toggle(
                     function () {
                                 $(".masPie").slideDown();
                                 $(".cerrarPie").text("-");
				 return false
                     },
                     function () {
                                $(".masPie").slideUp();
                                 $(".cerrarPie").text("+");
				 return false
                                
                     }
                   );
                
// Reproductor Videos
                $(".imgVideo").click(function(){
                                var video = $(this).attr("rel");
                                var titulo = $(this).attr("tituloVideo");
                                var descripcion = $(this).attr("descripcionVideo");
                                var html ='<object width="611" height="416">';
                                html = html + '<param name="movie" value="/home/videos/player01.swf?width=611&height=416&movie_url='+video+'"></param>';
                                html = html + '<param name="allowFullScreen" value="true"></param>'; 				
                                //html = html + '<param name="FlashVars" value="estado='+off+'"></param>';
                                html = html + '<param name="allowscriptaccess" value="always"></param>'; 
                                html = html + '<embed src="/home/videos/player01.swf?width=611&height=416&movie_url='+video+'"  type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="611" height="416"></embed>'; 
                                html = html + '</object>';
                             //   alert(html);
                                $("#reproductor").html(html);
                                $(".Ficha_content h3").text(titulo);
                                $(".Ficha_content p").text(descripcion);
                                return false
                });	 
			   $("#video a").click(function(){
					var imgBig =$(this).attr("href");
					$(".FichaImg").attr("src", imgBig);
					return false
				})
			  
			   $("#galeria_carrucel a").click(function(){
			   
							var imgBig =$(this).attr("href");
							$(".FichaImg").attr("src", imgBig);
							var descrip =$(this).find("img").attr("alt");
							var titulo    =$(this).find("img").attr("title");
							$(".galeria_titulo").text(titulo);
							$(".galeria_descripcion").text(descrip);
							return false
				 })
          

                $("#tab2").hide();
                $("#tab2b").css("background","#fff")
                $("#tab1b").click(function(){
                            $("#tab1").fadeIn();    
                            $("#tab2").fadeOut();
                            $("#tab1b").css("background","#E4E4E4");
                            $("#tab2b").css("background","#fff")
                return false
                })
                
                $("#tab2b").click(function(){
                                $("#tab2").fadeIn();    
                                $("#tab1").fadeOut();    
                                $("#tab2b").css("background","#E4E4E4");
                                $("#tab1b").css("background","#fff")                             
                                return false
                })
                $(".accordionBusqueda h3").toggle(
                     function () {
                               $(".accordionBusqueda h3").addClass("active");
                               $(".accordionBusqueda table").slideDown()
                     },
                     function () {
                               $(".accordionBusqueda h3").removeClass("active");
                               $(".accordionBusqueda table").slideUp()
                     }
                   );
		
                $("#accordion").accordion({
                        header: "h3",
                        autoHeight: false,
                        collapsible: true,
                        animation: false
                });
                $("#first").click();
                
                // Accordion sin submenu
               $("div#accordion div:not(:has(ul)) h3 a").each(function(){
                       var html = $(this).html();
                      //$(this).replaceWith("<p>" + html + "</p>");
                      $(this).addClass("sinSub");
                      //$(this).replaceWith("<a class='sinSub' href='#'><span style='margin: 0px 0 0 0; display: block'>" + html + "</span></a>");
                      $(this).css("position", "absolute").css("top","7px");
                  
                   
               });
               $("div#accordion div:not(:has(ul)) h3 ").each(function(){
                       var html = $(this).html();
                       $(this).css({backgroundPosition: '0px -30px'});
                      $(this).css("position", "relative");
                                 
                });
                
                $(".sinSub").click(function(){
	                var link = $(this).attr("href");
			window.location.href = link;
			return false;
                });
                
		
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);
		

                $('.otrasciudades_cont a').click(function() {
                $(".seccion1").animate({"right": "-500px"}, "slow");	
                      $(".seccion2").animate({"right": "-500px"}, "slow");	
                      $(".seccion3").animate({"right": "-557px"}, "slow");	
                      $(".seccion4").animate({"right": "-614px"}, "slow");	
                return false;
                });
	
		//var rel = $(this).attr();
		
                $("#seccion1").toggle(
                          function () {
                                  $(".seccion1").animate({"right": "115px"}, "slow");
                                  $(".seccion2").animate({"right": "-500px"}, "slow");	
                                  $(".seccion3").animate({"right": "-557px"}, "slow");	
                                  $(".seccion4").animate({"right": "-614px"}, "slow");	
                                  $(this).attr("rel","1");
                          },
                          function () {
                                /*	if (rel=='1'){
                                                $(".seccion1").animate({"right": "-442px"}, "slow");
                                                $(this).attr("rel","0");
                                }*/
                                $(".seccion1").animate({"right": "-442px"}, "slow");
                                $(".seccion2").animate({"right": "-500px"}, "slow");	
                                $(".seccion3").animate({"right": "-557px"}, "slow");	
                                $(".seccion4").animate({"right": "-614px"}, "slow");							  
                          }
                        );
                                        
                $("#seccion2").toggle(
                          function () {
                                  $(".seccion1").animate({"right": "115px"}, "slow");
                                  $(".seccion2").animate({"right": "58px"}, "slow");	
                                  $(".seccion3").animate({"right": "-557px"}, "slow");	
                                  $(".seccion4").animate({"right": "-614px"}, "slow");	
                          },
                          function () {
                                  $(".seccion1").animate({"right": "-442px"}, "slow");
                                  $(".seccion2").animate({"right": "-500px"}, "slow");	
                                  $(".seccion3").animate({"right": "-557px"}, "slow");	
                                  $(".seccion4").animate({"right": "-614px"}, "slow");	
                          }
                        );		
                $("#seccion3").toggle(
                          function () {
                                  $(".seccion1").animate({"right": "115px"}, "slow");
                                  $(".seccion2").animate({"right": "58px"}, "slow");	
                                  $(".seccion3").animate({"right": "2px"}, "slow");	
                                  $(".seccion4").animate({"right": "-614px"}, "slow");	
                          },
                          function () {
                                  $(".seccion1").animate({"right": "-442px"}, "slow");
                                  $(".seccion2").animate({"right": "-500px"}, "slow");	
                                  $(".seccion3").animate({"right": "-557px"}, "slow");	
                                  $(".seccion4").animate({"right": "-614px"}, "slow");	
                          }
                        );
                $("#seccion4").toggle(
                          function () {
                                  $(".seccion1").animate({"right": "115px"}, "slow");
                                  $(".seccion2").animate({"right": "58px"}, "slow");	
                                  $(".seccion3").animate({"right": "2px"}, "slow");	
                                  $(".seccion4").animate({"right": "-54px"}, "slow");	
                          },
                          function () {
                                  $(".seccion1").animate({"right": "-442px"}, "slow");
                                  $(".seccion2").animate({"right": "-500px"}, "slow");	
                                  $(".seccion3").animate({"right": "-557px"}, "slow");	
                                  $(".seccion4").animate({"right": "-614px"}, "slow");	
                          }
                        );
					
                //pie
                $(".maslinks").hide();
                $(".botonmaslinks").toggle(
                          function () {
                                  $(".maslinks").slideDown();
                                  $(".botonmaslinks").text("-")
                          },
                          function () {
                                  $(".maslinks").slideUp();
                                        $(".botonmaslinks").text("+")
                          }
                        );	
                        //atajo1
          /*      $(".atajo1cont").hide();
                $(".atajo1").toggle(
                          function () {
                                  $(".atajo1cont").slideDown();
                          },
                          function () {
                                  $(".atajo1cont").slideUp();
                          }
                        );
                        
                $(".atajo2cont").hide();
                $(".atajo2").toggle(
                          function () {
                                  $(".atajo2cont").slideDown();
                          },
                          function () {
                                  $(".atajo2cont").slideUp();
                          }
                        );
                        
                $(".atajo3cont").hide();
                $(".atajo3").toggle(
                          function () {
                                  $(".atajo3cont").slideDown();
                          },
                          function () {
                                  $(".atajo3cont").slideUp();
                          }
                        );
                        
                $(".atajo4cont").hide();
                $(".atajo4").toggle(
                          function () {
                                  $(".atajo4cont").slideDown();
                          },
                          function () {
                                  $(".atajo4cont").slideUp();
                          }
                        );
                        
                $(".atajo5cont").hide();
                $(".atajo5").toggle(
                          function () {
                                  $(".atajo5cont").slideDown();
                          },
                          function () {
                                  $(".atajo5cont").slideUp();
                          }
                        ); */


//Encuestas


$("#encuestaGeneral_Tab2, #encuesta1ContainerTab2, #encuesta2ContainerTab2, #encuesta3ContainerTab2, #encuesta4ContainerTab2, #encuesta5ContainerTab2, #encuesta6ContainerTab2").hide()

//encuesta 1
                $("#encuestaGeneral_Tab1").css("background","#fff");
                $("#encuestaGeneral_Tab1, #encuestaGeneral_volver1").click(function(){
                               // alert("hi!");
                                $("#encuestaGeneral_Tab1").show();    
                                $("#encuestaGeneral_Tab2").hide();    
                                $("#encuesta_Tab2").css("background","#E4E4E4");
                                $("#encuesta_Tab1").css("background","#fff")                             
                                return false
                })
                $("#encuesta_Tab1,   #encuestaGeneral_ver2Tab").click(function(){
                                $("#encuestaGeneral_Tab2").show();    
                                $("#encuestaGeneral_Tab1").hide();    
                                $("#encuesta_Tab1").css("background","#E4E4E4");
                                $("#encuesta_Tab2").css("background","#fff")                             
                                return false
                })
//encuesta 2
                $("#encuesta1Tab1").css("background","#fff");
                $("#encuesta1Tab1").click(function(){
                                $("#encuesta1ContainerTab1").show();    
                                $("#encuesta1ContainerTab2").hide();    
                                $("#encuesta1Tab2").css("background","#E4E4E4");
                                $("#encuesta1Tab1").css("background","#fff")                             
                                return false
                })
                $("#encuesta1Tab2,  #ver2Tab1").click(function(){
                                $("#encuesta1ContainerTab2").show();    
                                $("#encuesta1ContainerTab1").hide();    
                                $("#encuesta1Tab1").css("background","#E4E4E4");
                                $("#encuesta1Tab2").css("background","#fff")                             
                                return false
                })
//encuesta 3
                $("#encuesta2Tab1").css("background","#fff");
                $("#encuesta2Tab1").click(function(){
                                $("#encuesta2ContainerTab1").show();    
                                $("#encuesta2ContainerTab2").hide();    
                                $("#encuesta2Tab2").css("background","#E4E4E4");
                                $("#encuesta2Tab1").css("background","#fff")                             
                                return false
                })
                $("#encuesta2Tab2,  #ver2Tab2").click(function(){
                                $("#encuesta2ContainerTab2").show();    
                                $("#encuesta2ContainerTab1").hide();    
                                $("#encuesta2Tab1").css("background","#E4E4E4");
                                $("#encuesta2Tab2").css("background","#fff")                             
                                return false
                })

//encuesta 4
                $("#encuesta3Tab1").css("background","#fff");
                $("#encuesta3Tab1").click(function(){
                                $("#encuesta3ContainerTab1").show();    
                                $("#encuesta3ContainerTab2").hide();    
                                $("#encuesta3Tab2").css("background","#E4E4E4");
                                $("#encuesta3Tab1").css("background","#fff")                             
                                return false
                })
                $("#encuesta3Tab2,  #ver3Tab1").click(function(){
                                $("#encuesta3ContainerTab2").show();    
                                $("#encuesta3ContainerTab1").hide();    
                                $("#encuesta3Tab1").css("background","#E4E4E4");
                                $("#encuesta3Tab2").css("background","#fff")                             
                                return false
                })

//encuesta 5
                $("#encuesta4Tab1").css("background","#fff");
                $("#encuesta4Tab2,  #ver4Tab1").click(function(){
                                $("#encuesta4ContainerTab1").show();    
                                $("#encuesta4ContainerTab2").hide();    
                                $("#encuesta4Tab2").css("background","#E4E4E4");
                                $("#encuesta4Tab1").css("background","#fff")                             
                                return false
                })
                $("#encuesta4Tab1,  #ver4Tab1").click(function(){
                                $("#encuesta4ContainerTab2").show();    
                                $("#encuesta4ContainerTab1").hide();    
                                $("#encuesta4Tab1").css("background","#E4E4E4");
                                $("#encuesta4Tab2").css("background","#fff")                             
                                return false
                })
//encuesta 6
                $("#encuesta5Tab1").css("background","#fff");
                $("#encuesta5Tab1,  #ver5Tab1").click(function(){
                                $("#encuesta5ContainerTab1").show();    
                                $("#encuesta5ContainerTab2").hide();    
                                $("#encuesta5Tab2").css("background","#E4E4E4");
                                $("#encuesta5Tab1").css("background","#fff")                             
                                return false
                })
                $("#encuesta5Tab2").click(function(){
                                $("#encuesta5ContainerTab2").show();    
                                $("#encuesta5ContainerTab1").hide();    
                                $("#encuesta5Tab1").css("background","#E4E4E4");
                                $("#encuesta5Tab2").css("background","#fff")                             
                                return false
                })

//encuesta 7
                $("#encuesta6Tab1").css("background","#fff");
                $("#encuesta6Tab1,  #ver6Tab1").click(function(){
                                $("#encuesta6ContainerTab1").show();    
                                $("#encuesta6ContainerTab2").hide();    
                                $("#encuesta6Tab2").css("background","#E4E4E4");
                                $("#encuesta6Tab1").css("background","#fff")                             
                                return false
                })
                $("#encuesta6Tab2").click(function(){
                                $("#encuesta6ContainerTab2").show();    
                                $("#encuesta6ContainerTab1").hide();    
                                $("#encuesta6Tab1").css("background","#E4E4E4");
                                $("#encuesta6Tab2").css("background","#fff")                             
                                return false
                })

//encuesta costado LATERAL
                $("#ResultadosEncuestaSidebar").hide();

		$(".Encuesta .BotonEnviar").click(function(){
			$(".Encuesta .Opcion").hide();
			$("#ResultadosEncuestaSidebar").show();
			return false;
		})

	        $("#volverSidebar").click(function(){
                         $(".Encuesta .Opcion").show();
			 $("#ResultadosEncuestaSidebar").hide();
                         return false
                })

                                      
 //min font size
	var min=9; 	

	//max font size
	var max=16;	
	
	//grab the default font size
	var reset = $('p').css('fontSize'); 
	
	//font resize these elements
	var elm = $('p, .notas_lista h2');  
	
	//set the default font size and remove px from the value
	var size = str_replace(reset, 'px', ''); 
	
	//Increase font size
	$('a.fontSizePlus').click(function() {
		//alert("si")
		//if the font size is lower or equal than the max value
		if (size<=max) {
			
			//increase the size
			size++;
			
			//set the font size
			elm.css({'fontSize' : size});
		}
		
		//cancel a click event
		return false;	
		
	});


                

	$('a.fontSizeMinus').click(function() {

		//if the font size is greater or equal than min value
		if (size>=min) {
			
			//decrease the size
			size--;
			
			//set the font size
			elm.css({'fontSize' : size});
		}
		
		//cancel a click event
		return false;	
		
	});
	
	//Reset the font size
	$('a.fontReset').click(function () {
		
		//set the default font size	
		 elm.css({'fontSize' : reset});		
	});
        // Datepicker  
		/*
if($(".accordionBusqueda").length>0){
                $('#dateDesde,#dateHasta').datepicker({
                                inline: false
                });
}
               	
	    $('.news-container').vTicker({
		speed: 500,
		pause: 5000,
		showItems: 1,
		animation: false,
		mousePause: true,
		height: 0
	     });    
*/

		
});
//A string replace function
function str_replace(haystack, needle, replacement) {
	var temp = haystack.split(needle);
	return temp.join(replacement);
}

//New functions for the events registration
function findMe () {
	$("findMeForm").submit();
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
	return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
	return "";
	}
	else{
	return TRIM_VALUE;
	}
} 
	function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
	return"";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(0,iTemp +1);
	break;
	}
	iTemp = iTemp-1;
	
	} 
	return strTemp;
} 
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(iTemp,v_length);
	break;
	}
	iTemp = iTemp + 1;
	} 
	return strTemp;
} 

function submitForm(page, form){
	var form = document.getElementById(form);
	form.action= "/home/" + page;
	//form.target= '_blank';
	form.submit();
}

function changeValue(page, campoId, valor, form){
	var campo = document.getElementById(campoId);
	campo.value = valor;			
	submitForm(page, form);
}

function changeOnlyValue(campoId, valor){
	var campo = document.getElementById(campoId);
	campo.value = valor;			
}

function changeValues(page, campoId1, valor1, campoId2, valor2, form){
	var campo1 = document.getElementById(campoId1);
	campo1.value = valor1;
	var campo2 = document.getElementById(campoId2);
	campo2.value = valor2;						
	submitForm(page, form);
}

function changeMoreValues(page, campoId1, valor1, campoId2, valor2, campoId3, valor3, form){
	var campo1 = document.getElementById(campoId1);
	campo1.value = valor1;
	var campo2 = document.getElementById(campoId2);
	campo2.value = valor2;
	var campo3 = document.getElementById(campoId3);
	campo3.value = valor3;						
	submitForm(page, form);
}

function changeFourValues(page, campoId1, valor1, campoId2, valor2, campoId3, valor3, campoId4, valor4, form){
	var campo1 = document.getElementById(campoId1);
	campo1.value = valor1;
	var campo2 = document.getElementById(campoId2);
	campo2.value = valor2;
	var campo3 = document.getElementById(campoId3);
	campo3.value = valor3;
	var campo4 = document.getElementById(campoId4);
	campo4.value = valor4;						
	submitForm(page, form);
}

function votar(idEncuesta, respuesta){
    if(respuesta == 0) {
        Sexy.alert("Por favor seleccione una de las opciones");
		$("#BotonEnviar").click(function(){
			$(".Encuesta .Opcion").show();
			$("#ResultadosEncuestaSidebar").hide();
			return false;
		})
    } else {
        $.post('encuestaaction.dot?idEncuesta=' + idEncuesta + '&respuesta=' + respuesta, function(data){
            $('#encuesta_resultados').html(data);
            }
        );

	$("#BotonEnviar").click(function(){
			$(".Encuesta .Opcion").hide();
			$("#ResultadosEncuestaSidebar").show();
			return false;
		})
    }
}

function votarEncuesta(idEncuesta, respuesta){
    $.post('encuestaaction.dot?idEncuesta=' + idEncuesta + '&respuesta=' + respuesta, function(data){
            $('#encuesta_resultados_principal').html(data);      
        }
    );	
}

function votarAnteriores(idEncuesta, respuesta, i){
    $.post('encuestaaction.dot?idEncuesta=' + idEncuesta + '&respuesta=' + respuesta, function(data){
            $('#encuesta_resultados_i').html(data);      
        }
    );
	ocultarDivs(i);
}

function ocultarDivs(i){
        $("#encuesta_tab2_" + i).show();    
        $("#encuesta_tab1_" + i).hide();
	$("#encuestaTab" + i).css("background","#E4E4E4");
	$("#encuesta_tab2_" + i).css("visibility","");                               
        return false
}

function mostrarDivs(i){
        $("#encuesta_tab1_" + i).show();    
        $("#encuesta_tab2_" + i).hide();
	$("#encuestaTab" + i).css("background","#fff");                           
        return false
}

/*
jQuery(function($){
        $.datepicker.regional['es'] = {
               closeText: 'Cerrar',
               prevText: '&#x3c;Ant',
               nextText: 'Sig&#x3e;',
               currentText: 'Hoy',
               monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
               'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
               monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
               'Jul','Ago','Sep','Oct','Nov','Dic'],
               dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
               dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
               dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
               weekHeader: 'Sm',
               dateFormat: 'dd/mm/yy',
               firstDay: 1,
               isRTL: false,
               showMonthAfterYear: false,
               yearSuffix: ''};
        $.datepicker.setDefaults($.datepicker.regional['es']);
});
*/
function changeLanguage( form,pagina ) {   
	var newIndex = form.fieldname.selectedIndex;   
        if ( newIndex == 0 ) {   
        	Sexy.alert('Por favor seleccione un idioma');  
        } else {   
                var idioma = form.fieldname.options[newIndex].value;
		var campo = document.getElementById(pagina);
		campo.value = idioma;
		form.submit();
        }   
}

function passFieldChanged () {
	var campo = document.getElementById("passChanged");
	campo.value = "true";
}

function validateSearchHome(formulario, campoBusqueda){
	var form = document.getElementById(formulario); 
//	var busqueda=document.getElementById(campoBusqueda);
	var busqueda=form.elements[campoBusqueda];
	var busqueda1=escape(form.elements[campoBusqueda].value);
	var RegExTexto = /^[A-Za-z+][\s[A-Za-z]+]*$/;
	var errorBusqueda = 'El Texto a buscar no es válido';  
	var mensajes = "";
	if ((busqueda1 =='')) {  
		mensajes =  errorBusqueda + '<br/>';
	}
	if(mensajes != ""){	
		Sexy.alert(mensajes);
	}else{
		form.submit();
	}
}

function validateLogin(formulario){
	var form = document.getElementById(formulario); 
	var usuario = document.getElementById("findMeEmailAddress");	
	var RegExPattern = /[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
	var errorUsuario = 'El usuario no es válido';  
	var mensajes = "";
	if ((usuario .value == '') || !(usuario .value.match(RegExPattern))) {  
		mensajes = errorUsuario + '<br/>';
	}
	if(mensajes != ""){	
		Sexy.alert(mensajes);
	}else{
		findMe();	
		form.submit();
	}
}

function validateForgotPassword(formulario){
	var form = document.getElementById(formulario); 
	var mail = document.getElementById("email");	
	var RegExPattern = /[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
	var errorUsuario = 'El mail no es válido';  
	var mensajes = "";
	if ((mail.value == '') || !(mail.value.match(RegExPattern))) {  
		mensajes = errorUsuario + '<br/>';
	}
	if(mensajes != ""){	
		Sexy.alert(mensajes);
	}else{	
		form.submit();
	}
}

function validateCampos() {
	var valor_captcha = '';
	var campo_captcha = document.getElementById("seccode");
        campo_captcha = campo_captcha.value;
        campo_captcha = campo_captcha.toUpperCase();
	campo_captcha = campo_captcha + '\n';
        $.post('../archivos/validate_captcha.jsp', { }, function(data) { valor_captcha = data; });
	var form = document.getElementById("dotRegistrationForm");
        var accept = 'Al registrarse usted est&aacute; de acuerdo con los t&eacute;rminos de uso y pol&iacute;ticas de privacidad del portal Gobierno en L&iacute;nea';
	var ok = 'Al registrarse usted está de acuerdo con los términos de uso y políticas de privacidad del portal Gobierno en Línea';
        //alert(accept);
	alert(ok);
	//Sexy.alert(accept);
	var mail = document.getElementById("emailAddress");
	var nombre= document.getElementById("firstName");
	var apellido= document.getElementById("lastName");
	var nacionalidad= document.getElementById("suffix");
	var password= document.getElementById("password");
	var country= document.getElementById("country");
	var RegExPattern = /[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
	var RegExTexto = /^[A-Za-z+][\s[A-Za-z]+]*$/;
	var RegExPassword = "(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$";
	var errorMail = 'El formato del Mail no es v&aacute;lido.';
	var errorNombre = 'El formato del Nombre no es v&aacute;lido.';  
	var errorApellido = 'El formato del Apellido no es v&aacute;lido.';  
	var errorNacionalidad = 'El formato de la Nacionalidad no es v&aacute;lido.';
	var errorCaptcha = 'El formato del Captcha no es v&aacute;lido.';
        var errorCaptchaCoincide = 'El captcha no coincide';
	var errorPassword = 'La contraseña debe tener entre 8 y 10 caracteres, por lo menos un digito y un alfanumérico, y no puede contener caracteres especiales';
	var errorCountry = 'El pa&iacute;s es obligatorio';
	var mensajes = "";
	if ((mail.value == '') || !(mail.value.match(RegExPattern))) {  
		mensajes = errorMail + '<br/>';
	}
	if ((nombre.value =='') || !(nombre.value.match(RegExTexto))) {  
		mensajes = mensajes + errorNombre + '<br/>';
	}
	if ((apellido.value =='') || !(apellido.value.match(RegExTexto))) {  
		mensajes = mensajes + errorApellido + '<br/>';
	}
	if ((nacionalidad.value =='') || !(nacionalidad.value.match(RegExTexto))) {  
		mensajes = mensajes + errorNacionalidad + '<br/>';
	}
	if ((password.value =='') || !(password.value.match(RegExPassword))) {  
		mensajes = mensajes + errorPassword + '<br/>';
	}
	if ((country.value == '')) {  
		mensajes = mensajes + errorCountry + '<br/>';
	}
	if ((campo_captcha == '')) {  
		mensajes = mensajes + errorCaptcha + '<br/>';
	}
	if (!(valor_captcha.match(campo_captcha))) {
		mensajes = mensajes + errorCaptchaCoincide + '<br/>';		
	}
	if(mensajes != ""){
		Sexy.alert(mensajes);
	}else{
		form.submit();
	}
}

function actualizarClima(tmax, tmin){
    $.post('tiempoaction.dot?tmax=' + tmax + '&tmin=' + tmin, function(data){
            $('#tiempo_ciudad').html(data);      
        }
    );	
}

function validateCarta() { 
	var form = document.getElementById("submitContentForm"); 
	var nombre = document.getElementById("nombreYApellido");
	var email = document.getElementById("emailCarta");
	var comentario = document.getElementById("comentario");
	var RegExPattern = /[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
	var RegExTexto = /^[A-Za-z+][\s[A-Za-z]+]*$/;
	var errorMail = 'El formato del Mail no es v&aacute;lido.';
	var errorNombre = 'El formato del Nombre no es v&aacute;lido.';  
	var errorComentario = 'El formato del Comentario no es v&aacute;lido.';  
	var mensajes = "";
	if ((email.value == '') || !(email.value.match(RegExPattern))) {  
		mensajes = errorMail + '<br/>';
	}
	if ((nombre.value =='') || !(nombre.value.match(RegExTexto))) {  
		mensajes = mensajes + errorNombre + '<br/>';
	}
	//if ((comentario.value =='') || !(comentario.value.match(RegExTexto))) {  
		//mensajes = mensajes + errorComentario + '<br/>';
	//}
	if(mensajes != ""){	
		Sexy.alert(mensajes);
	}else{
		form.submit();
	}
}

function validateSearch() { 
	var arrayForm = document.getElementsByName("SearchForm");
	var form = arrayForm[0]; 
	//var dateDesde = document.getElementById("dateDesde");
	//var dateHasta = document.getElementById("dateHasta");
	var RegExPattern = /^\d{1,2}\/\d{1,2}\/\d{2,4}$/;
	//var errorDateDesde = 'El formato de la fecha Desde no es v&aacute;lida.';
	//var errorDateHasta = 'El formato de la fecha Hasta no es v&aacute;lida.';  
	var mensajes = "";
	//if ((dateDesde.value == '') || !(dateDesde.value.match(RegExPattern))) {  
		//mensajes = errorDateDesde + '<br/>';
	//}
	//if ((dateHasta .value =='') || !(dateHasta .value.match(RegExPattern))) {  
		//mensajes = mensajes + errorDateHasta + '<br/>';
	//}
	if(mensajes != ""){	
		Sexy.alert(mensajes);
	}else{
		form.submit();
	}
}

function validateSearch(){
	var arrayForm = document.getElementsByName("SearchForm");
	var form = arrayForm[0]; 
	//var dateDesde = document.getElementById("dateDesde");
	//var dateHasta = document.getElementById("dateHasta");

	//if (isDate(dateDesde.value,"Desde") && isDate(dateHasta.value,"Hasta")){
		//if(dateHasta.value > dateDesde.value){
	        //if (compareDates(dateDesde.value,dateHasta.value) < 0) {
		//	form.submit();
		//}else{
		//	Sexy.alert("La fecha Desde no puede ser mayor que la fecha Hasta")
		//}
	//}
        form.submit();
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr, fecha){
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	//if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	//if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) 
                    strYr=strYr.substring(1);
	}
	if(strDay.length < 2){
		Sexy.alert("Por favor ingrese un d&iacute;a v&aacute;lido en la fecha " +fecha);
		return false;
	}
	if(strMonth.length < 2){
		Sexy.alert("Por favor ingrese un mes v&aacute;lido en la fecha " +fecha);
		return false;
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		Sexy.alert("El formato de la fecha "+fecha+" debe ser: dd/mm/yyyy");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		Sexy.alert("Por favor ingrese un d&iacute;a v&aacute;lido en la fecha " +fecha);
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		Sexy.alert("Por favor ingrese un mes v&aacute;lido en la fecha " +fecha);
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		Sexy.alert("Por favor ingrese un a&ntilde;o entre "+minYear+" and "+maxYear+ " en la fecha " + fecha);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		Sexy.alert("Por favor ingrese una fecha " +fecha+ " v&aacute;lida");
		return false;
	}
return true;
}

function compareDates(dtStrFrom, dtStrTo){

	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;
	var daysInMonth = DaysArray(12);
	
	//FROM
	var pos1From=dtStrFrom.indexOf(dtCh);
	var pos2From=dtStrFrom.indexOf(dtCh,pos1From+1);
	var strDayFrom=dtStrFrom.substring(0,pos1From);
	var strMonthFrom=dtStrFrom.substring(pos1From+1,pos2From);
	var strYearFrom=dtStrFrom.substring(pos2From+1);
	strYrFrom=strYearFrom;
	
	monthFrom=parseInt(strMonthFrom);
	dayFrom=parseInt(strDayFrom);
	yearFrom=parseInt(strYrFrom);
	
	
	//TO
	var pos1To=dtStrTo.indexOf(dtCh);
	var pos2To=dtStrTo.indexOf(dtCh,pos1To+1);
	var strDayTo=dtStrTo.substring(0,pos1To);
	var strMonthTo=dtStrTo.substring(pos1To+1,pos2To);
	var strYearTo=dtStrTo.substring(pos2To+1);
	strYrTo=strYearTo;
	
	monthTo=parseInt(strMonthTo);
	dayTo=parseInt(strDayTo);
	yearTo=parseInt(strYrTo);
	
	
	var f1 =  new Date(yearFrom, monthFrom, dayFrom);
	var f2 =  new Date(yearTo, monthTo, dayTo);
	return f1.getTime() - f2.getTime();
	
}

function cargarMunicipio(idEstado){
    $.post('municipioaction.dot?idEstado=' + idEstado, function(data){
            $('#mostrar_municipio').html(data);
	    cargarParroquias("sin_codigo");	   
        }
    );	
}

function cargarParroquias(idMunicipio){
    $.post('parroquiaaction.dot?idMunicipio=' + idMunicipio, function(data){
            $('#mostrar_parroquia').html(data); 
        }
    );	
}

function mostrarRegion(id){
	if(id == "pais_venezuela"){
		$("#mostrar_titulo_estado").show();                               
		$("#mostrar_titulo_parroquia").show();                               
		$("#mostrar_titulo_municipio").show();
		$("#mostrar_estado").show();                                                             
		$("#mostrar_parroquia").show();                               
		$("#mostrar_municipio").show();
	}else{
		$("#mostrar_titulo_estado").hide();                               
		$("#mostrar_titulo_parroquia").hide();                               
		$("#mostrar_titulo_municipio").hide();
		$("#mostrar_estado").hide();                                                             
		$("#mostrar_parroquia").hide();                               
		$("#mostrar_municipio").hide();
	}
        return false;
}


function getNoticias(pagina,language){
	$.post('ajax_noticias.dot?paginaNoticia=' + pagina + '&languageId=' + language, function(data){
			$('#ajax_noticias').html(data);
		}
	);
}
