/* FW100R5 */
/* (c)2011 SugarHill Works LLC - http://www.sugarhillworks.com */
/**
 * A simple querystring parser.
 * Example usage: var q = $.parseQuery(); q.fooreturns  "bar" if query contains "?foo=bar"; multiple values are added to an array. 
 * Values are unescaped by default and plus signs replaced with spaces, or an alternate processing function can be passed in the params object .
 * http://actingthemaggot.com/jquery
 *
 * Copyright (c) 2008 Michael Manning (http://actingthemaggot.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 **/
$.parseQuery = function(qs,options) {
	var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = $.extend({}, o, options), params = {};
	$.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
		p = p.split('=');
		p[1] = o.f(p[1]);
		params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1];
	});
	return params;
}
var q = $.parseQuery();



// HANDLE LINKS TO EXTERNAL PAGES
var windowObjectReference = null;
var PreviousUrl;
function newWin(strUrl, windowOptions)
{
	if (!windowOptions) { var windowOptions = "width=730,height=640,scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=yes,titlebar=yes"; }
	if(windowObjectReference == null || windowObjectReference.closed) {
		windowObjectReference = window.open(strUrl, "SingleSecondaryWindowName", windowOptions);
	} else if (PreviousUrl != strUrl) {
		windowObjectReference = window.open(strUrl, "SingleSecondaryWindowName", windowOptions);
		windowObjectReference.focus();
	} else {
		windowObjectReference.focus();
	};
	PreviousUrl = strUrl;
}



// -- BEG SITE SETTINGS ----------------------------------------------------------------------------------------
var autoforwardTo, autoforwardWait, default_scroll_settings={}, jspapi,
	months = ['January','February','March','April','May','June','July','August','September','October','November','December'],
	days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
	thisItemDate;

