

var favBlock = 0;

function showVoteForm(event) {
	$("#rate-sliders").show();
		if (!$("#comment_form").is(":visible")) {
			//$(".m-add:eq(0)").trigger('click');
			$("#comment_form").slideDown(200);
		}
		if ($(this).hasClass("vote-plus")) {
			$('input.factor1').rating('select', 0);
			$(".factor-slider").slider('value', "100");
		} else if ($(this).hasClass("vote-minus")) {
			$('input.factor1').rating('select', 4);
			$(".factor-slider").slider('value', "-100");
		}
		//event.preventDefault();
}
$(document).ready(function() { 
	$(".vote").children("ul").children("li").children("a").bind('click',function(event) {
		showVoteForm(event)
	});
	
	$(".vote-butt").bind('click',function(event) {
		showVoteForm(event)
	});

	if(document.location.hash == '#rate') {
		$("#comment_form").removeClass('hidden').slideDown(200);
	}
	
	/*
	tab_select(0,'koo');
	tab_select(0,'med');
	$('a','.tab').click(function() {
		tab_select( tab=( $(this).parent().parent().children("li").index( $(this).parent() ) ), rel = $(this).parent().parent().attr("rel") );
		return false;
	});
	*/
	
	var galleries = $('.ad-gallery').adGallery({
		loader_image: baseUrl+'/img/adgallery/loader.gif',
		width: '658', // Width of the image, set to false and it will read the CSS width
		height: false, // Height of the image, set to false and it will read the CSS height
		thumb_opacity: 0.7, // Opacity that the thumbs fades to/from, (1 removes fade effect)
		                      // Note that this effect combined with other effects might be resource intensive
		                      // and make animations lag
		start_at_index: 0, // Which image should be displayed at first? 0 is the first image
		animate_first_image: false, // Should first image just be displayed, or animated in?
		animation_speed: 400, // Which ever effect is used to switch images, how long should it take?
		display_next_and_prev: false, // Can you navigate by clicking on the left/right on the image?
		display_back_and_forward: true, // Are you allowed to scroll the thumb list?
		scroll_jump: 0, // If 0, it jumps the width of the container
		slideshow: {
			enable: false,
			autostart: false
		},
		effect: 'fade', // or 'slide-vert', 'resize', 'fade', 'none' or false
		callbacks: {
			init: function () {
				$(".ad-active").children("img").fadeTo(1,0.7);
				$(".ad-active").removeClass("ad-active");
				
			},
			imageClick: function () {
			
				if ($("#med-photo").css("visibility") == "hidden") {
					$("#med-photo").css('visibility','visible');
					$("#med-photo").animate({
						height: $("#med-photo .txt").height() + $("#med-photo .ad-image-wrapper").height() + $("#med-photo .h2").height() + parseInt($("#med-photo .txt").css("margin-top")) + parseInt($("#med-photo .ad-image-wrapper").css("margin-top")) + parseInt($("#med-photo .ad-image-wrapper").css("margin-bottom")) + parseInt($("#med-photo .h2").css("margin-top"))
					},1000,"swing",function(){$("#med-photo").css("height","auto")});
				}
			}
		}
	});
	
	var galleries2 = $('.ad-ytgallery').youtubeGallery({
		loader_image: baseUrl+'/img/adgallery/loader.gif',
		width: '658', // Width of the image, set to false and it will read the CSS width
		height: false, // Height of the image, set to false and it will read the CSS height
		thumb_opacity: 0.7, // Opacity that the thumbs fades to/from, (1 removes fade effect)
		                      // Note that this effect combined with other effects might be resource intensive
		                      // and make animations lag
		start_at_index: 0, // Which image should be displayed at first? 0 is the first image
		animate_first_image: false, // Should first image just be displayed, or animated in?
		animation_speed: 1, // Which ever effect is used to switch images, how long should it take?
		display_next_and_prev: false, // Can you navigate by clicking on the left/right on the image?
		display_back_and_forward: true, // Are you allowed to scroll the thumb list?
		scroll_jump: 0, // If 0, it jumps the width of the container
		slideshow: {
			enable: false,
			autostart: false
		},
		effect: 'none', // or 'slide-vert', 'resize', 'fade', 'none' or false
		callbacks: {
			init: function () {
				$(".ad-active").children("img").fadeTo(1,0.7);
				$(".ad-active").removeClass("ad-active");
				
			},
			imageClick: function () {
			
				if ($("#med-video").css("visibility") == "hidden") {
					$("#med-video").css('visibility','visible');
					$("#med-video").animate({
						height: $("#med-video .txt").height() + $("#med-video .ad-image-wrapper").height() + $("#med-video .h2").height() + parseInt($("#med-video .txt").css("margin-top")) + parseInt($("#med-video .ad-image-wrapper").css("margin-top")) + parseInt($("#med-video .ad-image-wrapper").css("margin-bottom")) + parseInt($("#med-video .h2").css("margin-top"))
					},1000,"swing",function(){$("#med-video").css("height","auto")});
				}
			}
		}
	});
	
	$(".tab[id=clr-med]").children("li:eq(0)").children("ol").children("li").children("a").click(function (e) {
		e.preventDefault();
		if ($("#institution_comment_form").css("display") == "none") {
			$(".tab[rel=clr-med]").children("li:eq(0)").children("ol").children("li").children("a").toggle();
			$("#institution_comment_form").slideDown();
			$("#no_comments").slideUp();
		} else {
			$(".tab[rel=clr-med]").children("li:eq(0)").children("ol").children("li").children("a").toggle();
			$("#institution_comment_form").slideUp();
			$("#no_comments").slideDown();
		}
	});
	
	$(".tab[id=clr-med]").children("li:eq(1)").children("ol").children("li").children("a").click(function (e) {
		e.preventDefault();
		if ($("#thread_form").css("display") == "none") {
			$(".tab[rel=clr-med]").children("li:eq(1)").children("ol").children("li").children("a").toggle();
			$("#thread_form").slideDown();
			//$("#no_topics").slideUp();
		} else {
			$(".tab[rel=clr-med]").children("li:eq(1)").children("ol").children("li").children("a").toggle();
			$("#thread_form").slideUp();
			//$("#no_topics").slideDown();
		}
	});
	

	$("#resr2iul a").simpletooltip();
	$("#schfljul li").simpletooltip();
		
});

