$(document).ready(function() {
 	$("ul#ticker01").liScroll(); 
	$("form[@name=cautare_rapida]").submit(function() {

		$("#interior-narrow-content ul li a").each(function() {
			var text = $("#cauta_articol").val().toLowerCase();

			$(this).css('background-color', '');
			if ($(this).html().toLowerCase().indexOf(text) == 0) {
				this.focus();
				$(this).css('background-color', 'yellow');
			}
		});

		return false;
	});

	$("#ghid-index-search-content input[@type=button]").click(function(){
		var txt = $("#cauta_articol").val();

		$("#interior-narrow-content ul li a").each(function() {
			var text = $("#cauta_articol").val().toLowerCase();

			$(this).css('background-color', '');
			if ($(this).html().toLowerCase().indexOf(text) == 0) {
				this.focus();
				$(this).css('background-color', 'yellow');
			}
		});
	});
});

jQuery.fn.liScroll = function(settings) {
	settings = jQuery.extend({
		travelocity: 0.07
	}, settings);
	return this.each(function(){
		var $strip = jQuery(this);
		$strip.addClass("newsticker")
		var stripWidth = 0;
		var $mask = $strip.wrap("<div class='mask'></div>");
		var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");
		var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width
		$strip.find("li").each(function(i){
			stripWidth += jQuery(this, i).width();
		});
		$strip.width(stripWidth);
		var defTiming = stripWidth/settings.travelocity;
		var totalTravel = stripWidth+containerWidth;
		function scrollnews(spazio, tempo){
			$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
		}
		scrollnews(totalTravel, defTiming);
		$strip.hover(function(){
			jQuery(this).stop();
		},
		function(){
			var offset = jQuery(this).offset();
			var residualSpace = offset.left + stripWidth;
			var residualTime = residualSpace/settings.travelocity;
			scrollnews(residualSpace, residualTime);
		});
	});
};

/*$.fn.marquee = function (speed) {
var text = $(this).find("div").html();
var width = $(this).width();
var miliseconds = Math.ceil(width / speed * 1000);

$(this).css('overflow', 'hidden');
$(this).find("div").show();
$(this).find("div").css('position', 'relative');
$(this).find("div").css('white-space', 'nowrap');
$(this).find("div").css('left', width + 'px');
$(this).find("div").css('width', '0px');


$(this).find("div").animate({left: 0, width: width}, miliseconds, "linear", function() {
$(this).animate({opacity: 'hide'}, 3000, function(){
$(this).parent().marquee(speed);
});
});
}*/