// JavaScript Document

// setTimeout("cierra_noticias()","5000");
var access = true;

$(document).ready(function(){
			
			var bodywidth = $("body").width();
			var bodyheight = $("body").height();
			
			cierra_noticias();
			
			$("#noticias").css("left",(bodywidth-255));
			
			var contenedor = $("#contenedor");
			var mover = "-773px"; // contenedor.css("left");
			
			$(window).resize(function(){
				width = $("body").width();
				$("#noticias").css("left",(width-255));
			})
			
			$("#contenedor_control").click(function(e){
				$("#apDiv2").hide();
				$("#contenedor").animate({left:'0px'},function(){
					 if (access){
						 	funciones.Nowinterblues('show');
					 }
				 });
				e.preventDefault();
			})
			
			$("#nosotros_los_embajadores").click(function(){
					
					var pos = contenedor.css("left");
					if (pos=="-773px"){
						$("#contenedor").animate({left:'0px'});
					}else{
						$("#contenedor").animate({left:mover});
					}
					
			})
			
			$(".cerrar").click(function(e){
				$("#buscador").css("display","block");
				$("#apDiv1").animate({top:'-180px'},function(){
						$("#contenedor").animate({left:mover}, function(){
																			$("#apDiv2").show();
								});
				});
				e.preventDefault();
				
			})
			
			
			// Noticias 
				
				$(".titulo_noticias").click(function(){
					acordeon('lista_noticias');
					var H = $('#lista_noticias').css('height');
					$('.jScrollPaneContainer').hide();
					if (H == '0px'){
						$('#lista_noticias').animate({ height : '450px' });
					}else{
						$('#lista_noticias').animate({ height : '0px' });
					}
					
				})
			
			
			$("#btn_buscar").click(function(){
				acordeon('box_buscar');
				$('.jScrollPaneContainer').hide();
				var H = $('#box_buscar').css('height');
					if (H == '0px'){
						if($.browser.msie)
							$('#box_buscar').animate({ height : '330px' });//.toggle("slide", { direction: "up" }, 1000);
						else
							$('#box_buscar').animate({ height : '295px' });//.toggle("slide", { direction: "up" }, 1000);
					}else{
						$('#box_buscar').animate({ height : '0px' }).hide();//.toggle("slide", { direction: "up" }, 1000);
					}
			})
			
			$("#btn_favorito").click(function(){
				acordeon('box_favorito');
				var H = $('#box_favorito').css('height');
					if (H == '0px'){
						$('#box_favorito').animate({ height : '296px' });
						$('.jScrollPaneContainer , #list_favoritos ').show();
						//.toggle("slide", { direction: "up" }, 1000);
					}else{
						$('#box_favorito').animate({ height : '0px' });
						$('.jScrollPaneContainer, #list_favoritos ').hide();
						//.toggle("slide", { direction: "up" }, 1000);
					}
			})
	<!-- End onload !-->
})

function cierra_noticias(){
	$("#contenedor_noticias").hide("slide", { direction: "up" }, 1000);
}


function PopWindow()
{
window.open('http://www.compartetufortuna.com/foro/','Foro','width=980,height=600,menubar=yes,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=no,top=0,left=0');
}

function acordeon(ActualId){
	$(".acordeon").each(function(){
				var Id = $(this).attr('id');
				if (Id!=ActualId){
							if ($(this).css("display")!='none'){
									var H = $(this).css("height");
									if (H !='0px'){
										$(this).animate({ height : '0px' }).css("display","none").hide();
									}
							}
				}
	})
}


function show_windows(caption , url_maps , change){
	
	
	if (!caption) caption = 'Comparte tu Fortuna';
	
	
	if (jQuery.browser.version.substr(0,3)=="8.0"){
		  if (change)	
			 	parent.iframecontent.mapaInterno();
			else{
				//alert(url_maps);
				tb_remove();
				tb_show(caption, url_maps, false);
			}
	}else{
		// alert("yeee");
		tb_remove();
		tb_show(caption, url_maps, false);
	}
	return false;
}

function show_windows2(caption , url_maps , change){
	if (!caption) caption = 'Comparte tu Fortuna';
	
	// 
	/*	
		if (change){
			alert(change);
			$('#thickbox').attr('href','css/thickbox"'+change+'.css');
		}
	*/
	
	tb_remove();
	tb_show2(caption, url_maps, false);
	//'#TB_inline?height='+((gheight*1)-5)+'&width='+((gwidth*1))+'&inlineId=map',true
	//change
}

function gload(glabel,lat,lon,gheight,gwidth){
			if(mapload(glabel,lat,lon,gheight,gwidth)){  //check to see if the map loaded up into the div
				//if so, then make the thickbox call:
				tb_show('quick map view: '+glabel, '#TB_inline?height='+((gheight*1)-5)+'&width='+((gwidth*1))+'&inlineId=map',true);  // opens the map_window div into thickbox
			}
		}

function registro(){
		tb_remove();
		$("#iframecontent").attr("src","registro.php?site=true");
		var pos = $("#contenedor").css("left");
		if (pos=="-773px"){
			$("#contenedor").animate({left:'0px'});
		}else{
			$("#contenedor").animate({left:mover});
		}
		
}