/***************************************************
Author: Brian Dausman
URL:	mybridgepoint.com
email:  bdausman@mybridgepoint.com
***************************************************/

jQuery.noConflict();

//////////////////////////////////
//map javascript
//////////////////////////////////
jQuery(document).ready(function(){
	//hide at start
	jQuery('.marker span').hide();
	jQuery('.mapBtn').hide();
	
	//get url if from front page
	var pathname = jQuery(location).attr('href');
	var id = pathname.substring(pathname.lastIndexOf('?') + 1);
	
	if(id){
		jQuery('.' + id).show();
	}
	
	
	//hover over community area
	jQuery('.marker').hover(function(){
		jQuery(this).find('span').stop(true, true).fadeIn();
	},function(){
		jQuery(this).find('span').stop(true, true).fadeOut(100);
	});
	
	jQuery('.marker').click(function(){
		var divToLoad = jQuery(this).attr('title');

		jQuery('.marker span').hide();
		jQuery('.informationDiv').fadeOut('fast');
		
		/*remove this if using function below*/
		jQuery('.' + divToLoad).fadeIn();
		
		/*  used to hide the map after clicking locatoin
		/*  going to leave the map visible for now
		jQuery('.theMap').slideUp(function(){
			jQuery('.mapBtn').fadeIn(function(){
				jQuery('.' + divToLoad).slideDown();
		  	});
		});
		*/
		
	});
	
	
	/* shows the map button, if map doesn't hide...this isn't needed
	Query('.mapBtn').click(function(){
		jQuery(this).fadeOut();
		jQuery('.informationDiv').slideUp(function(){
			jQuery('.theMap').slideDown();
		});
	});
	*/
});

//////////////////////////////////
//select current page
//////////////////////////////////
jQuery(document).ready(function () {
    var page = window.location.pathname;
    jQuery('.communitiesNav a').each(function () {
        var href = '/' + jQuery(this).attr('href');

        if (href == page) {
            jQuery(this).prev().addClass('selected');
        } else {
            jQuery(this).parent().removeClass('selected');
        }
    });
});


//////////////////////////////////
//Exec Rotator
//////////////////////////////////
jQuery(document).ready(function () {
    jQuery('.execRotator').cycle({
        fx: 'scrollHorz',
        speed: 500,
        timeout: 18000,
        pause: 1,
        delay: -4000,
        pager: '.execPager',
        pagerEvent: 'mouseover',
		pagerAnchorBuilder: function (idx, slide) {
            return '.execPager li:eq(' + idx + ') a';
        }
    });
});

//////////////////////////////////
//job posting fadeout
//////////////////////////////////
jQuery(document).ready(function () {
    jQuery('.posting').hover(function () {
        jQuery(this).css({ 'opacity': 1.0 });
        jQuery('.posting').not(this).animate({ 'opacity': 0.6 }, 'fast');
    }, function () {
        jQuery('.posting').animate({ 'opacity': 1.0 }, 'fast');
    });

    jQuery('.posting:last-child').css({ 'border-bottom': 'none' });
});


//////////////////////////////////
//google maps plugin call
//////////////////////////////////
jQuery(document).ready(function () {
    jQuery('#map_canvas').googleMaps({
        latitude: 41.848617,
        longitude: -87.9423429,
        markers: {
            latitude: 41.848617,
            longitude: -87.9423429
        }
    });
}); 


