var d=document;

/** if on abo page redirect to SSL **/
var getstr = location.search.toLowerCase();
if (location.protocol.toLowerCase() == 'http:' && (getstr.indexOf('id=abo') > -1 || getstr.indexOf('id=46') > -1)) {
	location = location.href.replace('http:','https:');
} else if(location.protocol.toLowerCase() == 'https:' && getstr.indexOf('id=abo') == -1 && getstr.indexOf('id=46') == -1 ) {
	location = location.href.replace('https:','http:');
}


function show(element){
	element.className += "hover";
}
function hide(element){
	element.className = element.className = "";
}

jQuery().ready(function(){
	if(d.getElementById('aktuell_navi')) {
		jQuery('#aktuell_navi').Accordion({
			active: false,
			header: '.head',
			navigation: true,
			event: 'click',
			autoheight: true ,
			animated: 'bounceslide'
		});
		jQuery('#aktuell_navi').activate('#akt_active');
	}
	if(d.getElementById('abo-block')) {
		jQuery("#abo-block").codaSlider();
		/*$('#abo-block').pager('div.page', {
			navId: 'abo-nav',
			navAttach: 'prepend',
			
			prevText: 'zur&uuml;ck',
			nextText: 'weiter',
			linkText: ['Abo-Typ', 'Pr&auml;mien/Geschenke', 'Kundendaten', 'Lieferung', 'Zahlungsart', 'Bestell-&Uuml;bersicht']
		});*/
		checkform();
		$('#abo-block').click(function() {
			checkform();
		});
		$('#abo-block input').blur(function() {
			checkform();
		});
	}
});



/*****
Last revision: 02.15.2006
steve@slayeroffice.com

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*****/


window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);

var imgs = new Array(), zInterval = null, current=0, pause=false;
var imgs2 = new Array(), current2=0

function so_init() {
	if(!d.getElementById || !d.createElement)return;
	
	css = d.createElement("link");
	css.setAttribute("href","fileadmin/templates/styles/xfade.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);
	
	imgs = d.getElementById("imgplay1").getElementsByTagName("img");
	if (imgs.length > 0) {
		for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
		imgs[0].style.display = "block";
		imgs[0].xOpacity = .99;
	
		if (imgs.length > 0) {
			setTimeout(so_xfade,1000);
		}
	}
	
	imgs2 = d.getElementById("imgplay2").getElementsByTagName("img");
	if (imgs2.length > 0) {
		for(i=1;i<imgs2.length;i++) imgs2[i].xOpacity = 0;
		imgs2[0].style.display = "block";
		imgs2[0].xOpacity = .99;
	
		if (imgs2.length > 0) {
			setTimeout(so_xfade2,500);
		}
	}
}
function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,2500);
	} else {
		setTimeout(so_xfade,150);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}

function so_xfade2() {
	cOpacity2 = imgs2[current2].xOpacity;
	nIndex2 = imgs2[current2+1]?current2+1:0;
	nOpacity2 = imgs2[nIndex2].xOpacity;
	
	cOpacity2-=.05; 
	nOpacity2+=.05;
	
	imgs2[nIndex2].style.display = "block";
	imgs2[current2].xOpacity = cOpacity2;
	imgs2[nIndex2].xOpacity = nOpacity2;
	
	setOpacity2(imgs2[current2]); 
	setOpacity2(imgs2[nIndex2]);
	
	if(cOpacity2<=0) {
		imgs2[current2].style.display = "none";
		current2 = nIndex2;
		setTimeout(so_xfade2,2000);
	} else {
		setTimeout(so_xfade2,50);
	}
	
	function setOpacity2(obj2) {
		if(obj2.xOpacity>.99) {
			obj2.xOpacity = .99;
			return;
		}
		obj2.style.opacity = obj2.xOpacity;
		obj2.style.MozOpacity = obj2.xOpacity;
		obj2.style.filter = "alpha(opacity=" + (obj2.xOpacity*100) + ")";
	}
	
}

function setstartOpacity(obj) {
	obj.style.opacity = .99;
	obj.style.MozOpacity = .99;
	obj.style.filter = "alpha(opacity=99)";
}

