$(document).ready(function() {
	var in_suche = 'Suche...';
	$('#qf').focus(function() { $(this).removeClass('error'); if (this.value==in_suche) this.value='' })
	$('#qf').blur(function() { if (this.value=='') this.value=in_suche })
	$('form#form_forum').submit(function() {
		if ($('#qf').val() == in_suche) { $('#qf').addClass('error'); $('input.submit').blur(); return false; }
	})
	var e = $('div.nonverblaster');
	if (e.length > 0) {
		$('div.nonverblaster').flash({
			swf: '/img/swf/NonverBlaster.swf',
			width: $('div.nonverblaster > a > img').attr('width'),
			height: $('div.nonverblaster > a > img').attr('height'),
			flashvars: {
				mediaURL: $('div.nonverblaster > a').attr('href'),
				mediaURL: $('div.nonverblaster > a').attr('href'),
				teaserURL: $('div.nonverblaster > a > img').attr('src')
	
			}
		})
	}
	//living-pso
	var aktiv = false;
	$('div#living-pso p').hide();
	$('div#living-pso p').css('opacity',0);
	$('div#living-pso p').prepend('<small><a href="#">x</a></small>');
	$('div#living-pso p').prepend('<img src="/img/living-pso/pfeil.gif" class="pfeil">');
	$('div#living-pso p').each(function() {
		var myclass = $(this).attr('class') != undefined ? ' class="'+$(this).attr('class')+'"' : false;
		$(this).before('<span'+myclass+' style="margin-top:'+$(this).css('margin-top')+';margin-left:'+$(this).css('margin-left')+'"></span>');
		var x = parseInt($(this).css('margin-left').replace('px','')); x += 17; $(this).css('margin-left',x+'px');
		var y = parseInt($(this).css('margin-top').replace('px','')); y -= 20; $(this).css('margin-top',y+'px');
	});
	$('div#living-pso span').hover(function() {
		$(this).css('cursor','pointer');
	})
	$('div#living-pso span').live('click',function() {
		if (aktiv != false && aktiv != $(this).next()) { ausblenden($(aktiv)); }
		$(this).next().show();
		$(this).next().animate({opacity:1},200);
		aktiv = $(this).next();
	});
	$('div#living-pso img.deutschland').click(function() {
		if (aktiv != false) { ausblenden($(aktiv)); }
	});
	
	$('div#living-pso small').live('click',function() {
		$(this).blur();
		ausblenden($(this).parent()); return false;
	});
	function ausblenden(e) {
		e.animate({opacity:0},300,function() {e.hide()});
	}
	$('select#produktioner_firmenrubrik').change(function() {
		$.ajax({type: 'GET',url:'/content/produktioner/suche_firmenrubrik.php',data:'firmenrubrik='+$(this).val()+'&q=ajax',success:function(msg) {$('div#dyndiv_leistung').html(msg);}})
	})
	//living-pso end
	if ($('table.benchmark a.norm').length > 0 || $('form#benchmark_edit').length > 0) {
		$('body').append('<div id="benchmark_norm_tooltip"></div>');
		var tooltip = $('div#benchmark_norm_tooltip');
		$('table.benchmark a.norm, label.norm').mouseover(function() {
			tooltip.show();
			tooltip.html($(this).attr('alt'));
			$(document).mousemove(function(e){
				var l = e.pageX-10;
				var t = e.pageY-30;
				tooltip.css({left:l+'px',top:t+'px'});
				
			})
		});
		$('table.benchmark a.norm, label.norm').mouseout(function() {
			tooltip.hide();
		});
	}
	$('p.benchmark input[type=checkbox]').each(function() {
		var id = $(this).attr('id');
		if ($(this).is(':checked')) {
			$('span#upload_'+id).hide();
		}
		else {
			$(this).next().next().hide();
		}
	});
	$('p.benchmark input[type=checkbox]').click(function() {
		var id = $(this).attr('id');
		if ($(this).is(':checked')) {
			$(this).next().next().show();
		}
		else {
			$('span#gesichert_'+id).hide();
			$('span#upload_'+id).hide();
		}
	});
	$('a.zertifikat_auswaehlen').click(function() {
		$(this).parent().hide();
		$(this).parent().next().show();
		return false;
	})
	$('input.benchmark_gueltig').focus(function() { if (this.value=='gültig bis') this.value='' })
	$('input.benchmark_gueltig').blur(function() { if (this.value=='') this.value='gültig bis' })
	$('strong#benchmark_strong_suche').after('<a href="#" id="benchmark_suche_close" style="float:right;text-decoration:none">x</a>');
	$('div#div_benchmark_suche').before('<p id="benchmark_suche_show" style="float:right"><a href="#" class="navi">Suche...</a></p>');
	$('p#benchmark_suche_show').click(function() {
		$(this).hide();
		$('div#div_benchmark_suche').slideDown();
		return false;
	});
	$('a#benchmark_suche_close').click(function() {
		$('div#div_benchmark_suche').slideUp('fast',function() { $('p#benchmark_suche_show').show(); });
		/*$('div#div_benchmark_suche form input').each(function() {
			if ($(this).attr('type') == 'text') {
				$(this).val('');
			}
			else if ($(this).attr('type') == 'checkbox') {
				$(this).attr('checked',false);
			}
		});*/
		return false;
	});
	if ($('div#div_benchmark_suche').length==1 && $('div#div_benchmark_suche').attr('style') != 'visible') {
		$('div#div_benchmark_suche').hide();
	}
	else {
		$('p#benchmark_suche_show').hide();
	}
})

