$j=jQuery.noConflict();
jQuery(document).ready(function($){
	/******* search ********/
	if($j.browser.safari) {
		var s = document.getElementById('s') // going old school due to bug in juery 1.2.3 setting attributes
		s.setAttribute('type', 'search')
		$j("#s").attr({
			autosave: 'com.cristianos.search', 
			results: '9', 
			incremental: 'true', 
			placeholder: $j("#s").attr('value'), 
			size: '20'
		})
    }else{
		$j("#s").focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = '';
			}
		})
		$j("#s").blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	}
	/****** feature *******/
	$('#featured_menu .item').hover(
		function () {
			var id = $(this).attr('id');
			$(this).addClass('active')
			$('#featured .item').hide();
			$('#featured .'+id).fadeIn("fast");
		}, 
		function () {
			$(this).not('.selected').removeClass('active')
		}
	);
	/******* tabs ********/
	if ( $j("ul.tabsmenu") )
		$j("ul.tabsmenu").tabs({ fxAutoHeight:true, fxFade: true, fxSpeed: 'fast'});
		
	/***** clipshare *****
	$j("a#clipshare_prev").click(function(){
	      $j("#clipshare_prev div ul").animate({"left": "-=50px"}, "fast");
    });
	*/
	ajaxNav();
	function ajaxNav(){
		$j('.navigation .ajax a').click(function () { 
			$j.ajax({
				url: $j(this).attr('href')+'?ajax=true',
				cache: true,
				success: function(html){
					var find = '';
					html = html.replace(/\?ajax=true/g, '')
					$j(".ajax-list").html(html);
					ajaxNav()
				}
			});
			return false;
		});
	}

	/******** dinamically load content for cross scripts ********/
	$("#menu-container").load("http://cristianos.com/wp-content/themes/cristianos/menu.html");
	$("#footer-container").load("http://cristianos.com/wp-content/themes/cristianos/footer.html");
	
	
	/**** home carousel ***/
	if ( $('#home-carousel') ){
		$('#home-carousel').jcarousel({
	        auto: 2,
	        scroll: 6, 
	        wrap: 'last',
	        initCallback: mycarousel_initCallback
	    });
	}
	
});

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};