$(document).ready(function(){	
  
  $("#div_images a").colorbox({
    width:"90%", 
    height:"90%", 
    slideshow:true,
    slideshowSpeed: 5000
  });
  $("#div_images a.iframe").colorbox({iframe:true, innerWidth:425, innerHeight:344});
  //$("#div_images a").lightBox({fixedNavigation:true});
  
  //Hide (Collapse) the toggle containers on load
  $(".toggle_container").hide(); 
  
  //Faz com que comece aberto
  $(".trigger").next(".toggle_container").slideToggle("slow");
  $("#div_content").attr("rel", "open");
  
  //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
  $(".trigger").click(function(){
  	$(this).next(".toggle_container").slideToggle("slow");
  	
  	//$('p').addClass('myClass yourClass');
  	var state = $("#div_content").attr("rel");
  	if( state=="close" ) {
  	 $("#div_content").attr("rel", "open");
  	 $('#div_content .trigger').addClass('open-trigger');
  	 $('#div_content .trigger').removeClass('close-trigger');
  	 
    } else {
  	 $("#div_content").attr("rel", "close");  			 
  	 $('#div_content .trigger').addClass('close-trigger');
  	 $('#div_content .trigger').removeClass('open-trigger');
  	 
  	}
  	
  	return false; //Prevent the browser jump to the link anchor
  });		
  
  /*$(".change").click(function(){
  	
  	$('#div_main').fadeOut('5000');         
    
    var image = $(this).attr("href");
    $("#bg").attr("src", image);
    
    $('#bg').fadeIn('5000'); 
    
  	return false; //Prevent the browser jump to the link anchor
  	
  });*/
  
  //y - height
  //x - width
  
  /*var divImage = '#div_main';
  var vH=$(divImage).height();
  var vW=$(divImage).width();
  var vT=$(divImage).offset().top;
  var vL=$(divImage).offset().left;       
  
  $(divImage).mousemove(function(e){
      var state = $("#div_content").attr("rel");
      if( state=="close" ) {
        var ypos=e.pageY-vT;
        var xpos=e.pageX; //var xpos=e.pageX-vL;
        var y=Math.round(ypos/vW*100);
        var x=Math.round(xpos/vH); //var x=Math.round(xpos/vH*50);
        $(this).css({backgroundPosition: '50% '+y+'%'}); //$(this).css({backgroundPosition: x+'% '+y+'%'});
      }
  });*/
  
  /* POSICAO INICIAL*/
  /*var ypos=450-vT;
  var xpos=50;
  var y=Math.round(ypos/vW*100);
  var x=Math.round(xpos/vH);
  $(divImage).css({backgroundPosition: '50% '+y+'%'});*/
	
});	

  //function swapBackground( image ) {
    
  /*
  var div = 'div_main';
  var fade = 100;
  
  // div can be the ID of the div
  // image can be the url of the image
  $("#"+div).fadeOut(fade, function(){
    $("#"+div).css('background-image','url('+image+')');
    $("#"+div).fadeIn(fade);
  });
  
  */
  
  /*var div = '#div_main';
  var fade = 100;
  
  $(div).fadeOut(fade, function(){
    
    $(div).addClass('loading');
    $(div).fadeIn();
    
    $(div).load(function () {
        //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
        $(div).hide();
        $(div).removeClass('loading').append(this);
        $(div).fadeIn(); //$("#"+div).fadeIn();
    }).error(function () {
        // notify the user that the image could not be loaded
    }).css('background', 'url("'+image+'") 50% 0 no-repeat');
  
  });
  
  return false;
  
  }*/
  
  /*function swapImage( image ) {
  
  var div = 'div_main';
  $("#"+div).css('background-image','url('+image+')');
  
  return false;
  
  }*/
  
  $(function(){
  $('.div_scroll').jScrollPane();			
  });
  
  /*$(function () {
    $('#div_main').load(function () {
        //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
        $(this).hide();
        $('#div_main').removeClass('loading-main').append(this);
        $(this).fadeIn();
    }).error(function () {
        // notify the user that the image could not be loaded
    }).css('background', 'url("<?php echo $meta['bg-image']; ?>") 50% 0 no-repeat');       
  });*/
  
  $('#div_images .image img').each(function() {         
    //var img = new Image();
    $('#div_images .image img').load(function () {
        //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
        $(this).hide();
        $('#div_images .image').removeClass('loading').append(this);
        $(this).fadeIn();
    }).error(function () {
        // notify the user that the image could not be loaded
    });        
  });
