$(document).ready(function(){
	
	$("table").each(function(){ // table striping
		$(this).find("tr:even").addClass("alt");
	});

    $("ul.tabs").tabs("div.panes > div"); // set up jquery tools tabs
	$("dl.faq").tabs("dl.faq dd.pane", {initialIndex: -1, tabs: 'dt', effect: 'slide'}); // set up jquery tools accordion
	
	$('#recipient').sSelect(); // replace mail form with styled select tags

	$("#content a[title]").tooltip({ // set up jquery tools tooltip
								   tip: "#tooltip",
								   position: "top center",
								   offset: [0, -140]
								   }); 

	$('div.slider').masque('.masque,.white'); // set up front page feature box

	$('a.lightbox').lightBox(); // set up lightbox image viewer
	
	$('#tv-loader').fadeTo(15000,0);
	
});

function EmailUnobsfuscate() { 
	var link = document.getElementsByTagName && document.getElementsByTagName("a"); 
	var email, e; 
	for (e = 0; link && e < link.length; e++) { 
		if ((" "+link[e].className+" ").indexOf(" email ") >= 0) { 
			email = link[e].firstChild.nodeValue.toLowerCase() || ""; 
			email = email.replace(/\(dot\)/ig, "."); 
			email = email.replace(/\(at\)/ig, "@"); 
			email = email.replace(/\s/g, ""); 
			if (/^[^@]+@[a-z0-9]+([_\.\-]{0,1}[a-z0-9]+)*([\.]{1}[a-z0-9]+)+$/.test(email)) {
				link[e].href = "mailto:" + email; 
				link[e].firstChild.nodeValue = email; 
			} 
		} 
	} 
}

function frameBuster() {
	if (window!=top){top.location.href=location.href;}
	} 

function externalLinks() {
 if (!document.getElementsByTagName) return false;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "ext")
     anchor.target = "_blank";
	function openPopUp(linkURL) {
		window.open(linkURL,'popup','width=490,height=570,left=150,top=150');
		}
		if (anchor.getAttribute("href") &&
       	anchor.getAttribute("rel") == "popup") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			anchors[i].onclick = function() {	
			openPopUp(this.getAttribute("href"));	
			return false; 	
			} 	
		}
	function openApply08(linkURL) {
		window.open(linkURL,'apply-08','width=630,height=350,left=150,top=150');
		}
		if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "apply-08") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			anchors[i].onclick = function() {	
			openApply08(this.getAttribute("href"));	
			return false; 	
			} 	
		}
	}
}

$(function(){

	EmailUnobsfuscate();
	frameBuster();
	externalLinks();

});

// initialize scrollable together with the circular plugin
$("#headlineBox").scrollable({size: 1, easing: "linear", speed: "normal"}).circular().autoscroll({autoplay: true, autopause: true, interval: 6000}).mousewheel();

jQuery.fn.masque = function(classe) {
$(this).hover(function(){
	$(this).find(classe).stop().animate({height:'110px'},300);
	},function () { 
	$(this).find(classe).stop().animate({height:'15px'}, 300);
	});
}