$(function($){
	$.fn.reverse = [].reverse;
	$.extend({
		vpwidth: function(){
			var viewportwidth;
			if (typeof window.innerWidth != 'undefined') {// standards compliant (mozilla/netscape/opera/IE7)
				viewportwidth = window.innerWidth;
			} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {//IE6 stds cmpt mode
				viewportwidth = document.documentElement.clientWidth;
			} else {// older versions of IE
				viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
			}
			return viewportwidth;
		}
	});
	$.extend({
		vpheight: function(){
			var viewportheight;
			if (typeof window.innerHeight != 'undefined') {// standards compliant (mozilla/netscape/opera/IE7)
				viewportheight = window.innerHeight;
			} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0) {//IE6 stds cmpt mode
				viewportheight = document.documentElement.clientHeight;
			} else {// older versions of IE
				viewportheight = document.getElementsByTagName('body')[0].clientHeight;
			}
			return viewportheight;
		}
	});




	$.fn.toggleFade = function(settings) {
		settings = jQuery.extend(
			{
			speedIn: "normal",
			speedOut: settings.speedIn
			}, settings
		);
		return this.each(function()
		{
			var isHidden = jQuery(this).is(":hidden");
			jQuery(this)[ isHidden ? "fadeIn" : "fadeOut" ]( isHidden ? settings.speedIn : settings.speedOut);
		});
	};



	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 1,
			interval: 100,
			timeout: 1000
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};

		   
		   



	// SPASH PAGE
	if (autoforwardTo && autoforwardWait) {
		window.setTimeout(function(){
			$('#ceibw, #ceibw > *').animate({width:'0px',height:'0px', top:'50%'}, 750, function(){
																						$('#ceibw, #ceibw > *').hide();
																						if (autoforwardTo.match(/http:\/\//)) {
																							window.location = autoforwardTo;
																						} else {
																							window.location = rootPath+autoforwardTo;
																						}
																					 });
			}, autoforwardWait);
	}

	// GALLERY HOLD PREVIEWS
	if (window.location.toString().match('_hold')) {
		$('<div></div>').css({position:'absolute',
							top:'0px',
							left:'0px',
							width: '100%',
							height: '20px',
							paddingTop: '5px',
							background: '#C8D8FF',
							color: '#A00',
							textAlign: 'center'}).html('This is a preview and NOT live on the site.').appendTo($('#fullscr'));
	}
		
	// SETTINGS FOR SITE-WIDE NAV MENU(S)
	function initMenu (menu_cntr, over_col, out_col, cur_bg_css, cur_a_css) {
		var slinks = menu_cntr.find('li > a[href]'),
		url = window.location.toString(),
		rel,
		href,
		homePage;
		function currentPage(lnk) {
			$(lnk).removeAttr('href');
			$(lnk).parent().addClass('current-page');
		}
		for (var i = 0; i < slinks.length; i++) {
			rel = $(slinks[i]).attr('rel');
			href = rootPath + $(slinks[i]).attr('href').replace(/(\.\.\/)+/,'');
			if (href !== null) {
				if (rel) {
					if (url.match(rel)) {
						currentPage(slinks[i]);
					}
//'//						} else if (rel === 'LANG') {
//'//							if (rootPath.match(/localhost|\.local|192\.168|clientsites/)) { //TESTING ENVIRONMENT
//'//								if ((window.location.toString()).match('/es/')) {//switch to english
//'//									homePage = (window.location.toString()).replace('/es/','/');
//'//								} else {//switch to spanish
//'//									homePage = (window.location.toString()).replace(rootPath,rootPath+'es/');
//'//								}
//'//							} else { //LIVE SERVER 
//'//								if (rootPath.match(/randycole/)) {//switch to english
//'//									homePage = (window.location.toString()).replace('randycole','randycole');
//'//								} else if ((window.location.toString()).match(/randycole\.com\/es\//)) {//switch to english
//'//									homePage = (window.location.toString()).replace('randycole.com/es/','randycole.com/');
//'//								} else if (rootPath.match(/randycole/)) {//switch to spanish
//'//									homePage = (window.location.toString()).replace('randycole','randycole');
//'//								}
//'//							}
//'//							$(slinks[i]).attr('href',homePage);
//'//							$(slinks[i]).parent().removeClass('current-page');
//'//						}
				} else if ((url === rootPath) && (href === rootPath)) { // ROOT
					currentPage(slinks[i]);
				} else if (url.match(href) && (href !== rootPath)) {
					currentPage(slinks[i]);
				}
			}
		}
		
		menu_cntr.find('.menuFade:not(.current-page)').hover( 
			function() { 
				if ($(this).children('.menuitem_bg').length > 0) {
					$(this).children('.menuitem_bg').stop(true, true).animate({backgroundColor:over_col}, 325).fadeTo(325, 1);
				} else {
					$(this).stop(true, true).animate({backgroundColor:over_col}, 750);
				}
			}, 
			function(){
				if ($(this).children('.menuitem_bg').length > 0) {
					$(this).children('.menuitem_bg').stop(true, true).fadeTo(50, 0.8).animate({backgroundColor:out_col}, 750);
				} else {
					$(this).stop(true, true).animate({backgroundColor:out_col}, 750);
				}
			}
		);
		menu_cntr.find('.current-page > .menuitem_bg').css(cur_bg_css);
		menu_cntr.find('.current-page > a').css(cur_a_css);
		menu_cntr.mouseenter(function(){
								posMenuInit($(this).attr('id'));
							});
	}
	// -------------------- init site menus --------------------
	if ($("#menu_cntr_cntr").length > 0) {
		//$('#menu_cntr > ul').css({display:'block',visibility:'visible'});
		ddsmoothmenu.init({
			parentid: "main_cntr", //the id of the PARENT of #menu_cntr_cntr (usually hdr) -OR- containerfrom which the shadow pos is being computed
			mainmenuid: "menu_cntr", //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: 'nav_menu', //class added to menu's outer DIV
			showArrows: false // will show arrows to indicate submenus. note the arrows load in the browser last.
		});
		initMenu($('#menu_cntr'), '#C8D8FF', '#FFFFFF', {background:'#FFF', opacity:1, '-moz-opacity':1, 'filter':'alpha(opacity=100)'}, {cursor:'default', fontWeight:'bold', background:'none'});
	}
	if ($("#info_menu_cntr_cntr").length > 0) {
		ddsmoothmenu.init({
			parentid: "main_cntr", //the id of the PARENT of #menu_cntr_cntr (usually hdr)
			mainmenuid: "info_menu_cntr", //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: 'nav_menu', //class added to menu's outer DIV
			showArrows: false // will show arrows to indicate submenus. note the arrows load in the browser last.
		});
		initMenu($('#info_menu_cntr'), '#C8D8FF', '#FFFFFF', {background:'#C8D8FF', opacity:1, '-moz-opacity':1, 'filter':'alpha(opacity=100)'}, {cursor:'default'});
	}
	if ($("#gallery_menu_cntr_cntr").length > 0) {
		ddsmoothmenu.init({
			parentid: "main_cntr", //the id of the PARENT of #menu_cntr_cntr (usually hdr)
			mainmenuid: "gallery_menu_cntr", //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: 'nav_menu', //class added to menu's outer DIV
			showArrows: false // will show arrows to indicate submenus. note the arrows load in the browser last.
		});
		initMenu($('#gallery_menu_cntr'), '#C8D8FF', '#FFFFFF', {background:'#FFF', opacity:1, '-moz-opacity':1, 'filter':'alpha(opacity=100)'}, {cursor:'default', fontWeight:'bold', background:'none'});
	}
	if ($("#ftr_menu_cntr_cntr").length > 0) {
		ddsmoothmenu.init({
			parentid: "ceibw", //the id of the PARENT of #menu_cntr_cntr (usually hdr)
			mainmenuid: "ftr_menu_cntr", //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: 'nav_menu', //class added to menu's outer DIV
			showArrows: false // will show arrows to indicate submenus. note the arrows load in the browser last.
		});
		initMenu($('#ftr_menu_cntr'), '#C8D8FF', '#FFFFFF', {background:'#C8D8FF', opacity:1, '-moz-opacity':1, 'filter':'alpha(opacity=100)'}, {cursor:'default'});
	}
	if ($("#news_menu_cntr_cntr").length > 0) {
		for (var i = 0, n=0; i < slideshow.length; i++) {
			var thisItem = slideshow[i];
			thisItemDate = new Date(thisItem.imgtxt_names.caption1);
			thisItemYear = thisItemDate.getUTCFullYear();
			thisItemMonth = thisItemDate.getUTCMonth();
			if ($('#archive_menu > #year'+thisItemYear).length < 1) {
				$('#archive_menu').append($('<li id="year'+thisItemYear+'" class="menuFade"><div class="menuitem_bg"></div><a id="yr'+i+'">'+thisItemYear+'</a>'+
					'<ul id="months'+thisItemYear+'"><li id="'+months[thisItemMonth]+thisItemYear+'" class="menuFade"><div class="menuitem_bg"></div><a id="mn'+i+'">'+months[thisItemMonth]+'</a></li></ul></li>'));
	
				$('#mn'+i).click(function(){jspapi.scrollToElement($('#newsanchor'+$(this).attr('id').replace('mn','')), true, false);if($(this).attr('id').replace('mn','')>0){jspapi.scrollByY(40);}});
			} else {
				if ($('#months'+thisItemYear).length < 1) {
					$('#year'+thisItemYear).append($('<ul id="months'+thisItemYear+'"><li id="'+months[thisItemMonth]+thisItemYear+'" class="menuFade"><div class="menuitem_bg"></div><a id="mn'+i+'">'+months[thisItemMonth]+'</a></li></ul>'));
					$('#mn'+i).click(function(){jspapi.scrollToElement($('#newsanchor'+$(this).attr('id').replace('mn','')), true, false);if($(this).attr('id').replace('mn','')>0){jspapi.scrollByY(40);}});
				} else {
					if ($('#'+months[thisItemMonth]+thisItemYear).length < 1) {
						$('#months'+thisItemYear).append('<li id="'+months[thisItemMonth]+thisItemYear+'" class="menuFade"><div class="menuitem_bg"></div><a id="mn'+i+'">'+months[thisItemMonth]+'</a></li>');
						$('#mn'+i).click(function(){jspapi.scrollToElement($('#newsanchor'+$(this).attr('id').replace('mn','')), true, false);if($(this).attr('id').replace('mn','')>0){jspapi.scrollByY(40);}});
					}
				}
			}
		}
		$('#archive_menu').append($('<li class="lastItem"></li>'));
		
		ddsmoothmenu.init({
			parentid: "ceibw", //the id of the PARENT of #menu_cntr_cntr (usually hdr)
			mainmenuid: "news_menu_cntr", //menu DIV id
			orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
			classname: 'nav_menu', //class added to menu's outer DIV
			showArrows: false // will show arrows to indicate submenus. note the arrows load in the browser last.
		});
		initMenu($('#news_menu_cntr'), '#C8D8FF', '#FFFFFF', {background:'#C8D8FF', opacity:1, '-moz-opacity':1, 'filter':'alpha(opacity=100)'}, {cursor:'default'});
		
		if ($.browser.webkit) {
			setTimeout(function(){			
				//alert($('.jspContainer').height());
				$('.jspContainer').css({overflow:'auto'});
				$('.jspPane').css({width:'930px'});
				jspapi.reinitialize();
			},500);
		}

	}
	// -------------------- menu repositioning --------------------
	function posMenuInit(menu_cntr_id) {
		//alert(menu_cntr_id);
		if (!menu_cntr_id) {
			var menu_jqstr = '#menu_cntr > ul > li > ul, #gallery_menu_cntr > ul > li > ul, #info_menu_cntr > ul > li > ul, #news_menu_cntr > ul > li > ul';
		} else {
			var menu_jqstr = '#'+menu_cntr_id + ' > ul > li > ul';
		}
		$(menu_jqstr).each(function(i){
			var menu = $(this).parent().parent().parent(),
			submenu = $(this);
			if ($(submenu).children('li').children('ul').length > 0) {
				$(submenu).children('li').children('ul').each(function(){
																	   //alert($(menu).height() + '\n' + $(submenu).height() + '\n'+ $(this).height());
					posMenu(menu, submenu, $.vpheight(), $(menu).offset().top, $(menu).height(), $(submenu).height(), $(this).height(), $(this));
				});
			} else {
				 //alert($(menu).height() + '\n' + $(submenu).height() + '\n'+ $(menu).offset().top + '\n' + $.vpheight());
					posMenu(menu, submenu, $.vpheight(), $(menu).offset().top, $(menu).height(), $(submenu).height());
			}
		});
	}
	posMenuInit();
	//$(window).scroll(function(){posMenuInit();});
	//$(window).resize(function(){posMenuInit();});


	// SETTINGS FOR GENERAL USE VERTICAL SCROLL PANES
	default_scroll_settings = {
		showArrows: false, // controls whether to display arrows for the user to scroll with (defaults to false)
		animateScroll: true, // whether to animate when calling scrollTo and scrollBy (defaults to false)
		animateDuration: 300, // [int] 300
		animateEase: 'circ', //[str] 'linear'
		verticalDragMinHeight: 50, // [int] - the minimum height to allow the drag bar to be (defaults to 0)
		maintainPosition: true //[boolean] - Whether the contents of the scroll pane maintains its position when you re-init it(so it doesn't scroll as you add more content) (default true)
	};
	if ($('.scroll-pane').length > 0) {
		$('.scroll-pane').jScrollPane(default_scroll_settings);
		jspapi = $('.scroll-pane').data('jsp');
	}
	
	// SET UP ROLLOVER ANIMATIONS
	$(".fadeCol").hover( 
		function() {
			if ($(this).parent().hasClass('slctd')) { return false; }
			else { $(this).stop(true, true).animate({color:"#999"}, 750); }
		}, 
		function() {
			if ($(this).parent().hasClass('slctd')) { return false; }
			else { $(this).stop(true, true).animate({color:"#666"}, 750); }
		}
	);
	$(".fadeBodyCol").hover( 
		function() {
			$(this).stop(true, true).animate({color:"#666"}, 750);
			$(this).stop(true, true).animate({backgroundColor:"#C8D8FF"}, 750);			
		}, 
		function() {
			$(this).stop(true, true).animate({color:"#666"}, 750);
			$(this).stop(true, true).animate({backgroundColor:"#FFF"}, 750);	
		}
	);
//	$(".fadeNavCol").hover( 
//		function() {
//			$(this).stop(true, true).animate({color:"#999"}, 750);
//		}, 
//		function() {
//			$(this).stop(true, true).animate({color:"#666"}, 750);
//		}
//	);
//	$(".fadeFtrCol").hover( 
//		function() { 
//			$(this).stop(true, true).animate({color:"#666"}, 750);
//			//$(this).children("div").stop(true,true).fadeTo(750, 0.75);
//		}, 
//		function(){
//			$(this).stop(true, true).animate({color:"#999"}, 750)
//			//$(this).children("div").stop(true,true).fadeTo(750, 0);
//		}
//	);
	// fadeCopyCol is used in RCR footer 
	$(".fadeCopyCol").hover( 
		function() { 
			$(this).stop(true, true).animate({color:"#666"}, 750);
		}, 
		function(){
			$(this).stop(true, true).animate({color:"#AAA"}, 750)
		}
	);



	/*stickyfooter - might need this when layout is flex (height:auto) - see global.css stickyfooter comments. */
	if ($.browser.safari) {
//		$('#fullscr').css('margin','0 auto 0 auto');
//$('#fullscr').css({margin:'0 auto', background:'orange'});
//$('#ceibw').css({background:'maroon'});$('#hdr
//alert($('#fullscr').css('marginBottom'));
		//$('#copy').appendTo('#ceibw');
		//.css({padding:'15px 0 25px', height:'25px', background:'#fed009'})
		//$('#copy').css({marginTop:'10px'});//.appendTo('#ceibw');
		//$('#copy').css({position:'absolute', bottom:'0px', margin:'0'}).appendTo('#fullscr');
	}



	// SET UP VERTICAL POSITIONING ON INFO PAGES
	// Call this function to vertically center a content container in its parent. Takes jq selectors as arguments.
	function vCenter(content_cntr, parent_cntr, topOff) {
		//if ($(parent_cntr).height() === $(content_cntr).height()) {
			if (!topOff) { topOff = 0; }
			var topPos = $(parent_cntr+' > div:first').css({paddingTop:'0', marginTop:'0'}).offset().top;
			var btmPos = $(parent_cntr+' > div:last').css({paddingBottom:'0', marginBottom:'0'}).offset().top + $(parent_cntr+' > div:last').height();
			var content_h = btmPos - topPos;
			if (content_h < 1) {
				//alert(parseInt($(content_cntr).css('height')));
				//fall back to CSS if content h comes back 0
				content_h = parseInt($(content_cntr).css('height'));
			}
			var newTopPos = Math.floor((($(parent_cntr).height() / 2) - (content_h / 2)));
			//newTopPos = newTopPos - 30; //OFFSET ADJUSTMENT LINE - use any arbitrary math.
			$(content_cntr).css({top:(newTopPos+topOff)+'px'}); // use top: or paddingTop: depending on content 'push' needs, css, etc.
		//}
	}
	if ($("#main_txt_scr_cntr").length > 0) {
			//setTimeout(function(){vCenter('#v_center_wrap', '#main_txt_scr_cntr');},5000);
			vCenter('#v_center_wrap', '#main_txt_scr_cntr')
	}
	
	
	// INIT SLIDESHOW
	if ($('#ss_cntr').length > 0) {
		ss_init();
	}
	if ($('#auto_ss_cntr').length > 0) {
		ss_init();
	}
	
	
	
	// INIT VIDEO
//	if ($('#vid_cntr').length > 0) {
//		jwplayer("vid_plyr").setup({
//			flashplayer: "../shw_lib/mediaplayer-5.4/player.swf",
//			file: rootPath+"events/img/video1.mp4",
//			height: 240,
//			width: 320,
//			events: {
//				onComplete: function(event) { olayHide(); }
//			},
//			autostart: true,
//			controlbar: 'none'
//			
//		});
//	}
	
	$('#overlay_bg').click(function(){olayHide();});
});



