﻿jQuery(document).ready(function() {
	//Innerface	
    $('.wd-slice-activity ul').innerfade({
        animationtype   : 'slide',
        containerheight : '33px',
        speed           : 'slow',
        timeout         : 3000,
        type            : 'sequence'
    });
	
	$('.wd-slice-news ul')
		.cycle({
			fx:    'fade',
			speed: 500, 
			timeout:5000,
			next:  '.wd-control a.wd-prev', 
			prev:  '.wd-control a.wd-next'	
	});
	$('.wd-block .wd-right-content div').cycle({
			fx:    'fade',
			speed: 1000, 
			timeout:6000
	});
	$('.wd-tab').each(function(){
		$(this).find('.wd-sub-section').hide();

		var current = $(this).find('.wd-item').children('.wd-current');
		if (current.length == 0){
			$(this).find('.wd-item').children(':first-child').addClass('wd-current');
			$($(this).find('.wd-item').children(':first-child').find('a').attr('href')).show();
		}

		$(this).find('.wd-item').find('a').click(function(){
			var current = $(this).parent().hasClass('wd-current');
			if (current == false){
				$(this).parent()
					.addClass('wd-current')
					.siblings().each(function(){
						$(this).removeClass('wd-current');
						$($(this).find('a').attr('href')).hide();
					});
				$($(this).attr('href')).fadeIn();
			}
			return false;
		});
	});
	$(".wd-section-gallery ul li a[rel=img-group]").fancybox({
		'transitionIn'		:'none',
		'transitionOut'		:'none',
		'titlePosition' 	:'over',
		'titleFormat'		:function(title, currentArray, currentIndex, currentOpts){
					return '<span id="fancybox-title-over">' + (title.length ? '  ' + title :'') + '</span>';
		}
	});
	/*member-info*/
	$('#wd-send-friend a.wd-preview-link').click(function(){
		var this_click = $(this).parent().parent().parent();		
		$(this_click).addClass('wd-email-none');
		$(this_click).next().removeClass('wd-email-none');
		return false;	
	});
	$('#wd-send-friend a.wd-back-link').click(function(){	
		var this_click = $(this).parent().parent().parent();		
		$(this_click).addClass('wd-email-none');
		$(this_click).parent().find('div:first').removeClass('wd-email-none');
		return false;
	});
	$("a.wd-fancybox-dialog").fancybox();
	/* news-detail*/
	$('#wd-send-friends a.wd-preview-link').click(function(){
		var this_click = $(this).parent().parent().parent();		
		$(this_click).addClass('wd-email-none');
		$(this_click).next().removeClass('wd-email-none');
		return false;	
	});
	$('#wd-send-friends a.wd-back-link').click(function(){	
		var this_click = $(this).parent().parent().parent();		
		$(this_click).addClass('wd-email-none');
		$(this_click).parent().find('div:first').removeClass('wd-email-none');
		return false;
	});
	$("a.wd-fancybox-dialogs").fancybox();
	
	if ($('#mycarousel').children().length > 2){
		var heightleft=$('.wd-tab .wd-panel .wd-sub-section').height();
		$('.wd-tab .wd-panel .wd-sub-section').animate({'height': heightleft+1});
		/*$(".wd-congratulate-mycarousel").jCarouselLite({
			vertical: true,
			visible: 2,
			auto:true,
			speed: 1000,
			mouseWheel:true
		});*/
		// update 24-8-2011
		$(".wd-congratulate-mycarousel").simplyScroll({
			autoMode:'loop',
			horizontal: false,
			speed: 2
		});
		// update 24-8-2011
		
		$('.wd-carousel-img').css({'padding-bottom':'0'});
	}
	$("#wd-search-link select").uniform();
	$('#wd-slider').nivoSlider({
		'controlNav':false
	});
	    //table
    $('.table').find('tr:even').addClass('even');
	$('.table').find('tr.wd-paging-tr:even').addClass('odd');
	//
	$(".wd-links-list .wd-jcarouselLite #wd-slides-vertical").jCarouselLite({
		visible: 1,
		btnNext: ".wd-jcarouselLite #next",
		btnPrev: ".wd-jcarouselLite #prev",
		auto:5000,
		speed: 500
	});
});

