﻿//jquery pielāgotās fjas

$(document).ready(function () {

	//augšējā filiāļu navigācija
	$('div.muzIzv ul li a').hover(function() {
		$('a.muzAct').stop().animate({width: "718px"}, {duration: 450, easing:"easeInOutQuad"});
		if ($(this).is(':animated')) {
			$(this).stop().animate({width: "943px"}, {duration: 450, easing:"easeOutQuad"});
		} else {
			$(this).stop().animate({width: "250px"}, {duration: 400, easing:"easeOutQuad"});
		}
	}, function () {
		if ($(this).is(':animated')) {
			$(this).stop().animate({width: "25px"}, {duration: 400, easing:"easeInOutQuad"})
		} else {
			$(this).stop('animated:').animate({width: "25px"}, {duration: 450, easing:"easeInOutQuad"});
		}
	});

	$('div.muzIzv').hover(function() {}, function() {
		$('div.muzIzv ul li a.muzAct').stop().animate({width: "943px"}, {duration: 450, easing:"easeOutQuad"});
	});
	
	//komentāru formas aktivizēšana
	
	$('#com').click(function(){
		if ($('#comform').is(':hidden')) $('#comform').slideDown();
	});

	//fonta maiņa saturam
	$('#large').click(function(){
			if ($.cookie("FontSize")=='13px' || $.cookie("FontSize")==null){
				$.cookie("FontSize", null);
				$('#content p,#content table,#content ul').css('font-size','16px');
				$.cookie("FontSize","16px", { path: '/', expires: 1 });
				return false;
			}
			if ($.cookie("FontSize")=='16px'){
				$.cookie("FontSize", null);
				$('#content p,#content table,#content ul').css('font-size','13px');
				$.cookie("FontSize","13px", { path: '/', expires: 1 });
				return false;
			}
	});
	
	//aptaujas apstrāde
	$('form[name=aptauja]').submit(function(){
		$.post(
			'/fjas/jpoll.php',
			{
				quest: $('form[name=aptauja] input[name=jaut]:checked').val()
			},
			function(res){
				$('#poll').empty();
				$('#poll').append(res['pres']).hide().fadeIn(1500);
				$('.rez').each(function(ind){
					var gar = $(this).width();
					$(this).width(0);
					$(this).animate({width: gar}, 1500);
				});
			},
			'json'
		);
		
		return false; //nolikvidējam refreshu
	});
	
  //pieteikuma apstrāde
	$('#forma').submit(function(){
    
    $.fancybox.showActivity();
    
		$.post(
			'/fjas/jpoll.php',
			{
				org: $('form[name=forma] input[name=org]').val(),
        sk: $('form[name=forma] input[name=grupa]').val(),
        dat: $('form[name=forma] input[name=datums]').val(),
        kpers: $('form[name=forma] input[name=k_name]').val(),
        tel: $('form[name=forma] input[name=k_tel]').val()
			},
			function(res){
				$.fancybox(res.inf);
			},
			'json'
		);
		return false; //nolikvidējam refreshu
	});
  
	$( "#footer a" ).mouseover( function() {  
        $( this ).children( "img" ).stop( true, true ).animate({  
            opacity: 0.6  
        }, 200, "swing", function() {  
            $( this ).animate({  
                opacity: 1  
            }, 400 );  
        });  
    });

  $("#piet").fancybox({
	'scrolling'		: 'no',
	'titleShow'		: false,
	'onClosed'		: function() {
	    $("#login_error").hide();
	}
});
	
	$("a.raksta_img").fancybox();

	
});

$(window).load(function(){
	$('#content p,#content table,#content ul').css('font-size', $.cookie("FontSize"));
	
	$('#pasImg').capty({
	 animation: 'fixed'
	});
});

function print_url(url){
 location=url;
 var ow = window.open(url,"ow");
 ow.document.close();
}
