var explorer = false;


// IMPORTANTE:
// Il metodo "check_browser()" viene richiamato alla fine dell'header
// altrimenti IE non lo esegue!
function check_browser() {
  explorer = $.browser.msie;
  if(explorer) {
    // Rimuovo la cache altrimenti jQuery.load() non funziona!
    $.ajax({
      cache: false
    });
  }

  if(explorer && ($.cookie("alert_page_visited") != "true" || $.cookie("alert_page_visited") == 'null')) {
    $.cookie("alert_page_visited", "true");
    window.location = "alert_explorer.php";
  }
}


// SETUP CSS CONSTANTS
$(document).ready(function() {
  // elimino gli indici per l'ordinamento delle categorie della forma XX_,
  // dove X è una cifra decimale. La correzione va fatta su <title>, #page_description e #links
  var regexp = new RegExp('^[0-9]+[0-9]+_', 'i');
  var txt = "";
  $('#links h2 a').each(function() {
    txt = $(this).text();
    if(txt.match(regexp) != null) {
      txt = txt.slice(3);
      $(this).text(txt);
    }
  })
  
  if($('#page_description h2').text().match(regexp) != null) {
    txt = $('#page_description h2').text();
    txt = txt.slice(3);
    $('#page_description h2').text(txt);
  }

  if(document.title.match(regexp) != null) {
    txt = document.title;
    txt = txt.slice(3);
    document.title = txt;
  }


  if($.browser.mozilla) {
    // a seconda della versione di mozilla, lavora una delle due!
    $('#wrapper #inner .column').css('-moz-border-radius', '5px');
    $('#wrapper #inner .column').css('border-radius', '5px');
    // idem per la box shadow
    $('#footer').css('-moz-box-shadow', '-5px 0 15px #000');
    $('#footer').css('box-shadow', '-5px 0 15px #000');
  } else if ($.browser.webkit) {
    $('#wrapper #inner .column').css('-webkit-border-radius', '5px');
    $('#footer').css('-webkit-box-shadow', '-5px 0 15px #000');
  } else {
    $('#wrapper #inner .column').css('border-radius', '5px');
    $('#footer').css('box-shadow', '-5px 0 15px #000');
  }
  // CSS contants for width & height
  var WRAPPER_W = 1220; // 1220px to avoid the lower scrolling bar in 1240px monitors
  var RIGHT_CONTENT_W = WRAPPER_W - 300;
  var MAX_IMG_W = 900;
  $('#wrapper').width(WRAPPER_W);
  $('#rand_image').width(RIGHT_CONTENT_W);
  $('#inner').width(RIGHT_CONTENT_W);
  $('.content').width(RIGHT_CONTENT_W);
  $('#gallery_wrapper').width(RIGHT_CONTENT_W);
  $('#gallery').width(RIGHT_CONTENT_W);
// max-width for images in the gallery is defined in gallery.js

})

