/// <reference path="C:\projects\_jQuery\jquery-vsdoc.js"/>
$(document).ready(function () {
	if (typeof OneWeb.Admin === "undefined") {
		//do stuff only when NOT logged in to OW
		// setup ul.tabs to work as tabs for each div directly under div.panes
		$("ul.tabs").tabs("div.hp_events_dates_copy > div");

		//$("#slide_1").css("display","block");			
		$("#slide_1").fadeIn();

		// initialize scrollable 
		$("div.sliderbox").scrollable({
			size: 3,
			items: '#slider_tabs',
			hoverClass: 'hover',
			onSeek: function () {
				var index = $(".active").attr("id");
				var last_char = index.charAt(index.length - 1);

				if (parseInt(last_char) < this.getIndex() + 1) {
					$(".active").removeClass("active");
					$("#tab_" + (this.getIndex() + 1)).addClass("active");
				}
				else if (parseInt(last_char) > this.getIndex() + 3) {
					$(".active").removeClass("active");
					$("#tab_" + (this.getIndex() + 3)).addClass("active");
				}

				index = $(".active").attr("id");
				last_char = index.charAt(index.length - 1);

				$(".slider_content").css("display", "none");
				$("#slide_" + last_char).fadeIn();
			}
		});
		//survey
		if ($("#survey_con").length > 0) {
			$("#modalBackgroundOverlay").prependTo('body');
			$("#colorbox").appendTo('form');
			//check for survey cookie - if not present launch survey and create cookie
			if ($.cookie('msvu_survey') == null) {
				$.colorbox({ opacity: 0.7, width: "675px", inline: true, href: "#survey" });
			}
		}
		//set cookie when close button is clicked or when form is submitted
		function set_msvu_cookie() {
			if ($.cookie('msvu_survey') == null) {
				$.cookie('msvu_survey', "surveyed", { expires: 9999, path: '/', domain: 'msvu.isl.ca', secure: false }); //staging
				//$.cookie('msvu_survey', "surveyed", { expires: 9999, path: '/', domain: 'msvu.ca', secure: false });//prod
			}
		}
		$("#cboxClose").click(function () { set_msvu_cookie(); });
		$(".submit_survey").click(function () { set_msvu_cookie(); });
	} else {
		//do stuff when LOGGED IN to OW
		// setup slider divs for display when in admin view
		$(".slider_text").css("height", "1000px");
		$(".slider_content").css("height", "auto");
		//survey
		$("#survey_con").css({ "display": "block" });
		$("#survey").css({ "width": "675px" });
	}
	//do stuff logged in to OW or not
	//programs & depts. drop menu
	$(".dd").hover(
	    function () {
	    	$(this).addClass("over");
	    },
	    function () {
	    	$(this).removeClass("over");
	    }
    );
});

