var previouslink = '';

function LinkConvert(element,action,button)
		{	
		if (action != '') {script = 'javascript:ActionSubmit(\'' + action + '\')'; }
			else {script = 'javascript:FormSubmit()';}
			if (document.forms[0].k.value < 16 || document.forms[0].k.value > 17) 
				{if ((button < 2 && navigator.userAgent.toLowerCase().indexOf('msie')!=-1) || (button < 1 && navigator.userAgent.toLowerCase().indexOf('msie')==-1) || (button = 1 && navigator.userAgent.toLowerCase().indexOf('safari')!= -1))
					{document.forms[0].action = element.href;
					element.href= script;
					window.status= element;}
				}
		}
function linkclear(element) {
	window.status='';
	element.href = previouslink;
	document.forms[0].action = requesthandler;
}
function LinkSet(element) {
	previouslink = element.href;
}

var imgTimeOut;
var div;

function createImage(){
	div = document.createElement('div');
	div.id = 'divImage';
	div.style.backgroundImage = 'url("../interface/conf_wait.gif")';
	div.style.display = 'none';
	document.body.appendChild(div);
}

function hideImage(){
	window.clearTimeout(imgTimeOut);
	if(div = document.getElementById('divImage')){
		div.style.display='none';
	}
}

function popupImage(image){
	var imgUrl = image;
	div = document.getElementById('divImage')
	div.style.position = 'absolute';
	div.style.backgroundColor = 'silver';
	div.style.backgroundPosition = 'top left';
	div.style.backgroundRepeat = 'no-repeat';
	div.style.backgroundImage = 'url("../interface/conf_wait.gif")';
	div.style.border = '1px outset';
	if(div.hasChildNodes()){
		div.removeChild(div.childNodes[0]);}
	img = document.createElement('img');
	img.style.padding='1px';
	img.src = imgUrl;
	div.appendChild(img);
	div.style.display = 'block'
}

function followImage(event){
	if(div = document.getElementById('divImage')){
		if(document.all){
		    div.style.left = event.clientX + document.body.scrollLeft + 8 + 'px';
		    div.style.top = event.clientY + document.body.scrollTop + 8 + 'px';
		}else{
		    div.style.left = event.pageX + 8 +'px';
		    div.style.top = event.pageY + 8 +'px';
	    }
	}
	
}

function formchanged ()
	{
	document.form.form_changed.value = 'yes';
	}

// Set Focus on the first field that contains an error
function errfocus (fieldname)
		{
		document.forms[0].elements[fieldname].focus();
		}

// Rückfrage (Ja,Nein) auslösen, Aktion zwischenspeichern

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=10}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

function help(destination,win_name,win_dim) 
	{
		myWindow = window.open (baseurl + '/' + destination ,win_name,win_dim + ',' + 'resizable=yes,scrollbars=yes,toolbar=no,Left=250,Top=250,status=no,directories=no,menubar=no,location=tabelle');
 		myWindow.focus();
	}
function SetChecked(name) 
{
	dml=document.forms[0];
	len = dml.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) 
	{
		if (dml.elements[i].name == name) 
		{
			dml.elements[i].checked=dml.checkall.checked;
		}
	}
}
	
function ConfirmSubmit(action,message) 
{
	if (confirm(message) == true)
	  {
	  ActionSubmit(action);
	  }
}

function CategorySelect(fieldname)
	{
		var categoryID = document.forms[0].elements[fieldname].options[document.forms[0].elements[fieldname].selectedIndex].value;
		action = 'act_accounts_list_search:categoryID=' + categoryID;
		document.forms[0].action = 'leute-treffen.cfm?categoryID=' + categoryID;
		ActionSubmit(action);
}
		
// Aktion über URL-Variable verschicken.
var submitRunning = 0;
function ActionSubmit(action) {
	document.forms[0].jsaction.value = action;
	if (submitRunning == 0)
		{
		submitRunning = 1;
		document.forms[0].submit();
		}
	else 
		tmp = window.setTimeout('document.forms[0].submit();',200);
	}
	
function FormSubmit(action) {
	if (submitRunning == 0)
		{
		submitRunning = 1;
		document.forms[0].submit();
		}
	else 
		tmp = window.setTimeout('document.forms[0].submit();',200);
	}

function popitup(destination,win_name,win_dim) 
	{
		myWindow = window.open (baseurl + '/' + destination ,win_name,win_dim + ',' + 'resizable=no,scrollbars=no,toolbar=no,Left=250,Top=250,status=no,directories=no,menubar=no,location=tabelle');
		myWindow.focus();
	}
