var zutaten_poolpool = false;
var MS = 0, NS = 0, OP = 0;	
var session_values;

if ((typeof(parent.frames[0]) == 'object') && (window.name == "ecocktailcontent"))
{
	if (typeof(parent.ecocktailsession) == 'object')
	{
		if (typeof(parent.ecocktailsession.document.values) == 'object')
		{
			session_values = parent.ecocktailsession.document.values;
		}
	}
}

function init()
{
	if (window.opera) {OP = 1}
	if(document.all && !OP) {MS = 1}
	if(document.layers && !OP) {NS = 1}

	if(typeof(session_values) != 'object'){return 1}

	if(typeof(session_values.alert) == 'object')
	{
		if (session_values.alert.value != '')
		{
			alert(session_values.alert.value);
			session_values.alert.value = '';
		}
	}

	markieren();
	return 1;
}

function pp_over(imgsrc)
{
	if (document.pp)
	{
		document.pp.src = imgsrc;
	}
	return 1;
}

function pp_out()
{
	if (document.pp)
	{
		document.pp.src = '/de/images/blank.gif';
	}
	return 1;
}



function login_logout()
{
	var html = "";
	var login_box = document;

	if (window.opera) {OP = 1}
	if(document.all && !OP) {MS = 1}
	if(document.layers && !OP) {NS = 1}

	if (NS == 1){login_box = document.ec.document}


	if (typeof(session_values) != 'object'){return 1}
	if (typeof(session_values.user) != 'object')
	{
		html += '<form action="/de/ecocktail-cgi/datenbank/login.cgi" name="login_box" target="ecocktailsession">';
		html += '<input type="hidden" name="zutaten_pool" value="' + session_values.zutaten_pool.value + '">';
		html += '<table border="0" cellpadding="5" cellspacing="0" width="200" class="rahmen">';
		html += '<tr>';
		html += '<td width="20%">User:</td>';

		html += '<td width="80%"><input type="text" name="user" size="10" id="user" ></td>';
		html += '</tr>';
		html += '<tr>';
		html += '<td width="20%">Passwort:</td>';
		html += '<td width="80%"><input type="password" name="pw" size="10" id="pw"></td>';
		html += '</tr>';
		html += '<tr>';
		html += '<td width="100%" colspan="2" align="center"><input type="submit" name="login" value="Anmelden"></td>';
		html += '</tr>';
		html += '</table>';
		html += '</form>';
	}
	else
	{
		html += "Sie sind angemeldet als <b>" + session_values.ansprechpartner.value + '</b><br> <a href="/de/ecocktail-cgi/datenbank/login.cgi?logout" target="ecocktailsession">klicken Sie hier um sich abzumelden</a>';
	}

	login_box.write(html);
	return 1;
}


function markieren()
{
	var i = -1;
	var zutaten_pool_obj;
	if (NS == 1) 
	{
		while (typeof(window.document.ec.document.forms[++i])  == 'object')
		{
			if (window.document.ec.document.forms[i].name == "zutaten") {zutaten_pool_obj = window.document.ec.document.forms[i]}
		}
	}
	else
	{
		while (typeof(document.forms[++i])  == 'object')
		{
			if (window.document.forms[i].name == "zutaten") {zutaten_pool_obj = window.document.forms[i]}
		}
	}




	if (typeof(zutaten_pool_obj) != 'object'){return 1}
	if (typeof(session_values) != 'object'){return 1}

	i = -1;
	var values = "|"+ session_values.zutaten_pool.value + "|";

	while (typeof(zutaten_pool_obj.elements[++i])  == 'object')
	{
		if (zutaten_pool_obj.elements[i].name == "zutaten_select")
		{
			if	(find_item(zutaten_pool_obj.elements[i].value,values)) 
			{
				zutaten_pool_obj.elements[i].checked = true 
			}
		}
	}
	return 1;
}

function zutaten_del_add(self)
{
	var item = self.value;

	if (typeof(session_values) != 'object'){return 1}
	var values = "|"+ session_values.zutaten_pool.value + "|";
	var searchstring = "\\\|"+ item +"\\\|";
	var temp_string;
	if (values == "||") 
	{
		session_values.zutaten_pool.value = item;
		return 1;
	}



	if	(find_item(item,values)) 
	{
		eval("temp_string = values.replace(/"+searchstring+"/,\"|\")");
		temp_string = temp_string.substr(1,temp_string.length);
		temp_string = temp_string.substr(0,temp_string.length - 1);
		session_values.zutaten_pool.value = temp_string;
	}
	else
	{	
		session_values.zutaten_pool.value +=  "|" + item;
	}
	return 1;
}

function find_item (item,values) {
	var searchstring = "\\\|"+ item +"\\\|";
	eval("found = values.match(/"+searchstring+"/)");
	return found;
}



1;


