/*function highlightLinks(obj) {
   var linkList = document.getElementById("navigation_search").getElementsByTagName("label");
   for (i = 0; i < linkList.length; i++) {
      linkList[i].className = "";
   }
   obj.className = "active";
}

function search_from_site() {
document.this_form.action = "/haku";
}

function search_from_forum() {
document.this_form.action = "/keskustelu/haku";
}

function search_from_products() {
document.this_form.action = "/tuotteet/haku";
}*/



function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback); 
}

jQuery.fn.idle = function(time){
	var i = $(this);
	i.queue(function(){
		setTimeout(function(){
			i.dequeue();
		}, time);
	});
};

jQuery(document).ready(function() {


$('dl.forum-category-list dt').hover(
			function() { 
				$('p.forum_quotation').stop(true, true);
				$(this).next('dd').find('p').animate({opacity: 1.0}, 500).fadeIn(150); 
				$('p', this).css('background-position', '0 -32px'); 
			},
			function() { 
				$('p.forum_quotation').fadeOut(150);
				$('p', this).css('background-position', '0 0'); 
});

$('dl#forum_list dt').hover(
			function() { 
				$('p.forum_quotation').stop(true, true);
				$(this).next('dd').find('p').animate({opacity: 1.0}, 1000).fadeIn(150);
				$('p', this).css('background-position', '0 -32px'); 
			},
			function() { 
				$('p.forum_quotation').fadeOut(150); 
				$('p', this).css('background-position', '0 0'); 
});



// accordion	
	$('dl#calendar-list dd').hide();
	$('dl#calendar-list dd div').hide();
	$('dl#calendar-list dd.first').show();
	$('dl#calendar-list dt').click(
	
	function() {
		$(this).next().fadeToggle('normal');	
		$(this).toggleClass("active"); 
	});

	$('dl#calendar-list dd p.more-info').click(
	
	function() {
		$(this).next().fadeToggle('normal');	
		$(this).toggleClass("active"); 
	});

    $('#mycarousel').cycle({
        fx:     'fade',
        speed: 800,		// transition speed
        timeout: 4000,	// wait
        //after: onAfter,
        //before: onBefore,
        slideExpr: 'li',
        prev:    '#cycle-prev', 
        next:    '#cycle-next'
    });
    $('div#banner_carousel').cycle({
        speed: 2000,		
        timeout: 10000
    });
    $('#product_carousel_big').cycle({
        fx:     'fade',
        speed: 800,		// transition speed
        timeout: 4000,	// wait
        //after: onAfter,
        //before: onBefore,
        slideExpr: '.cycle-group ul',
        prev:    '#cycle-prev', 
        next:    '#cycle-next'
    });
    function onBefore() {
        //$(this).fadeIn();
    }
    function onAfter() {
        //$(this).fadeOut();
    }
    
	$('a#back_to_up').click(function(){
		$.scrollTo( 0, 400, {queue:true} );
		return false;
	});
	
	
	$('[class^=col_]').hide();
	
	$('a[class^=trigger]').click(function() {
		var $this = $(this);
		var x = $this.attr("className");
		$('.col_' + x).slideToggle(400);
		$(this).text($(this).text() == 'Piilota' ? 'Näytä' : 'Piilota');
		return false;
	});
	
  $("#ezcoa-711_marketing").click(function () {
    if($("#ezcoa-711_marketing").attr('checked')){
      $("#ezcoa-850_testgroup").attr('checked', false).attr('disabled', true);
    } else {
      $("#ezcoa-850_testgroup").attr('disabled', false);
    }
  });
  // Alussa tarkistetaan mikä on marketing kohdan value ja siten muutetaan testiryhmän statusta
  if($("#ezcoa-711_marketing").attr('checked')){
    $("#ezcoa-850_testgroup").attr('checked', false).attr('disabled', true);
  }
});

$(function() {
		$("#tabs").tabs();
});

function captureOnclick(actionnumber, name) 
{
	var YWATracker = YWA.getTracker("10001758215368");
	YWATracker.setDocumentName(name);
	YWATracker.setAction(actionnumber);
	YWATracker.submit_action();

}
