var web_host= 'http://www.votum-sa.pl';

$.fn.makeAbsolute = function(rebase) {
    return this.each(function() {
        var el = $(this);
        var pos = el.position();
        el.css({ position: "absolute",
            marginLeft: 0, marginTop: 0,zIndex: 999,
            top: pos.top, left: pos.left });
        if (rebase)
            el.remove().appendTo("body");
    });
}



$(function() {

$('a[rel=lightbox]').colorbox();

   var zIndexNumber = 1000;
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});

		$('#show_all').click(function() {
				$('#false_margin').css({ "margin-top": "195px"});
		    $('#makeme').css({ position: "absolute"});
         //$("#makeme").width(440);
         //$("p").show("slow")
         //$("#part2").slideToggle();//show("slow");
        $('#makeme').animate({width: "440px"}, { queue:false, duration:400 });
        //$("#part2").slideToggle();
				$("#part2").show("slow");
				$("#ask_case").slideUp();


		});
		
		$('#hide_all').click(function() {
		     $("#part2").hide("fast");
				 $('#makeme').animate({width: "239px"}, { queue:false, duration:400 });
		});

		$('#show_ask').click(function() {
		
				if ($('#makeme').is(":visible")) {
								 $('#false_margin').css({ "margin-top": "10px"});
								 $('#makeme').css({ position: "relative"});
						     $("#part2").hide("fast");
								 $('#makeme').animate({width: "239px"}, { queue:false, duration:400 });
								 $("#makeme").slideUp();
				 }
	
         $("#ask_case").slideToggle();
		});
		
		$('#show_top_form').click(function() {
				if ($('#ask_case').is(":visible")) {
				         $("#ask_case").slideUp();
				} 
				
				if ($('#makeme').is(":hidden")) {
								$("#makeme").slideDown();
							 	$('#false_margin').css({ "margin-top": "195px"});
							 	$('#makeme').css({ position: "absolute"});
				        $('#makeme').animate({width: "239px"}, { queue:false, duration:400 });
				}
		});

	$("#makeme").makeAbsolute();
	$("#makeme").width('239');
	$("#footer").corner();
	
		$('#more_news').click(function() {
		var id = document.getElementById("a_id").value;
		$("#authors").append("<p id='author" + id + "'></p>");
		$("#author" + id).load(web_host+"/ajax/authors/"+id);
		id = (id - 1) + 2;
		document.getElementById("news_id").value = id;
		});
		
		$('.last_group').click(function() {
			all_parts  = $(this).attr("id").split("_");
			hide_this = all_parts[1];
			//$('.last_'+hide_this).hide();
				$('.lg_'+hide_this).each(function(){
					if($(this).css('display')  == 'none')
					     $(this).show();
					else
					{
					     $(this).hide();                       
					}
				});
			
		});
		
		$('.scroll_me').click(function() {
			all_parts2  = $(this).attr("id").split("_");
			hide_this2 = all_parts2[1];
			//$('.last_'+hide_this).hide();
				$('.sc_'+hide_this2).each(function(){
					if($(this).css('display')  == 'none')
					     $(this).show();
					else
					{
					     $(this).hide();                       
					}
				});
		});
		
		$('.popup').click(function() {
			current_href = $(this).attr("href");
			$(this).attr("href", "#");
			$.fn.colorbox({width:"80%", height:"80%", iframe:true,href:current_href, open:true}); 
			$(this).attr("href", current_href); 
			return false;
		});
		
		$('#rinput').click(function() {
			$(this).val("");
		});
		
$('#news a').tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - " 
    //fade: 250 
});

});
	  
