$(function(){
	
	var windowEvent = {
		init: function(time){
			windowEvent.timer = window.setInterval(windowEvent.animate, time);
		},
		animate: function(){
			$("#surveyFormContainer:visible").slideUp("slow");
			$(".arrow").attr("src", "/utilitydroplets/experience_survey/images/black_arrow_close.gif");
		},
		timer: null
	};
	
	windowEvent.init(5000);
    $("#surveyFormContainer").mouseover(function() {
        window.clearInterval(windowEvent.timer);
    });
    $("#surveyFormContainer").mouseout(function() {
        
    });	
	
	$("#surveyLink").click(function(){
		window.clearInterval(windowEvent.timer);
	});
				
});

$(document).ready(function(){

	$("#surveyLink").toggle(function(){
		$("#surveyFormContainer:hidden").slideDown(1000, "easeInOutSine");
		$(".arrow").attr("src", "/utilitydroplets/experience_survey/images/black_arrow_open.gif");
	},				
	function(){
		$("#surveyFormContainer:visible").slideUp(1000, "easeInOutSine");
		$(".arrow").attr("src", "/utilitydroplets/experience_survey/images/black_arrow_close.gif");
	});
		
		
	$("#closeSurvey").click(function(){
		$("#surveyFormContainer").slideUp(1000, "easeInOutSine");
		$(".arrow").attr("src", "/utilitydroplets/experience_survey/images/black_arrow_close.gif");
	});
	
	$("#submitGlobalSurvey").click(function(){
		$("#surveyFormContainer").slideUp(1000, "easeInOutSine");
		$(".arrow").attr("src", "/utilitydroplets/experience_survey/images/black_arrow_close.gif");
	});
});
//This function sets a cookie so that the survey will only drop down once
function closeSurvey() {
	sbweb.util.cookies.setCookie("SurveyClosed",true,'Thu, 31-Dec-2020 00:00:00 GMT',ROOT_LEVEL_LOCAL,COOKIE_DOMAIN_LOCAL);
}

var surveyClosedCookie = sbweb.util.cookies.getCookie('SurveyClosed');

if(surveyClosedCookie == false){
	$(function(){
		$("#surveyFormContainer").slideDown(1000, "easeInOutSine");
		$(".arrow").attr("src", "/utilitydroplets/experience_survey/images/black_arrow_open.gif");
	});
	
	closeSurvey();
}