var zumAclick = false;
var weiter = 'http://fotoleinwand-angebote.de/anbieter';
//ANFANG function zeigeFormat(aktivFormat);
function zeigeFormat(aktivFormat){
	var praefix = "anfl";
	var formatPraefix = "format";
	$("#" + praefix + aktivFormat).css("display", "inline");
	$("#" + formatPraefix + aktivFormat).css("background-color", "#ffcc33");
	$("#formate .format").each(function(i, node){
		var n = $(node);
		var format_index = n.attr("id").substring(formatPraefix.length, n.attr("id").length);
		if(format_index !== aktivFormat && $(praefix + format_index).css("display") != "none"){
			$("#" + praefix + format_index).css("display", "none");
			n.css("background-color", "#9FB1C4");
		}
	});
}
//ENDE function zeigeFormat(aktivFormat);
//ANFANG Format-Wechsel
$("#formate .format").each(function(i, node){
	var n = $(node);
	var format_id_pre = 'format';
	$("#" + n.attr('id')).click(function(){
		zeigeFormat(n.attr("id").substring(format_id_pre.length, n.attr("id").length));
	});
});
$(".anfl").each(function(i, node){
	var n = $(node);
	n.find("ol li").each(function(ii, node2){
		var n2 = $(node2);
		var anbieter_id_pre = 'anbieter';
		var anbieter_id = n2.attr("id").substring(anbieter_id_pre.length, n2.attr("id").length);
		n2.click(function(){
			if(!zumAclick){
				bcde(anbieter_id);
				zumAclick = false;
			}
		});
	});
});
//ENDE Format-Wechsel
$(".zumanbieter a").each(function(i, node){
	var n = $(node);
	n.click(function(){
		zumAclick = true;
	});
});
function abcd(where){
	window.open(where.replace(/&amp;/g,"&"), "_blank");
}
function bcde(where){
	window.open(weiter + '?' + where, "_blank");
}
function ztab(num){
	var praefix = 'tabtext';
	var praefix2 = 'tablabel';	$(".multiboxtext li").each(function(i, node){
		var n = $(node);
		if(i === num){
			n.addClass("active");
			n.removeClass("inactive");
		}else{
			n.addClass("inactive");
			n.removeClass("active");
		}
	});
	$(".multiboxtab li").each(function(i, node){
		var n = $(node);
		if(i === num){
			n.addClass("active");
			n.removeClass("inactive");
		}else{
			n.addClass("inactive");
			n.removeClass("active");
		}
	});	
	return true;
}
$(".multiboxtab li").each(function(i, node){
	var n = $(node);
	n.mouseover(function(){
		ztab(i);
	});
});

