function mobileCheck() {
	$(".main-content").css({ minHeight: 0 });
	if ($(".body.dark").length) {
		if ($("#sidebar").outerHeight() > $(".main-content").outerHeight()) {
			$(".main-content").css({ minHeight: $("#sidebar").outerHeight()+60 });
		};
	} else {
		$(".main-content").css({ minHeight: $("#sidebar").outerHeight()+62 });
		$(".wb0 .main-content").css({ minHeight: $("#sidebar").outerHeight()+47 });
	};
	window.setTimeout(function() {
		if (!$(".arrow-l").length) {
			$(".home-slider4 .bx-pager").prepend("<span class='arrow-l'><i class='fa fa-angle-double-left'></i></span>");
			$(".home-slider4 .bx-pager").append("<span class='arrow-r'><i class='fa fa-angle-double-right'></i></span>");
		}
	}, 5);
}

$(document).ready(function() {
	/*$(".switcher .switch").click(function() {
		$(this).toggleClass("active-right");
		$(this).next().toggleClass("active");
		$(this).prev().toggleClass("active");
	});*/


	if (/*@cc_on !@*/false && ( document.documentMode === 9) ) {
		document.documentElement.className += ' ie9';
	};

	mobileCheck();
	$(window).resize(function() {
		mobileCheck();
	});
	$(window).load(function() {
		mobileCheck();
	});
	var default0 = false;

	var next = true;

	/*$('.bxslider-home').bxSlider({
		mode: "fade",
		speed: 1100,
		onSlideBefore: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
			$('.active-slide').removeClass('active-slide');
			window.setTimeout(function() {
				doThis(currentSlideNumber, totalSlideQty, currentSlideHtmlObject);
			}, 100);
		},
		onSlideAfter: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
			$('.active-slide').removeClass('active-slide');
			window.setTimeout(function() {
				$('.bxslider-home li:not(.bx-clone)').eq(currentSlideHtmlObject).addClass('active-slide')
			}, 0);
		},
		onSliderLoad: function () {
			$('.bxslider-home li:not(.bx-clone)').eq(0).addClass('active-slide')
		},
	});//to be removed
	$(".bxslider-con").bxSlider();
	$(".bxslider-home2").bxSlider();
	$(".bxslider-score").bxSlider();


	var slider = $(".bxslider-home4:not(.aa)").bxSlider({
		onSlideBefore: doThis2,
		speed: 1000
	});

	var slider1 = $(".bxslider-home4.aa").bxSlider({
		mode: "fade",
		speed: 1000,
		pager: false,
		controls: false,
	});

	function doThis(ele, oldIndex, newIndex){
		if (next) {
			$('.custom-animation li').removeClass('pt-page-rotateRoomLeftOut pt-page-rotateRoomLeftIn pt-page-current pt-page-ontop');
			$('.custom-animation li').removeClass('pt-page-rotateRoomLeftOut').eq(oldIndex).addClass('pt-page-current pt-page-rotateRoomLeftOut pt-page-ontop');
			$('.custom-animation li').removeClass('pt-page-rotateRoomLeftIn').eq(newIndex).addClass('pt-page-current pt-page-rotateRoomLeftIn');
			window.setTimeout(function() {
				$('.custom-animation li').removeClass('pt-page-rotateRoomLeftOut pt-page-rotateRoomLeftIn').eq(oldIndex).removeClass('pt-page-current');
			}, 1000);
		} else {
			$('.custom-animation li').removeClass('pt-page-rotateRoomRightOut pt-page-rotateRoomRightIn pt-page-current pt-page-ontop');
			$('.custom-animation li').removeClass('pt-page-rotateRoomRightOut').eq(oldIndex).addClass('pt-page-current pt-page-rotateRoomRightOut pt-page-ontop');
			$('.custom-animation li').removeClass('pt-page-rotateRoomRightIn').eq(newIndex).addClass('pt-page-current pt-page-rotateRoomRightIn');
			window.setTimeout(function() {
				$('.custom-animation li').removeClass('pt-page-rotateRoomRightOut pt-page-rotateRoomRightIn').eq(oldIndex).removeClass('pt-page-current');
			}, 1000);
		}
	}
	function doThis2(ele, oldIndex, newIndex){
		slider1.goToSlide(newIndex);
	}*/
	$(".trigger-more, .trigger-less").click(function() {
		$(this).parent().toggleClass("showmore")
		return false;
	});
	/*$("#header .top-line .search .close-trig, #header .header-bar .search .close-trig").click(function() {
		$("#header .top-line .search input, #header .header-bar .search input").val("").blur();
		return false;
	});*/

	/*$(".home-slider .bx-pager-item a").click(function() {
		default0 = true;
	});*/
	$(document).on('click', ".home-slider4 .bx-pager .arrow-l", function () {
		$(".home-slider4 .bx-prev").trigger("click");
		return false;
	});
	$(document).on('click', ".home-slider4 .bx-pager .arrow-r", function () {
		$(".home-slider4 .bx-next").trigger("click");
		return false;
	});
	$(".drop-trigger-h select").change(function() {
		$(this).parent().parent().find(".drop-trigger").text($(this).find("option:selected").text());
		$(".drop-c").removeClass("vis");
		$("#"+$(this).val()).addClass("vis");
	});
	if ($('.pdfd').length) {
		var doc = new jsPDF();
		var specialElementHandlers = {
		    '#editor': function (element, renderer) {
		        return true;
		    }
		};
	}
	$('.pdfd').click(function () {
		var nr = $('.entry').html().trim();
		nr = nr.replace($(".share").html().trim(), "");
		nr = nr.replace($(".tags").html().trim(), "");
		nr = nr.replace($(".actions").html().trim(), "");
		console.log(nr);
	    doc.fromHTML(nr, 15, 15, {
	        'width': 170,
	            'elementHandlers': specialElementHandlers
	    });
	    doc.save('post.pdf');
	    return false
	});
	/*$("#dep").change(function() {
		var val = $(this).val();
		$(".con-module .persons article, .con-module .inline-persons article").removeClass("vis0").removeClass("even").removeClass("odd")
		if (val == "all") {
			$(".con-module .persons article, .con-module .inline-persons article").addClass("vis0")
		} else {
			$(".con-module .persons article").each(function() {
				if ($(this).find(".role").text() == val) {
					$(this).addClass("vis0")
				}
			});
			$(".con-module .inline-persons article").each(function() {
				if ($(this).find(".role").text() == val) {
					$(this).addClass("vis0")
				}
			});	
		};
		$(".con-module .persons article.vis.vis0:odd, .con-module .inline-persons article.vis.vis0:odd").addClass("odd");
		$(".con-module .persons article.vis.vis0:even, .con-module .inline-persons article.vis.vis0:even").addClass("even");
		equalHeight($(".height-1"));
		equalHeight($(".height2"));
		equalHeight($(".height3"));
		equalHeight2($(".con-box3 .news, .con-box3 .score"));
	}).change();*/
	$("#let").change(function() {
		var val = $(this).val();
		$(".con-module .persons article, .con-module .inline-persons article").removeClass("vis").removeClass("even").removeClass("odd")
		if (val == "az") {
			$(".con-module .persons article, .con-module .inline-persons article").addClass("vis")
		} else {
			val = val.charAt(0);
			$(".con-module .persons article, .con-module .inline-persons article").each(function() {
				if ($(this).find(".name").text().substr($(this).find(".name").text().indexOf(" ") + 1).charAt(0) == val) {
					$(this).addClass("vis")
				}
			});	
			$(".con-module .persons article, .con-module .inline-persons article").each(function() {
				if ($(this).find("h3").text().substr($(this).find("h3").text().indexOf(" ") + 1).charAt(0) == val) {
					$(this).addClass("vis")
				}
			});	
		};
		$(".con-module .persons article.vis.vis0:odd, .con-module .inline-persons article.vis.vis0:odd").addClass("odd");
		$(".con-module .persons article.vis.vis0:even, .con-module .inline-persons article.vis.vis0:even").addClass("even");
		equalHeight($(".height-1"));
		equalHeight($(".height2"));
		equalHeight($(".height3"));
		equalHeight2($(".con-box3 .news, .con-box3 .score"));
	}).change();
	//$(".bxslider").bxSlider();
	$('.gallery a').fancybox({
		helpers : {
			title: { type: 'outside'}
		},
		afterLoad: function(){
			this.title = "<strong>Description: </strong>" +this.title;
		}
	});

	$('.fancybox-trigger').fancybox({
		afterLoad: function () {
			$(".fancybox-overlay").addClass("style-2");
		}
	});
	$('.fancybox.media').fancybox({
		helpers : {
			media : {}
		}
	});
	/*
	$("input[type=checkbox], input[type=radio]").crfi();
	$("select").crfs();
    */
	var currentSize = 1;
	$(".font-size .ico").click(function() {
		$(".entry").removeAttr("style");
		currentSize = 1;
		return false
	});
	$(".font-size a.plus").click(function() {
		if (currentSize < 3) {
			currentSize++;
			$(".entry").css({ fontSize: 16 +16*currentSize/10 })
			$(".entry.lg").css({ fontSize: 17 +17*currentSize/10 })
		}
		return false
	});
	$(".font-size a.minus").click(function() {
		if (currentSize > -3) {
			currentSize--;
			if (currentSize== 0) {
				currentSize = -1;
			}
			$(".entry").css({ fontSize: 16 +16*currentSize/10 })
			$(".entry.lg").css({ fontSize: 17 +17*currentSize/10 })
		}
		return false
	});
    
	/* ADJUSTMENT MADE TO FIX MAIN CONTENT FROM DISAPPEARING - 11/17/16 */
	
	$(".widget-menu .plus .nn").click(function() {
		$(this).parent().toggleClass("current0")
		$(this).next().next().slideToggle(300, function() {
		mobileCheck();
		})
		mobileCheck();
		return false
	});
	
	/* ADJUSTMENT MADE TO FIX MAIN CONTENT FROM DISAPPEARING - 11/17/16 */
	
	$(".line-view-trigger").click(function() {
		$(this).parent().parent().parent().removeClass("cards-view"),
		$(this).parent().parent().parent().addClass("line-view")
		$(".con-module .filter-bar article a").removeClass("active");
		$(this).addClass("active");
		equalHeight($(".height-1"));
		equalHeight($(".height2"));
		equalHeight($(".height3"));
		equalHeight2($(".con-box3 .news, .con-box3 .score"));
		return false
	});
	$(".cards-view-trigger").click(function() {
		$(this).parent().parent().parent().removeClass("line-view"),
		$(this).parent().parent().parent().addClass("cards-view");
		$(".con-module .filter-bar article a").removeClass("active");
		$(this).addClass("active");
		equalHeight($(".height-1"));
		equalHeight($(".height2"));
		equalHeight($(".height3"));
		equalHeight2($(".con-box3 .news, .con-box3 .score"));
		return false
	});
	$(".menu-trigger").click(function() {
		$(this).toggleClass("active").next().toggleClass("active")
		$("#menu .menu-hold").slideToggle(300);
	});
	$("#menu .menu-dropdown li.with-in>a").click(function() {
		$(this).parent().toggleClass("active")
		$(this).toggleClass("active").next().stop(true).slideToggle(300).toggleClass("active")
		return false;
	});
	$(".programs .cols article .pic").click(function() {
		$(this).next().click()
	});
	$(".more-trigger").click(function() {
		$(this).toggleClass("active").next().stop(true).slideToggle(300).toggleClass("active")
	});
	$("#menu .with-in>.sub-trigger").click(function() {
		$(this).parent().toggleClass("active")
		return false
	});
	$("#menu .with-sub a>.sub-trigger").click(function() {
		$(this).parent().parent().toggleClass("active")
		return false
	});
	$(".quicklinks-trigger").click(function() {
		$("body").toggleClass("active-quicklinks")
		return false
	});
	$("#main-hold-inner").click(function() {
		$("body").removeClass("active-quicklinks")
	});
	$(".switcher p").click(function() {
		if (!$(this).hasClass("active")) {
			$(".switcher .switch").click();
		}
	});
	$(".blog article .pic img").each(function() {  
		$(this).parent().attr("style", "background-image:url("+$(this).attr("src")+")");
	});

	$('#header .header-bar .search input, #header .top-line .search input').each(function() {  
		var input = $(this);
		input.attr('placeholder0', input.attr('placeholder'));
		input.removeAttr("placeholder");

		$(input).focus(function(){
			$("#header .header-bar .search, #header .top-line .search").addClass("focusk");
			if (input.val() == input.attr('placeholder0')) {
				input.val('').removeClass("placeholder0");
			}
		});

		$(input).blur(function(){
			$("#header .header-bar .search, #header .top-line .search").removeClass("focusk");
			if (input.val() == '' || input.val() == input.attr('placeholder0')) {
				input.val(input.attr('placeholder0')).addClass("placeholder0");
			}
		});
	}).blur();

	$('[placeholder]').each(function() {  
		var input = $(this);
		$(input).focus(function(){
			if (input.val() == input.attr('placeholder')) {
				input.val('').removeClass("placeholder");
			}
		});
		$(input).blur(function(){
			if (input.val() == '' || input.val() == input.attr('placeholder')) {
				input.val(input.attr('placeholder')).addClass("placeholder");
			}
		});
	}).blur();

	$('.to-top').click( function() {
		$('html, body').stop().animate({
			scrollTop: 0
		}, 1000);
		return false;
	});
	$('.screen-reader-shortcut').click( function() {
		var hre = $(this).attr("href");
		$('html, body').stop().animate({
			scrollTop: $(hre).offset().top
		}, 0);
		return false;
	});

	if ($(".paralax-block").length) {
		var offset = $(".paralax-block").offset();
		$(window).scroll(function() {
			$(".paralax-block").css({ 'background-position-y': -($(window).scrollTop()-offset.top)*.1 })
		});
	};
	if ($(".con-video").length) {
		var offset = $(".con-video").offset();
		$(window).scroll(function() {
			$(".con-video").css({ 'background-position-y': -($(window).scrollTop()-offset.top)*.1 })
		});
	};

	/*var cookieWarning = $('<div class="warning"><span class="close-trig"></span><h4>The Omak Campus is closed today due to wildfire activity. </h4><a class="btn btn-white" href="#">Learn More</a></div>');
	$("#main-hold-inner").prepend(cookieWarning);

	var modalPopup = $('<a class="fancybox-trigger" id="modal" href="#fancy1"></a><div id="fancy1" class="fancy-box"><div class="holder"><h2>Modal Title</h2><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempor elit a ligula pulvinar tristique. Nulla vestibulum ipsum vel enim rhoncus, vitae posuere justo bibendum. Suspendisse potenti. Donec sed urna malesuada, rhoncus erat id, semper elit. Integer id ligula ornare, tincidunt velit sed, dapibus metus. Integer nec commodo velit. Maecenas porta risus auctor, convallis leo at, interdum lorem. Cras suscipit ex quis massa molestie tincidunt.</p><div class="bt-line"><strong>Posted:</strong> 11/2/15 @ 8:32 AM</div></div></div>');
	$("body").append(modalPopup);*/

});

