jQuery(document).ready(function($) {
  FB_RequireFeatures(["XFBML"], function() {
    FB.init("152363e144d8ef1492f00909c52467f9", "?xd_receiver=1", {"permsToRequestOnConnect":"email"});
  });
  
  $('#flickr_badge_wrapper a').each(function() {
    $(this).attr('target','_blank');
    //$(this).attr('rel','lightbox-flickr');
    //var imgSrc = $(this).children().attr('src');
    //$(this).attr('href',imgSrc.replace('_s.jpg','.jpg'))
  });
  if(screen.width >= 1285) {
    $('.followus').show();
  } else if(screen.width <= 1024) {
    $('.wrapper').css({'width':'auto'});
    $('#trentino').css({'width':'1064px', 'overflow':'hidden', 'position':'relative', 'left':'-73px'});
  }
  $('.clearOnFocus').clearOnFocus();
  $('#login .submit').click(function() {
    $('#login').submit();
  });
  $('a.fb').click(function() {
    var href = $(this).attr('href');
		FB.Facebook.apiClient.users_hasAppPermission('email',function(res,ex){
			if( !res ) {
				FB.Connect.showPermissionDialog("email", function(perms) {
					//window.location.reload();
					window.location.href = href;
				});
			} else {
				//window.location.reload();
				window.location.href = href;
			}
		});
		return false;
  });
  //$('select, input:checkbox, input:radio, input:file').uniform();
  $('.top select, .top input:checkbox, .top input:radio, input:file').uniform();
  
  $('#filterform select').change(function() {
    $('#filterform select').each(function() {
      if($(this).val() == 0) {
        $(this).attr('disabled', 'disabled');
      }
    });
    $('#filterform').submit();
  });
  
  //sharethis.com
  /*var shared_object = SHARETHIS.addEntry({
  	title: document.title,
  	url: document.location.href
  });
  
  shared_object.attachButton(document.getElementById('ck_sharethis'));
  shared_object.attachChicklet('facebook', document.getElementById('ck_facebook'));
  shared_object.attachChicklet('twitter', document.getElementById('ck_twitter'));*/
});