try{
	zeigeFormat('14');
}catch(e){}$('#navigation ul li.na-f-i-st').hover(
	function(){
		$(this).find('div').css('display','inline-block');
	},
	function(){
		$(this).find('div').css('display','none');
	}
);
//Ende nav
//subids:
$(document).ready(function() {
	$('a').each(function(i, node) {
		var a = $(node);
		if(a.attr('href')){
			var subid = document.location.pathname.replace(/\//g, '_');
			var link_mit_subid = '';
			var trenner = '&';
			var a_html = a.html();
			//Affilinet
			if (a.attr('href').indexOf('partners.webmasterplan.com') != -1
			&& a.attr('href').indexOf('=505512') != -1
			&& a.attr('href').indexOf('subid=') == -1){
				if(a.attr('href').indexOf('diurl=') !== -1){
					var entzwei = a.attr('href').split(trenner + 'diurl=');
					var diurl = (entzwei[1]?entzwei[1]:'');
					link_mit_subid = entzwei[0]
					+ trenner
					+ 'subid='
					+ subid
					+ trenner
					+ 'diurl='
					+ diurl;
				}else{
					link_mit_subid = a.attr('href') + trenner + 'subid=' + subid;
				}
				a.attr('href', link_mit_subid);
				a.html(a_html);
			}
			//Belboon
			else if(a.attr('href').indexOf('www1.belboon.de/adtracking') != -1
			&& a.attr('href').indexOf('seite=') == -1){
				if(a.attr('href').indexOf('deeplink=') !== -1){
					var entzwei = a.attr('href').split(trenner + 'deeplink=');
					var deeplink = (entzwei[1]?entzwei[1]:'');
					link_mit_subid = entzwei[0]
					+ trenner
					+ 'seite='
					+ subid
					+ trenner
					+ 'deeplink='
					+ deeplink;
				}else{
					link_mit_subid = a.attr('href') + '/' + trenner + 'seite=' + subid;
				}
				a.attr('href', link_mit_subid);
				a.html(a_html);
			}
			//Zx
			else if(a.attr('href').indexOf('ad.zanox.com') != -1
			&& a.attr('href').indexOf('zpar0=') == -1){
				link_mit_subid = a.attr('href') + trenner + 'zpar0=' + subid;
				a.attr('href', link_mit_subid);
				a.html(a_html);
			}
		}
	});
});
//Ende subids
//sb_m:
function email_url_encode(text){
	ersatz_tabelle= Array({
		'%' : '%25'
		,' ' : '%20'
		,'Ä' : '%C4'
		,'Ö' : '%D6'
		,'Ü' : '%DC'
		,'ä' : '%E4'
		,'ö' : '%f6'
		,'ü' : '%FC'
		,'\n': '%0A'
		,'-' : '%2D'
		,'ß' : '%DF'
		,'\\?' : '%3F'
		,'!' : '%21'
		,'#' : '%23'
		,':' : '%3A'
		,'\\*' : '%2A'
		,'/' : '%2F'
		,'<' : '%3C'
		,'>' : '%3E'
		,'&' : '%26'
		,'€' : 'EUR'
		,'–' : '-'
	});
	//alert(text);
	$.each(ersatz_tabelle[0], function(key, value){
		text = text.replace(new RegExp( key, "g" ),value);
	});
	return text;
}
var sb_m_title = $('title').html();
var nachricht = email_url_encode('Hallo\n'
+ '\n'
+ 'diese Seite könnte interessant sein: \n'
+ '\n'
+ location.href);
var sb_m_url = location.href;


var sb_m = Array();
var empfaenger = 'wer@wo.de';
sb_m.push({'name' : 'Email-Empfehlung','url' : 'mailto:' + email_url_encode(empfaenger), 'parameters' : new Array( {'subject' :  email_url_encode(sb_m_title), 'body' : nachricht})});

sb_m.push({'name' : 'Facebook', 'url' : 'http://www.facebook.com/sharer.php', 'parameters' : new Array( {'u' : sb_m_url, 't' : sb_m_title})});

sb_m.push({'name' : 'deli.cio.us', 'url' : 'http://del.icio.us/save', 'parameters' : new Array( {'url' : sb_m_url, 'title' : sb_m_title, 'v' : '5', 'noui' : '', 'jump' : 'close'})});
sb_m.push({'name' : 'MySpace', 'url' : 'http://www.myspace.com/index.cfm', 'parameters' : new Array( {'u' : sb_m_url, 't' : sb_m_title, 'fuseaction' : 'postto'})});
sb_m.push({'name' : 'Digg', 'url' : 'http://digg.com/submit', 'parameters' : new Array( {'url' : sb_m_url, 'title' : sb_m_title, 'phase' : '2'})});
sb_m.push({'name' : 'Google Bookmarks', 'url' : 'http://www.google.com/bookmarks/mark', 'parameters' : new Array( {'bkmk' : sb_m_url, 'title' : sb_m_title, 'op' : 'add'})});
sb_m.push({'name' : 'studiVZ meinVZ schülerVZ', 'url' : 'http://www.studivz.net/Suggest/Selection/', 'parameters' : new Array( {'u' : sb_m_url, 'desc' : sb_m_title, 'prov' : 'http://fotoleinwand-angebote.de/'})});


sb_m.push({'name' : 'Mister Wong', 'url' : 'http://www.mister-wong.de/index.php', 'parameters' : new Array( {'bm_url' : sb_m_url, 'bm_description' : sb_m_title, 'action' : 'addurl'})});


sb_m.push({'name' : 'StumbleUpon', 'url' : 'http://www.stumbleupon.com/submit', 'parameters' : new Array( {'url' : sb_m_url, 'title' : sb_m_title})});
sb_m.push({'name' : 'Yahoo Bookmarks', 'url' : 'http://myweb2.search.yahoo.com/myresults/bookmarklet', 'parameters' : new Array( {'u' : sb_m_url, 't' : sb_m_title, 'd' : '', 'tag' : ''})});
sb_m.push({'name' : 'Yigg', 'url' : 'http://www.yigg.de/neu', 'parameters' : new Array( {'exturl' : sb_m_url, 'exttitle' : sb_m_title})});
$('.social .mail img').each(function(i, node){
	if(sb_m[i]){
		get = Array();
		//alert(sb_m[i]['parameters'][0]['u']);
		$.each(sb_m[i]['parameters'][0], function(key, value){
			get[get.length] = key + '=' + value;
		});
		get = '?' + get.join('&');
		$(node).replaceWith('\<a href="' + sb_m[i]['url'] + get + '" rel="nofollow" target ="_blank"><img src="' + $(node).attr('src') + '" alt="' + $(node).attr('alt') + '" title="' + sb_m[i]['name'] + '"><\/a/>');
	}
});
//Ende sb_m:
$('#footer span a[title=Partner]').attr("href","/partner");