
		 $(document).ready(function() {
			 
			if($.cookie("style")) {
				var style = $.cookie("style");
				setStyle(style);								
			}

            $(".change-style").click(function() {
				var style2 = $(this).attr("id");
				$.cookie("style", style2);
				setStyle(style2);
				return false;
            });

			$("#custom").click(function() {
				$(this).val("");
			});
		 });

		 function setStyle(name) {
			$("#main-center").attr("class", "main_"+name);
			$("#main-bot").attr("class", "main_bot_"+name);
			$("#mbox").attr("class", "m-box01_"+name);
			$("#main-top").attr("class", "main_top_"+name);
		 }


function checkVoteForm(voteid) {	
	var val = $(":radio[name=variant]").filter(":checked").val();	
	if (val == 'custom') {
		if ($("#custom").val() == "" || $("#custom").val() == "Ваш вариант") {
			$("#custom").addClass("error");
			return false;
		}
	}

	if (val == "undefined") {
		return false;
	}

	var name = $("#votename").val();
	var email = $("#voteemail").val();

	if (name == "" && email == "") {
		if (val == 'custom') {
			ajaxVoting(val, voteid, $("#custom").val());
		}
		else ajaxVoting(val, voteid, false);
	}

	
}

function ajaxVoting(val, voteid, custom) {

	var name = $("#votename").val();
	var email = $("#voteemail").val();
	
	if (name == "" && email == "") {

		if (custom) {
			$.post(
			  '/vote/vote.php',
			  {
				variantId: val,				
				voteId: voteid,		
				custom: custom,
				mode: 'addval'
			  },
			onAddVote
			);	
		}
		else {
			$.post(
			  '/vote/vote.php',
			  {
				variantId: val,				
				voteId: voteid,
				mode: 'addval'
			  },
			onAddVote
			);	
		}
		
		$("#send").hide();
		$("#preloader").show();		
	}
	
}

function onAddVote(data) {	
	if(data == "ok") {
		$("#preloader").hide();
		$(".radio").hide();
		$(".custom-variant").hide();
		$(".send").css("bottom", "50px");
		$("#success").show().html("<p>Спасибо за Ваш голос</p>");		
	}
	else {
		$("#preloader").hide();
		$("#success").show().html("<p>Не отправлено</p>");
	}
}

(function($) {

	$.fn.easyTooltip = function(options){
	  
		// default configuration properties
		var defaults = {	
			xOffset: -201,		
			yOffset: 1,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var title = $(this).attr("title");				
			$(this).hover(function(e){											 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");		
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")						
						.css("display","none")
						.fadeIn("fast")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	  
	};

})(jQuery);

$(document).ready(function(){
		$(".titles").easyTooltip({

		});
	});

