// JavaScript Document

// load default actions
addLoadEvent(blurLinks);
addLoadEvent(EmailUnobsfuscate);


///////////////////////////////////////////////////////////////////

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}



//----------------------------------------------------------------------------------+
// remove all focus lines from links when clicked
//----------------------------------------------------------------------------------+
function blurLinks() {
	var links = document.getElementsByTagName('a');
	for (i=0;i<links.length;i++) {
		links[i].onfocus = function() {
			this.blur();
		}
	}
}



//----------------------------------------------------------------------------------+
// anti-robot email formatting
//----------------------------------------------------------------------------------+
function EmailUnobsfuscate() {
	
	// find all links in HTML
	var link = document.getElementsByTagName && document.getElementsByTagName("a");
	var email, e;
	
	// examine all links
	for (e = 0; link && e < link.length; e++) {
	
		// does the link have use a class named "email"
		if ((" "+link[e].className+" ").indexOf(" email ") >= 0) {
		
			// get the obfuscated email address
			email = link[e].firstChild.nodeValue.toLowerCase() || "";
			
			// transform into real email address
			email = email.replace(/dot/ig, ".");
			email = email.replace(/\(at\)/ig, "@");
			email = email.replace(/\s/g, "");
			
			// is email valid?
			if (/^[^@]+@[a-z0-9]+([_\.\-]{0,1}[a-z0-9]+)*([\.]{1}[a-z0-9]+)+$/.test(email)) {
				// change into a real mailto link
				link[e].href = "mailto:" + email;
				link[e].firstChild.nodeValue = email;
			}
			
		}
	}
}



function embedVideo(id, videoFile, iWidth, iHeight, boolAutoplay, splashImg) {
	
		
	new flashembed(id, { 
		src: "../assets/video/FlowPlayerLight.swf", width: iWidth, height: iHeight, wmode: 'transparent' }, {
			config: {
				autoPlay: boolAutoplay,
				autoRewind: true,
				showStopButton: true, 
				showScrubber: true, 
				showVolumeSlider: false,
				showMuteVolumeButton: false, 
				showFullScreenButton: false, 
				showMenu: false, 
				controlsOverVideo: 'ease',
				controlBarBackgroundColor: -1,
				backgroundColor: -1,
				controlBarGloss: 'high',
				bufferLength:55,
				timeDisplayFontColor:0x1c6c91,
				startingBufferLength:25,
				bufferingAnimationColor:0x1c6c91,
				initialScale: 'scale',
				videoFile: videoFile,
				splashImageFile: splashImg,
				loop:false
			}
		}
	);
}



