﻿/** @LightBox **/
(function($)
{ $.LightboxClass=function(){this.construct()};
    
  $.fn.lightbox=function(options)
  { $.Lightbox=$.Lightbox||new $.LightboxClass();
    options=$.extend({start:false},options);
    var obj=$(this);
    $(obj).click(function()
    { var url=$(obj).attr('href');
      if(!$.Lightbox.start(url)){return false}
      return false
    });
    if(options.start)
    { var obj=$(this);var url=$(obj).attr('href');
      if(!$.Lightbox.start(url)){return this}
    }return this
  };
    
  $.extend($.LightboxClass.prototype,
  { params:new Object(),
    className:'lbanchor',
    width:550,
    height:460,
    opacity:0.8,
    src:'',
    construct:function(){return true},
    domReady:function()
    { $('body').append('<div id="lb_overlay"></div><div id="lb_wrap"><div id="lb_window"><div id="lb_close"><a href="#">Cerrar</a></div><iframe frameborder="0" scrolling="no" hspace="0" src="'+this.src+'" id="lb_iframe" name="lb_iframe"></iframe></div></div>');
      this.resize();this.reposition();$('#lb_overlay, #lb_wrap').hide();$(window).resize(function(){$.Lightbox.resize()});$.Lightbox.bind();return true
    },
    bind:function()
    { $.each($('a.'+this.className),function(index,obj){$(obj).lightbox()});return true; },
    start:function(url)
    { this.parseQuery(url);$('#lb_iframe').attr({'src':url});$('embed, object, select').css({'visibility':'hidden'});$.Lightbox.resize();
      if(navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1)
      { $('#lb_overlay').css({'backgroung':'#CCCCCC','display':'block','position':'absolute'}); }
      else
      { $('#lb_overlay').css({'position':'fixed'});$('#lb_overlay').css({opacity:this.opacity}).fadeIn('fast'); }
      $('#lb_wrap').show();
      $('#lb_overlay, #lb_close a, #lb_wrap').click(function(event){$.Lightbox.finish();return false});this.resize();this.reposition();return true;
    },
    finish:function()
    { $('#lb_wrap').hide();$('embed, object, select').css({'visibility':'visible'});$('#lb_iframe').attr({'src':this.src});
      if(navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1)
      { $('#lb_overlay').hide(); }
      else
      { $('#lb_overlay').fadeOut('fast',function(){$('#lb_overlay').hide()}); }
      if(navigator.userAgent.toLowerCase().indexOf('msie 6')==-1)
      { $("html").css("overflow","auto"); }
      this.params['height']=undefined;
      this.params['width']=undefined
    },
    resize:function()
    { var pageSize=this.getPageSize();$('#lb_overlay').css({width:pageSize.largestWidth,height:pageSize.largestHeight});$('#lb_window').css("width",this.getWindowWidth()+'px');$('#lb_iframe').css("width",this.getWindowWidth()+'px');$('#lb_iframe').css("height",this.getWindowHeight()+'px'); },
    reposition:function(options)
    { options=$.extend({},options);var pageSize=this.getPageSize();var chHeight=parseInt($('#lb_wrap').height());var cbTop=$(window).scrollTop()+(pageSize.windowHeight-chHeight)/4;var cbLeft=$(window).scrollLeft();
      if(cbTop<0)
      { cbTop=0; }
      $('#lb_wrap').css({left:cbLeft,top:cbTop})
    },
    parseQuery:function(url)
    { query=url.replace(/^[^\?]+\??/,'');
      if(!query)return this.params;
      pairs=query.split(/[;&]/);
      for(var i=0;i<pairs.length;i++)
      { kv=pairs[i].split('=');
        if(!kv||kv.length!=2)continue;
        key=unescape(kv[0]);val=unescape(kv[1]);val=val.replace(/\+/g,' ');this.params[key]=val;
      }
    },
    getWindowWidth:function(){return this.params['width']||this.width},getWindowHeight:function(){return this.params['height']||this.height},
    getPageSize:function()
    { var xScroll,yScroll;xScroll=$(document).width();yScroll=$(document).height();var windowWidth,windowHeight;
      if(self.innerHeight)
      { if(document.documentElement.clientWidth)
        { windowWidth=document.documentElement.clientWidth; }
        else
        { windowWidth=self.innerWidth; }
        windowHeight=self.innerHeight;
      }
      else if(document.documentElement&&document.documentElement.clientHeight)
      { windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight; }
      else if(document.body)
      { windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight; }
      if(yScroll<windowHeight)
      { pageHeight=windowHeight; }
      else
      { pageHeight=yScroll; }
      if(xScroll<windowWidth)
      { pageWidth=xScroll; }
      else
      { pageWidth=windowWidth; }
      var largestWidth,largestHeight,smallestWidth,smallestHeight;
      if(pageWidth>=windowWidth)
      { largestWidth=pageWidth;smallestWidth=windowWidth; }
      else
      { largestWidth=windowWidth;smallestWidth=pageWidth; }
      if(pageHeight>=windowHeight)
      { largestHeight=pageHeight;smallestHeight=windowHeight; }
      else
      { largestHeight=windowHeight;smallestHeight=pageHeight; }
      return{'pageWidth':pageWidth,'pageHeight':pageHeight,'windowWidth':windowWidth,'windowHeight':windowHeight,'largestWidth':largestWidth,'largestHeight':largestHeight}
    }
  });
  $(function() { $.Lightbox=$.Lightbox||new $.LightboxClass();$.Lightbox.domReady(); });
})(jQuery);
/** @END - LightBox **/
$(document).ready(function()
{ $('html').addClass('js');
  $('dl.slide dd').hide();
  $('ul#menu li:last').addClass('noborder'); 
     
    $('dl.slide dt').click(function()
    {    if($(this).parent().children('dd').attr('class')!='open')
        {    $(this).parent().children('dd').attr('class','open').slideDown('slow'); }
    });
    $('div.close_button').click(function()
    {    if($(this).parent().attr('class')=='open')
        {    $(this).parent().attr('class','').slideUp('slow'); }
    });
    
  /** @Aladino **/
  $('#product_navigation').Fisheye(
  { maxWidth: 35,
    items: 'a',
    itemsText: 'p',
    container: '.dock-container',
    itemWidth: 68,
    proximity: 100,
    alignment : 'left',
    valign: 'bottom',
    halign : 'center' 
  })
  /** @END - Aladino **/

  /** @PopUp **/
  $.fn.popup = function(options)
  { $(this).click(function()
    { var thisURL = $(this).attr('href');
      window.open(thisURL, '','width='+options['width']+',height='+options['height']+',scrollbars='+options['scrollbars']+',resizable='+options['resizable']+',menubar='+options['menubar']+',location='+options['location']+'');
      return false;
    });
  }
  $('a.pu_500').popup({width:'500', height:'600',scrollbars:'yes',resizable:'no',menubar:'no',location:'no'});
  $('a.pu_550').popup({width:'600', height:'600',scrollbars:'yes',resizable:'no',menubar:'no',location:'no'});
  $('a.pu_600').popup({width:'600', height:'600',scrollbars:'yes',resizable:'no',menubar:'no',location:'no'});
  /** @END - PopUp **/
            
});