// JavaScript Document
var pullLink;
var pullText;


// initialise Superfish plugin for Nav
$(document).ready(function(){ 
	
	$("ul.sf-menu").superfish({ 
		pathClass:  'current',
		autoArrows:    false, 
		dropShadows:   false,
		speed:         300,           // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
		delay: 		300,
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){$("li").removeClass("sf-breadcrumb");}
	});
	
	 $("a.odni_visitnow_offsite_button").click(function(){
		 var val = $('#js_jumpmenu option:selected').val();
        if (val != '') {
		  if(cookieVal == null) {
			pullLink = $('#js_jumpmenu option:selected').val();
			pullText = $('#js_jumpmenu option:selected').text();
			$('a.jsPullLink').text(pullText);
			$('a.jsPullLink').attr({href: pullLink});
			$('.odni_modalbutton_continue').attr({href: pullLink});
			$('div.odni_screen').show();
			return false;
		} else {
		window.open(val);
		}
        }
	});
	 
	// the Leaving site alert trigger 
	$(".odni_offsite_link a").click(function(){
		if(cookieVal == null) {
			pullLink = $(this).attr("href");
			pullText = $(this).text();
			$('a.jsPullLink').text(pullText);
			$('a.jsPullLink').attr({href: pullLink});
			$('.odni_modalbutton_continue').attr({href: pullLink});
			$('div.odni_screen').show();
			return false;
		} else {
			return true;
		}
	});
	
	// Modal Navication Functionality //
	$(".odni_modalbutton_continue").click(function(){
			$('div.odni_screen').hide();
			return true;
	});
	$("a.jsPullLink").click(function(){
			$('div.odni_screen').hide();
			return true;
	});
	$(".odni_modalbutton_cancel").click(function(){
			$('div.odni_screen').hide();
			return false;
	});
	$(".odni_modalBackdrop").click(function(){
			$('div.odni_screen').hide();
			return true;
	});
	
	
	// Cookie Scripts //
	var COOKIE_NAME = 'noShow_cookie';
	var options = { path: '/', expires: 1 };
	// set cookie by number of days
	//Clicking setting the Checkbox to selected 
	$('.odni_modalbutton_continue').click(function() {
		if ($('input#do-not-show-me-this-again').is(':checked')) {
			$.cookie(COOKIE_NAME, 'NoShow', options);
			cookieVal = "cookieVal";
		}
	});
	$('a.jsPullLink').click(function() {
		if ($('input#do-not-show-me-this-again').is(':checked')) {
			$.cookie(COOKIE_NAME, 'NoShow', options);
			cookieVal = "cookieVal";
		}
	});
	// get cookie
	var cookieVal = ($.cookie(COOKIE_NAME));

}); 

