$(function() {
	// investors
	$('.logos a').attr('target','_blank');
	// catalog
	$('.catalog td a').attr('target','_blank');
	// general
	$('.external').attr('target','_blank');

	// Graceful E-Mail Obfuscation
	$("a[href*='contact/']").each(function() {
		var href = this.href;
		var address = this.href.replace(/.*contact\/([a-z0-9._%-]+)\/?([a-z0-9._%-]*)/i, '$1' + '@axela.com');
		if (href != address) {
			var title = address;
			var subject = href.replace(/.*contact\/([a-z0-9._%-]+)\/?([a-z0-9._%-]*)/i, '$2');
			if (subject) address += '?subject=' + subject;
			$(this).attr('href', 'mailto:' + address).attr('title', title).text(title);
		}
	});

});


/*
* immediateSiblings 1.0.0 (2008-07-14)
*
* Copyright (c) 2006,2007 Jonathan Sharp (http://jdsharp.us)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://jdsharp.us/
*
* Built upon jQuery 1.2.6 (http://jquery.com)
*/
$.fn.immediateSiblings = function(selector) {
var siblings = [];
if ( this.length > 0 ) {
this.each(function() {
var elm = $(this);
while ( elm.prev().is( selector ) ) {
elm = elm.prev();
siblings.unshift( elm[0] );
}
siblings.push( this );
var elm = $(this);
while ( elm.next().is( selector ) ) {
elm = elm.next();
siblings.push( elm[0] );
}
});
}
return this.pushStack( $.unique( siblings ) );
};

function createCookie(name,value,hours) {
	if (hours) {
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return '';
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

