// CCDC Coleman Town Javascript Library
// Requires jquery.js

// Javascript Rollover Navbar
$(function() {
    $("#navbar img").hover(function() {
	$(this).attr("src", $(this).attr("src").split("_no.").join("_ro."));
    }, function() {
	$(this).attr("src", $(this).attr("src").split("_ro.").join("_no."));
    });
});

// Javascript Rollover Sidebar
$(function() {
    $("#sidenav img").hover(function() {
	$(this).attr("src", $(this).attr("src").split("_no.").join("_ro."));
    }, function() {
	$(this).attr("src", $(this).attr("src").split("_ro.").join("_no."));
    });
});

// Preload Image Function
jQuery.preloadImages = function()
{
    for(var i = 0; i<arguments.length; i++)
    {
	jQuery("<img>").attr("src", arguments[i]);
    }
}

// Email Hiding
$(function(){
    var spt = $('span.mailme');
    var at = / at /;
    var dot = / dot /g;
    var addr = $(spt).text().replace(at,"@").replace(dot,".");
    $(spt).after('<a href="mailto:'+addr+'" title="Send an email" class="footer_links">'+ addr +'</a>')
	.hover(function(){window.status="Send a letter!";}, function(){window.status="";});
    $(spt).remove();
});

// Detect Flash Version
// From: http://www.prodevtips.com/2008/11/20/detecting-flash-player-version-with-javascript/
function getFlashVersion(){ 
  // ie 
    try { 
	try { 
      // avoid fp6 minor version lookup issues 
	    // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
	    var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
	    try { axo.AllowScriptAccess = 'always'; } 
	    catch(e) { return '6,0,0'; } 
	} catch(e) {} 
	return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
    } catch(e) { 
	try { 
	    if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
		return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
	    } 
	} catch(e) {} 
    } 
    return '0,0,0'; 
} 