// MENU FUNCTIONS
function posMenu(menu, submenu, vpH, mT, mH, smH, ssmH, subsubmenu) {
	var avail, newTpos, maxTpos;
	avail = ($.vpheight() - mT - mH - $(window).scrollTop());
	if (!ssmH) { ssmH = 0; }
	newTpos = (((vpH)-(mT+mH+smH+ssmH)) + $(window).scrollTop());
	maxTpos = ((smH) * -1);
	
	if (newTpos < 0) {
			if (newTpos < maxTpos) { newTpos = maxTpos; }
			submenu.css({top: newTpos+'px'});
	} else {
			submenu.css({top: mH+'px'});
	}
	
	if (ssmH) {
		//alert(ssmH);
		avail = ($.vpheight() - subsubmenu.offset().top - mH - ssmH - $(window).scrollTop());
		newTpos = (((vpH)-(mT+mH+ssmH)) + $(window).scrollTop());
		//alert(newTpos);
		newTpos = -1 * (ssmH);
		//alert(newTpos);
		window.setTimeout(function(){
			subsubmenu.css({top: (newTpos+mH)+'px'});
		},1000);
	}
	return;
}

// OVERLAY FUNCTIONS
function olayShow(content_cntr,vcenter) {
	//$('#overlay').css({top:($('#main_cntr').offset().top)+'px', left:(parseInt($('#main_cntr').offset().left)+10)+'px', width:($('#main_cntr').width()-18)+'px', height:($('#main_cntr').height())+'px'});
	//jwplayer().stop();
	$('#overlay').fadeIn(500,function(){$('#overlay').show();});
	if (vcenter === true) {	//VCENTER CONTENT CNTR

		var newTopPos = Math.floor((($.vpheight() / 2) - (parseInt($(content_cntr).css('height')) / 2))) + ($(document).scrollTop()) - ($('#main_cntr').offset().top);
		if (newTopPos < 250) {
			newTopPos = 250;
		}
		$(content_cntr).css({top:(newTopPos)+'px'}); // use top: or paddingTop: depending on content 'push' needs, css, etc.
	}

}
function olayHide() {
	//$('#vid_cntr').hide(0);
	//jwplayer().stop();
	$('#overlay').fadeOut(500,function(){$('#overlay').hide();});
}
function olayToggle() {
	$('#overlay').toggleFade(500);
}

function centerVideoCntr() {
	//$('#vid_cntr').css({top:(($('#vid_cntr').parent().height() - $('#vid_cntr').height()) / 2) + 'px', left:(($('#vid_cntr').parent().width() - $('#vid_cntr').width()) / 2) + 'px'});
	vCenter('#vid_cntr','#overlay');
}
// VIDEO FUNCTIONS



// -- END SETTINGS ----------------------------------------------------------------------------------------









