﻿aasc = {
	/* 
		looks for links with class="external" and:
		- if "modal" class is not also present (class="external modal"), adds target="_blank" if no target is present
		- else binds click handler to open the external site in a modal dialog box
	*/
	bindExternalLinks: function(){
		$('a.external').each(function(i,o){
			var $this = $(this);
			
			if ( $this.hasClass('modal') ){
				if ( $this.attr('target') ) $this.removeAttr('target');

				$this.click(function(){
					$('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
						title: ($this.attr('title')) ? $this.attr('title') : 'External Site',
						autoOpen:true,
						width:800,
						height:500,
						modal:true,
						resizable:false, // note: if true, we'd have to resize the inner iframe on the fly
						overlay: { 
							opacity: 0.5, 
							background: "black" 
						} 
					});
					return false;
				});
			}
			else if ( ! $this.attr('target') ) $this.attr('target','_blank');
		});
	}
}
