$(document).ready(function() {
	//$('ul.sub-nav').css('opacity', 0.9);
	$("#main_nav > li").hoverIntent(config);
//_________ end main nav _________\\
if($('#slider').length){
	$('#slider').after('<ul id="pager">').cycle({
	    fx:     'scrollHorz',
	    speed:  2000,
	    timeout: 6000,
		slideExpr: 'img',
		pager:  '#pager',
		pagerAnchorBuilder: pagerFactory,
		manualTrump: false,
		after: onAfter
	});
}
//_________ end image cycle for properties _________\\
	$('#image_nav li:nth-child(2)').addClass('middle');
//_________ end add class for pager _________\\
	var $scrollingDiv = $("#find_place.resource, #find_place.search");

	if($('#content').length){
		var bodyY = parseInt($('#content').offset().top) - 20;

		$(window).scroll(function () { 
			var scrollY = $(window).scrollTop();
			var isfixed = $scrollingDiv.css('position') == 'fixed';

			if($scrollingDiv.length > 0){
				//console.log("srollY : " + scrollY + ", bodyY : " + bodyY + ", isfixed : " + isfixed);
				if ( scrollY > bodyY && !isfixed ) {
					$scrollingDiv.stop().css({
						position: 'fixed',
						top: 20
					});
				} else if ( scrollY < bodyY && isfixed ) {
					$scrollingDiv.css({
						position: 'relative',
						top: 0
					});
				}
			}
		});
	}
//________ end find place scroller _________\\
	// var selectOptions = {
	//         	optionsTop: 0,
	//         	optionsWidth: 240
	// 
	//         }
	// $("#header_search_form div select").styleSelect(selectOptions);
//_________ end select re-styler _________\\
	$('#header_search_button').hover(function(){
		$(this).attr('src', 'accelsite/themes/temp999/images/mcm_go_on.png');
	},
	function(){
		$(this).attr('src', 'accelsite/themes/temp999/images/mcm_go.png');
	});
//_________ / search button _________\\
	$('#main_nav > li:gt(4)').addClass('special');
});
//_________ end doc ready _________\\
function onAfter() {
	// console.log(this.name);
	$('#find_more').attr('href', 'http://'+ this.name +''); 
}
var config = {
	sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
	interval: 10, // number = milliseconds for onMouseOver polling interval
	over: hoverOn, // function = onMouseOver callback (REQUIRED)
	timeout: 250, // number = milliseconds delay before onMouseOut
	out: hoverOff // function = onMouseOut callback (REQUIRED)
};
function hoverOn(){
	$(this).siblings('li').children('ul:visible').slideUp(100);
	$(this).find('ul.sub-nav').slideDown(200);
}
function hoverOff(){
	$(this).find('ul.sub-nav').slideUp(200);
}
//_________ end main nav hover _________\\
function pagerFactory(idx, slide) {
    var s = idx > 20 ? ' style="display:none"' : '';
    return '<li'+s+'><a href="#"><span>'+(idx+1)+'</span></a></li>';
};
//_________ end pager _________\\
