/**
 * JavaScript Library required for all pages of the public site.
 *
 */

jQuery(document).ready(function()
{
    // Open external links (specified by rel= or class=) in a new browser window:    
    jQuery("a[rel*='external'],a[class*='external']").attr('target','_blank');
    
    // Top:
    jQuery("#footer").find("a#top").bind("click", function() {
        jQuery('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
    
    // swfobject:
    if (jQuery("#slideshow").exists()) {
        var flashvars = {xmlsource:"/wp-content/themes/easternpcm/projects.xml.php"};
        var params = {menu: "false"};
        var attributes = {};
        swfobject.embedSWF("/wp-content/themes/easternpcm/epcm.swf", "slideshow", "620", "445", "10.0.0","expressInstall.swf", flashvars, params, attributes);
    }
    
    // apply lightbox behavior:
    jQuery('.ngg-gallery-thumbnail a').fancybox({
		titlePosition: 'inside'
	});
	
	// webcam:
	jQuery('.webcam').appendTo('.entry-content').bind('click', function(e) {
		e.preventDefault();
		href = jQuery(this).attr('href');
		jQuery.fancybox({
			href: href,
			width: 496,
			height: 425,
			padding: 0,
			scrolling: 'no',
			type: 'iframe'
		});
		return false;
	});
    
    jQuery('li.widget_archive h3').click(function() { location.href = '/news/'; });

});

// SIFR:
var heading = {
  src: '/wp-content/themes/easternpcm/heading.swf'
  ,ratios: [6, 1.66, 8, 1.54, 9, 1.39, 10, 1.34, 11, 1.31, 15, 1.29, 25, 1.25, 33, 1.23, 43, 1.22, 65, 1.21, 69, 1.2, 70, 1.21, 117, 1.2, 118, 1.19, 122, 1.2, 123, 1.19, 1.2]
};
sIFR.useStyleCheck = true;
sIFR.activate(heading);

sIFR.replace(heading, {
  selector: '#content h1'
  ,wmode: 'transparent'
  ,tuneHeight: -5
  ,css: [
    '.sIFR-root { color: #ffffff; font-weight: bold; }'
    ,'a { text-decoration: none; }'
    ,'a:link { color: #ffffff; }'
    ,'a:hover { color: #ff0000; }'
  ]
});

sIFR.replace(heading, {
  selector: '#content h2, #content h3'
  ,css: [
    '.sIFR-root { color: #000000; font-weight: bold; }'
    ,'a { text-decoration: none; }'
    ,'a:link { color: #000000; }'
    ,'a:hover { color: #cc0000; }'
  ]
});

/* ============================================================================
   HELPERS */
   
jQuery.fn.exists = function(){return jQuery(this).length>0;}

