function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;


		/*
		* DEFAULT OPTIONS
		*
			options: {
			template:"yourMenuVoiceTemplate", --> the url that returns the menu voices via ajax. the data passed in the request is the "menu" attribute value as "menuId"
			additionalData:"",								--> if you need additional data to pass to the ajax call
			menuSelector:".menuContainer",		--> the css class for the menu container
			menuWidth:150,										--> min menu width
			openOnRight:false,								--> if the menu has to open on the right insted of bottom
			iconPath:"ico/",									--> the path for the icons on the left of the menu voice
			hasImages:true,										--> if the menuvoices have an icon (a space on the left is added for the icon)
			fadeInTime:100,										--> time in milliseconds to fade in the menu once you roll over the root voice
			fadeOutTime:200,									--> time in milliseconds to fade out the menu once you close the menu
			menuTop:0,												--> top space from the menu voice caller
			menuLeft:0,												--> left space from the menu voice caller
			submenuTop:0,											--> top space from the submenu voice caller
			submenuLeft:4,										--> left space from the submenu voice caller
			opacity:1,												--> opacity of the menu
			shadow:false,											--> if the menu has a shadow
			shadowColor:"black",							--> the color of the shadow
			shadowOpacity:.2,									--> the opacity of the shadow
			openOnClick:true,									--> if the menu has to be opened by a click event (otherwise is opened by a hover event)
			closeOnMouseOut:false,						--> if the menu has to be cloesed on mouse out
			closeAfter:500,										--> time in millisecond to whait befor closing menu once you mouse out
			minZindex:"auto", 								--> if set to "auto" the zIndex is automatically evaluate, otherwise it start from your settings ("auto" or int)
			hoverInted:0, 										--> if you use jquery.hoverinted.js set this to time in milliseconds to delay the hover event (0= false)
			onContextualMenu:function(o,e){} 	--> a function invoked once you call a contextual menu; it pass o (the menu you clicked on) and e (the event)
		},
		*/


		$(function(){
			$(".myMenu").buildMenu(
			{
				template:"",
				additionalData:"",
				menuWidth:90,
				openOnRight:false,
				menuSelector: ".menuContainer",
				iconPath:"ico/",
				hasImages:false,
				fadeInTime:100,
				fadeOutTime:300,
				adjustLeft:0,
				minZindex:"auto",
				adjustTop:10,
				opacity:.95,
				shadow:false,
				openOnClick:false,	
				closeOnMouseOut:true,
				closeAfter:0
			});


		}
	);


$(function() {

  $('.collapse-btn a').toggle(function() {	
  //alert("collapse");
  	$('.subtabs div > div:visible').addClass('selectedsubtab');
  }, function() {
	$('div .selectedsubtab').removeClass('selectedsubtab');
  });

	var $tabs = $('#tab-container').tabs(); 
	var $whowearetabs = $('#tab-whoweare').tabs(); 
	var $whatweachievetabs = $('#tab-whatweachieve').tabs(); 
	var $whatyoucandotabs = $('#tab-whatyoucando').tabs(); 

	// keeps the tab content closed by default on non-home pages
	$('body:not(.homepage) .subtabs div > div:visible').addClass('selectedsubtab');

	$('.subtabs td a').click(function() { 
		$('div .selectedsubtab').removeClass('selectedsubtab');
		return false;
	});

	$('#whowearetab a').click(function() { 
		$whowearetabs.tabs('select', 0); 
		return false;
	});
	$('#whatweachievetab a').click(function() { 
		$whatweachievetabs.tabs('select', 0); 
		return false;
	});

	$('#whatyoucandotab a').click(function() { 
		$whatyoucandotabs.tabs('select', 0); 
		return false;
	});

  $('.subtabs li:first a').toggle(function() {	
//alert("clicked 1");
	$('div .selectedsubtab').removeClass('selectedsubtab');

  }, function() {
//alert("clicked 2");
  	$('.subtabs div > div:visible').addClass('selectedsubtab');

  });
/*  $('.homepage .subtabs li:first a').toggle(function() {	
alert("clicked 1");
  	$('.subtabs div > div:visible').addClass('selectedsubtab');

  }, function() {
alert("clicked 2");
	$('div .selectedsubtab').removeClass('selectedsubtab');


  });*/


	$('#newslink').click(function() {
		$tabs.tabs('select', 2); 
		$whatweachievetabs.tabs('select', 1); 
		$('div .selectedsubtab').removeClass('selectedsubtab');
		return false;
	});




$('#tab-container a').click(function(){
        if ($(this).attr('rel') != '' && $(this).attr('class') == 'external') {
            window.open($(this).attr('rel'));
     
        }
        return false;
    });
    
$('.subtabs a[href$=".pdf"]').click(function() {
    window.open($(this).attr('href'));
	return false;
});

$('.subtabs a[rel^="external"]').click(function() {
    window.open($(this).attr('href'));
	return false;
});

$('.subtabs a[href^="mailto"]').click(function() {
    window.open($(this).attr('href'));
	return false;
});

	$('#sidebar1 a[href$=.pdf]').addClass('pdflink');
	$('#maincontent a[href$=.pdf]').addClass('pdflink');

	$('.subtabs a[href$=.pdf]').addClass('pdflink');
	//$('#fragment-brochure a[rel$=.pdf]').addClass('pdflink');
	//$('#fragment-news a[rel$=.pdf]').addClass('pdflink');
});

$(function() {
	$("a[rel^='prettyPhoto']").prettyPhoto({
            animationSpeed: 'normal', /* fast/slow/normal */
            padding: 40, /* padding for each side of the picture */
            opacity: 0.35, /* Value betwee 0 and 1 */
            showTitle: false, /* true/false */
            allowresize: false, /* true/false */
            counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
            theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
            callback: function(){}
        });
});

function highlightNav() {
	 $(function() {
		$('body.developmentpage li#development').mouseover();	
		$('body.developmentpage li#development').addClass('selected');
		$('body.architecturepage li#architecture').mouseover();	
		$('body.architecturepage li#architecture').addClass('selected');
		$('body.residentservicespage li#resident').mouseover();	
		$('body.residentservicespage li#resident').addClass('selected');
		$('body.housingservicespage li#housing').mouseover();	
		$('body.housingservicespage li#housing').addClass('selected');
		return false;
	});
}


$(function() {

	$("body.blogpage a[rel^='prettyPhoto']").addClass("thumbpadding");

});



function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
	thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
	thisfield.value = defaulttext;
	}
}