// JavaScript Document

/* header map mouseover bg change */
$(function() {
	$('#map').mouseover(function() {
		$("#header").animate({backgroundPosition:'0px -76px'}, {queue:false, duration: 0});
	});
	$('#map').mouseout(function() {
		$("#header").animate({backgroundPosition:'0px 0px'}, {queue:false, duration: 0});
	});
	
});

var drawer_open = 0;

/* slide-up personality module: MOUSEOVER */
$(function() {
	$('#persongo').mouseover(function() {
		// alert("got a mouseover");
		drawer_open = 1;
		$("#mainwrap").css({'z-index':'800'});
		$("#mainwrap-single").css({'z-index':'800'});
		$("#mainwrap-pr").css({'z-index':'800'});
		$("#footer").css({'z-index':'5000'});
		$("#footsubwrap").css({'z-index':'6000'});
		$("#footsubwrap-in").css({'z-index':'6000'});
		$("#person").animate({top:'0px'}, {queue:false, duration: 500});
		$("#personbar").animate({backgroundPosition:'0px -147px'}, {queue:false, duration: 0});
	});
	
	$('#footer').mouseleave( function() { hide_drawer(); });
	$('#personbar').mouseenter( function() { hide_drawer(); });
	$('#bottom').mouseenter( function() { hide_drawer(); });
	$('#mainwrap').mouseenter( function() { hide_drawer(); });
	$('#mainwrap-pr').mouseenter( function() { hide_drawer(); });
	$('#mainwrap-single').mouseenter( function() { hide_drawer(); });
});

function hide_drawer () {
	if(drawer_open == 0) {
		return;
	}
	drawer_open = 0;

	$("#person").animate({top:'236px'}, {queue:false, duration: 400, complete:function() { 
		$('#footer').css({'z-index':'1000'});
		$('#footsubwrap').css({'z-index':'1000'});
		$('#footsubwrap-in').css({'z-index':'1000'});
		$("#mainwrap-single").css({'z-index':'3000'});
		$("#mainwrap-pr").css({'z-index':'3000'});
		$("#mainwrap").css({'z-index':'3000'}) }
	});
	$("#personbar").animate({backgroundPosition:'0px 0px'}, {queue:false, duration: 0});
}

/* slide-up personality module: CLICK TOGGLE
$(function() {
	$('#persongo').toggle(function() {
		// alert("got a toggle on");
		$("#mainwrap").css({'z-index':'800'});
		$("#mainwrap-single").css({'z-index':'800'});
		$("#mainwrap-pr").css({'z-index':'800'});
		$("#footer").css({'z-index':'5000'});
		$("#footsubwrap").css({'z-index':'6000'});
		$("#footsubwrap-in").css({'z-index':'6000'});
		$("#person").animate({top:'0px'}, {queue:false, duration: 500});
		$("#personbar").animate({backgroundPosition:'0px -147px'}, {queue:false, duration: 0});
	}, function() {
		// alert("got a toggle off");
		$("#person").animate({top:'236px'}, {queue:false, duration: 400, complete:function() { $('#footer').css({'z-index':'1000'});$('#footsubwrap').css({'z-index':'1000'});$('#footsubwrap-in').css({'z-index':'1000'});$("#mainwrap").css({'z-index':'3000'}) }});
		$("#personbar").animate({backgroundPosition:'0px 0px'}, {queue:false, duration: 0});
	});
});
*/

/* accordian menu on Project & Repairs page */

function initMenu() {
  $('#prmenu ul').hide();
  $('#prmenu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#prmenu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
$(document).ready(function() {initMenu();});

/* end *******************/


