
function mainMenu(){
	$("#nav li").hover(function(){	
		$(this).find('ul:first').css({visibility: "visible", display: "none"}).slideDown();
		$(this).css({ 'background':'#54B948' });
	},function(){						
		$(this).find('ul:first').css({visibility: "hidden", display: "none"});
		$(this).css({ 'background':'' });
	});
}

function accordionMenu() {
  $('#menu ul').hide();
  $('#menu li.selected ul').show();
  $('#menu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
  
function closeDialog(theID) {
	$(theID).hide(0);
	$('#overlay').hide(0);
}

function openDialog(theID, img, alt) {	

	if (img != "") {
		$("#first_gallery_image").attr('src',"assets/images/projects-gallery/" + img);
		$("#first_gallery_image").attr('alt', alt);
	}
	$(theID).show(0);
	$('#overlay').show(0);
	$('#overlay').css("opacity", "0.7");
	$('#overlay').width('100%');
	$('#overlay').height($(document).height());
	$('.dialog_box').each(function(){									   					  
		//var dialogPos = ($(document).height() / 2) - ($(this).height() / 2);
		//$(this).css({ 'margin-top' : dialogPos +'px' });
		$(this).centerInClient({ container: window });
	});
	
}

function showImage(img, alt) {
	if (img != "") {
		$("#first_gallery_image").attr('src',"assets/images/projects-gallery/" + img);
		$("#first_gallery_image").attr('alt', alt);
	}
}
  
$(document).ready(function(){
	
	mainMenu();	
	accordionMenu();
	
	$('body').supersleight();
	
	
	$('#home_images').cycle({
		fx: 'fade'
	});	
	
	$('dl').find('dd:last').css({ 'margin-bottom':'0px', 'border-bottom': 'none' });
	
	$(window).resize(function() {							  
		$('.dialog_box').each(function(){	
			$(this).centerInClient({ container: window });
		});
	});
	
	$(window).scroll(function () { 
	$('.dialog_box').each(function(){	
			$(this).centerInClient({ container: window });
		});
    });
	
	$('table.dialog_tbl').each(function(){
		$(this).find('td').each(function(){						   
			$(this).find('p:last').css({ 'margin-bottom':'0px' });				   
		});						   
								   
	});
	
	$('.gallery_thumbs').each(function(){
		$(this).find('.thumb_holder:last').css({ 'margin-right':'0px' });						   
								   
	});
});



