// Example: "~dubtuning~@~dubwerks.com~" (no quotes)
emailRegex = /(~([^~]+)~@~([^~]+)~)/gi;
emailLink  = "<a href=\"mailto:$2@$3\">$2@$3</a>";
function emails() { document.body.innerHTML = document.body.innerHTML.replace( emailRegex, emailLink ); }

var Browser = {
	IE:           !!( window.attachEvent && !window.opera ),
	Gecko:        navigator.userAgent.indexOf( 'Gecko' ) > -1 && navigator.userAgent.indexOf( 'KHTML' ) == -1,
	Opera:        !!window.opera,
	WebKit:       navigator.userAgent.indexOf( 'AppleWebKit/' ) > -1,
	MobileSafari: !!navigator.userAgent.match( /Apple.*Mobile.*Safari/ )
};

function _( tag ) { return document.getElementsByTagName( tag ); }
function killTheAnts( ar ) { for( i = 0; i < ar.length; i++ ) { ar[i].onfocus = function() { if( this.blur ) { this.blur(); } } } }
String.prototype.trim = function() { return this.replace( /(?:^\s+)|(?:\s+$)/g, "" ); }

function $() {
	function get$( el ) { if( typeof el == 'string' ) el = document.getElementById( el ); return el; }
	if( arguments.length == 1 ) return get$( arguments[0] );
	var elements = [];
	$c( arguments ).each( function( el ) { elements.push( get$( el ) ); } );
	return elements;
}

function menu() {
	nav = $( "menu" ).getElementsByTagName( "LI" );
	for( i = 0; i < nav.length; i++ ) {
		node = nav[i];
		if( node.sub = node.getElementsByTagName( "UL" )[0] ) {
			node.onmouseover = menuHover;
			node.onmouseout = menuHover;
		}
	}
}
function menuHover() { this.sub.className = ( /hover/.test( this.sub.className ) )? this.sub.className.replace( /hover/, "" ): this.sub.className + " hover"; }

function swapImage() {
	$( "previewImage" ).src = this.childNodes[0].src.replace( "thumbs/", "" );
	return false;
}

// **** initialize the window **** keeps this last ****
window.onload = function() {
	emails();
	killTheAnts( $( "wrapper" ) );
	if( Browser.IE ) { menu(); }
	
	if( ps = $( "photoStrip" ) ) {
		var pre = [];
		var imgLinks = ps.getElementsByTagName( "A" );
		for( var i = 0; i < imgLinks.length; i++ ) {
			pre[i] = document.createElement( "IMG" );
			pre[i].setAttribute( "src", imgLinks[i].childNodes[0].src.replace( "/thumbs/", "" ) );
			imgLinks[i].onclick = swapImage;
		}
	}
}
// **** initialize the window **** keeps this last ****




