	// a simple confirm for links
	function confirm_link(text,url){
		value = confirm(text);
	 	if(value == true){
	 		window.location.href = url;
	 	}
	 }
	 function switch_div(id){
		$(document.getElementById(id)).toggle();
	 }
	function openWindow(target,width,height) {
		window1 = window.open(target, "window", "width="+width+",height="+height+",left=100,top=200");
		window1.focus();
	}
	function tellNav(frame,linkID,category){
		targetFrame = eval('parent.'+frame);
		activeFrame = $.cookie('activeFrame');

		if(activeFrame != null){
			oldFrame = eval('parent.'+activeFrame);
		}

		if(targetFrame && (activeFrame == null || oldFrame)){
			setTimeout('targetFrame.setNav("'+linkID+'","'+frame+'","'+category+'")',500);
		}else{
			setTimeout('tellNav("'+frame+'","'+linkID+'","'+category+'")',500);
		}
	}
	function unsetNav(){
		activeLink = $.cookie('activeLink');
	 	if(activeLink != null && document.getElementById(activeLink)){
			document.getElementById(activeLink).className = '';
		}
	}
	function setNav(linkID,frame,category){
		activeFrame = $.cookie('activeFrame');

		if(activeFrame != null){
			oldFrame = eval('parent.'+activeFrame);
			oldFrame.unsetNav();
		}
		$.cookie('activeLink', linkID);
		$.cookie('activeFrame', frame);
		if(document.URL.indexOf('navi_resize.php') == -1){
				document.getElementById(linkID).className = 'selectednav';
		}

		if((category && category != 'null') && ($.cookie(category) == 'hidden')){
			targetFrame = eval('parent.'+frame);
			$.cookie(category, 'visible', {expires: 180});
			targetFrame.location.reload();
		}
	}
	function listInput(id, maxElements, offset, showLineNumbers)
	{
		numElements = $(document.getElementById(id)).find('input').size();
		var filledElements = 0;

		for(i = offset; i < (numElements+offset); ++i){
			if(document.getElementById(id+'['+i+']').value != ''){
				++filledElements;
			}
		}
		if(filledElements >= numElements-1 && numElements < maxElements){

			fieldNumber = numElements+offset;
			if(showLineNumbers > 0){
				var lineNumber = (numElements+1)+': ';
			}else{
				var lineNumber = '';
			}
			field = '<span id="'+id+'_box['+fieldNumber+']">'+lineNumber+'<input type="text" class="edit" id="'+id+'['+fieldNumber+']" name="'+id+'['+fieldNumber+']" onfocus="listInput(\''+id+'\','+maxElements+','+offset+');"/><br/><span>';
			$(document.getElementById(id)).append(field);
			$(document.getElementById(id+'_box['+i+']')).fadeIn('slow');
		}
	}
		/* logging number of changes
		var editCount = 0;*/
		var editSet = false;
        var mainForm = false;

		function resetEditCount(){
			$.cookie('editCount', null, {expires: -1});
		}
		function increaseEditCount(){
			if(mainForm){
				editCount = $.cookie('editCount');
				if(editCount == null){
					editCount = 0;
				}
				++editCount;
				$.cookie('editCount', editCount);

				if(!editSet){
					var disk = '&nbsp;<img src="images/icons/silk-icons/bullet_disk.png" border="0" alt="" style="margin:0 0 1px 0;vertical-align:middle;"/>';
					$(document.getElementById("submit1")).append(disk);
					$(document.getElementById("submit2")).append(disk);
					document.getElementById("submit1").style.color = "#000";
					document.getElementById("submit2").style.color = "#000";
					editSet = true;
				}
			}
		}

		function confirmProceed2(text){
			editCount = $.cookie('editCount');
			if(editCount != null){
				if(confirm(text) == true){
					resetEditCount();
					return true;
				}else{
				 	return false;
				}
			}else{
				return true;
			}
		}

		function cookieCheck(){
			if($.cookie('cookieCheck')!=1){
				$.cookie('cookieCheck', '1');
			}
			if($.cookie('cookieCheck') == 1){
				return true;
			}
			return false;
		}
		function ajaxSwitch(objID)
		{
			$('#'+objID).blur();
			$('#'+objID).find('img').attr('src','images/indicator.gif');

			table = $('#'+objID+'_table').attr('value');
			id = $('#'+objID+'_id').attr('value');
			field = $('#'+objID+'_field').attr('value');
			data_active = $('#'+objID+'_data').attr('value');
			data_on = $('#'+objID+'_data_on').attr('value');
			data_off = $('#'+objID+'_data_off').attr('value');
			image_on = $('#'+objID+'_image_on').attr('value');
			image_off = $('#'+objID+'_image_off').attr('value');

			if(typeof data_off=='undefined'){
				data_off = '';
			}
			if(data_active==data_on){
				data = data_off;
				image = image_off;
			}else{
				data = data_on;
				image = image_on;
			}
			$.post('modules/ajax/switch.php', { table: table, id: id, field: field, data: data }, function(text){
				if(text==1){
					$('#'+objID).find('img').attr('src',image);
					$('#'+objID+'_data').attr('value',data);
				}else{
					alert('Fehler beim Ajax-Aufruf: '+text);
				}
			});
		}
	$.ajaxSelect = function() {}
	$.fn.ajaxSelect = function(i)
	{
		var table = $(this).find('input.table').attr('value');
		var id = $(this).find('input.id').attr('value');
		var field = $(this).find('input.field').attr('value');

		$(this).change(function(){
			data = $(this).find('option:selected').attr('value')
			$(this).find('select').css('background','#FEFF7F');

			$.post('modules/ajax/switch.php', { table: table, id: id, field: field, data: data }, function(text){
				if(text!=1){
					alert('Fehler beim Ajax-Aufruf: '+text);
				}
				$(this).find('select').css('background','');
			});
		});
	}
