var onloadHooks = [];


        function encode_utf8(rohtext) {
             // dient der Normalisierung des Zeilenumbruchs
            rohtext = rohtext.replace(/\r\n/g,"\n");
             var utftext = "";
             for(var n=0; n<rohtext.length; n++)
                 {
                // ermitteln des Unicodes des  aktuellen Zeichens
               var c=rohtext.charCodeAt(n);
                // alle Zeichen von 0-127 => 1byte
                 if (c<128)
                   utftext += String.fromCharCode(c);
                 // alle Zeichen von 127 bis 2047 => 2byte
                 else if((c>127) && (c<2048)) {
                    utftext += String.fromCharCode((c>>6)|192);
                     utftext += String.fromCharCode((c&63)|128);}
                // alle Zeichen von 2048 bis 66536 => 3byte
                 else {
                     utftext += String.fromCharCode((c>>12)|224);
                     utftext += String.fromCharCode(((c>>6)&63)|128);
                    utftext += String.fromCharCode((c&63)|128);}
                }
                return utftext;
         }

temptitel = document.title.substring(8, document.title.length);
temptitel = encode_utf8(temptitel);
flashtitel = temptitel.replace("&", '#');



function printVersion(target)
{
	if (target == "danke")
	{
		window.open('/printVersionDanke.php','printVersion','menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
	}
	else
	{
		window.open('/printVersion.php','printVersion','menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
	}
}

function printVersionSFA()
{
	window.open('/printVersionSFA.php','printVersion','menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
}

function printVersionAids()
{
	window.open('/printVersion.php?target=aids','printVersion','menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
}


// imgGallery
var tempo = 10;
var aktiv;
var direction;
var mLeft=0;
var active;
var countPics;
var thumbWidth = 560; // Breite der angezeigten Thumbs bzw des sichtbaren Teil des DIVs
var maxWidth = 611; // Max Breite der Bilder


function scrollGallery(direction){
	aktiv = window.setInterval("move('"+direction+"')", tempo);
}

function stopGallery(){
	window.clearInterval(aktiv);
}



function move(direction){
	var width = document.getElementById("imgGalleryNavi").offsetWidth;
	if (direction == "left"){
		mLeft = mLeft+5;
	}
	else{
		mLeft = mLeft-5;
	}
	maxScroll = (document.getElementById("countPics").value - thumbWidth) * (-1);

	if (direction == "left" && mLeft > 0){
		window.clearInterval(aktiv);
	}
	else if (direction == "right" && mLeft < maxScroll){
		window.clearInterval(aktiv);
	}
	else{
		document.getElementById("imgGalleryNavi").style.marginLeft = mLeft+"px";
	}
}


function showPic(id){
	if (document.getElementById(id)){
		if (active != null){
			disappear(active);
		}
		if (formActive != null){
			document.getElementById(formActive).style.display = "none";
			formActive = null;
		}
		
		document.getElementById(id).style.width = 0;
		document.getElementById(id).style.display = "block";
		appear(id);
		active = id;
	}
}

function bigPic(id){
	if(document.getElementById(id)){
		if (bigActive != null){
				disappear(bigActive);
				bigActive = null;
		}
		else if (bigActive == id){
				document.getElementById(id).style.display = "none";
				bigActive = null;
		}
		else{
			document.getElementById(id).style.display = "block";
			bigActive = id;
		}
		document.getElementById(id).style.display = "block";
	}
}

function searchMom(id){
	if(document.getElementById(id)){
		if (sucheActive != null){
				document.getElementById(id).style.display = "none";
				sucheActive = null;
		}
		else if (sucheActive == id){
				document.getElementById(id).style.display = "none";
				sucheActive = null;
		}
		else{
			document.getElementById(id).style.display = "block";
			sucheActive = id;
		}
	}
}

function disappear(id){
	document.getElementById(id).style.display = "none";	
}

var aPic=0;
function appear(id){
	aPic = aPic + 30;
	document.getElementById(id).style.width = aPic+"px";	
	if(aPic < maxWidth){
		setTimeout("appear('"+id+"')",1);
	}
	else{
		aPic=0;
	}
	//document.getElementById(id).style.width = "611px";
}

function close_big(id)
{	
	if(document.getElementById(id))
	{
		document.getElementById(id).style.display = "none";
	}
}


var sucheActive;
var bigActive;
var formActive;


function sendPic(id){
	if(document.getElementById(id)){
		if (formActive != null){
				document.getElementById(id).style.display = "none";
				formActive = null;
		}
		else if (formActive == id){
				document.getElementById(id).style.display = "none";
				formActive = null;
		}
		else{
			document.getElementById(id).style.display = "block";
			formActive = id;
		}
	}
}


window.onload = function(){
	for(i = 0; i < onloadHooks.length; i++)	{
		onloadHooks[i]();
	}
	
	if (document.getElementById("firstGalleryPic")){
		showPic(document.getElementById("firstGalleryPic").value);
	}
}


var xmlobject = createRequestObject();
var response = null;
var i = 0;
var imgfehler = false
var ref;

function sendECard(form){
	simage = document.getElementById(form).getElementsByTagName("form")[0].elements[0].value;
	name = document.getElementById(form).getElementsByTagName("form")[0].elements[1].value;
	empfaenger = document.getElementById(form).getElementsByTagName("form")[0].elements[2].value;
	email = document.getElementById(form).getElementsByTagName("form")[0].elements[3].value;
	
	
	ref = document.getElementById("ref").value;

	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (name == ""){
		alert("Bitte geben Sie einen Namen ein!");
		imgfehler = true;
	}
	else if (empfaenger == ""){
		alert("Bitte geben Sie einen Empfänger ein!");
		imgfehler = true;
	}
	else if (filter.test(email) != true){
		alert("Die eingegebene E-Mail Adresse ist ungültig!");
		imgfehler = true;
	}
	else
	{
		imgfehler = false;
	}
	if(imgfehler != true){
		xmlobject.open('GET', '/fileadmin/scripts/ecard.php?name='+escape(name)+'&empfaenger='+escape(empfaenger)+'&img='+escape(simage)+'&email='+escape(email)+'&ref='+escape(ref), true);
		xmlobject.onreadystatechange = handleResponse;
		xmlobject.send(null);
		sendPic(form);
		thankYouDiv();
	}
}
function sendPicture(form){
	simage = document.getElementById(form).getElementsByTagName("form")[0].elements[0].value;
	name = document.getElementById(form).getElementsByTagName("form")[0].elements[1].value;
	empfaenger = document.getElementById(form).getElementsByTagName("form")[0].elements[2].value;
	email = document.getElementById(form).getElementsByTagName("form")[0].elements[3].value;
	dbuid = document.getElementById(form).getElementsByTagName("form")[0].elements[4].value;
	nachricht = document.getElementById(form).getElementsByTagName("form")[0].elements[5].value;
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (name == ""){
		alert("Bitte geben Sie einen Namen ein!");
		imgfehler = true;
	}
	else if (empfaenger == ""){
		alert("Bitte geben Sie einen Empfänger ein!");
		imgfehler = true;
	}
	else if (filter.test(email) != true){
		alert("Die eingegebene E-Mail Adresse ist ungültig!");
		imgfehler = true;
	}
	else
	{
		imgfehler = false;
	}
	if(imgfehler != true){
		xmlobject.open('GET', '/fileadmin/scripts/muetter_aids_fwd.php?name='+escape(name)+'&empfaenger='+escape(empfaenger)+'&img='+escape(simage)+'&email='+escape(email)+'&dbuid='+escape(dbuid)+'&nachricht='+escape(nachricht), true);
		xmlobject.onreadystatechange = handleResponse;
		xmlobject.send(null);
		sendPic(form);
		thankYouDiv();
	}
}

function sucheMutter(){
	grossmuttersuche = document.getElementById("grossmuttersuche").value;
	
	if (grossmuttersuche == ""){
		alert("Bitte geben Sie einen Namen ein!");
		imgfehler = true;
	}
	else
	{
		document.getElementById("form_suche").submit();

	}
}


var thankYou;
function thankYouDiv(){
	if (document.getElementById("thankYou")){
		if (thankYou != null){
			document.getElementById("thankYou").style.display = "none";
			thankYou = null;
		}
		else{
			document.getElementById("thankYou").style.display = "block";
			thankYou = true;
		}
	}
}

function handleResponse(form) {
    if(xmlobject.readyState == 4){
		response = xmlobject.responseText;	
   }
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

function mitMachen()
{
	window.location = "grossmuetter.html";
}

function spenden()
{
	window.location = "einzelspende.html";
}


function updateAction()
{
	if(document.getElementById('se_eins_select').value == "Einmalig"){
		document.getElementById('se_eins_form_id').action = "https://www.unicef.de/bankeinzug.html";
	}else{
		document.getElementById('se_eins_form_id').action = "https://www.unicef.de/foerdermitglied-klassisch.html";
	}
}





// -------------DRAG--------N---------DROP-------------------------------------- 



var Drag = {

    obj : null,

    init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
    {
        o.onmousedown    = Drag.start;

        o.hmode            = bSwapHorzRef ? false : true ;
        o.vmode            = bSwapVertRef ? false : true ;

        o.root = oRoot && oRoot != null ? oRoot : o ;

        if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
        if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
        if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
        if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

        o.minX    = typeof minX != 'undefined' ? minX : null;
        o.minY    = typeof minY != 'undefined' ? minY : null;
        o.maxX    = typeof maxX != 'undefined' ? maxX : null;
        o.maxY    = typeof maxY != 'undefined' ? maxY : null;

        o.xMapper = fXMapper ? fXMapper : null;
        o.yMapper = fYMapper ? fYMapper : null;

        o.root.onDragStart    = new Function();
        o.root.onDragEnd    = new Function();
        o.root.onDrag        = new Function();
    },

    start : function(e)
    {
        var o = Drag.obj = this;
        e = Drag.fixE(e);
        var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
        o.root.onDragStart(x, y);

        o.lastMouseX    = e.clientX;
        o.lastMouseY    = e.clientY;

        if (o.hmode) {
            if (o.minX != null)    o.minMouseX    = e.clientX - x + o.minX;
            if (o.maxX != null)    o.maxMouseX    = o.minMouseX + o.maxX - o.minX;
        } else {
            if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
            if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
        }

        if (o.vmode) {
            if (o.minY != null)    o.minMouseY    = e.clientY - y + o.minY;
            if (o.maxY != null)    o.maxMouseY    = o.minMouseY + o.maxY - o.minY;
        } else {
            if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
            if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
        }

        document.onmousemove    = Drag.drag;
        document.onmouseup        = Drag.end;

        return false;
    },

    drag : function(e)
    {
        e = Drag.fixE(e);
        var o = Drag.obj;

        var ey    = e.clientY;
        var ex    = e.clientX;
        var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
        var nx, ny;

        if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
        if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
        if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
        if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

        nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
        ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

        if (o.xMapper)        nx = o.xMapper(y)
        else if (o.yMapper)    ny = o.yMapper(x)

        Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
        Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
        Drag.obj.lastMouseX    = ex;
        Drag.obj.lastMouseY    = ey;

        Drag.obj.root.onDrag(nx, ny);
        return false;
    },

    end : function()
    {
        document.onmousemove = null;
        document.onmouseup   = null;
        Drag.obj.root.onDragEnd(    parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
                                    parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
        Drag.obj = null;
    },

    fixE : function(e)
    {
        if (typeof e == 'undefined') e = window.event;
        if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
        if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
        return e;
    }
};

function blurLink(el)
{
	el.blur();
}


// Newsradar
function doit_unicef()
		{
		
		var footer = "<table cellpadding='0' cellspacing='0' border='0' width='350'><tr><td bgcolor='#C0C0C0'> </td></tr><tr><td><br><font face='Verdana' size='2'>Diese Presseschau wird erstellt mit <strong>Newsradar publishing</strong> von pressrelations.<br>Weitere Infos unter <a href='http://www.newsradar.de' target='_blank'>http://www.newsradar.de</a></font></td></tr><tr><td align='right'><img src='http://www.newsradar.de/pics/logo_final.gif' width='220' height='78'  border='0'></td></tr></table>";

		document.writeln(header);
		document.writeln("<TABLE BORDER='0' bgcolor="+bgcolor+" CELLPADDING='0' CELLSPACING='0' WIDTH="+pagewidth+">");
		document.writeln("<TR BGCOLOR=#"+toptext_bgcolor+"><TD>");
		document.writeln("<font color="+toptext_fgcolor+" face="+toptext_font+" size="+toptext_font_size+"'>");
		document.writeln("<B>"+toptext+"</B></font></td></TR>");
		document.writeln("<tr><td><img height="+topspacing+" width='1' src='http://www.pressrelations.de/pics/spacer.gif'></td></tr>");
		// Starte loop
		for (var i=0; i < nc; i++)
		    {
		    
		    	noshow = false;
		    	notest1 = -1;
		    	notest2 = -1;
		    	
		    	
		    	if (pis[i].headline_text.search(/NPD/)!=-1) noshow++;
		    	if (pis[i].text.search(/NPD/)!=-1) noshow++;
		    	if (pis[i].headline_text.search(/Scientology/)!=-1) noshow++;
		    	if (pis[i].text.search(/Scientology/)!=-1) noshow++;
		    	
		    	//console.log(notest1);
		    	
		    	if (noshow!=false)
		    	{
		    		noshow = true; 
		    	}
		    
		    if (noshow!=true){
			document.writeln("<TR BGCOLOR=#"+datumherkunft_bgcolor+">");
			// Print datum
			if (datum_display == "Yes")
			    {
				if (uhrzeit_display == "Yes"){
					document.writeln("<td><font color="+datum_fgcolor+" face="+datum_font+" size="+datum_font_size+"'>"+datum_type+pis[i].datum+" "+pis[i].uhrzeit+datum_type_endtag+"</font><img height='1' width='20' src='http://www.pressrelations.de/pics/spacer.gif'><font color="+herkunft_fgcolor+" face="+herkunft_font+" size="+herkunft_font_size+"'>"+herkunft_type+pis[i].herkunft+herkunft_type_endtag+"</font></td>");
				}
				else {
					document.writeln("<td><font color="+datum_fgcolor+" face="+datum_font+" size="+datum_font_size+"'>"+datum_type+pis[i].datum+datum_type_endtag+"</font><img height='1' width='20' src='http://www.pressrelations.de/pics/spacer.gif'><font color="+herkunft_fgcolor+" face="+herkunft_font+" size="+herkunft_font_size+"'>"+herkunft_type+pis[i].herkunft+herkunft_type_endtag+"</font></td>");
				}
			    }	
			else
				{	
				document.writeln("<td><font color="+herkunft_fgcolor+" face="+herkunft_font+" size="+herkunft_font_size+"'>"+herkunft_type+pis[i].herkunft+herkunft_type_endtag+"<font></td>");			
				}			
			document.writeln("</TR>");
			// Print headline_text
			document.writeln("<TR><TD BGCOLOR=#"+headline_bgcolor+">");
			document.writeln("<A HREF="+pis[i].url+" TARGET=_blank><font color="+headline_fgcolor+" face="+headline_font+" size="+headline_font_size+"'>");
			document.writeln(headline_type+pis[i].headline_text+headline_type_endtag+"</font></A><br>");
			document.writeln("</TD></TR>");
			// Print text abstract
			if (text_display == "Yes"){
				document.writeln("<TR><TD><img height='10' width='1' src='http://www.pressrelations.de/pics/spacer.gif'></td></tr>");
				document.writeln("<TR><TD BGCOLOR=#"+text_bgcolor+">");
				document.writeln("<font color="+text_fgcolor+" face="+text_font+" size="+text_font_size+"'>");
				document.writeln(text_type+pis[i].text+text_type_endtag+"</font><br>");
				document.writeln("</TD></TR>");
				document.writeln("<TR><TD><br><hr width='90%' noshade size='1'></td></tr>");
			}
			document.writeln("<TR><TD><img height="+newsspacing+" width='1' src='http://www.pressrelations.de/pics/spacer.gif'></td></tr>");
			
			}
		    }
		// End loop
		document.writeln("</TABLE>");
		document.writeln(footer);
	    }

