var toggled = false;

toggleCollapse = function(){

};
$(document).ready(function(){
    $(".collapsable").before("<div class=clpsTrigger><a href='#'>&#1050;&#1040;&#1058;&#1040;&#1051;&#1054;&#1043;</a></div>");
    toggled = true;
    $(".collapsable").hide("fast");
    if(window.location == "http://alternenergy.ru/index.php?data=pricelist_new.xml&level1=1#priceanc" || 
        window.location == "http://alternenergy.ru/index.php?data=pricelist_new.xml&level1=1")
    {
         $(".collapsable").show("slow");
    }
    $(".clpsTrigger").click(function(e){
       //console.log("Table clicked!");
       if(!toggled){
           $(".collapsable").hide("slow");
           toggled=!toggled;
            e.preventDefault();

       }
       else
       {
           $(".collapsable").show("slow");
           toggled=!toggled;
            e.preventDefault();
       }
    });
     $(".linkTrigger").click(function(e){
       if(toggled){
             $(".collapsable").show("slow");
             toggled=!toggled;
       }

    });
    
   $("#dialogDiv").css('visibility','hidden');
    $("#dialogLink").click(function(e){
	initQuizDialog();
       

        
    });
});

function initQuizDialog()
{
       
       $("#dialogDiv").dialog(dialogOpts);
       $("#dialogDiv").css('visibility','visible');			
       $(".ui-dialog-title").prepend("&#1040;&#1085;&#1082;&#1077;&#1090;&#1072;");	
       $("#acceptKey").click(function(e){
		var feedback = $("#quizForm").serialize();
		//alert(feedback);
		$.ajax({
			type:"POST",
			url:"feedbackProcess.php",
			data:feedback,
			success:function(resp){
				alert(resp);
				$(this).close();
			}
		});
	
	});	
};

var dialogOpts = {	
	zIndex: 6000, 
	width:650, 
	height:430,
	resizable:false, 
	title:$("#dialogLink").html()
};

function hideFlash()
{
    $(".SpecialActObj").css('display','none');
}
function unhideFlash()
{
    $(".SpecialActObj").css('display','block');
}
