/* Query.ScrollTo */
; (function($) { var m = $.scrollTo = function(b, h, f) { $(window).scrollTo(b, h, f) }; m.defaults = { axis: 'xy', duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1 }; m.window = function(b) { return $(window).scrollable() }; $.fn.scrollable = function() { return this.map(function() { var b = this, h = !b.nodeName || $.inArray(b.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!h) return b; var f = (b.contentWindow || b).document || b.ownerDocument || b; return $.browser.safari || f.compatMode == 'BackCompat' ? f.body : f.documentElement }) }; $.fn.scrollTo = function(l, j, a) { if (typeof j == 'object') { a = j; j = 0 } if (typeof a == 'function') a = { onAfter: a }; if (l == 'max') l = 9e9; a = $.extend({}, m.defaults, a); j = j || a.speed || a.duration; a.queue = a.queue && a.axis.length > 1; if (a.queue) j /= 2; a.offset = n(a.offset); a.over = n(a.over); return this.scrollable().each(function() { var k = this, o = $(k), d = l, p, g = {}, q = o.is('html,body'); switch (typeof d) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)) { d = n(d); break } d = $(d, this); case 'object': if (d.is || d.style) p = (d = $(d)).offset() } $.each(a.axis.split(''), function(b, h) { var f = h == 'x' ? 'Left' : 'Top', i = f.toLowerCase(), c = 'scroll' + f, r = k[c], s = h == 'x' ? 'Width' : 'Height'; if (p) { g[c] = p[i] + (q ? 0 : r - o.offset()[i]); if (a.margin) { g[c] -= parseInt(d.css('margin' + f)) || 0; g[c] -= parseInt(d.css('border' + f + 'Width')) || 0 } g[c] += a.offset[i] || 0; if (a.over[i]) g[c] += d[s.toLowerCase()]() * a.over[i] } else g[c] = d[i]; if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], u(s)); if (!b && a.queue) { if (r != g[c]) t(a.onAfterFirst); delete g[c] } }); t(a.onAfter); function t(b) { o.animate(g, j, a.easing, b && function() { b.call(this, l, a) }) }; function u(b) { var h = 'scroll' + b; if (!q) return k[h]; var f = 'client' + b, i = k.ownerDocument.documentElement, c = k.ownerDocument.body; return Math.max(i[h], c[h]) - Math.min(i[f], c[f]) } }).end() }; function n(b) { return typeof b == 'object' ? b : { top: b, left: b} } })(jQuery);
/************************************************************************************/
/**************************** DATOS PARA LOS BANNERS FLASH *************************/
var TxtPos = 1;
var TextoAsesores = "";
var foto1 = JSResolveUrl + "../archivos/Banners/ExtAzul.jpg";
var TIT = "";
var idiomaNum = "1";
///////////////////////////////////////////////////////////
if (idioma == "es") {
    TIT = "";
    TextoAsesores = "";
    idiomaNum = "1";
};
if (idioma == "en") {
    TIT = "";
    TextoAsesores = "";
    idiomaNum = "2";
};
if (idioma == "pt") {
    TIT = "";
    TextoAsesores = "";
    idiomaNum = "3";
};
/**********************************************************************************/
/**************************** Acordeon ********************************************/

function ProyectosAccordion() {
    var rand = Math.floor(Math.random() * 1019);    
    var Contador = '<input type="hidden" value="' + rand + '" id="ProyectosContador' + rand + '" />'; 	/******** genero CONTADOR */
    $("body").append(Contador);

    $('.ProyectosDesplegable').css("display", "none");
    $('.BtnAmpliar').click(
		  function() {
		      var nuevo = $(this).attr('rel');
		      if ($('.ProyectosDesplegable[rel=' + nuevo + ']').css("display") == "none") {	/******* SI ES OCULTO */
		          if ($('#ProyectosContador' + rand).attr('value') != nuevo) {
		              var Cerrar = $('#ProyectosContador' + rand).attr('value');
		              if (casos == false) { $('.ProyectosAccordion[rel=' + Cerrar + ']').css({ 'height': '120px' }); }
		              $('.ProyectosDesplegable[rel=' + Cerrar + ']').hide();
		              $('.BtnAmpliar[rel!=' + nuevo + ']').css("backgroundPosition", "0px 0px");
		          }
		          $('#ProyectosContador' + rand).attr('value', nuevo);
		          if (casos == false) { $('.ProyectosAccordion[rel=' + nuevo + ']').css({ 'height': 'auto' }); }
		          $('.ProyectosDesplegable[rel=' + nuevo + ']').show();
		          $(this).css("backgroundPosition", "0px -46px");
		      } else {/******************** SI ES VISIBLE */
		      //alert($('.ProyectosDesplegable[rel=' + nuevo + ']').html());
		      if (casos == false) { $('.ProyectosAccordion[rel=' + nuevo + ']').css({ 'height': '120px' }); }
		          $('.ProyectosDesplegable[rel=' + nuevo + ']').hide();
		          $('#ProyectosContador' + rand).attr('value', '999');
		          $(this).css("backgroundPosition", "0px 0px");
		      }
		  }
		);
    $('.BtnAmpliar').hover(
			  function() {
			      var nuevo = $(this).attr('rel');
			      if ($(this).css("backgroundPosition") == "0px -46px") {
			          $(this).css("backgroundPosition", "0px -69px");
			      } else {
			          $(this).css("backgroundPosition", "0px -23px");
			      }
			  },
			  function() {
			      var nuevo = $(this).attr('rel');
			      if ($('.ProyectosDesplegable[rel=' + nuevo + ']').css("display") == "none") {
			          $(this).css("backgroundPosition", "0px 0px");
			      } else {
			          $(this).css("backgroundPosition", "0px -46px");
			      }
			  }
   		 );   		 	 		 	  
}

