/*  //--------------------------------------------------------------------------------
	Check Login
---------------------------------------------------------------------------------// */
function encrypt(f){
	with(f)
	{
		fu.value = hex_md5(fu.value.toUpperCase());
		fp.value = hex_md5(fp.value.toUpperCase());
		fc.value = hex_md5(fc.value.toUpperCase());
	}
}

function ckL(f){
	var alertStr = "Folgende Punkte müssen angegeben und erfüllt sein:\n";
	var alerten = 0;

	with(f)
	{
		if(fu.value == "")
		{
			alertStr = alertStr + "\n - Benutzername";
			alerten++;
		}
		if(fp.value == "")
		{
			alertStr = alertStr + "\n - Passwort";
			alerten++;
		}
		
		if(fc.value == '')
		{
			alertStr = alertStr + "\n - Sicherheitscode";
			alerten++;
		}
	}

	CheckCookie();
	if (alerten > 0)
	{
		alert(alertStr);
		return false;
	}

	encrypt(f);
	return true;
}


/*  //--------------------------------------------------------------------------------
	Mail Senden, Bild weiterempfehlen
---------------------------------------------------------------------------------// */
function ckSp(f){
	var alertStr = "Folgende Punkte müssen angegeben und erfüllt sein:\n";
	var alerten = 0;

	with(f)
	{
		if(fv.value == "")
		{
			alertStr = alertStr + "\n - Absender: Von";
			alerten++;
		}
		if(fve.value == "")
		{
			alertStr = alertStr + "\n - Absender: E-Mail";
			alerten++;
		}else{
			if( !fve.value.match(/^([\w-\.])+\@{1}([\w-\.])+\.([\D]){2,5}$/) )
			{
				alertStr = alertStr + "\n - Absender: E-Mailformat";
				alerten++;
			}
		}
		
		if(fa.value == '')
		{
			alertStr = alertStr + "\n - Empfänger: An";
			alerten++;
		}
		if(fae.value == '')
		{
			alertStr = alertStr + "\n - Empfänger: E-Mail";
			alerten++;
		}else{
			if( !fae.value.match(/^([\w-\.])+\@{1}([\w-\.])+\.([\D]){2,5}$/) )
			{
				alertStr = alertStr + "\n - Empfänger: E-Mailformat";
				alerten++;
			}
		}
	}
	
	if (alerten > 0){
		alert(alertStr);
		return false;
	}
	return true;
}



/*  //------------------------
 Function:setAlpha 
---------------------------// */
function setAlpha(eid, a) {
	if(document.getElementById)
	{
		var picElem = document.getElementById(eid);	
		picElem.style.filter = 'alpha(opacity=' + a + ')';
		picElem.style.opacity = a/100;
	}
}

/*  //--------------------------------------------------------------------------------
	Function: CheckCookie
---------------------------------------------------------------------------------// */
function CheckCookie(){
	if (navigator.cookieEnabled == false)
	{
		alert("Sie müssen Cookies von dieser Webseite akzeptieren, um diese Aktion auszuführen zu können.");
		return false;
	}
	return true;
}
/*  //--------------------------------------------------------------------------------
	Function: Window
---------------------------------------------------------------------------------// */
function winOpen(url, breite, hoehe, scrollbar) {
    links = (screen.width/2)-(breite/2);
    oben = (screen.height/2)-(hoehe/2);
    window.open(url,"popup","height="+hoehe+",width="+breite+",status = no,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no,scrollbars = "+scrollbar+",fullscreen = no,top ="+oben+",left ="+links);
} 
function winOpenFlash(url) {	
	var breite = 720;
	var hoehe = 480;
    var links = (screen.width/2)-(breite/2);
    var oben = (screen.height/2)-(hoehe/2);
    window.open(url,"popup","height="+hoehe+",width="+breite+",status = no,toolbar = no,menubar = no,location = no,resizable = yes,titlebar = no,fullscreen = no,top ="+oben+",left ="+links);
} 
function newLocation(dest){
	window.location.href = dest;
}

/*  //--------------------------------------------------------------------------------
	 Function: Bild als Hintergrundbild downloaden
---------------------------------------------------------------------------------// */
function BGDownload(){
	alert('Um die Originaldatei downloaden zu können, klicken Sie\nfür Windows: mit der rechten Maustaste auf Download und dann auf Ziel speichern unter\nfür Mac-Benutzer: control(CTRL) inkl. Maustaste auf Download und dann Ziel speichern unter');
	return false;
}

/*  //--------------------------------------------------------------------------------
	Bilder / Alben merken
---------------------------------------------------------------------------------// */
/*  //---------------------------
 Function: Bilder merken
---------------------------// */
function addPic(pc,ps){
	if(CheckCookie())
	{
		$('kontobildgemerkt').innerHTML = '&nbsp;(..)';
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'addPic', pc, ps, EvalJs);
	}
}
/*  //---------------------------
 Function: Album merken
---------------------------// */
function addAlb(cs){
	if(CheckCookie())
	{
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'addAlb', cs, EvalJs);
	}
}
/*  //---------------------------
 Function: Bild löschen
---------------------------// */
function delPic(pc,lc) {
	if(CheckCookie())
	{
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'delPic', pc, lc, EvalJs);
	}
}
/*  //---------------------------
 Function: Alle Bild löschen
---------------------------// */
function delAllPics(lc) {
	if(CheckCookie())
	{
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'delAllPics',lc, EvalJs);
	}
}
/*  //---------------------------
 Function: picToMail
---------------------------// */
function picToMail(dest, cc, ac, pc){
	if(CheckCookie())
	{
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'picToMail', cc, ac, pc, dest, EvalJs);
	}
}
/*  //---------------------------
 Function: Evaluate
---------------------------// */
function EvalJs(js){
	eval(js);
}

/*  //--------------------------------------------------------------------------------
	Keywords
---------------------------------------------------------------------------------// */
function getWords(pg,r) {
	if(document.getElementById)
	{
		objKeyw = document.getElementById("keylist");
		objKeyw.innerHTML = "";
		alb = document.getElementById("akey").value;
	
		DWRUtil.useLoadingMessage('key');
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'getKeywords', alb, pg, r, EvalJs);
	}
}

function nextK(u) {
	if(document.getElementById)
	{
		objKey = document.getElementById("ckey");
		objKey.value = parseInt(objKey.value) + 1;
		getWords(objKey.value,u);
	}
}

function backK(u) {
	if(document.getElementById)
	{
		objKey = document.getElementById("ckey");
		objKey.value = parseInt(objKey.value) - 1;
		if(parseInt(objKey.value) < 1) objKey.value = 1;
		getWords(objKey.value,u);
	}
}

/*  //--------------------------------------------------------------------------------
	Pic to Mail, anzahl Zeichen
---------------------------------------------------------------------------------// */
function calcCharLeft(inf,upf){
  	var maxLength = 200;
	  if (inf.value.length > maxLength) {
		inf.value = inf.value.substring(0,maxLength);
		charleft = 0;
	  } else {
		charleft = maxLength - inf.value.length;
	  }
	document.getElementById(upf).value = charleft;
}

/*  //--------------------------------------------------------------------------------
	set Timeout
	set Location
---------------------------------------------------------------------------------// */
function np(l,t){
	setTimeout("sl(l)", t);
}

function sl(l){
	window.location.href = l;
}
