/* window.onload = function () {
	tooltip.init ();
}
 */
	var aquarelle = {src:'/templates/default/js/sifr3-r436/aquarelle.swf',wmode:'transparent'};
	sIFR.activate(aquarelle);
	sIFR.replace(aquarelle, {selector:'#cont_welcom', css: ['.sIFR-root {color:#7c1d1d; font-size:24px;text-align:left;}']});
	sIFR.replace(aquarelle, {selector:'#cont_welcom2', css: ['.sIFR-root {color:#7c1d1d; font-size:20px;text-align:left;}']});
	sIFR.replace(aquarelle, {selector:'#cont_welcom3', css: ['.sIFR-root {color:#7c1d1d; font-size:20px;text-align:left;}']});

		function toggle_sidebar(){
			if($('#hide_sidebar').attr('title')=='свернуть' || $('#hide_sidebar').attr('tiptitle')=='свернуть' || status===false){
				$('.sidebar').hide();
				$('#hide_sidebar').addClass('hidden_sidebar');
				$('#hide_sidebar').attr('title','развернуть');
				//$('#hide_sidebar').attr('tiptitle','развернуть');
				$('#html').html('развернуть');
				$.get('/index.php?module=articles&action=setstatus&status=1');
				tooltip.init();
			}else{
				$('.sidebar').show();
				$('#hide_sidebar').removeClass('hidden_sidebar')
				$('#hide_sidebar').attr('title','свернуть');
				//$('#hide_sidebar').attr('tiptitle','свернуть');
				$('#html').html('свернуть');
				$.get('/index.php?module=articles&action=setstatus&status=0');
				tooltip.init();
			}
		}
		
		
		
		
$().ready(function() {
	$("#nicemenu").flickrmenu();
	//$("a[rel='gall']").colorbox();
	//$("a[rel^='gall']").prettyPhoto({theme:'facebook'});
	//$("a[rel^='gall']").prettyPhoto({theme:'facebook'});
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
	tooltip.init ();

		$('#hide_sidebar').click(function(){
			 toggle_sidebar();
		});	
	
	
	
	
	
	
	
	
/* 	$("a[rel=example_group]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});	
	$(".various").fancybox({
		'padding'			: 0,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});	
	 */
	$('#faq').makeFAQ({
                indexTitle: "Содержание",
                displayIndex: false,
                faqHeader: "h2"
	});
	
	
});







(function($) { 
	$.fn.flickrmenu = function(options) { 
	
		var defaults = {
			headClass: "head_menu",
			subClass: "sub_menu",
			arrowClass: "head_menu",
			arrowPic: "/modules/navigation/templates/arrow.gif",
			arrowPicA: "/modules/navigation/templates/arrow_hover.gif",
			arrowPicH: "/modules/navigation/templates/arrow_hover.gif"
		};
		
		var options = $.extend(defaults, options); 
	
		return this.each(function() {

			var head_class = options.headClass;
			var sub_class = options.subClass;
			var arrow_class = options.arrowClass;
			var arrow = options.arrowPic;
			var arrow_select = options.arrowPicA;
			var arrow_hover = options.arrowPicH;
			
			var menu_id = this.id;			
			var obj = $(this);
			var headlevels = $('.' + head_class, obj);
			var arrows = $('.' + arrow_class, obj)
			
			
			
			
			arrows.click(function() {
				$('span.' + head_class).removeClass('active');
				submenu = $(this).parent().find('div.' + sub_class);
				
				if(submenu.css('display')=="block"){
					$(this).removeClass("active"); 	
					submenu.hide(); 		
					//$(this).attr('src', arrow_hover);									
				}else{
					$(this).addClass("active"); 	
					//submenu.fadeIn(400); 
					submenu.fadeIn(400, function() {
								if(jQuery.browser.msie)
									$(this).get(0).style.removeAttribute('filter');
					});					
					//$(this).attr('src', arrow_select);	
				}
				
				$('div.' + sub_class + ':visible').not(submenu).hide();
				//$('img.' + arrow_class).not(this).attr('src', arrow);
				
			})
			
			//.mouseover(function(){ $(this).attr('src', arrow_hover); })
			//.mouseout(function(){ 
			//	if($(this).parent().parent().find('div.' + sub_class).css('display')!="block"){
			//		$(this).attr('src', arrow);
			//	}else{
			//		$(this).attr('src', arrow_select);
			//	}
			//});
			
			
			$('span.' + head_class).mouseover(function(){ 
				$(this).addClass('over')
			}).mouseout(function(){ 
				$(this).removeClass('over') 
			});

			$('div.' + sub_class).mouseover(function(){ 
				//$(this).fadeIn(400); 
/////////////////////////////////////////////////////////////					
					$(this).fadeIn(400, function() {
								if(jQuery.browser.msie)
									$(this).get(0).style.removeAttribute('filter');
					});
/////////////////////////////////////////////////////////////				
			}).blur(function(){ 
				$(this).hide();
				$('span.' + head_class).removeClass('active');
			});
			
			$(document).click(function(event){ 		
				var target = $(event.target);
				if (target.parents('#' + menu_id).length == 0) {
					$('#'+ menu_id + ' span.' + head_class).removeClass('active');
					$('#'+ menu_id + ' div.' + sub_class).hide();
					//$('#'+ menu_id + ' img.' + arrow_class).attr('src', arrow);
				}
			});
		});
	}; 
	
	
    $.fn.makeFAQ = function(options) {
        var defaults = {
            indexTitle: "Index",
            faqHeader: ":header",
            displayIndex: false
        };
        var options = $.extend(defaults, options);
        return this.each(function() {
            var $obj = $(this);
            $obj.wrap("<div id='faqRoot'></div>");
            if(options.displayIndex) {
                $obj.before("<div id='faqindex'><h2>" + options.indexTitle + "</h2><ul></ul></div>");
            };
            var $faqEntries = $obj.children(options.faqHeader);
			var i = 0;
            $faqEntries.each(function () {
                var $entry = $(this);
                var entryName = $entry.text();
                var entryNameSafe = entryName.replace(/\W/g,"") + i;
                i++;
                var itemHTML = "<li><a id='" + entryNameSafe.toString() + "Index' href='#" + entryNameSafe.toString() + "' >" + entryName + "</a></li>";
                $('#faqindex ul').append(itemHTML);
                if(options.displayIndex) {
                    $('#' + entryNameSafe.toString() + 'Index').click( function(){ 
                        $('#' + entryNameSafe.toString()).next('span').slideDown('fast');
                        $('#' + entryNameSafe.toString()).addClass('faqopened');
                     });
                };
                $entry.next("div").addClass('faqcontent');
                $entry.attr({
                    title: "Click to expand/collapse",
                    name: entryNameSafe,
                    id: entryNameSafe                    
                    })
                    .addClass("faqclosed")
                    
                    .click( function() {
                        $entry.next('div').slideToggle('fast');
                        $entry.toggleClass('faqopened');
                        })
                        .next('div').css({ 
                            display: "none"
                        });
            });

        });
    };	
	
	
	
	
	
	
	
	
	
	
	
})(jQuery);


