jQuery(function($){
	$('input:checkbox[checkall]').click(function(){
		var me = $(this).attr('checkall');
		if(this.checked)
			$('input:checkbox[checkme='+me+']').attr('checked', true);
		else
			$('input:checkbox[checkme='+me+']').attr('checked', false);
	})
	
	$("[name=keyword]").autocomplete({
		source:function(request, answer){
			$.getJSON('/index.php?plugin=ajax&do=autocomplete&word='+request.term, function(json){answer($.makeArray(json))});
		}
	});
	
	$("#search-keyword").one("click", function(){$(this).val("")})
	
	var fo = $('#follow_div').show();
	var fo2 = $('#follow2_div');
	var rep = function(){
		if(fo2.is('div')){
			fo2.css({top : $(document).scrollTop()+$(this).height()-fo2.height()});
		}
		fo.css({top : $(document).scrollTop()+$(this).height()-fo.height(), left : $('body').width() - fo.width()})
	};
	$( window ).scroll(rep).resize(rep).load(rep);
	$('#follow_div_close').click(function(){$('#follow_div').hide()});
	logined('logined_head', $('#header > .top > .l'));
	
	$('img[src$="/i_m_g_c_o_d_e.php"]').css({cursor:'pointer'}).live('click', function(){
		$(this).after('<img src="/i_m_g_c_o_d_e.php">').remove();
	})
	
	//setTimeout('skip_goog()', 2000);
});
function AddFavorite(sTitle){try{window.external.addFavorite(window.location.href, sTitle);}catch(e){try{window.sidebar.addPanel(sTitle, window.location.href, "");}catch(e){alert("加入收藏失败，请使用Ctrl+D进行添加");}}}
function logined(str, o){$.get('/index.php?plugin=ajax&do=getinfo&tpl='+str, function(data){if(data.length > 0){o.html(data);}});}
function googleTranslateElementInit(){new google.translate.TranslateElement({pageLanguage: 'zh-CN'}, 'google_translate_element');}
function skip_goog(){
	if($('div .goog-te-gadget').is('div')){
		alert($('#google_translate_element').html());
		var o = $('div .goog-te-gadget').children('div');
		o.css('display','inline');
		$('select', o).css('display','inline');
		$('div .goog-te-gadget').empty().append(o).css('display', 'inline');
	}else{
		setTimeout('skip_goog()', 2000);
	}
}

