﻿function del_checkFTT(myid, FTTname)
{
	var checkOut;

	checkOut=confirm ("Wollen Sie den Freitext Teaser '" + FTTname + "' wirklich löschen?");
	if (checkOut==true)
		{
			document.delFttForm.todel.value = myid;
			document.delFttForm.submit();
		}

}

function activateradio(wert)
{
	document.getElementById('activate_radio_value').value = wert;
	showSaveBT();
}

function searchradio(wert)
{
	document.getElementById('search_radio_value').value = wert;
	showSaveBT();
}

function commentradio(wert)
{
	document.getElementById('comment_radio_value').value = wert;
	showSaveBT();
}

function rssradio(wert)
{
	document.getElementById('rss_radio_value').value = wert;
	showSaveBT();
}


function rahmen_an(wert, artikel)
{
	document.getElementById(wert).style.backgroundColor = '#8A1313';
	document.getElementById('artikel_output').style.backgroundColor = '#FFFFFF';
	document.getElementById('artikel_output').innerHTML = artikel;
}

function rahmen_aus(wert)
{
	document.getElementById(wert).style.backgroundColor = '';
	document.getElementById('artikel_output').innerHTML = '&nbsp;';
	document.getElementById('artikel_output').style.backgroundColor = '';
}

function upload_pic(myc, u_size)
{
	document.getElementById('upload_size_' + myc).value = u_size;
}

function showSaveBT()
{
	document.getElementById('uploadBT').style.visibility = 'visible';
}

function SetCharCounter(ctrlSource,ctrlDisplay,Limit)
{
	if (document.getElementById('uploadBT').style.visibility == 'hidden')
		document.getElementById('uploadBT').style.visibility = 'visible';
	
    if (ctrlSource.value.length <= Limit)
    {
		ausgabe = Limit - ctrlSource.value.length;
		ctrlDisplay = document.getElementById(ctrlDisplay);
		ctrlDisplay.innerHTML = 'noch ' + ausgabe + ' Zeichen';
	}
}

function chkTextarea(ctrlSource,Limit)
{
	if (ctrlSource.value.length > Limit)
    {
		ctrlSource.value = ctrlSource.value.substring(0, Limit);
	}
}

function del_check(bild, bildsize)
{
	var checkOut;

	checkOut=confirm ("Wollen Sie das Bild für die Größe " + bildsize + " wirklich löschen?");
	if (checkOut==true)
		{
			document.DelForm.delete_picture.value = bild;
			document.DelForm.submit();
		}

}


var bild_popup_fenster;
function closeBildWindow()
{
	if (bild_popup_fenster && !bild_popup_fenster.closed)
	{
		bild_popup_fenster.close();
	}
}

function showBild(bild, bildsize)
{
	var mysizes = bildsize.split('x');
	var mywidth = mysizes[0];
	var myheight= mysizes[1];
	if (myheight == '?')
		myheight = 350;
	mywidth = parseInt(mywidth) + 100;
	myheight = parseInt(myheight) + 150;	
	var myleft = window.screenX + 780 + 3;
	if (window.screenX == undefined)
		myleft = window.screenLeft + 780 + 3;
	var mytop = window.screenY;
	if (window.screenY == undefined)
		mytop = window.screenTop - 20;

	var Fensteroptionen = "toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=0,";
	var CurTopic = "/?menu=bildvorschau&BildID=" + bild;
	var WinPos = "width=" + mywidth + ", height=" + myheight + ", left=" + myleft + ", top=" + mytop; 
	
	bild_popup_fenster = window.open(CurTopic , "BilderVorschau", Fensteroptionen + WinPos);
}

function showBild2(bild, bildsize, thissite)
{
	var mysizes = bildsize.split('x');
	var mywidth = mysizes[0];
	var myheight= mysizes[1];
	if (myheight == '?')
		myheight = 350;
	mywidth = parseInt(mywidth) + 100;
	myheight = parseInt(myheight) + 150;	
	var myleft = window.screenX + 780 + 3;
	if (window.screenX == undefined)
		myleft = window.screenLeft + 780 + 3;
	var mytop = window.screenY;
	if (window.screenY == undefined)
		mytop = window.screenTop - 20;

	var Fensteroptionen = "toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=0,";
	var CurTopic = "/?menu=bildvorschau&BildID=" + bild + "&site=" + thissite;
	var WinPos = "width=" + mywidth + ", height=" + myheight + ", left=" + myleft + ", top=" + mytop; 
	
	bild_popup_fenster = window.open(CurTopic , "BilderVorschau", Fensteroptionen + WinPos);
}

function showInfo(nr)
{
	if (nr == 1)
	{
		mywidth = 309 + 20;
		myheight = 113 + 80;
	}
	else
	{
		mywidth = 617 + 20;
		myheight = 223 + 80;
	}
	var myleft = window.screenX + 780 + 3;
	if (window.screenX == undefined)
		myleft = window.screenLeft + 780 + 3;
	var mytop = window.screenY;
	if (window.screenY == undefined)
		mytop = window.screenTop - 20;

	var Fensteroptionen = "toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=0,";
	var CurTopic = "/?menu=teaserinfo&info=" + nr;
	var WinPos = "width=" + mywidth + ", height=" + myheight + ", left=" + myleft + ", top=" + mytop; 
	
	bild_popup_fenster = window.open(CurTopic , "TeaserInfo", Fensteroptionen + WinPos);
}

// Standardfunktion Right(string, count)
function Right(str, n)
{
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function FileFormatCheck()
{   
	check = 0;
	var buttonList = document.uploadForm.uploadList.value;
	var buttonElemente = buttonList.split(",");
	
	for (i=0; i <= (buttonElemente.length-1); i++)
	{
		FileFormat = document.getElementById(buttonElemente[i]).value.toLowerCase();
		
		if (FileFormat != '')
		{
			filevar = Right(FileFormat, 3);
			filevar1 = Right(FileFormat, 4);
			
			if ((filevar!="jpg") & (filevar!="gif") & (filevar1!="jpeg"))
			{
				alert("Sie haben ein "+filevar1+" Format gewählt. \nEs sind nur .jpg .jpeg oder .gif als Bilder erlaubt. \nBitte wählen Sie ein anderes Bild.");
				document.getElementById(buttonElemente[i]).value = null;
				check =+ 1;		
			}
		}
	}

	if (check == 0)
	{
		document.uploadForm.submit();
	}

}

function PopUpAdmin(openurl)
{
    var URL = openurl;
    var Name = "Administration";
    var Fensteroptionen = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0";
    var Breite = 760;
    var Hoehe = 620;
	var Top = 100;
	var Left = 10;
    window.open(URL, Name, Fensteroptionen + ',width=' + Breite + ',height=' + Hoehe + ',top=' + Top + ',left=' + Left);
}

function TextTable(an, aus, text, textout)
{
	document.getElementById(aus).style.display='none';
	document.getElementById(an).style.display='block';
	document.getElementById(textout).style.fontWeight='normal';
	document.getElementById(textout).style.color='#999999';
	document.getElementById(text).style.fontWeight='bold';
	document.getElementById(text).style.color='#000000';
}