//////////////////////////////
//navigation functionality
//////////////////////////////////
jQuery(document).ready(function () {
    //nav dropdowns
    jQuery(document).ready(function () {

        //on hover of main nav item
        jQuery('nav ul li').hover(function () {
            jQuery(this).find('.children').fadeIn();
        }, function () {
            jQuery(this).find('.children').fadeOut('fast');
        });


        //remove border from last child
        jQuery('.children ul li:last-child').css('border-bottom', 'none');

        //remove border from 1st half col
        jQuery('.half-col:first').css('border', 'none');

        //remove border from last blog post
        jQuery('.half-col .blogPost:last').css('border', 'none');

        //if screen is too small move dropdown the other direction
        if ((jQuery(window).width() <= 1100)) {
            jQuery('nav ul li:last-child .children').find('ul').css('margin-left', '-135px');
            jQuery('nav ul li:last-child .children ul li ul').css('left', '-183px');
        }
        if ((jQuery(window).width() <= 800)) {
            jQuery('nav ul li .children ul li ul').css('left', '-183px');
        }
    });

    jQuery('nav ul li:first').css('border-left', 'none');
	
	
	//locations nav
        jQuery('#pager ul li').hover(function () {
            jQuery(this).find('.children').fadeIn();
        }, function () {
            jQuery(this).find('.children').fadeOut('fast');
        });
});

/////////////////////////////////////////
////////// Homepage Rotator /////////////
/////////////////////////////////////////
jQuery(document).ready(function () {
    jQuery('.art_rotator ul').cycle({
        fx: 'fade',
        speed: 1500,
        timeout: 3000,
        pause: 1,
        delay: -1000
    });
});

/////////////////////////////////////////
////////// Services Thumbs //////////////
/////////////////////////////////////////
jQuery(document).ready(function () {
    var speed = 10000; 								//speed
    var run = setInterval('rotate()', speed); 		//timer
    var item_width = jQuery('#slides li').outerWidth(); //outer width
    var left_value = item_width * (-1); 				//left value

    jQuery('#carousel').css({ 'overflow': 'hidden' });
    jQuery('#slides li:first').before(jQuery('#slides li:last')); //move last item before first item
    jQuery('#slides ul').css({ 'left': left_value }); //move to correct position

    jQuery('#carousel #next').click(function () {
        var left_indent = parseInt(jQuery('#slides ul').css('left')) + item_width; //get right position

        jQuery('#slides ul').animate({ 'left': left_indent }, 200, function () {
            jQuery('#slides li:first').animate({ 'opacity': 1 });
            jQuery('#slides li:last').animate({ 'opacity': 0 });
            jQuery('#slides li:first').before(jQuery('#slides li:last')); 		//move last back to first
            jQuery('#slides ul').css({ 'left': left_value }); 					//set default to correct position
        });

        return false;

    });

    jQuery('#carousel #prev').click(function () {
        var left_indent = parseInt(jQuery('#slides ul').css('left')) - item_width; //get right position

        jQuery('#slides ul').animate({ 'left': left_indent }, 200, function () {
            jQuery('#slides li:last').after(jQuery('#slides li:first')); 		//move last to first
            jQuery('#slides ul').css({ 'left': left_value }); 					//set default to correct position
            jQuery('#slides li:first').animate({ 'opacity': 0 });
            jQuery('#slides li:last').animate({ 'opacity': 1 });
        });

        return false;
    });

    jQuery('#slides').hover(function () {
        clearInterval(run);
    },
	function () {
	    run = setInterval('rotate()', speed);
	});

    jQuery('#carousel .pagers').css({ 'opacity': 0.3 });
    jQuery('#carousel .pagers').hover(function () {
        jQuery(this).animate({ 'opacity': 1.0 });
    },
	function () {
	    jQuery(this).animate({ 'opacity': 0.3 });
	});
});

function rotate() {
    jQuery('#carousel #next').click();
}
/////////////////////////////////////////
////////// Please Upgrade IE ////////////
/////////////////////////////////////////
jQuery(document).ready(function () {

    jQuerybrowser = navigator.appName;
    if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 8) {
        jQuery('#upgrade').animate({ bottom: "0", opacity: ".7" }, "slow");
        jQuery('#upgrade').hover(function () {
            jQuery(this).stop(true, true).animate({ opacity: "1", bottom: "0" }, "slow");
        }, function () {
            jQuery(this).stop(true, true).animate({ opacity: ".3", bottom: "-30" }, "slow");
        });
    }
});


































