//jQuery.noConflict()

var jquerypopupmenu={
	arrowpath: 'arrow.gif', //full URL or path to arrow image
	popupmenuoffsets: [0, 0], //additional x and y offset from mouse cursor for popup menus
	animspeed: 200, //reveal animation speed (in milliseconds)
	showhidedelay: [150, 150], //delay before menu appears and disappears when mouse rolls over it, in milliseconds

	//***** NO NEED TO EDIT BEYOND HERE
	startzindex:1000,
	builtpopupmenuids: [], //ids of popup menus already built (to prevent repeated building of same popup menu)

	positionul:function($, $ul, e){
		var istoplevel=$ul.hasClass('jqpopupmenu') //Bool indicating whether $ul is top level popup menu DIV
		var docrightedge=$(document).scrollLeft()+$(window).width()-40 //40 is to account for shadows in FF
		var docbottomedge=$(document).scrollTop()+$(window).height()-40
		if (istoplevel){ //if main popup menu DIV
			var x=e.pageX+this.popupmenuoffsets[0] //x pos of main popup menu UL
			var y=e.pageY+this.popupmenuoffsets[1]
			x=(x+$ul.data('dimensions').w > docrightedge)? docrightedge-$ul.data('dimensions').w : x //if not enough horizontal room to the ridge of the cursor
			y=(y+$ul.data('dimensions').h > docbottomedge)? docbottomedge-$ul.data('dimensions').h : y
		}
		else{ //if sub level popup menu UL
			var $parentli=$ul.data('$parentliref')
			var parentlioffset=$parentli.offset()
			var x=$ul.data('dimensions').parentliw //x pos of sub UL
			var y=0

			x=(parentlioffset.left+x+$ul.data('dimensions').w > docrightedge)? x-$ul.data('dimensions').parentliw-$ul.data('dimensions').w : x //if not enough horizontal room to the ridge parent LI
			y=(parentlioffset.top+$ul.data('dimensions').h > docbottomedge)? y-$ul.data('dimensions').h+$ul.data('dimensions').parentlih : y
		}
		$ul.css({left:x, top:y})
	},
	
	showbox:function($, $popupmenu, e){
		clearTimeout($popupmenu.data('timers').hidetimer)
		$popupmenu.data('timers').showtimer=setTimeout(function(){$popupmenu.show(jquerypopupmenu.animspeed)}, this.showhidedelay[0])
	},

	hidebox:function($, $popupmenu){
		clearTimeout($popupmenu.data('timers').showtimer)
		$popupmenu.data('timers').hidetimer=setTimeout(function(){$popupmenu.hide(100)}, this.showhidedelay[1]) //hide popup menu plus all of its sub ULs
	},


	buildpopupmenu:function($, $menu, $target){
		$menu.css({display:'block', visibility:'hidden', zIndex:this.startzindex}).addClass('jqpopupmenu').appendTo(document.body)
		$menu.bind('mouseenter', function(){
			clearTimeout($menu.data('timers').hidetimer)
		})		
		$menu.bind('mouseleave', function(){ //hide menu when mouse moves out of it
			jquerypopupmenu.hidebox($, $menu)
		})
		$menu.data('dimensions', {w:$menu.outerWidth(), h:$menu.outerHeight()}) //remember main menu's dimensions
		$menu.data('timers', {})
		var $lis=$menu.find("ul").parent() //find all LIs within menu with a sub UL
		$lis.each(function(i){
			var $li=$(this).css({zIndex: 1000+i})
			var $subul=$li.find('ul:eq(0)').css({display:'block'}) //set sub UL to "block" so we can get dimensions
			$subul.data('dimensions', {w:$subul.outerWidth(), h:$subul.outerHeight(), parentliw:this.offsetWidth, parentlih:this.offsetHeight})
			$subul.data('$parentliref', $li) //cache parent LI of each sub UL
			$subul.data('timers', {})
			$li.data('$subulref', $subul) //cache sub UL of each parent LI
			$li.children("a:eq(0)").append( //add arrow images
				'<img src="'+jquerypopupmenu.arrowpath+'" class="rightarrowclass" style="border:0;" />'
			)
			$li.bind('mouseenter', function(e){ //show sub UL when mouse moves over parent LI
				var $targetul=$(this).css('zIndex', ++jquerypopupmenu.startzindex).addClass("selected").data('$subulref')
				if ($targetul.queue().length<=1){ //if 1 or less queued animations
					clearTimeout($targetul.data('timers').hidetimer)
					$targetul.data('timers').showtimer=setTimeout(function(){
						jquerypopupmenu.positionul($, $targetul, e)
						$targetul.show(jquerypopupmenu.animspeed)
					}, jquerypopupmenu.showhidedelay[0])
				}
			})
			$li.bind('mouseleave', function(e){ //hide sub UL when mouse moves out of parent LI
				var $targetul=$(this).data('$subulref')
				clearTimeout($targetul.data('timers').showtimer)
				$targetul.data('timers').hidetimer=setTimeout(function(){$targetul.hide(100).data('$parentliref').removeClass('selected')}, jquerypopupmenu.showhidedelay[1])
			})
		})
		$menu.find('ul').andSelf().css({display:'none', visibility:'visible'}) //collapse all ULs again
		$menu.data('$targetref', $target)
		this.builtpopupmenuids.push($menu.get(0).id) //remember id of popup menu that was just built
	},

	

	init:function($, $target, $popupmenu){
		if (this.builtpopupmenuids.length==0){ //only bind click event to document once
			$(document).bind("", function(e){
				if (e.button==0){ //hide all popup menus (and their sub ULs) when left mouse button is clicked
					$('.jqpopupmenu').find('ul').andSelf().hide()
				}
			})
		}
		if (jQuery.inArray($popupmenu.get(0).id, this.builtpopupmenuids)==-1) //if this popup menu hasn't been built yet
			this.buildpopupmenu($, $popupmenu, $target)
		if ($target.parents().filter('ul.jqpopupmenu').length>0) //if $target matches an element within the popup menu markup, don't bind onpopupmenu to that element
			return
		$target.bind("mouseenter", function(e){
			$popupmenu.css('zIndex', ++jquerypopupmenu.startzindex)
			jquerypopupmenu.positionul($, $popupmenu, e)
			jquerypopupmenu.showbox($, $popupmenu, e)
		})
		$target.bind("mouseleave", function(e){
			jquerypopupmenu.hidebox($, $popupmenu)
		})
	}
}

