/*@Allen Zhou 20110825  honglundyz@163.com*/
$(function(){
	$(window).resize(function(){
		if($(window).width()<990){
			$('body').css('width',990);
		}else{
			$('body').css('width','auto');
		}
	});
	//right-top  search
	$('#top-search .text').focus(function(){
		if($(this).val()===unescape('%u641C%u7D22')){
			$(this).val('');
		}
		$(this).addClass('focus');	
	}).blur(function(){
		if($(this).val().length<1){
			$(this).val(unescape('%u641C%u7D22'));
		}
		$(this).removeClass('focus');	
	});
	//text-overflow
	(function(){
		var tmp=$('<span style="position:absolute;left:0;top:0;visibility:hidden;white-space:nowrap;font-size:12px;"></span>')[0];
		$('body').append(tmp);
		if($.browser.mozilla){
			$('.text-overflow').each(function(){
				doSlice($(this)[0]);
			});
		}
		$('.j-text-overflow').each(function(){
			doSlice($(this)[0]);	
		});
		function doSlice(elem){
			var index=0,flagWidth=$(elem).width(),overflow=false;
			if(parseInt($(elem).attr('maxwidth'))>0){
				flagWidth=parseInt($(elem).attr('maxwidth'));
			}
			elem.value=$(elem).html();
			tmp.innerHTML=elem.value;
			if($(tmp).width()>(flagWidth-20)){
				overflow=true;
			}
			while($(tmp).width()>(flagWidth-20)){
				index-=1;
				tmp.innerHTML=elem.value.slice(0,index);
			}
			if(overflow){
				$(elem).html(tmp.innerHTML+"...");
			}
		}
		$(tmp).remove();
	})();
	//events about trees
	//show-hide
	/*$('.haschild').each(function(){
		if($(this).next()[0] && $(this).next().attr('class').indexOf('none')!=-1){
			$(this).toggle(function(){
				$(this).next().slideDown();
				$(this).removeClass('plus').removeClass('none').addClass('minus');
				return false;
			},function(){
				$(this).next().slideUp();
				$(this).removeClass('minus').addClass('plus').addClass('none');
				return false;
			});
		}else{
			$(this).toggle(function(){
				$(this).next().slideUp();
				$(this).removeClass('minus').addClass('plus').addClass('none');
				return false;
			},function(){
				$(this).next().slideDown();
				$(this).removeClass('plus').removeClass('none').addClass('minus');
				return false;
			});
		}
	});	*/
});