/* 

	$(document).ready(function() {	
		
	});
 */






var qTipTag = "a,label,input,td,span"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = 0; //This is qTip's X offset//
var qTipY = 15; //This is qTip's Y offset//

tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle, elements;
	
	var elementList = qTipTag.split(",");
	for(var j = 0; j < elementList.length; j++)
	{	
		elements = document.getElementsByTagName(elementList[j]);
		if(elements)
		{
			for (var i = 0; i < elements.length; i ++)
			{
				a = elements[i];
				sTitle = a.getAttribute("title");				
				if(sTitle)
				{
					a.setAttribute("tiptitle", sTitle);
					a.removeAttribute("title");
					a.removeAttribute("alt");
					a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
					a.onmouseout = function() {tooltip.hide()};
				}
			}
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}
















function get_month(month, year){
	
		$("#calendar").empty();                  
		$.ajax({  
			type: "POST",  
			url: "/index.php?module=articles&action=getcalendar",  
			data: "month=" + month + "&year=" + year,  
			success: function(html){  
				$("#calendar").html(html);  
				tooltip.init();
			}  
		});
		return false;  
};















































/* $(document).ready(function(){
   jQuery(".menu_top li").hover(function() {
		//jQuery(this).css('border-bottom', '5px solid #760b01');
		jQuery(this).addClass("act");

   }, function() {
		//jQuery(this).css('border-bottom', '2px solid #760b01');
		jQuery(this).removeClass("act");
   });

});
 */

function popup(datei,name,breite,hoehe,noresize)
{ 
	var posX=(screen.availWidth-breite)/2;
	var posY=(screen.availHeight-hoehe)/2;
	var resizable = (noresize==1) ? 0 : 1;
	window.open(datei,name,"resizable="+resizable+",scrollbars=1,width=" + breite + ",height=" + hoehe + "screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + "");
}


function galpop(datei,name,breite,hoehe,noresize)
{ 
	var posX=(screen.availWidth-breite)/2;
	var posY=(screen.availHeight-hoehe)/2;
	var resizable = (noresize==1) ? 0 : 1;
	var scrollbar = (document.all) ? 0 : 1;
	window.open(datei,name,"resizable="+resizable+",scrollbars="+scrollbar+",width=" + breite + ",height=" + hoehe + "screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + "");
}


function textCounter(field, countfield, maxlimit)
{ 
	if (field.value.length > maxlimit)
	{ 
		field.value = field.value.substring(0, maxlimit);
	} else { 
		countfield.value = maxlimit - field.value.length;
	}
}


function elemX (element) {
	var x = 0;
	while (element) {
		x += element.offsetLeft;
		element = element.offsetParent;
	}
	return x;
}

function elemY (element) {
	var y = 0;
	while (element) {
		y += element.offsetTop;
		element = element.offsetParent;
	}
	return y;
}

function getWidth (element) {
	return element.offsetWidth;
}

function getHeight (element) {
	return element.offsetHeight;
}

function elemObj(elementId) {
	if (document.all)
		return document.all[elementId];
	else if (document.getElementById)
		return document.getElementById(elementId);
	else
		return null;
}





