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;

// Show the presentation dialog

$(function() {
    
    // test for cookies
    $.cookie('ct', 'true');
    if (($.cookie('ct') === 'true') && ($('body.presentation').length < 1)){
        
        // clear test cookie
        $.cookie('ct', null);
        
        // test for pValid cookie.  If they have validated the email, they shouldn't get the popup.
        if ($.cookie('pValid') != 1){
            
            // test for shownPreview cookie.  If they have seen the preview, they shouldn't get the popup.
            if ($.cookie('shownPreview') != 'true')
                var blockTimeout = setTimeout( showPresentation, 20000 );
        
        }
        
    }
    
    function showPresentation(){
        
        // test for pValid cookie.  If set, go directly to presentation
        if ($.cookie('pValid') == 1){
            window.location = '/presentation/';
            return;
        }
        
        // set shownPreview cookie.
        $.cookie('shownPreview', 'true', { expires: 7} );
        
        // clear the pop timer if it exists
        if (typeof blockTimeout != 'undefined')
            clearTimeout(blockTimeout);
    	
    	// create modal
    	$.blockUI({ 
            message: $('#presentation_div'), 
            css: { top: '20%' } 
        });
        $('.blockOverlay').attr('title','Return to site').click($.unblockUI); ;
    	
    	// focus email field
    	$("#email").focus();
    	
    }

    // Hide the presentation dialog
    function hidePresentation(){
        $.unblockUI()
    	$("#contact").removeClass("selected");
    }
    
	$("#presentation_request").click(function() {
		$(this).addClass("selected");
		showPresentation();
		return false;
	});

	$(".close").live('click', function() {
	    hidePresentation();
		return false;
	});
});


    // possibly no longer needed:
    $.fn.slideFadeToggle = function(easing, callback) {
	    return this.animate({ opacity: 'toggle', height: 'toggle' }, "fast", easing, callback);
    };


/*
case 'small':
			newwindow = window.open( "/presentation/small.php", "Isla Palenque Interactive Presentation", "status = 1, height = 561, width = 1000, resizable = 0, location = 0, menubar = 0, toolbar = 0")
			break;
		case 'medium':
			newwindow = window.open( "/presentation/medium.php", "Isla Palenque Interactive Presentation", "status = 1, height = 719, width = 1260, resizable = 0, location = 0, menubar = 0, toolbar = 0" )
			break;
		case 'large':
			newwindow = window.open( "/presentation/large.php", "Isla Palenque Interactive Presentation", "status = 1, height = 932, width = 1660, resizable = 0, location = 0, menubar = 0, toolbar = 0" )
			break;
		default:
			newwindow = window.open( "/presentation/small.php", "Isla Palenque Interactive Presentation", "status = 1, height = 561, width = 1000, resizable = 0, location = 0, menubar = 0, toolbar = 0" )
*/
