function collectsubmit(){
	
	var month = $('#monthdd').val();
	var cat = $('#catdd').val();
	var group = $('#groupsdd').val();
	var program = $('#programdd').val();
	var q = $('#txtSearch').val();
	var temp="?alttemplate=calenderv2";
	if (month != '')
		temp += "&month=" + month;
	if (cat != '')
		temp += "&cat=" + cat;
	if (group != '')
		temp += "&group=" + group;
	if (program != '')
		temp += "&program=" + program;		
	if (q != '')
			temp += "&q=" + q;

				
	window.location=temp;
	
	
	
}


(function ($) {
	$(document).ready(function ($) {
		

		
		$('.filtersv2 select').change(function() {
		 collectsubmit();
		});
		
		$(".searchbarv2 #txtSearch").keyup(function(e) {
			e.preventDefault();
	     	if(e.keyCode == 13) {
				
	    		collectsubmit();
	     	}
	     return false;
	  });
		
		
		$(".searchbarv2 .reset").click(function () {
			
			$("#programdd").val('');			
			$("#txtSearch").val('');
			$("#groupsdd").val('');
			$("#monthdd").val('');
			$("#catdd").val('');
			
		    collectsubmit();
		});	
			
		$(".searchbarv2 #BtnSearch").click(function () {

		    collectsubmit();
		});

		/*
		= reset calendar
		/////////////////////////////////////////////////////////////// */

		$(".search-bar .reset").click(function () {
			// alert("aaa");
			$("#Content_Calendar_5_DdlFacilities").val('0');
			$("#Content_Calendar_5_DdlMonths").val('0');
			$("#Content_Calendar_5_DdlCategories").val('0');
			$("#Content_Calendar_5_DdlTargetGroups").val('0');
		});


		/*
		= Subnavigation
		/////////////////////////////////////////////////////////////// */

		/* :: subnavigation dropdown :: */
		jQuery('#sub-navigation').superfish({
			delay: 300,
			animation: { opacity: 'show', height: 'show' },
			speed: 'normal',
			autoArrows: false,
			dropShadows: false,
			disableHI: false
		});

		/* :: Menu hover background fix :: */
		var $menuBgImg;
		$("#sub-navigation .level2-item").hover(function () {
			$(this).prev().addClass("no-sep");
			//$(this).find("ul").css("width",$(this).find("a").width() + 16); // fixed ticket ID=13
		}, function () {
			$(this).prev().removeClass("no-sep");
		}
		).filter(':last-child').addClass('last');

		/*
		= Utilitybar
		/////////////////////////////////////////////////////////////// */

		/* :: Print icon :: */
		$("#header .utility-bar .ico-print").click(function () {
			window.print();
			return false;
		});

		/*Speech icon opens new window */
		$('#header .utility-bar .ico-speak').click(function () {
			window.open(this.href);
			return false;
		});

		/* :: Newsletter icon :: */
		$(".utility-bar .btn-heart").hover(
			function () { $(this).addClass("hover").find(".newsletter-dropout").show() },
			function () { $(this).removeClass("hover").find(".newsletter-dropout").hide() }
		);

		/* :: Text resizer :: */
		var $orgFontSize;
		var $txtResizeArea = $(".article .textcontent");
		$("#header .utility-bar .ico-text").toggle(
			function () {
				$orgFontSize = $txtResizeArea.css("fontSize");
				$txtResizeArea.fadeTo("fast", 0.2).animate({ 'fontSize': '1.2em' }, 200).fadeTo("fast", 1);
				return false;
			}, function () {
				$txtResizeArea.fadeTo("fast", 0.2).animate({ 'fontSize': '1.4em' }, 200).fadeTo("fast", 1);
				return false;
			}, function () {
				$txtResizeArea.fadeTo("fast", 0.2).animate({ 'fontSize': $orgFontSize }, 200).fadeTo("fast", 1);
				return false;
			}
		);

		/* :: ScrollToLink (sitemap) :: */
		$('.scrollToLink').click(function (e) {
			if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
				var $rawHash = this.hash;
				var $target = $(this.hash);
				$target = $target.length && $target || $('[name=' + $rawHash.slice(1) + ']');

				if ($target.length) {
					var targetOffset = $target.offset().top;
					if ($.browser.webkit) { aniEl = $('body'); }
					else { aniEl = $('html'); }
					aniEl.animate({ scrollTop: targetOffset }, 1200, function () {
						window.location.hash = $rawHash
					});
					e.preventDefault();
				}
			}
		});

		/*
		= Section expand/ collapse
		/////////////////////////////////////////////////////////////// */
		$(".sectionhead .section-close").toggle(
			function () { $(this).parent().parent().find(".section").slideUp("normal"); },
			function () {
				$(this).parent().parent().find(".section").slideDown("normal");
			})

		/*
		= Fancybox / google maps + gallery
		/////////////////////////////////////////////////////////////// */

		/* :: google map link :: */
		if (typeof $.fn.fancybox == "function") {
			$(".map-box .more").fancybox({
				'frameWidth': 650,
				'frameHeight': 360,
				'height': 400,
				'width': 600,
				'transitionIn': 'none',
				'transitionOut': 'none',
				'hideOnContentClick': false,
				'callbackOnClose': function () { $("#fancy_content").empty(); }
			});
		}

		/* :: video link :: */
		if (typeof $.fn.fancybox == "function") {
			$(".video-box .media a").click(function () {
				$.fancybox({
					'padding': 10,
					'autoScale': false,
					'transitionIn': 'none',
					'transitionOut': 'none',
					'title': this.title,
					'width': 680,
					'height': 495,
					'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type': 'swf',
					'swf': { 'wmode': 'transparent', 'allowfullscreen': 'true' }
				});
				return false;
			});
		}

		/* :: carousel init for image gallery :: */
		if (typeof $.fn.jcarousel == "function") {
			$('#carousel').jcarousel();
		}

		/* :: carousel link for fancybox image zoom :: */
		if (typeof $.fn.fancybox == "function") {
			$("#carousel li a[rel=img_group_1]").fancybox({
				'transitionIn': 'elastic',
				'transitionOut': 'elastic',
				'titleShow': true,
				'titlePosition': 'over'
			});
		}

		/*
		= Star rating
		/////////////////////////////////////////////////////////////// */
		starRatingInit();

		/*
		= Equal Height on medium sized teaser
		/////////////////////////////////////////////////////////////// */
		$(".frontpage .section .teaser-medium").equalHeight();

		/*
		= Facility overview
		/////////////////////////////////////////////////////////////// */
		$facilityView = $(".facility-overview")
		if ($facilityView.length) {
			$facilityAllLink = $facilityView.find(".facility-list a");
			$facilityMap = $facilityView.find(".facility-map");

			$facilityAllLink.hover(function () {
				$thisAnchor = $(this);
				hoverIntent = setTimeout(function () {
					$facilityAllLink.removeClass("selected");

					$thisAnchor.addClass("selected");

					$facilityMap.animate({ opacity: 0 }, 400, function () {
						$facilityMap.find("img").attr("src", $thisAnchor.attr("rel"));

//						if ($thisAnchor.attr("rel2")) {
//							$facilityMap.find("img.secondImage").attr("src", $thisAnchor.attr("rel2")).show();
//							$facilityMap.find(".facility-map-addtion").text( $thisAnchor.attr("imageText"));
//						} else {
//							$facilityMap.find("img.secondImage").hide();
//							//$facilityMap.find("iText").hide();
//						}
						$facilityMap.animate({ opacity: 1 }, 400);
					});

				}, 200);
			}, function () {
				try { clearTimeout(hoverIntent); } catch (e) { };
			});
		}

	}); // ready
})(jQuery);

/* Cleartext fix for ie upon text resize */
jQuery.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
/**/

/* equalHeights  */
jQuery.fn.equalHeight = function(callback) { 
	if(this.length){
		objHeights = [];
		this.each(function(){ objHeights.push($(this).height()); })
	
		objHighest = Math.max.apply(Math, objHeights);
		objLowest = Math.min.apply(Math, objHeights);
	
		if(objHighest > objLowest)
			this.height(objHighest);	
	}
	if (jQuery.isFunction(callback)) 
		callback.apply(this);
}; 

function starRatingInit() {
	if (typeof $.fn.rating == "function") {
		$('.star-rating-active input[type=radio].star').rating();
	}
}

// function called after ....
function endRequest() {
	starRatingInit();
}
