function getOffice(url)
{
	var width = 700; 
	$("#popup").css("width" , width);
	$("#popup-content").load(url);
	openPopup(width);
}

function openFlash(file)
{
	var url = BASE_URL+'/files/'+file;
	var content = "<div style='text-align:center;width:100%'>";
	content += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="423" height="784" id="animation" align="middle">';
	content += '<param name="allowScriptAccess" value="sameDomain" />';
	content += '<param name="movie" value="'+url+'" />';
	content += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
	content += '<embed src="'+url+'" quality="high" bgcolor="#ffffff" width="423" height="784" name="animation" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	content += '</object></div>';
	$("#popup").css("width" , "471px");
	$("#popup").css("height" , "834px");
	$("#popup-content").html(content);
	openPopup(471);
	return false;
}

function openPopup(width)
{
	var el = "#popup";
	$(el).css('top', '50px'); 
	$(el).css('left', '50%'); 
	$(el).css('margin-left', -(width/2)); 
	
	$(el).slideDown("slow");
}
function closePopup()
{
	var el = "#popup";
	$(el).slideUp("slow");
}

function showTab(name)
{
	$('.tabs').not('#'+name).hide().removeClass('show');
	$('#'+name).fadeIn('fast');
}

$(function() {
    $(".lavaLamp ul.mnav").lavaLamp({
	fx: "backout", 
	speed: 700,
	click: function(event, menuItem) {
	    return true;
	}
    });
    
	//-----------------------------------
    $("#portfolio img").hover(
      function () {
      	$(this).css({ pointer:"hand"});
        $(this).fadeTo("slow", 1.00);
      }, 
      function () {
        $(this).fadeTo("slow", 0.30);
      }
    );
	//-----------------------------------
	var previousImg = '#bigimg0';
	var previousImgTxt = '#textimg0';
	if($(previousImgTxt) && $(previousImg)) {
		$(previousImgTxt).fadeIn("normal");
		 $(previousImg).fadeIn("normal");
		  
	}
	
    $(".casestudyGallery #thumb img").click(
    	function() {
	        var imageId = $(this).attr("id");
    		if (previousImgTxt != null) {
    			$(previousImgTxt).fadeOut("fast");
    		}
	        $('#text' + imageId).fadeIn("normal");
	        previousImgTxt = '#text' + imageId;
	        
    		if (previousImg != null) {
    			$(previousImg).fadeOut("fast");
    		}
	        $('#big' + imageId).fadeIn("normal");
	        
	        previousImg = '#big' + imageId;	        
	     return false;
        });
	//-----------------------------------
    
	 var previousStaff = '';
	 var hoverEffect = true;
	 /*if($(previousImgTxt) && $(previousImg)) {
		$(previousImgTxt).fadeIn("normal");
		 $(previousImg).fadeIn("normal"); 
	 }*/	
     if(hoverEffect == true) {
	    $(".staffThumb img").hover(
	      function () {
	      	var staffThumb = $(this).attr("id");
	      	if(this != previousStaff) {
		      	$(this).css({ pointer:"hand"});
		        $(this).fadeTo("slow", 1.00);    
	        }
	      }, 
	      function () {
	      	var staffThumb = $(this).attr("id");
	      	if(staffThumb != previousStaff) {
	       		$(this).fadeTo("slow", 0.30);
	        }
	      }
	    );     
     }
	$(".staffThumb img").click(
    	function() {
	        var staff = $(this).attr("id");
    		if (previousStaff != "") {
    			$('#staff_' + previousStaff).fadeOut("fast");
    			 $('#' + previousStaff).fadeTo("slow", 0.30);
    		}
	        $('#staff_' + staff).fadeIn("normal");
	        $('#' + staff).fadeTo("slow", 1.00);
	        hoverEffect = false;
	        previousStaff = staff;	        
	     return false;
        });
       
	//-----------------------------------
	$(".portfolio li").each(function(n, v) {
		if(((n+1) % 4) == false) {
			$(this).addClass('last');
		}
	});
	$(".portfolio li:last").addClass('last');
	
	//addClass('last');
	//-----------------------------------
	
	$("#footer .popup").click(
		function() {
			getOffice(this.href);			
		return false;
		}
	);
	

 });

