// 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);


// 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>');
}





// cmxform
$(document).ready(function() {                
	if(jQuery.browser.mozilla) {
		$('.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);
			$('.cmxform').show();
		});
	};             
});


//$(document).ready(function(){

	//$("div.featurebutton a").hover(function() {
	  //$(this).next("em").animate({opacity: "show", top: "0"}, "slow");
	//}, function() {
	  //$(this).next("em").animate({opacity: "hide", top: "0"}, "fast");
	//});

//});

/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 2;
		yOffset = 2;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});

// collapsible jqery side menu
function initMenu() {
  $('#menu ul').hide();
  $('#menu li a').click(
    function() {
        $(this).next().slideToggle('normal');	
      }
    );
  }
$(document).ready(function() {initMenu();});


// collapsible jqery side menu
//$(document).ready(function(){
	//$("dd").hide();
	//$("dt a").click(function(){
		//$("dd:visible").slideUp("slow");
		//$(this).parent().next().slideDown("slow");
		//if ($(this).parent().next().is(':hidden')) 
		//return false;
	//});
//});

// second simple accordion with special markup
//$(document).ready(function(){
	//jQuery('#navigation').accordion({
		//active: false,
		//header: '.head',
		//navigation: true,
		//event: 'mouseover',
		//fillSpace: false,
		//animated: 'easeslide'
	//});
//});

