/*

yukelong.com all rights reserved

update: 2010-3-11

*/

$(document).ready(function(){

DD_roundies.addRule(".blockUI,.keyword,.link-tip a .pad10,.events .box,.nav-list,.contain,.pic,.tip,.tipb,.tipx,.tip-pj,.button,.product .list .info,.related li,.warning,.telephone h2",'5px',true);
$(".tbsorter").tablesorter();
$('.text').each(function(){if($(this).attr('readonly')!=''){$(this).addClass('grey');}});
function greybg(){
	$('.text,textarea').addClass('grey');
	$('.text,textarea').focus(function(){
		$(this).removeClass('grey');
	}).blur(function(){
		$(this).addClass('grey');
	});
}
/* nav */
$('#nav li').hover(function(){
	$(this).addClass('hover');
},function(){
	$(this).removeClass('hover');
});	
$('#nav ul li').unbind();
$('#nav li').hover(function(){
	$(this).css('z-index','111').find('ul:first').fadeIn();
},function(){
	$(this).css('z-index','110').find('ul:first').css('display','none');
});
/* side nav*/
$('.ul-nav strong').toggle(function(){
	if(!$(this).attr('nav_height'))$(this).attr('nav_height',$(this).parent().height());
	$(this).parent().stop().animate({height:31});
	$(this).css("background-position","right bottom");
},function(){
	var h=$(this).attr('nav_height');
	$(this).parent().stop().animate({height:h});
	$(this).css("background-position","right top");
});

/* main */

$('.our-products .main-products a').tooltip({
    track: true, 
    delay: 0, 
    showURL: false,
	 extraClass: 'tipx',
    fade: 0 
});

// product -type
$('.product-types a').tooltip({
    track: false, 
    delay: 0, 
    showURL: false,
	 bodyHandler: function() { 
        return $(this).find('.hide').html();
    }, 
	 extraClass: 'tipx',
    fade: 0 
});
/*$('.link-tip a').hover(function (){
	$(this).css('z-index','102').find('.pad10').css('display','block');
},function (){
	$(this).css('z-index','100').find('.pad10').css('display','none');
});*/
$('.link-tip a .pad10').mouseover(function (){$(this).css('display','none');});
/* product */
//$('.news-list li,.product .list li').click(function(){location.href=$(this).find('a').attr('href');});													
$('.product .list a img').hover(function(){
	$(this).parent().parent().addClass('hover').css({border:'solid 1px #CCC'}).parent().css('z-index','100');
},function(){
	$(this).parent().parent().removeClass('hover').css({border:'solid 1px #FFF'}).parent().css('z-index','1');
});
$(".pic").toggle(function(){
	$(this).stop().animate({width:300});$(this).find('span').text('点击缩小');
},function(){
	$(this).stop().animate({width:200});$(this).find('span').text('点击放大')
});
$('.tips').click(function(){window.alert($(this).attr('title'));});
/* project */
$('.project .list .imgbox').hover(function (){
		$(this).parent().css('z-index',2);
		if(!$(this).parent().find('.full-view').length){
			$(this).parent().append('<div class="full-view"><div class="box"><div><img src="'+$(this).find('a').attr('href')+'" /></div><b>'+$(this).parent().find('h4 a').text()+'</b></div></div>');
	   }
	   $(this).mousemove(function (e){
     		$(this).parent().find('.full-view div').css({visibility:'visible',top:(e.pageY - $(this).offset().top - 335)});
	   });								  
	},function (){
		$(this).parent().css('z-index',1);
		$(this).unbind('mousemove');
		$(this).parent().find('.full-view div').css('visibility','hidden');
});
$('.project .list .imgbox a').click(function (){
	location.href=$(this).parent().parent().find('h4 a').attr('href');
	return false;
});
$('#main.project .gallery').toggle(function (){
	var h=$(this).find('img').css('height');
	$(this).stop().animate({height:h});
},function (){$(this).stop().animate({height:300});
});
$('#main.project .gallery,#main.project .gallery img').tooltip({
	 track: true, 
    delay: 0, 
    showURL: false,
	 bodyHandler: function() { 
        return "点击展开/收起图片";
    }, 
	 extraClass: 'tip-pj',
    fade: 0 
});
ppbox('.related li','-30');

function ppbox(id,h){
	$(id).hover(function(){
		$(this).find('div').stop().animate({bottom:'0'},200);
	},function(){
		$(this).find('div').stop().animate({bottom:h},200);
	});
}
	
/*  forum */
$('.content img').load(function(){
	var x=$(this).width();if(x>='740'){$(this).css('width','740px');}
});	
			
/* contact */
$('.map-photo,.map-pointer').hover(function(){
	$('.map-photo-con').removeClass('hide');
},function(){
	$('.map-photo-con').addClass('hide');
});	
$('#we-contact-you a').click(function (){
	$('#contact-form').attr({src:'site/contact/',height:'500px'});
	$(this).unbind();
});
$('.mail').each(function(){
	var type=$(this).find('img').attr('src').slice(7,8);
	if(type=='x'){
		type='webmaster';
	}else {
		type='service';
	}
	$(this).attr('href','ma'+'il'+'to:'+type+'@'+'yukelong.com');
});
/* about */ 
/*var abtab="#us";
$('#about-tab a').click(function (){
	var cur=$(this).attr('href');
	$(this).parent().find('a').removeClass('cur');
	$(this).addClass('cur');	  
	$(cur).removeClass('hide');
	$(abtab).addClass('hide');
	abtab=cur;
	return false;
});*/
showinfo('#ceo');
$('.great-hall td img').hover(function (){
	$(this).addClass('hover');
	$('.staff').stop().animate({top:'5'},400);
	showinfo(this);
},function (){
	 $(this).removeClass('hover');
	 $('.staff').stop().animate({top:'-300'},200);
});
function showinfo(v){
   $('.staff img').attr('src',$(v).attr('src'));
	$('.staff h3 span').text($(v).attr('alt'));
	$('.staff h3 em').text('（'+$(v).attr('title')+'）');
	$('.staff .info').html($(v).parent().find('div').html());
}
 //
});