// JavaScript Document
function MM_preloadImages() { //v3.0
 	
	var d=document; 
	if(d.images)
	{ 
		if(!d.MM_p) d.MM_p=new Array();
    	var i, j=d.MM_p.length, a=MM_preloadImages.arguments;
    
    	for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0)
    	{
    		d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
    	}
	}
}


window.onload = (function(){
	try{
		//alert($("div#oprosdata").height());
		var height_oprosdata = Number($("#oprosdata").height())-15;
		$("#oprosdata .bottom").css("bottom","auto")
		$("#oprosdata .bottom").css("top",height_oprosdata+"px")
		
		height_oprosdata = Number($("#oprosresult").height())-15;
		$("#oprosresult .bottom").css("bottom","auto")
		$("#oprosresult .bottom").css("top",height_oprosdata+"px")
		
		
		$("#votingresult").click(function () {
			$("#oprosdata").fadeOut("slow", function () {
		      	$("#oprosresult").fadeIn("slow");
			});
		});	
		$("#votinggdata").click(function () {
			$("#oprosresult").fadeOut("slow", function () {
		      	$("#oprosdata").fadeIn("slow");
			});
		});	
		
		$("#subscribe-but2").click(function () {
			//alert("Подписаться");
			$("#subscribe").fadeIn("slow", function(){}); 
			$("#subscribe").css("top","auto");
			$("#subscribe").css("bottom","200px");
		});	
		$("#subscribe-but").click(function () {
			//alert("Подписаться");
			$("#subscribe").fadeIn("slow", function(){}); 
			$("#subscribe").css("bottom","auto");
			$("#subscribe").css("top","200px");
		});	
		$("#close_subscribe").click(function () {
			$("#subscribe").hide("slow"); 
		});	
		$("#lgt1").click(function () {
			$("#registr").hide("slow", function(){$("#logout").fadeIn("slow"); }); 
		});	
		$("#regst1").click(function () {
			$("#logout").hide("slow", function(){$("#registr").fadeIn("slow");}); 
			 
		});	
		
		$("#lgt").click(function () {
			$("#registr").hide("slow", function(){$("#logout").fadeIn("slow"); }); 
		});	
		$("#regst").click(function () {
			$("#logout").hide("slow", function(){$("#registr").fadeIn("slow");}); 
			 
		});	
		$("#regst_").click(function () {
			$("#logout").hide("slow", function(){$("#registr").fadeIn("slow");}); 		 
		});	
		$("#close_registr").click(function () {
			$("#registr").hide("slow"); 
		});	
		$("#close_logout").click(function () {
			$("#logout").hide("slow"); 
		});	
		$("#exitauth").click(function () {
			document.getElementById("f_exitauth").submit();
		});
		
		$("#dvoting").click(function () 
		{
			var submit = false;
			var count_answer = $("#voting_answer input:radio").size();
			
			//alert(count_answer);
			
			for(var i=0; i < count_answer; i++)
			{
				if($("#voting_answer input:radio:eq(" + i + "):checked").val() > 0) submit = true;
			}
			if(submit==true) document.getElementById("f_dvoting").submit();
		});
		
		$("#vklphoto").click(function () {	
			
			document.getElementById("vkl").style.backgroundImage="url('"+template_path+"images/vkladka_photo_video.jpg')";
			document.getElementById("photo_y").style.display="block"; 
			document.getElementById("video_y").style.display="none"; 
			document.getElementById("all_photo_bottom").style.display="block"; 
			document.getElementById("all_video_bottom").style.display="none";
		});	
		$("#vklvideo").click(function () {

			document.getElementById("vkl").style.backgroundImage="url('"+template_path+"images/vkladka_video_photo.jpg')";
			document.getElementById("photo_y").style.display="none"; 
			document.getElementById("video_y").style.display="block"; 
			document.getElementById("all_photo_bottom").style.display="none"; 
			document.getElementById("all_video_bottom").style.display="block";
		});	
		MM_preloadImages(template_path+"images/registr.png", template_path+"images/forma_logout.png", template_path+'images/vkladka_video_photo.jpg', template_path+'images/bg_photo_video_top.jpg');
	}
	catch(e){}
});


/*jQuery(function($) { 
	$(document).ready( function() { 
		var currentOpen; 
		$("#menu_left .item").each( function (index){
			//alert("dsd");
			$(this).bind("mouseenter", function(){                        
				$( "#pod" + this.id  ).slideDown(300);                                                   
			});
			
			$(this).bind("mouseleave", function(){  
				$( "#pod" + this.id  ).slideUp(100);
			});
		});              
	}); 
});*/

$(function(){
	//$("#main_menu .main_menu_item .main_menu_item_podmenu").fadeTo(0,0);
	$("#menu_left .item").each(function(){
		// показать субменю
		$(this).bind("mouseenter",function(){
			$(".menu_left_podmenu",this).css("display","block");	
			$(".menu_left_podmenu",this).fadeTo(300,1);
		});

		// скрыть субменю
		$(this).bind("mouseleave",function(){
			$(".menu_left_podmenu",this).fadeTo(0,0);		
			$(".menu_left_podmenu",this).css("display","none");	
		});
	});
});