// sfHover
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


 /* slideshow on homepage */ 
//$(document).ready(
//	function(){
//		$('#header div').innerfade({
//			speed: 'slow',
//			timeout: 20000,
//			type: 'random',
//			containerheight: '297px'
//		});
//	}
//);
$(document).ready(
	function(){
		$('.slideshow').cycle({ 
			fx:    'fade', 
			speed:  4000 
		 });
	}
);




// open external link in new tab/window
// use rel="external" instead of target="_blank"
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;




// Hides emails from spam
var user;
var domain;
var suffix;
function ehide(user, domain, suffix){
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '" >' + user + '@' + domain + '.' + suffix + '</a>');
}

// open external link in new tab/window
// use rel="external" instead of target="_blank"
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;

// cmxform
//if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false );
//function cmxform(){
//  // Hide forms
//  $( 'form.cmxform' ).hide().end();  
//  // Processing
//  $( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
//    var labelContent = this.innerHTML;
//    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
//    var labelSpan = document.createElement( 'span' );
//        labelSpan.style.display = 'block';
//        labelSpan.style.width = labelWidth;
//        labelSpan.innerHTML = labelContent;
//    this.style.display = '-moz-inline-box';
//    this.innerHTML = null;
//    this.appendChild( labelSpan );
//  } ).end();  
//  // Show forms
//  $( 'form.cmxform' ).show().end();
//}

$(document).ready(function() {                
	if(jQuery.browser.mozilla) {
		$('form.cmxform').hide().find('label:not(.nocmx)').each(function(){
			var $labelContent = $(this).html();
			var $labelWidth = $(this).css('width');
			$(this).empty();
			$(this).append('<span style="display: block; width: '+$labelWidth+';">');
			$(this).prepend('</span>');
			$(this).css('display', '-moz-inline-box');
			$(this).find('span').html($labelContent);
			$('form.cmxform').show();
		});
	};             
});