document.onmousemove = getMousePosition;

var mouse_x_pos = 0;
var mouse_y_pos = 0;
function getMousePosition(e) {
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		mouse_x_pos = e.pageX;
		mouse_y_pos = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		mouse_x_pos = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		mouse_y_pos = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
}
var sel_bid = false;
function display_benchmark_detail(id) {
	if (sel_bid != false) {
		document.getElementById(sel_bid).style.display = 'none';
	}
	var xpos; var ypos;
	if (id == 'benchmark_info') {
		xpos=10; ypos=-80;
	}
	else {
		xpos=50; ypos=-70;
	}
	document.getElementById(id).style.left = mouse_x_pos+xpos;
	document.getElementById(id).style.top = mouse_y_pos+ypos;
	document.getElementById(id).style.display = 'block';
	sel_bid = id;
}

function tranq(f,u) {
	m = new Array("&#105;","&#116;","&#111;","&#109;","&#97;","&#108;");
	document.write("<a href="+m[3]+m[4]+m[0]+m[5]+m[1]+m[2]+"&#58;"+u+"&#64;"+f+">");
	document.write(u+"&#64;"+f+"</a>");
}

function win(url,name,feat) {
	name=window.open(url,name,feat);
}

function setcookie(name,value,days) {
	var date = new Date();
	date.setTime(date.getTime()+(days*24*60*60*1000))
	var expires = "; expires="+date.toGMTString();
	document.cookie = name+"="+value+expires+"; path=/";
}
function readcookie(name) {
	var tmp_arr = document.cookie.split(';');
	var value = false;
	for(i=0;i<tmp_arr.length;i++) {
		tmp_arr_c = tmp_arr[i].split('=');
		if (tmp_arr_c[0].indexOf(name) != -1) {
			value = tmp_arr_c[1];
			break;
		}
	}
	return value;
}


var MM_contentVersion = 5;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
function flash_obj(ver,src,id,wmode,flashvars,bgcolor,w,h,img_src,img_alt,img_url) {
	var out='';
	if (MM_FlashCanPlay) {
		out = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+',0,0,0" width="'+w+'" height="'+h+'" id="'+id+'">';
		out += '<param name="movie" value="'+src+'">';
		out += '<param name="quality" value="high">';
		out += '<param name="wmode" value="'+wmode+'">';
		out += '<param name="flashvars" value="'+flashvars+'">';
		out += '<param name="bgcolor" value="'+bgcolor+'">';
		out += '<embed src="'+src+'" wmode="'+wmode+'" flashvars="'+flashvars+'" quality="high" bgcolor="'+bgcolor+'" width="'+w+'" height="'+h+'" name="'+id+'" id="'+id+'" type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed>';
		out += '</object>';
	}
	else if (img_src) {
		out = '<a href="'+img_url+'"><img src="'+img_src+'" width="'+w+'" height="'+h+'" alt="'+img_alt+'" /></a>';
	}
	document.write(out);
}
function display_element(id) {
	e = document.getElementById(id);
	if (e.style.display == 'none') { e.style.display = 'block'; }
	else { e.style.display = 'none'; }
}

var display_element_switch_sel = false;
function display_element_switch(id) {
	if (display_element_switch_sel != false) {
		document.getElementById(display_element_switch_sel).style.display = 'none';
	}
	document.getElementById(id).style.display = 'block';
	display_element_switch_sel = id;
}
function insert_code(feld,tag1,tag2) {
	var input = document.getElementById(feld);
	input.focus();
	if (typeof document.selection != 'undefined') {
		var range = document.selection.createRange();
		var insText = range.text;
		range.text = tag1 + insText + tag2;
		range = document.selection.createRange();
		if (insText.length == 0) { range.move('character', -tag2.length); }
		else { range.moveStart('character', tag1.length + insText.length + tag2.length); }
		range.select();
	}
	else if (typeof input.selectionStart != 'undefined') {
		var start = input.selectionStart;
		var end = input.selectionEnd;
		var insText = input.value.substring(start, end);
		input.value = input.value.substr(0, start) + tag1 + insText + tag2 + input.value.substr(end);
		var pos;
		if (insText.length == 0) { pos = start + tag1.length; }
		else { pos = start + tag1.length + insText.length + tag2.length; }
		input.selectionStart = pos;
		input.selectionEnd = pos;
	}
	else {
		var pos;
		var re = new RegExp('^[0-9]{0,3}$');
		while (!re.test(pos)) { pos = prompt("Einf�gen an Position (0.." + input.value.length + "):", "0"); }
		if (pos > input.value.length) { pos = input.value.length; }
		var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
		input.value = input.value.substr(0, pos) + tag1 + insText + tag2 + input.value.substr(pos);
	}
}
function benchmark_bewerbung() {
	var txt_body = 'Bitte%20schicken%20Sie%20mir%20die%20Bewerbungsunterlagen%20zur%20Aufnahme%0Ain%20Ihrem%20Benchmark%20%22Nachhaltige%20Medienproduktion%22%20an%20folgende%20Adresse%3A';
	window.location.href='mailto:benchmark_tmp_080424@f-mp.de?subject=Bewerbung%20Benchmark&body='+txt_body;
}
function checkall(form) { var e = document.getElementById(form); for (var x=0; x<e.elements.length; x++) { var y=e.elements[x]; if (y.name != 'all') { y.checked=e.all.checked; } } }