/***************************************************************************/

$(document).ready(function() {

    /******************************* MENU IDIOMA *******************************/
    $('a[name=Bandera' + idioma + ']').addClass('Bandera' + idioma + 'SEL');
    /***************************************************************************/
    //$("#Pagina").height(Math.max($(document).height(), $("#Pagina").height()) - 5);
    
});

function OpaMdd(e, o, a) {
    e.style.filter = 'alpha(Opacity=' + a + ')';
    e.style.opacity = o;
}

/*************  Replace All Function **************/

String.prototype.ReplaceAll = function(stringToFind, stringToReplace) {

    var temp = this;
    var index = temp.indexOf(stringToFind);
    while (index != -1) {
        temp = temp.replace(stringToFind, stringToReplace);
        index = temp.indexOf(stringToFind);
    }
    return temp;
}

/***Funcion para un Caso de estudio según atributo rel *************/
function DesplegarCaso(rel_attr) {
    var nuevo = rel_attr;
    
    var rand = Math.floor(Math.random() * 1019);    
    var Contador = '<input type="hidden" value="' + rand + '" id="ProyectosContador' + rand + '" />'; 	/******** genero CONTADOR */
    $("body").append(Contador);

    $('.ProyectosDesplegable').css("display", "none");

    if ($('.ProyectosDesplegable[rel=' + nuevo + ']').css("display") == "none") {	/******* SI ES OCULTO */
      if ($('#ProyectosContador' + rand).attr('value') != nuevo) {
          var Cerrar = $('#ProyectosContador' + rand).attr('value');
          $('.ProyectosDesplegable[rel=' + Cerrar + ']').hide();
          $('.BtnAmpliar[rel!=' + nuevo + ']').css("backgroundPosition", "0px 0px");
      }
      $('#ProyectosContador' + rand).attr('value', nuevo);
      $('.ProyectosDesplegable[rel=' + nuevo + ']').show();
      $(this).css("backgroundPosition", "0px -46px");
    } else {/******************** SI ES VISIBLE */
      //alert($('.ProyectosDesplegable[rel=' + nuevo + ']').html());
    $('.ProyectosDesplegable[rel=' + nuevo + ']').hide();
      $('#ProyectosContador' + rand).attr('value', '999');
      $(this).css("backgroundPosition", "0px 0px");
    }

    $('.BtnAmpliar').click(
		  function() {
		      var nuevo = $(this).attr('rel');
		      if ($('.ProyectosDesplegable[rel=' + nuevo + ']').css("display") == "none") {	/******* SI ES OCULTO */
		          if ($('#ProyectosContador' + rand).attr('value') != nuevo) {
		              var Cerrar = $('#ProyectosContador' + rand).attr('value');
		              $('.ProyectosDesplegable[rel=' + Cerrar + ']').hide();
		              $('.BtnAmpliar[rel!=' + nuevo + ']').css("backgroundPosition", "0px 0px");
		          }
		          $('#ProyectosContador' + rand).attr('value', nuevo);
		          $('.ProyectosDesplegable[rel=' + nuevo + ']').show();
		          $(this).css("backgroundPosition", "0px -46px");
		      } else {/******************** SI ES VISIBLE */
		          //alert($('.ProyectosDesplegable[rel=' + nuevo + ']').html());
		      $('.ProyectosDesplegable[rel=' + nuevo + ']').hide();
		          $('#ProyectosContador' + rand).attr('value', '999');
		          $(this).css("backgroundPosition", "0px 0px");
		      }
		  }
		);
    $('.BtnAmpliar').hover(
			  function() {
			      var nuevo = $(this).attr('rel');
			      if ($(this).css("backgroundPosition") == "0px -46px") {
			          $(this).css("backgroundPosition", "0px -69px");
			      } else {
			          $(this).css("backgroundPosition", "0px -23px");
			      }
			  },
			  function() {
			      var nuevo = $(this).attr('rel');
			      if ($('.ProyectosDesplegable[rel=' + nuevo + ']').css("display") == "none") {
			          $(this).css("backgroundPosition", "0px 0px");
			      } else {
			          $(this).css("backgroundPosition", "0px -46px");
			      }
			  }
   		 );
    		   
}  

