/* ***** BEGIN LICENSE BLOCK *****
 * This file is part of DotClear.
 * Copyright (c) 2004 Olivier Meunier and contributors. All rights
 * reserved.
 *
 * DotClear is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * DotClear is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DotClear; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * ***** END LICENSE BLOCK ***** */

/*img = new Image;
img.src = 'images/moins.png';*/

function hl_getE(id)
{
	if(document.getElementById) {
		return document.getElementById(id);
	} else if(document.all) {
		return document.all[id];
	} else return;
}

function hl_openClose(id,mode,dir)
{
	element = hl_getE(id);
	img = hl_getE('img_'+id);
	if(element.style) {
		if(mode == 0) {
			if(element.style.display == 'block' ) {
				element.style.display = 'none';
				img.src = dir+'/plus.png';
				img.alt='[+]';
			} else {
				element.style.display = 'block';
				img.src = dir+ '/moins.png';
				img.alt='[-]';
			}
		} else if(mode == 1) {
			element.style.display = 'block';
			img.src = dir+'/moins.png';
			img.alt='[-]';
		} else if(mode == -1) {
			element.style.display = 'none';
			img.src = dir+'/plus.png';
			img.alt='[+]';
		}
	}
}

function hl_createCookie(name,value) {
	document.cookie = name+"="+value+";path=/;";
}

function hl_readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function hl_openCloseOptions(id,cookie_name,mode,dir)
{
	if (mode != null) {
		hl_openClose(id,mode,dir);
		e = hl_getE(id);
		if (e.style.display == 'block') {
			cookie_value = '1';
		} else {
			cookie_value = '-1';
		}
		hl_createCookie(cookie_name,cookie_value);
	} else {
		cookie = hl_readCookie(cookie_name);
		if (!cookie) {
			cookie = -1
		}
		hl_openClose(id,cookie);
	}
}

