var  publi1;
var publi2;
var publi3;
var grafico;

var _idioma = "I";


jQuery.fn.focus_first = function() {
  var elem = $('input:visible', this).get(0);
  var select = $('select:visible', this).get(0);
  if (select && elem) {
    if (select.offsetTop < elem.offsetTop) {
      elem = select;
    }
  }
  var textarea = $('textarea:visible', this).get(0);
  if (textarea && elem) {
    if (textarea.offsetTop < elem.offsetTop) {
      elem = textarea;
    }
  }
  
  if (elem) {
    elem.focus();
  }
  return this;
}

function setIdioma(idioma){
    _idioma=idioma;
}

function guardar(){
    publi1 = jQuery("#publi1").html();
    publi2 =  jQuery("#publi2").html();
    publi3 = jQuery("#publi3").html();

    jQuery("#publi1").html('<img src="/images/layer/publi1.gif" alt="" />');
    jQuery("#publi2").html('<img src="/images/layer/publi2.gif" alt="" />');
    jQuery("#publi3").html('<img src="/images/layer/publi3.gif" alt="" />');
    //    jQuery("#Grafico").html('<img src="/images/layer/grafico.gif" alt="" />');
    jQuery("#centro1_c").hide()
}

function disablePopup(){
    jQuery("#backgroundPopup").fadeOut("slow");
    jQuery("#popupContact").fadeOut("slow");
    jQuery("#publi1").html(publi1);
    jQuery("#publi2").html(publi2);
    jQuery("#publi3").html(publi3);
    //    jQuery("#Grafico").html(grafico);
    jQuery("#centro1_c").show();
}
function loadPopup(){
    // alert("Load Pop-Up");
    jQuery("#backgroundPopup").css({"opacity": "0.7"});
    jQuery("#backgroundPopup").fadeIn("slow");
    jQuery("#popupContact").fadeIn("slow");

}
//centering popup
function centerPopup(){
    //    alert("Center Pop-Up");
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#popupContact").height();
	var popupWidth = jQuery("#popupContact").width();

	/*	jQuery("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	*/
	jQuery("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


jQuery(document).ready(function(){
/*
	if (jQuery.cookie('bnasearch') == null){
	    guardar()
		jQuery.cookie("bnasearch", "bnasearch", { expires: 1 });
	    centerPopup();
	    loadPopup();
	  	  setTimeout('disablePopup()', 25000);		
	}
	jQuery("#popupContact").click(function(){
		disablePopup();
		document.getElementById("txtKeyword").focus();
	    });
	    
	jQuery("#head_layer").click(function(){
		disablePopup();
		document.getElementById("txtKeyword").focus();
	});

	jQuery("#backgroundPopup").click(function(){
		disablePopup();
	});

	jQuery(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
*/
});

