var ADAPT_CONFIG = {
  path: './css/',
  dynamic: true,
  range: [
    '0px    to 760px      = mobile.css',
    '760px  to 980px    = 960_12_col.css',
    '980px  to 1280px  = 960_12_col.css',
    '1280px to 1600px = 960_12_col.css',
    '1600px to 1920px = 960_12_col.css',
    '1920px         	    = 960_12_col.css'
  ]
};

$(document).ready(function() {
   	
   	$('#bt_login').mouseover (function() {
		$('#bt_login').attr('src','./images/entra_area_over.jpg');
   	});
   	$('#bt_login').mouseout (function() {
		$('#bt_login').attr('src','./images/entra_area.jpg');
   	});   	
    	/* for strict validation, with rel external we simulate target"_blank" tag */
	$("a[rel*=external]").live("click", function(){
		window.open($(this).attr("href"));
		return false;
	});

	/* looking for lightbox images */
	var nrel=0;
	$("a").each(function (i) {
		if ($(this).hasClass("lightbox")) {
			nrel++;
		}
	});

	if (jQuery.fancybox) {
		for (u=1;u<=nrel;u++) {
			$("a[rel=lightbox" + u +"]").fancybox({
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'titlePosition' 	: 'over',
			'titleShow'		: false,
			'overlayOpacity'  : 0.7,
			'overlayColor'    : '#000',
			'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Immagine ' + (currentIndex + 1) + ' di ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<'+'/span>';
				}
			});
		}
	} else {
		$(".lightbox").click(function() {
			openpiccenter($(this).attr('href'),"thePIcture",640,480);
			return (false);
		});
	}
	
	/* antispam subtitution for e m a i l links */
	$('a.email').each(function(i) {
		var text = $(this).attr("href");
		var address = text.replace("_at_", "@");
		$(this).attr('href', 'mailto:' + address);
	});  

});	

/* miscellaneous functions */
function openCtg( form ) { 
	var newIndex = form.ctg.selectedIndex; 
	if ( newIndex === 0 ) { 
		alert( "Fai una selezione" ); 
	} else { 
		cururl = form.ctg.options[ newIndex ].value; 
		window.location.assign( cururl ); 
	} 
} 

function validacerca(t) {
	if (t.srcid.value == ""){
		alert("Scrivi un codice da cercare- Insert a code to search");
		t.srcid.focus();
		return (false);
	}
	return (true);
}

function openpiccenter(url,name,x,y){
	var sx = screen.width;
	var sy = screen.height;
	var wx = (sx/2) - (x/2);
	var wy = (sy/2) - (y/2) - 50;
	picxywindow = window.open(url,name,"width=" + x + ",height=" + y + ",menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,left="+ wx +",top=" + wy);
	picxywindow.focus();
}	

function imageFullSize() {
	var theimg = $('#imgFull').parent('div').width();  //or however you get a handle to the IMG 
	$('#imgFull').width( $('#imgFull').parent('div').width());

	//$('#imgFull').height( $(window).height()-$('#footer').height()-200);
}