jQuery.fn.addpopupmenu=function(popupmenuid){
	var $=jQuery
	return this.each(function(){ //return jQuery obj
		var $target=$(this)
			jquerypopupmenu.init($, $target, $('#'+popupmenuid))
	})
};

//By default, add popup menu to anchor links with attribute "data-popupmenu"
jQuery(document).ready(function($){
	var $anchors=$('*[data-popupmenu]')
	$anchors.each(function(){
		$(this).addpopupmenu(this.getAttribute('data-popupmenu'))
	})
})
//end pop up menu


function ThisYear()
{  
	document.write( new Date().getFullYear() );
}
//end copyright


//start auto email function
function ShareThisPage() {
    var emptyTitle = !(document.title) || document.title == '',
        emptySearch = !(window.location.search) || window.location.search == '';

    var store = $('meta[name="flp\:store"]').attr('content');
    var language = $('meta[name="flp\:language"]').attr('content');

    var link = window.location.href + (emptySearch?'?':'&') + 'share=email'
        + (store && window.location.search.indexOf('store=') < 0 ? '&store='+store : '')
        + (language && window.location.search.indexOf('language=') < 0 ? '&language='+language : '')
    ;

    window.location = "mailto:?subject=" + encodeURIComponent(emptyTitle ? link : document.title) + "&body="+encodeURIComponent(link);
}
//end auto email function

function SelectRegion( region ) {
	var id = 'flp_region_' + region;
	$('ul#popmenu1 div.countryMenu').each(function(idx,div){
		if(  $(div).attr('id') == id  ) {
			$(div).show();
		} else {
			$(div).hide();
		}
	});
}

//start main menu dropDown
var DDSPEED = 3;
var DDTIMER = 3;

// main function to handle the mouse events //
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function ddCancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}

//end main menu dropDown

//start pop up window function

function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


//end pop up function

//go to a new page

function jumpto(url){
 window.location=url
}
//end go to new page
<!--Swap Images Function-->

$(document).ready( function (){//anything that needs to load after the document goes under here...

var changeSec = $("a[rel^=shadowbox]").addClass('outSide');
$('a.outSide').each(function() {
var hrefOut = $(this).attr('href');
var hrefOut = hrefOut.replace('http://','https://');
$(this).attr('href', hrefOut);
});

});//end document.ready

