$(document).ready(function(){
	$("#add_name").autocomplete("index.php?doc=ajax_server&action=autoComplete",
		{delay:10,
		minChars:2,
		width: 350,
		matchSubset:1,
		matchContains:1,
		cacheLength:10,
		scroll:false,
		selectFirst:false,
		autoFill:false}
	);
});

var amount;
var current_id = 1;
var prev_id = null;
var timeId = null;

	function startAnim() {
		prev_id = current_id;
		$("#icon_"+current_id).css({opacity: 1});
		setTimeout("showNext("+current_id+", true)", 6000);
	}
	function showNext(id, action) {
		if (id != current_id-1) {
			if (amount-1 < id) {
				id = 0;
			}
			prev_id = current_id;
			current_id = id+1;
			$("#icon_"+current_id).css({opacity: 1});
			$("#icon_"+prev_id).css({opacity: 0.6});
			var offset = id*800;
			$("#banner").animate({scrollLeft: offset}, 600);
			if (action) {
				timeId = setTimeout("showNext("+(id+1)+", true)", 6000);
			}
		}
	}
	function showGray(id) {
		if (current_id != id) {
			$("#icon_"+id).css({opacity: 0.6});
		}
	}
	function clearTime(id) {
		clearTimeout(timeId);
		showNext(id, false);
	}
	$(window).load(function() {
		$("#banner_preloader").hide();
		var numRand = Math.floor(Math.random()*amount) + 1;
		showNext(numRand, true);
		startAnim();
	});
	
	function infoShow(info, type) {
		$("<div id='insideOverdiv'></div>").appendTo("#overDiv2");
		$("#insideOverdiv").css({margin: 25, opacity: 1, "z-index": 1000, position: "relative"}).text(info);
				
		if (type == 1) {
			$("#overDiv2").css({position: "absolute", top: (screen.height/2)-125, left: (screen.width/2)-220, width: 440, height: 70, "font-size": 16, background: "#dff3dc", "border": "1px solid #45ab34", "text-align": "center", color: "#105305", "font-weight": "bold", "z-index": 20}).show();
		} else {
			$("#overDiv2").css({position: "absolute", top: (screen.height/2)-125, left: (screen.width/2)-220, width: 440, height: 70, "font-size": 16, background: "#eacfc7", "border": "1px solid #e12405", "text-align": "center", color: "#e12405", "font-weight": "bold", "z-index": 20}).show();
		}
		setTimeout("$('#overDiv2').fadeOut();",3000);
		
	}
