$(document).ready(function() {

	$('a.external').click(function(et){
		et.preventDefault();
		window.open($(this).attr('href'));
	});
	
	 slideShow(60000); // Speed
});

function slideShow(speed) {  
     $('ul.visual li').css({opacity: 0.0});   
     $('ul.visual li:first').css({opacity: 1.0});  
          
     var timer = setInterval('gallery()',speed);  
       
     //pause the slideshow on mouse over  
     $('ul.slider').hover(  
         function () {  
             clearInterval(timer);     
         },    
         function () {  
             timer = setInterval('gallery()',speed);           
         }  
     );  
       
 }  
   
function gallery() {  
 	 var OpacitySpeed = 3000; // Speed Opacity
   
     var current = ($('ul.visual li.show')?  $('ul.visual li.show') : $('#ul.visual li:first'));  
    
     var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.visual li:first') :current.next()) : $('ul.visual li:first'));  
     next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, OpacitySpeed);  
     current.animate({opacity: 0.0}, OpacitySpeed).removeClass('show');  
   
}
	
function ToggleMxEmail(Link,Id)
{
	if(Link.checked){
		document.getElementById('mx-email-'+Id).value ='';
		document.getElementById('domain-email-'+Id).value ='';
		$('#domxemail-'+Id).hide();
		$('#domainemail-'+Id).hide();
		$('#syncemail-'+Id).show();
	}
}

function ToggleOneTwoEmail(Link,Id)
{
	if(Link.checked){
		document.getElementById('local-part-'+Id).value ='';
		document.getElementById('domain-email-'+Id).value ='';
		$('#syncemail-'+Id).hide();
		$('#domainemail-'+Id).hide();
		$('#domxemail-'+Id).show();
	}
}

function ToggleDomainEmail(Link,Id)
{
	if(Link.checked){
		document.getElementById('mx-email-'+Id).value ='';
		document.getElementById('local-part-'+Id).value ='';
		$('#syncemail-'+Id).hide();
		$('#domxemail-'+Id).hide();
		$('#domainemail-'+Id).show();
	}
}

function ToggleOwnDomain(Link,Id)
{
	if(Link.checked){
		document.getElementById('kkdomain-'+Id).value ='';
		$('#kk_domain-'+Id).hide();
		$('#own_domain-'+Id).show();
	}
}

function ToggleKkDomain(Link,Id)
{
	if(Link.checked){
		document.getElementById('regdomain-'+Id).value ='';
		$('#own_domain-'+Id).hide();
		$('#kk_domain-'+Id).show();
	}
}

function ToggleData(Link)
{
	if(Link.checked){
		$('#cutstomer-data').hide();
		$('#pass').hide();
		$('#notes').hide();
		$('#cutstomer-login').show();
	} else {
		$('#cutstomer-data').show();
		$('#pass').show();
		$('#notes').show();
		$('#cutstomer-login').hide();
	}
}

/*
	--------------------------------------------------------------------------
	$Id: spamspan.js 5 2007-09-29 15:56:26Z moltar $
	--------------------------------------------------------------------------
	Version: 1.03
	Release date: 13/05/2006
	Last update: 07/01/2007

	(c) 2006 SpamSpan (www.spamspan.com)

	This program is distributed under the terms of the GNU General Public
	Licence version 2, available at http://www.gnu.org/licenses/gpl.txt
	--------------------------------------------------------------------------
*/

var spamSpanMainClass		= 'milk';
var spamSpanUserClass		= 'la';
var spamSpanDomainClass		= 'le';
var spamSpanAnchorTextClass = 'lu';
var spamSpanParams			= new Array('subject', 'body');

/*
	--------------------------------------------------------------------------
	Do not edit past this point unless you know what you are doing.
	--------------------------------------------------------------------------
*/

// load SpamSpan
addEvent(window, 'load', spamSpan);

function spamSpan() {
	var allSpamSpans = getElementsByClass(spamSpanMainClass, document, 'span');
	for (var i = 0; i < allSpamSpans.length; i++) {
		// get data
		var user = getSpanValue(spamSpanUserClass, allSpamSpans[i]);
		var domain = getSpanValue(spamSpanDomainClass, allSpamSpans[i]);
		var anchorText = getSpanValue(spamSpanAnchorTextClass, allSpamSpans[i]);
		// prepare parameter data
		var paramValues = new Array();
		for (var j = 0; j < spamSpanParams.length; j++) {
			var paramSpanValue = getSpanValue(spamSpanParams[j], allSpamSpans[i]);
			if (paramSpanValue) {
				paramValues.push(spamSpanParams[j] + '=' +
					encodeURIComponent(paramSpanValue));
			}
		}
		// create new anchor tag
		var at = String.fromCharCode(32*2);
		var email = cleanSpan(user) + at + cleanSpan(domain);
		var anchorTagText = document.createTextNode(anchorText ? anchorText : email);
		var mto = String.fromCharCode(109,97,105,108,116,111,58);
		var hrefAttr = mto + email;
			hrefAttr += paramValues.length ? '?' + paramValues.join('&') : '';
		var anchorTag = document.createElement('a');
			anchorTag.className = spamSpanMainClass;
			anchorTag.setAttribute('href', hrefAttr);
			anchorTag.appendChild(anchorTagText);
		// replace the span with anchor
		allSpamSpans[i].parentNode.replaceChild(anchorTag, allSpamSpans[i]);
	}
}

function getElementsByClass(searchClass, scope, tag) {
	var classElements = new Array();
	if (scope == null) node = document;
	if (tag == null) tag = '*';
	var els = scope.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (var i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function getSpanValue(searchClass, scope) {
	var span = getElementsByClass(searchClass, scope, 'span');
	if (span[0]) {
		return span[0].firstChild.nodeValue;
	} else {
		return false;
	}
}

function cleanSpan(string) {
	// string = string.replace(//g, '');
	// replace variations of [dot] with .
	string = string.replace(/[\[\(\{]?[dD][oO0][tT][\}\)\]]?/g, '.');
	// replace spaces with nothing
	string = string.replace(/\s+/g, '');
	return string;
}

// http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
function addEvent(obj, type, fn) {
	if (obj.addEventListener)
		obj.addEventListener(type, fn, false);
	else if (obj.attachEvent)
	{
		obj['e' + type + fn] = fn;
		obj[type + fn] = function() { obj['e' + type + fn](window.event); }
		obj.attachEvent('on' + type, obj[type + fn]);
	}
}
