 $(function (){
 	picAuto(4000);

 	var emails = [
 	         	{ name: "Peter Pan", to: "peter@pan.de" },
 	         	{ name: "Molly", to: "molly@yahoo.com" },
 	         	{ name: "Forneria Marconi", to: "live@japan.jp" },
 	         	{ name: "Master <em>Sync</em>", to: "205bw@samsung.com" },
 	         	{ name: "Dr. <strong>Tech</strong> de Log", to: "g15@logitech.com" },
 	         	{ name: "Don Corleone", to: "don@vegas.com" },
 	         	{ name: "Mc Chick", to: "info@donalds.org" },
 	         	{ name: "Donnie Darko", to: "dd@timeshift.info" },
 	         	{ name: "Quake The Net", to: "webmaster@quakenet.org" },
 	         	{ name: "Dr. Write", to: "write@writable.com" }
 	         ];



	table_even();
    captcha_click();
	$(window).resize(function(){
		//changeWidth();
	});

    $(".confirm_del").click(
      function () {

        var msg = "您真的确定要删除吗？\n\n请确认！";
        if (confirm(msg)==true) {
            return true;
        } else {
            return false;
        }
      }
    );
});

//首页轮播图片
function picAuto(_AutoTime) {
    var t = n = 0; count = $("#play_list a").size();
	$("#play_list a:not(:first-child)").hide();
	$("#play_text li:first-child").addClass("selected");
	$("#play_text li").click(function() {
		var i = $(this).text() - 1;
		n = i;
		if (i >= count) return;
		$("#play_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
		$(this).addClass("selected").siblings().removeClass("selected");
	});
	t = setInterval("showAuto()", _AutoTime);
	$("#pic").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", _AutoTime);});
    //移动到图片上后不自动跳转图片
}
function showAuto() {
	n = n >= (count - 1) ? 0 : ++n;
	$("#play_text li").eq(n).trigger('click');
}

function captcha_click() {

    $("#captcha").click(
      function () {
        $(this).attr("src",$(this).attr("src") + "/");

      }
    );
}

function table_even() {
	$(".table_even tr").mouseover(function(){ //如果鼠标移到class为table_even的表格的tr上时，执行函数
	$(this).addClass("over");}).mouseout(function(){ //给这行添加class值为over，并且当鼠标一出该行时执行函数
	$(this).removeClass("over");}) //移除该行的class
	$(".table_even tr:even").addClass("even"); //给class为table_even的表格的偶数行添加class值为alt
}

//自动延伸
function changeWidth() {
    var windowsWidth = document.body.offsetWidth;
    var sidebarWidth= $("#sidebar").width();
    newWidth = windowsWidth - sidebarWidth - 5;
    $("#primary").css({"width":newWidth});
}

function bd() {
    	$(".search_list").autocomplete(emails, {
		minChars: 0,
		width: 200,
		max: 16,
		matchContains: true,
		autoFill: false,
		scroll: true,
		scrollHeight: 160,

		formatItem: function(row, i, max) {
			return "[" + row.to + "]" + " " + row.name ;
			//return i + "/" + max + ": \"" + row.name + "\" [" + row.to + "]";
		},
		formatMatch: function(row, i, max) {
			return row.name + " " + row.to;
		},
		formatResult: function(row) {
			return row.name;
		}
	});



	$(".search_list").result(function(event, data, formatted) {

		if (data) {
			ajaxAction(data.to);
		}
	});
}