function get_browser_width() {
	var custom_v_scrollbar_width = 17;
  if (window.innerWidth == undefined) { // IE
      return document.documentElement.clientWidth;
  } else {
    if (document.getElementById("html").scrollHeight > document.getElementById('html').clientHeight) {
    	return window.innerWidth - custom_v_scrollbar_width;
    } else {
    	return window.innerWidth;
    }
  }
}

var current_container_width;
var current_gallery_id;

function set_container_width() {
	var container_left_margin = 78;
	current_container_width = (get_browser_width() - container_left_margin);
	document.getElementById("container").style.width = current_container_width + "px";
	// DI SEGUITO FORZA IL RIDIMENSIONAMENTO DELLA GALLERY
	if (document.getElementById("colorbox") != null) {
		if (document.getElementById("colorbox").style.display == "block") {
			jQuery('#cboxWrapper, #cboxLoadedContent').animate(
	    	{ width: (current_container_width - 249) + 'px' }, 1
	  	);
	  	jQuery('#colorbox, #cboxContent').animate(
	    	{ width: (current_container_width - 249 - 40) + 'px' }, 1
	  	); 
		}
	}
}

window.onresize = function () {	set_container_width(); }

var arrow_timer_show;
var arrow_timer_hide;

function clear_arrow_timer() {
	clearTimeout(arrow_timer_hide);
}

function show_arrow(toggle) {
	switch (toggle) {
		case 0:
			jQuery(document).ready(function() {
				jQuery('#arrow_left').fadeOut(200);
				jQuery('#arrow_left_low').fadeOut(200);
			});
			jQuery(document).ready(function() {
				jQuery('#arrow_right').fadeOut(200);
				jQuery('#arrow_right_low').fadeOut(200);
			});
			break;
		case 1:
			jQuery(document).ready(function() {
				jQuery('#arrow_left').fadeIn(200);
				jQuery('#arrow_left_low').fadeIn(200);
			});
			jQuery(document).ready(function() {
				jQuery('#arrow_right').fadeIn(200);
				jQuery('#arrow_right_low').fadeIn(200);
			});
			break;
	}
}

function clear_gallery_arrow_timer() {
	clearTimeout(arrow_timer_hide);
}

function show_gallery_arrow(toggle) {
	switch (toggle) {
		case 0:
			jQuery(document).ready(function() {
				jQuery('#gallery_arrow_left').fadeOut(200);
				jQuery('#gallery_arrow_left_low').fadeOut(200);
			});
			jQuery(document).ready(function() {
				jQuery('#gallery_arrow_right').fadeOut(200);
				jQuery('#gallery_arrow_right_low').fadeOut(200);
			});
			break;
		case 1:
			jQuery(document).ready(function() {
				jQuery('#gallery_arrow_left').fadeIn(200);
				jQuery('#gallery_arrow_left_low').fadeIn(200);
			});
			jQuery(document).ready(function() {
				jQuery('#gallery_arrow_right').fadeIn(200);
				jQuery('#gallery_arrow_right_low').fadeIn(200);
			});
			break;
	}
}