function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		$(this).height("auto");
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

function equalHeight2(group) {
	var tallest = 0;
	group.each(function() {
		$(this).height("auto");
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest-86);
	$(".con-box3 .score").height(tallest);
}

$(window).load(function() {
	equalHeight($(".height-1"));
	equalHeight($(".height2"));
	equalHeight($(".height3"));
	equalHeight2($(".con-box3 .news, .con-box3 .score"));
	/*$(".bxslider-home3").bxSlider({
		mode: "fade",
		speed: 1000,
		onSlideAfter: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
			$('.active-slide').removeClass('active-slide');
			window.setTimeout(function() {
				$('.bxslider-home3 li:not(.bx-clone)').eq(currentSlideHtmlObject).addClass('active-slide')
			}, 0);
		},
		onSliderLoad: function () {
			$('.bxslider-home3 li:not(.bx-clone)').eq(0).addClass('active-slide')
		},
	});*/
	/*if ($.cookie('modal') != 'true') {
		$("#modal").trigger("click")
	}
	if ($.cookie('warning') != 'true') {
		$(".warning").addClass("active");
	}
	$(".warning .close-trig").click(function() {
		$(this).parent().toggleClass("active")
		$.cookie('warning', 'true', { expires: 1, path: '/' });
	});
	$(document).on('click', ".fancybox-close", function () {
		$.cookie('modal', 'true', { expires: 1, path: '/' });
	});*/
	
	
	var isMobile = {
	    hasTouch: function() {
	        return 'ontouchstart' in document.documentElement;
	    },
	    Android: function() {
	        return navigator.userAgent.match(/Android/i);
	    },
	    BlackBerry: function() {
	        return navigator.userAgent.match(/BlackBerry/i);
	    },
	    iOS: function() {
	        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
	    },
	    Opera: function() {
	        return navigator.userAgent.match(/Opera Mini/i);
	    },
	    Windows: function() {
	        return navigator.userAgent.match(/IEMobile/i);
	    },
	    any: function() {
	        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
	    },
	    ismobi: function() {
	        return navigator.userAgent.match(/Mobi/i);
	    }
	};
	if(!isMobile.hasTouch()) {
	    $('#menu .menu-dropdown li a').addClass('hover');
	}
});
$(window).resize(function() {
	equalHeight($(".height-1"));
	equalHeight($(".height2"));
	equalHeight($(".height3"));
	equalHeight2($(".con-box3 .news, .con-box3 .score"));
});