$(document).ready(function(){ 
        $("ul.sf-menu").supersubs({ 
            minWidth:    12,    
            maxWidth:    27,    
            extraWidth:  1       
        }).superfish({
            animation: {height:'show'},   // slide-down effect without
			delay:     500 ,              // 1.2 second delay on
			firstOnClick: false,
			disableHI   : false,
			autoArrows  : true,
            dropShadows : true		
								});
  
		$("ul.sf-menu_lefter").supersubs({ 
            minWidth:    19.5,    
            maxWidth:    19.5,    
            extraWidth:  1       
        }).superfish({
            animation: {height:'show'},   // slide-down effect without
			firstOnClick: true,
			noout       : true,
			disableHI   : false,
			autoArrows  : true,
            dropShadows : true		
								}); 
 
	
           
				$('.qa_link').each(function(){
					//rel = $(this).attr("rel");
					//alert($('#'+rel).attr('id'));

					$(this).click(function() {
							//if($('#'+$(this).attr("rel")).css('display')  == 'none')
							hide_q();	
						     $('#'+$(this).attr("rel")).show();
						//else
						     //$('#'+$(this).attr("rel")).hide();
						//alert($('#'+rel).attr('id'));
						return false;                       
					});
				});
		                 
    	/*$('#mask').css({'height':$('#panel-1').height()});     
          
    	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));   
          
    	$('#panel div').width($('#mask').width());   
       
  
	    $('a[rel=panel]').click(function () {   
       
        var panelheight = $($(this).attr('href')).height();   
             
        $('a[rel=panel]').removeClass('selected');   
        $(this).addClass('selected');   
              
        $('#mask').animate({'height':panelheight},{queue:false, duration:500});            
        $('#mask').scrollTo($(this).attr('href'), 0,{ easing:'swing', queue:false, axis:'xy' });        
              
        return false;   
    });*/
	$(function() {
		$("#tabs").tabs({
			/*event: 'mouseover',*/
			/*fx: { opacity: 'toggle' }*/
		});
		
		$("#tabs_q").tabs({
			/*event: 'mouseover',*/
			/*fx: { opacity: 'toggle' }*/
		});
		
		$("#tabs2").tabs({
			/*event: 'mouseover',*/
			fx: { opacity: 'toggle' }
		});
	}); 

 		$('.wizard').live("click",function() {
 		//alert($(this).attr('id'));
		     //var id = $('input[name=answer]:checked').val();
		     var id = $(this).attr('id');
			var user = $('input[name=identifier]').val();
		     if (id) {
			   /*$('#wizard').slideUp('slow').load(web_host+"/ajax/wizard/"+id+"/"+user, function() {
			     //initBinding();
				$(this).slideDown('slow');
			   });*/
			   $("#wizard").empty().html('<img src="'+web_host+'/media/img/ajax-loader.gif" style="margin-left:50px;margin-top:20px;"  />');
			   $('#wizard').load(web_host+"/ajax/wizard/"+id+"/"+user); 
			} 
	      		//$("#wizard").load(web_host+"/ajax/wizard/"+id+"/"+user);
		});

		//$('#next').click(function() {
		     //var id = $('input[name=answer]:checked').val();
		     //var user = $('input[name=identifier]').val();
		     //if (id) {
			   //$('#wizard').slideUp('slow').load(web_host+"/ajax/wizard/"+id+"/"+user, function() {
			     //$(this).slideDown('slow');
			   //});
		        //$("wizard").empty().html('<img src="'+web_host+'/media/img/ajax-loader.gif" />');
			   //$('#wizard').load(web_host+"/ajax/wizard_prev/"+user);
			//} 
	      		//$("#wizard").load(web_host+"/ajax/wizard/"+id+"/"+user);
		//}); 
		
		//$('#prev').click(function() {
		     //var user = $('input[name=identifier]').val();
			   //$('#wizard').slideUp('slow').load(web_host+"/ajax/wizard_prev/"+user, function() {
			     //$(this).slideDown('slow');
				// });
	      	//$("#wizard").load(web_host+"/ajax/wizard_prev/"+user);
		//});
		
		//$('.bread').each(function() {
		//$(this).click(function() {
		
			//alert($(this).attr('id'));
			//alert('aaa');
		     //var id = $('input[name=answer]:checked').val();
		     //var user = $('input[name=identifier]').val();
		     //if (id) 
	      		//$("#wizard").load(web_host+"/ajax/wizard/"+id+"/"+user);
		//});
		//}); 
		
		//initBinding();
		
$("#iframe_log").colorbox({width:"45%", height:"50%", iframe:true}); 
$("#iframe_reg").colorbox({width:"80%", height:"80%", iframe:true});
$("#wizard_log").colorbox({width:"46%", height:"55%", iframe:true}); 
                                                        
}); 

function costam(id)
{
		     //alert('c'+id);
			var user = $('input[name=identifier]').val();
	      		//$("#wizard").load(web_host+"/ajax/wizard/"+id+"/"+user);
			   /*$('#wizard').slideUp('slow').load(web_host+"/ajax/wizard/"+id+"/"+user, function() {
			     $(this).slideDown('slow');
			   });*/
	      	$("#wizard").empty().html('<img src="'+web_host+'/media/img/ajax-loader.gif" style="margin-left:50px;margin-top:20px;"  />');		
		     $('#wizard').load(web_host+"/ajax/wizard/"+id+"/"+user);
}

function hide_q() 
{
	$('.hide_q').each(function(){
			$(this).hide();                     
	});
}

/*function initBinding() 
{
 		$('.wizard').click(function() {
 		//alert($(this).attr('id'));
		     //var id = $('input[name=answer]:checked').val();
		     var id = $(this).attr('id');
			var user = $('input[name=identifier]').val();
		     if (id)
			   $('#wizard').slideUp('slow').load(web_host+"/ajax/wizard/"+id+"/"+user, function() {
			     initBinding();
				$(this).slideDown('slow');
			   });
			 
	      		//$("#wizard").load(web_host+"/ajax/wizard/"+id+"/"+user);
		});
}*/
