// F1 front-end/back-end toggle
	if (document.all) {
		document.onhelp = function() {
			location.href = 'admin/';
			return false;
		}
	} else {
		document.onkeydown = function (evt) {
			if (evt.keyCode == '112') {
				location.href = 'admin/';
				return false;
			}
		}
	}





/* ********************************************************************************
					PRENDO VALORI DALLA QUERY STRING
******************************************************************************** */
function getParameterByName(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
};





function isInteger(s){
    if ( s == null) return false;
    var i;
    for(i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if(((c < "0") || (c > "9"))) return false;
    }
    return true;
};




/* ********************************************************************************
						JGROWL - NOTICE, WARNING, ERROR
******************************************************************************** */
function showNotice(text, title){ $.jGrowl(text, { header: title, theme: 'notice' }) };
function showWarning(text, title){ $.jGrowl(text, { header: title, sticky: true, theme: 'warning' }) };
function showError(text, title){ $.jGrowl(text, { header: title, sticky: true, theme: 'error' }) };





/* ********************************************************************************
								RESET DEFAULT
		RIPOPOLO I CAMPI VUOTI CON IL VALORE DI DEFAULT (cancellato al submit)
******************************************************************************** */
function resetDefault(formId){
	if (!formId) formId = '';
	$(formId + ' [emptyIf]').each(function(){
		if ( $(this).val() == '' ){
			$(this).val($(this).attr('emptyIf'));
		}
	})
};




function isInteger(s){
	if ( s == null) return false;
	var i;
	for(i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if(((c < "0") || (c > "9"))) return false;
	}
	return true;
};




/* ********************************************************************************
									DOM READY
******************************************************************************** */
$(document).ready(function(){
	
	
	
	// SCROLLABLE offerte coldx
		$(".offerteColDx").scrollable({
			size: 1
			, vertical: true
			, interval: 4000
			, items: ".items"
			, loop: true
			, speed: 1000
			, easing: "easeInBack"
		});

	
	
	// FILTRI LISTA PRODOTTI (submit al change)
	$("form[name='filtri'] :radio").change(function(){
		$("form[name='filtri']").submit();
	});
	


	/* ********************************************************************************
										DROPDOWN
	******************************************************************************** */
	var hoverIntentConfig = {
		over:
			function(){
				$('.dropDownTrigger').removeClass('selected'); // spengo i pulsanti
				$('.dropDownWrapper')
					.stop(false,true) // interrompo eventuali altre animazioni non completate
					.hide() // nascondo tutti i wrapper
					.filter('[rel='+ $(this).attr("rel") +']') // trovo il corrispondente da aprire (che abbia lo stesso 'rel' del trigger) e...
                        .slideDown('fast', function(){ // lo mostro
							$(this).mouseleave(function(){ // imposto la chiusura al mouseout
								$(this).slideUp('fast');
								$('.dropDownTrigger[class~=selected]').removeClass('selected');
							});
							// MASONRY
							$('.dropDownWrapper[rel='+ $(this).attr("rel") +'] .dropDownContent').masonry({ singleMode: true });
                        });
				$(this).addClass('selected'); // ... accendo il relativo pulsante
			}
		, out: function(){}
		, interval: 100
	};
	$('.dropDownTrigger').hoverIntent(hoverIntentConfig);

		
		
	/* ********************************************************************************
										COLORBOX
	******************************************************************************** */
	// DEFAULT: carico il contenuto via ajax (n.b.: la pagina chiamata non deve essere una pagina completa di tag html, head, ecc.)
	$('a[class~=colorbox]').colorbox();

	// APPLICATO AI PULSANTI
	$(':button[class~=colorbox]').click(function(){ $.fn.colorbox({ href: $(this).attr('href') }) });

	// IFRAME (in colorbox): apro una pag esterna completa di tag html, head, ecc.
	$('[class~="cBoxIframe"]').colorbox({iframe: true, width: '1050px', height: '90%' });

	// INLINE: apre un elemento (il cui ID è definito nell'href con #) contenuto nella pagina del chiamante
	$('.showDiv').colorbox({ inline: true, href: function(){ return $(this).attr('href') } });


	
	
	/* ********************************************************************************
					SVUOTO IL CAMPO SE CON ATTRIBUTO 'EMPTYIF'
	******************************************************************************** */
	// AL FOCUS...
	$(':text[emptyIf], textarea[emptyIf]')
		.live('focusin', function(){
			if ( $(this).val() == $(this).attr('emptyIf') ){
				$(this).val('')
			}
		})
		.live('focusout', function(){
			if ( $.trim($(this).val()) == '' ){
				$(this).val($(this).attr('emptyIf'));
			}
		})
	;
	// ... AL SUBMIT NEI MOTORI DI RICERCA PRINCIPALI
	$("form").live('submit', function() {
		$(this).find("[emptyIf]").each(function() { // per ogni campo
			if ($(this).val() == $(this).attr('emptyIf')) { // se ha il testo di default
				$(this).val(''); // lo svuoto
			};
		});
	});



	/* ********************************************************************************
									TABS HOME (SLIDESHOW)
	******************************************************************************** */
	$('#homeTabs')
		.tabs('#homePanes > div', {
			effect: 'fade'
			, rotate: true
		})
		.slideshow({
			autoplay: true
			, interval: 5000
			, clickable: false
		});



	/* ********************************************************************************
										TOOLTIP
	******************************************************************************** */
	// piccolo nero
	$('.tip[title]').tooltip({ effect: 'slide' }).dynamic();
	// grande nero
	$('.tip2[title]').tooltip({ tipClass: 'tooltip2', effect: 'slide' }).dynamic();
	// piccolo bianco
	$('.tip3[title]').tooltip({ tipClass: 'tooltip3', effect: 'slide' }).dynamic();
	// grande bianco
	$('.tip4[title]').tooltip({ tipClass: 'tooltip4', effect: 'slide' }).dynamic();
	// su campi "locked"
	$(':text.locked[title]').tooltip({ effect: 'slide', events: { input: 'click,mouseleave'} });



	/* ********************************************************************************
									LAYOUT / CSS
	******************************************************************************** */	
	$('#productHighlights > div:last').css({ border: '0' });




});

