$(document).ready(function(){
	$(".mTeaserSliders a.teaser").hover(
		function(){
			if($("span",this).queue("fx").length < 2) {
	  			$("span",this).slideDown(300);
			}
		},
		function(){
			$("span",this).slideUp(300);
		}
	);
	$("#searchType").change(function(){
		$(".searchArea").css("display","none");
		$("#pleasure_category_" + $("#searchType")[0].value).css("display","block");
	});
	
	$(".mRelatedThemes .moreFeatures a[rel]").click(function() {
		return relatedThemesToggleShow($(this));
	});
	
	$(".p26 ul.tab li a").click(function () {

        var that = $(this);

        that.parent().addClass('active').siblings().removeClass('active');

        that.parent().parent().next().find('ul').hide().end().find('.articles'+ that.attr('class')).show();

        return false;
    });

	generateClicks();
	
	$(".p25_quickpoll .reply, .p13_quickpoll .reply").click(function() {
		var dl = $(this).parent().prev(),
			pollId = dl.attr('id').replace('pollId','');
			taURL = dl.find('.formerPolls').attr('id').replace('taURL','');
			answerId = dl.find('input:checked').attr('class');
		pollVote(pollId, answerId, dl, taURL);
		return false;
	});
	
	
	$(function(){ $('input[@type=radio].star').rating(); });
});

function generateClicks() {
	
	$(".p25_quickpoll_list dl dd a").unbind('click').click(function() {
		var dl = $(this).parent().parent();
		if(dl.hasClass('pollListActive')) {
			dl.removeClass('pollListActive').next('div.pollListResult').hide();
		} else {
			dl.siblings('.pollListActive').removeClass('pollListActive');
			dl.siblings('.pollListResult').hide();
			pollResultShow(dl.attr('id').replace('pollListId',''), dl);
		}
		return false;
	});

}

function setPopup(oThis, sHeight, sWidth){
	var popupWin = window.open(oThis.href, "_blank", "width=" + sWidth + ", height=" + sHeight + ", status=0, resizable=0, scrollbars=auto");
	return false;
}

function pollShowContent(divID,modID,offset,pageNum) {
	jQuery.post("/../../services/frontend/pleasure/ajax/mFrontendP25_quickpoll_list_content.php", { modID: modID, offset: offset, pageNum:pageNum }, function(data) {
		var obj = document.getElementById(divID);
		obj.innerHTML=data;
		generateClicks();
  	});
}

function pollResultShow(polldId, dl){
	$.post("/../../services/frontend/pleasure/ajax/mFrontendP25_quickpoll_list.php", { pollResultid: polldId }, function(data) {
		dl.next().html(data).show().prev().addClass('pollListActive');
  	});
}

function pollVote(pollId, answerId, dl, taURL) {
	$.post("/../../services/frontend/pleasure/ajax/mFrontendP25_quickpoll_single_show.php", { pollId: pollId, answerId: answerId, taURL: taURL}, function(data) {
		dl.html(data).next().remove().end().parent().parent().addClass('p25_quickpoll_ajax').end().parent().next('.formerPolls').remove();
	});
}

