// JScript File
jQuery(document).ready(function () {
    	jQuery.noConflict();
    
	jQuery('ul.lavaLampWithImage').lavaLamp({
		fx: 'easeInQuart',
		speed: 400,
	        click: function(event, menuItem) {
	            return true;
	        }
	});

	//gestione dei link nei testi dinamici
	jQuery.each(jQuery('#div_testo a'), function(index, value) { 
		var linkVal = new String(value);
		if ((linkVal.indexOf("annafietta.it") != -1) || (linkVal.indexOf("annafietta.com") != -1)) {
		    jQuery('#div_testo a')[index].setAttribute("target","_top");
		} else {
		    jQuery('#div_testo a')[index].setAttribute("target","_blank");
		}
	});


    jQuery("body").append('<div id="scrollTop"><a href="javascript:;" onclick="jQuery(\'html:not(:animated),body:not(:animated)\').animate({ scrollTop: 0}, 1000);return false;">&nbsp;&nbsp;^&nbsp;Top&nbsp;&nbsp;</a></div>');
    jQuery(window).scroll(function () { 
      if (jQuery(window).scrollTop()==0){
        jQuery("#scrollTop").fadeOut();
      }else{
        jQuery("#scrollTop").fadeIn();
      }
    });
    Cufon.replace('div#scrollTop', { fontFamily: 'ag-foreigner-roman', color: '#FFFFFF' });


	jQuery('#txtRicerca').keypress(function(e) {
	    // Ho premuto il tasto enter
	    if(e.keyCode == '13') {
	      // Evito che l'evento continui
	      e.stopPropagation();
	      gotoRicerca();
	    } 
	});

});

//png fix
jQuery(function(){jQuery(document).pngFix();});

//ricerca
function gotoRicerca(){
    if (jQuery("#txtRicerca") != null) {
	var ric=jQuery("#txtRicerca").val();
	if (ric.length < 3) {
	    alert('Selezionare un testo di ricerca di almeno 3 caratteri');
	} else {
	    window.location.replace('ricerca.aspx?q=' + ric);
	}
    }
}

function checkEnterRicerca(obj) {
    jQuery('#txtRicerca').keypress();
    return false;
}

