/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(name,value,options){if(typeof value!="undefined"){options=options||{};if(value===null){value="";options.expires=-1}var expires="";if(options.expires&&(typeof options.expires=="number"||options.expires.toUTCString)){var date;if(typeof options.expires=="number"){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires="; expires="+date.toUTCString()}var path=options.path?"; path="+(options.path):"";var domain=options.domain?"; domain="+(options.domain):"";var secure=options.secure?"; secure":"";document.cookie=[name,"=",encodeURIComponent(value),expires,path,domain,secure].join("")}else{var cookieValue=null;if(document.cookie&&document.cookie!=""){var cookies=document.cookie.split(";");for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+"=")){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}};


// URL plugin

jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();


// Lightbox plugin
(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:"#000",overlayOpacity:0.8,fixedNavigation:false,imageLoading:"images/lightbox-ico-loading.gif",imageBtnPrev:"images/lightbox-btn-prev.gif",imageBtnNext:"images/lightbox-btn-next.gif",imageBtnClose:"images/lightbox-btn-close.gif",imageBlank:"images/lightbox-blank.gif",containerBorderSize:10,containerResizeSpeed:400,txtImage:"Image",txtOf:"of",keyToClose:"c",keyToPrev:"p",keyToNext:"n",imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false}function _start(objClicked,jQueryMatchedObj){$("embed, object, select").css({visibility:"hidden"});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute("href"),objClicked.getAttribute("title")))}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute("href"),jQueryMatchedObj[i].getAttribute("title")))}}while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute("href")){settings.activeImage++}_set_image_to_view()}function _set_interface(){$("body").append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$("#jquery-overlay").css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$("#jquery-lightbox").css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$("#jquery-overlay,#jquery-lightbox").click(function(){_finish()});$("#lightbox-loading-link,#lightbox-secNav-btnClose").click(function(){_finish();return false});$(window).resize(function(){var arrPageSizes=___getPageSize();$("#jquery-overlay").css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$("#jquery-lightbox").css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]})})}function _set_image_to_view(){$("#lightbox-loading").show();if(settings.fixedNavigation){$("#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber").hide()}else{$("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber").hide()}var objImagePreloader=new Image();objImagePreloader.onload=function(){$("#lightbox-image").attr("src",settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){}};objImagePreloader.src=settings.imageArray[settings.activeImage][0]}function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$("#lightbox-container-image-box").width();var intCurrentHeight=$("#lightbox-container-image-box").height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$("#lightbox-container-image-box").animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image()});if((intDiffW==0)&&(intDiffH==0)){___pause(250)}$("#lightbox-container-image-data-box").css({width:intImageWidth});$("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({height:intImageHeight+(settings.containerBorderSize*2)})}function _show_image(){$("#lightbox-loading").hide();$("#lightbox-image").fadeIn(function(){_show_image_data();_set_navigation()});_preload_neighbor_images()}function _show_image_data(){$("#lightbox-container-image-data-box").slideDown("fast");$("#lightbox-image-details-caption").hide();if(settings.imageArray[settings.activeImage][1]){$("#lightbox-image-details-caption").html(settings.imageArray[settings.activeImage][1]).show()}if(settings.imageArray.length>1){$("#lightbox-image-details-currentNumber").html(settings.txtImage+" "+(settings.activeImage+1)+" "+settings.txtOf+" "+settings.imageArray.length).show()}}function _set_navigation(){$("#lightbox-nav").show();$("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({background:"transparent url("+settings.imageBlank+") no-repeat"});if(settings.activeImage!=0){if(settings.fixedNavigation){$("#lightbox-nav-btnPrev").css({background:"url("+settings.imageBtnPrev+") left 15% no-repeat"}).unbind().bind("click",function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false})}else{$("#lightbox-nav-btnPrev").unbind().hover(function(){$(this).css({background:"url("+settings.imageBtnPrev+") left 15% no-repeat"})},function(){$(this).css({background:"transparent url("+settings.imageBlank+") no-repeat"})}).show().bind("click",function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false})}}if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$("#lightbox-nav-btnNext").css({background:"url("+settings.imageBtnNext+") right 15% no-repeat"}).unbind().bind("click",function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false})}else{$("#lightbox-nav-btnNext").unbind().hover(function(){$(this).css({background:"url("+settings.imageBtnNext+") right 15% no-repeat"})},function(){$(this).css({background:"transparent url("+settings.imageBlank+") no-repeat"})}).show().bind("click",function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false})}}_enable_keyboard_navigation()}function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent)})}function _disable_keyboard_navigation(){$(document).unbind()}function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE}key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=="x")||(keycode==escapeKey)){_finish()}if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation()}}if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation()}}}function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0]}if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0]}}function _finish(){$("#jquery-lightbox").remove();$("#jquery-overlay").fadeOut(function(){$("#jquery-overlay").remove()});$("embed, object, select").css({visibility:"visible"})}function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight}}var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth}else{windowWidth=self.innerWidth}windowHeight=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight}else{if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight}}}if(yScroll<windowHeight){pageHeight=windowHeight}else{pageHeight=yScroll}if(xScroll<windowWidth){pageWidth=xScroll}else{pageWidth=windowWidth}arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize}function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft}else{if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft}}}arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll}function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date()}while(curDate-date<ms)}return this.unbind("click").click(_initialize)}})(jQuery);



jQuery(document).ready(function() {

	var urlDirFull = jQuery.url.attr("directory");

	/* --- jQuery extensions --- */
	
	// css properties selectors
	jQuery.extend(jQuery.expr[':'],{
		float: function(a) {
		  return (jQuery(a).css("float") === "left" || jQuery(a).css("float") === "right");
		},
		inline: function(a) {
		  return jQuery(a).css("display") === "inline";
		},
		marginx: function(a) {
		  return ((parseInt(jQuery(a).css("margin-left")) > 0) || (parseInt(jQuery(a).css("margin-right")) > 0));
		},
		marginy: function(a) {
		  return ((parseInt(jQuery(a).css("margin-bottom")) > 0) || (parseInt(jQuery(a).css("margin-top")) > 0));
		},
		margin: function(a) {
		  return ((parseInt(jQuery(a).css("margin-left")) > 0) || (parseInt(jQuery(a).css("margin-right")) > 0) || (parseInt(jQuery(a).css("margin-bottom")) > 0) || (parseInt(jQuery(a).css("margin-top")) > 0));
		}
	});
	
	
	$('.input-datepicker').datePicker({startDate:'01.01.1900'});
	

	/* --- bookmark & set as homepage --- */

	jQuery("#s-m-fav").click(function() {
		var url = document.location.href;
		url = url.replace('#','');
		var title = document.title;
		arctBookmarkIt(title, url);
	});
	jQuery("#set-as-homepage-button").click(function() {
		arctSetAsHomepage(this, 'http://www.spletna-stran.si');
	});


	/*--- printing ---*/

	jQuery("#s-m-print").click(function(e) {
		e.preventDefault();
		window.print();
	});
	
	
	/*--- poll ---*/
	
	jQuery("form#poll-form").submit(function() {
		var responseData = '';
		if (jQuery('#multi-answers').val() != '1') 
			// one answer
			responseData = jQuery("form#poll-form input:checked").val();
		else {
			// multiple answers
			jQuery("form#poll-form input:checked").each(function () {
				responseData += this.value + ' ';
			});
		}
		jQuery.post("/util/ajaxresponse.php",{
				func: "poll", 
				response: responseData
		     }, function(html) {
		   showPoll(html);
		 });
		return false;
	});

	function showPoll(htmlResponse) {
		jQuery("#poll-container").html(htmlResponse);
		jQuery("#poll-container img").each(function() {
			var tmp = jQuery(this).attr("class");
			var aVals = tmp.match(/[0-9]+$/); // get number at the end of the string
			var val = aVals[0];
			jQuery(this).animate({ width: val+"px" }, 1000 );
		});
	}
	
	
	/*--- FAQ ---*/
	
	if ($("div#faq-form-section").length) {
		$("p#faq-form-toggle").slideDown();
		$("p#faq-form-toggle").click(function() {
			$("p#faq-form-toggle").slideUp(0);
			$("div#faq-form-section").slideToggle(0);
		});
	}
	
	if ($("div#faq-list").length) {
		$("div#faq-list h2").click(function() {
			$(this).next("dl.faq-list").slideToggle(0);
			$(this).next("dl.faq-list").toggleClass('open');
			$(this).toggleClass('open');
		});
	}
	

	/* --- main menu --- */

	$("#main-menu a[href != '#']").each(function() {
		// consider the id in the url when comparing
		if($(this).attr("class") == "m-m-useid"){
			// find matching url
			var urlDir = urlDirFull;
			var aHref = $(this).attr("href"); // trim IDs from url (example. "123758363528/")
		// ignore the id in the url when comparing
		} else {
			// find matching url
			var urlDir = urlDirFull.replace(/all\/|[_\d]+\/.*/g, ''); // trim IDs from url (.../all/34235435234623/313/123123/...)
			var aHref = $(this).attr("href").replace(/all\/|[_\d]+\/.*/g, ''); // trim IDs from url (.../all/34235435234623/313/123123/...)
		}
		
		// the page url is the same as the menu link, so open the menu
		if (urlDir == aHref) {
			$(this).parents("li").each(function() {
				var tmp = $(this).attr('class');
				var aLevels = tmp.match(/[0-9]+/); // get number at the end of the string
				//if (aLevels != undefined) {
				var level = aLevels[aLevels.length-1];				
				$(this).addClass("menu-level"+level+"-open");
				//}
			});
			$(this).parents("ul").show();
			$(this).next("ul").show();
		}
	});

	$("#main-menu span").click(function(e) {
		var liEl = $(this).parents("li:first"); // li element
		var liSibl = liEl.siblings(); // sibling li elements
		
		// find out li level
	   	var tmp = liEl.attr('class');
	   	var aLevels = tmp.match(/[0-9]+/);
	   	var tgtlevel = aLevels[aLevels.length-1]; // tgt level
		
		liSibl.find("ul").slideUp('fast'); // hide all of the siblings' uls
		liEl.find("ul ul").slideUp('fast'); // hide child uls
		liEl.find("ul:first").slideToggle('fast'); // toggle the current submenu
		
		liSibl.removeClass("menu-level"+tgtlevel+"-open"); // remove the 'm-m-levelX-open' class from all the siblings of the clicked li
		liSibl.find('li').each(function() {
			var tmp = jQuery(this).attr('class');
			var aLevels = tmp.match(/[0-9]+/); // get number at the end of the string
			var level = aLevels[aLevels.length-1];
			jQuery(this).removeClass("menu-level"+level+"-open"); // remove the 'm-m-levelX-open' class from all the children of the siblings of the clicked li
		});
		liEl.find('li').each(function() {
			var tmp = jQuery(this).attr('class');
			var aLevels = tmp.match(/[0-9]+/); // get number at the end of the string
			var level = aLevels[aLevels.length-1];
			jQuery(this).removeClass("menu-level"+level+"-open"); // remove the 'm-m-levelX-open' class from all the children of the clicked li
		});
		
		liEl.toggleClass("menu-level"+tgtlevel+"-open"); // toggle class 'm-m-levelX-open' of the clicked li
		
		// prevent jumping to the top of the page for invalid (#) links
		if (liEl.find("a").attr("href") == '#') {
			e.preventDefault();
		}
	});


	/* --- text resizing --- */

	jQuery("#t-s-normal").click(function(e) {
		jQuery("body").css({"fontSize": "62.5%"});
		jQuery.cookie('page_font_size', "62.5%", {path: '/'}); // save font size in cookie
	})

	jQuery("#t-s-larger").click(function(e) {
		jQuery("body").css({"fontSize": "70%"});
		jQuery.cookie('page_font_size', "70%", {path: '/'}); // save font size in cookie
	})

	jQuery("#t-s-largest").click(function(e) {
		jQuery("body").css({"fontSize": "85%"});
		jQuery.cookie('page_font_size', "85%", {path: '/'}); // save font size in cookie
	})

	// retrieve font size if cookie has been set
	var cookieFontSize = jQuery.cookie('page_font_size');
	if (cookieFontSize != '') {
		jQuery("body").css({"fontSize": cookieFontSize});
	}


	/* --- alt style switcher --- */
	
	function switchStylestyle(styleName) {
		$('link[@rel*=style][title]').each(function(i) {
        	this.disabled = true;
	        if (this.getAttribute('title') == styleName) this.disabled = false;
	    });
		$.cookie('style', styleName, {path: '/'});
	}
	
	function clearStylestyle() {
		$('link[@rel*=style][title]').each(function(i) {
        	this.disabled = true;
	    });
		$.cookie('style', null, {path: '/'});
	}
	
	$('#s-m-s-contrast').click(function() {
		var c = $.cookie('style');
		if (c) {
			clearStylestyle();
		} else {
    		switchStylestyle("high contrast style");
		}
    	return false;
	});
	var c = $.cookie('style');
	if (c) switchStylestyle(c);
	
	
	/* --- anchor click scrolling --- */
	
	$('a[href^=#]').click(function(e) {
		// scroll to anchor if there is actually more after the # sign in the link
		if ($(this).attr('href').length > 1) {
			scrollToElementName = $(this).attr('href').substr($(this).attr('href').indexOf("#")+1);
			scrollTo = $("a[name="+scrollToElementName+"]").offset().top;
			$('html, body').animate({scrollTop: scrollTo}, 500);
			e.preventDefault();
		}
	});	


	/* --- populate text fields and clear them on focus --- */

	jQuery.fn.textBoxHint = function () {
		return this.each(function () {
	    	var t = jQuery(this); // get jQuery version of 'this'
			var title = t.attr('title'); // get it once since it won't change
		    // only apply logic if the element has the attribute
		    if (title) {
				// on blur, set value to title attr if text is blank
				t.blur(function () {
					if (t.val() == '') {
						t.val(title);
						t.addClass('blur');
					}
				});
				// on focus, set value to blank if current value
				// matches title attr
				t.focus(function () {
					if (t.val() == title) {
						t.val('');
						t.removeClass('blur');
					}
				});
				// clear the pre-defined text when form is submitted
				t.parents('form:first').submit(function() {
					if (t.val() == title) {
						t.val('');
						t.removeClass('blur');
					}
				});
				t.blur(); // now change all inputs to title
			}
		});
	}


	/* --- table zebra striping --- */

	jQuery.fn.zebraStripeIt = function() {
		jQuery("tr:odd", this).addClass("odd"); // set class to every odd row in a table
	}


	/* --- image framer --- */

	$.fn.initImageFramer = function() {
		jQuery(this).each(function() {
			
			var caption = jQuery(this).next('span.caption').text();
			var imageTitle = jQuery(this).attr("title"); // get title text

			if (imageTitle == '') {
				imageTitle = jQuery(this).attr("alt"); // no title text available, use alt text
			}
			// no text available - skip
			if (imageTitle != '') {
				var addClass = '';
				if (jQuery(this).hasClass('left')) {
					addClass = ' photo-frame-left';
				} else if (jQuery(this).hasClass('right')) {
					addClass = ' photo-frame-right';
				} else {
					addClass = ' photo-frame-unaligned';
				}
				var imgWidth = jQuery(this).width();
				jQuery(this).wrap('<div class="photo-frame'+addClass+'" style="width:'+imgWidth+'px"></div>');
				jQuery(this).after('<p>'+caption+'</p>');
				jQuery(this).next('p').width(imgWidth);
			}
		});
	}


	/* --- external links --- */

	$.fn.markExternalLinks = function() {
		jQuery(this).filter(function() {
			return this.hostname && this.hostname !== location.hostname;
		}).addClass("external");
	}


	/* --- calendar --- */

	function initCalendar() {
		// advance a month
		var lng = jQuery('#calendar-response').attr('class');
		var strId = 'evnt_'+lng;
		jQuery("#cal-next-month").click(function(e) {
			var cName = jQuery("#cal-next-month").attr("class");
			var y = cName.substr(6,4);
			var m = cName.substr(10,2);
			jQuery("#calendar-response").load("/util/ajaxresponse.php", { 'func': 'outputCalendar', 'y': y, 'm': m, 'eventsStrId':strId }, function() {
				initCalendar();
			});
			e.preventDefault();
		});

		// backtrack a month
		jQuery("#cal-prev-month").click(function(e) {
			var cName = jQuery("#cal-prev-month").attr("class");
			var y = cName.substr(6,4);
			var m = cName.substr(10,2);
			jQuery("#calendar-response").load("/util/ajaxresponse.php", { 'func': 'outputCalendar', 'y': y, 'm': m, 'eventsStrId':strId}, function() {
				initCalendar();
			});
			e.preventDefault();
		});
	}
	
	
	/* --- Photogallery --- */

	function initPhotogallery() {
		if (jQuery("#photo-gallery-container").length) {
			var galleryWidth = jQuery("div#photo-gallery-container").width();
			var galleryItemWidth = jQuery("div#photo-gallery-container .photo-gallery-item:first").width();
			var itemsPerRow = Math.floor(galleryWidth / galleryItemWidth);
			var cnt = 1;
			var cntItems = 0;
			var maxHeight = 0;
			var aHighest = new Array();
			var nItems = jQuery("div#photo-gallery-container .photo-gallery-item").length;
			jQuery("div#photo-gallery-container .photo-gallery-item").each(function() {
				cntItems++;
				if (cnt > itemsPerRow) {
					cnt = 0;
					maxHeight = 0;
				}
				//var totalHeight = 
				if (jQuery(this).height() > maxHeight) {
					maxHeight = jQuery(this).height();
				}
				if (cnt == itemsPerRow || cntItems == nItems) {
					aHighest.push(maxHeight);
				}
				cnt++;
			});
			cnt = 1;
			cnt2 = 0;
			jQuery("div#photo-gallery-container .photo-gallery-item").each(function() {
				if (cnt > itemsPerRow) {
					cnt = 1;
					cnt2++;
				}
				jQuery(this).height(aHighest[cnt2]);
				
				// check for thumbs which are too wide and remove the height attribute / add width
				if (jQuery(this).width() <= jQuery("img", this).width()) {
					jQuery("img", this).removeAttr("height");
					jQuery("img", this).width(jQuery(this).width());
				}
				
				cnt++;
			});
		}
	}

	
	/* --- Photolist --- */
	
	// resize the photolist widths for non-standard width photos
	function resizePhotolist() {
		if (jQuery("dl.photo-list").length) {
			var imgWidth = jQuery("dl.photo-list img:first").width();
			var dlWidth = jQuery("dl.photo-list").width();
			
			jQuery("dl.photo-list dt, dl.photo-list dd.summary").width(dlWidth - imgWidth - 10 + "px");
		}
	}
	
	
	/* --- equal height - DEPRECATED? --- */
	
	function equalHeight(containerObj, itemClass) {
		if (containerObj.length) {
			containerObj.each(function() {
				var galleryWidth = jQuery(this).width();
				var galleryItemWidth = jQuery(itemClass+":first", jQuery(this)).width();
				var itemsPerRow = Math.floor(galleryWidth / galleryItemWidth);
				var cnt = 1;
				var cntItems = 0;
				var maxHeight = 0;
				var aHighest = new Array();
				var nItems = jQuery(itemClass, jQuery(this)).length;
				jQuery(itemClass, jQuery(this)).each(function() {
					cntItems++;
					if (cnt > itemsPerRow) {
						cnt = 0;
						maxHeight = 0;
					}
					//var totalHeight = 
					if (jQuery(this).height() > maxHeight) {
						maxHeight = jQuery(this).height();
					}
					if (cnt == itemsPerRow || cntItems == nItems) {
						aHighest.push(maxHeight);
					}
					cnt++;
				});
				cnt = 1;
				cnt2 = 0;
				jQuery(itemClass, jQuery(this)).each(function() {
					if (cnt > itemsPerRow) {
						cnt = 1;
						cnt2++;
					}
					jQuery(this).height(aHighest[cnt2]);				
					cnt++;
				});
			});
		}
	}
	
	
	/* --- make all given objects the same height --- */
	
	$.fn.equalHeightColumns = function() {
		var tallest = 0;
		
		$(this).each(function() {
			if ($(this).outerHeight(true) > tallest) {
				tallest = $(this).outerHeight(true);
			}
		});
		
		$(this).each(function() {
			var diff = 0;
			diff = tallest - $(this).outerHeight(true);
			$(this).height($(this).height() + diff);
		});
	};
	

	/* --- on load --- */
	
	
	$('input:text').textBoxHint(); // titles to input text
	$(".table-data").zebraStripeIt(); // alternate coloring of table rows
	$("#text-content-container a, ul.grouped-link-list a").markExternalLinks(); // adds class to external links
	initCalendar(); // initialize the calendar
	
	/* wait for images to load too */
	$(window).load(function() {
		//$("#text-content-container img.content-photo").initImageFramer(); // format content images with title
		initPhotogallery(); // initialize the photogallery
		resizePhotolist(); // resize the photolist widths for non-standard width photos
		$("#photo-gallery-container div").equalHeightColumns();
		$(".scrollableArea .photo-gallery-item").equalHeightColumns();
		
		//gallery
		$("div#makeMeScrollable").smoothDivScroll({ 
			autoScroll: "onstart" , 
			autoScrollDirection: "backandforth", 
			autoScrollStep: 1, 
			autoScrollInterval: 15,	
			startAtElementId: "startAtMe", 
			visibleHotSpots: "always"
		});			
		
		
		//quick item hover
		$(".quick-item-text a").mouseover(function(e) {
			$(this).parent('.link-holder').parent(".quick-item-text").parent(".quick-item").css("background","#00cc99");
		});
		
		$(".quick-item-text a").mouseout(function(e) {
			$(this).parent('.link-holder').parent(".quick-item-text").parent(".quick-item").css("background","url('../images/backgrounds/bgnd-quick-item.png') repeat left top");
		});		
		
		//set minheight on content div
		var windowHeight = $(window).height();
		windowHeight = windowHeight - 500;
		$("#container").css("min-height", windowHeight + "px")		
		
		
		
		var summer = $("#quick-area-summer").height();
		var winter = $("#quick-area-winter").height();
		if (summer > winter) {
			$("#quick-area").css("min-height",summer + "px");
		}else {
			$("#quick-area").css("min-height",winter + "px");
		}
		
		//poletje click
		$("#container-wrapper-winter #arrow-right").click(function() {	
			if ($("#container-wrapper-summer").css("display") == 'none') {
				$("#container-wrapper-summer").css("visibility","visible");	
				$("#container-wrapper").css("width","200%");
				$("#container-wrapper-winter").css("width","50%");
				$("#container-wrapper-summer").css("width","50%");
				$("#container-wrapper-summer").css("display","block");	
				$("#container-wrapper").animate({ left: '-100%' }, 800, function() {
					$("#container-wrapper-winter").css("visibility","hidden");	
				});
				$("#m-16slo, #m-16eng").addClass("menu-level1-open");
				$("#m-16slo, #m-16eng").children("ul").show();
				$("#m-17slo, #m-17eng").removeClass("menu-level1-open");
				$("#m-17slo, #m-17eng").children("ul").hide();
			}
		});	

		//winter click
		$("#container-wrapper-summer #arrow-left").click(function() {	
			if ($("#container-wrapper-summer").css("display") == 'block') {
				$("#container-wrapper-winter").css("visibility","visible");	
				$("#container-wrapper").animate({ left: '0' }, 800, function() {
					$("#container-wrapper").css("width","100%");
					$("#container-wrapper-winter").css("width","100%");
					$("#container-wrapper-summer").css("width","100%");
					$("#container-wrapper-summer").css("display","none");
					$("#container-wrapper-summer").css("visibility","hidden");	
				});
				$("#m-17slo, #m-17eng").addClass("menu-level1-open");
				$("#m-17slo, #m-17eng").children("ul").show();
				$("#m-16slo, #m-16eng").removeClass("menu-level1-open");
				$("#m-16slo, #m-16eng").children("ul").hide();	
			}	
		});				

		
	});		

	/* --- window resizing --- */
	
	$(window).resize(function() {
		// resize elements, reposition elements, ...
	});

});
