function	autoUrl(name, dest) {

	var loc;
	var id_list;

	id_list = document.getElementById(name);
	loc = id_list.options[id_list.selectedIndex].value;
	if (loc != 0)
		location.href = dest+loc;
	return ;
}

/*
** show or hide element e depending on condition show
*/
function toggle(e, show)
{
	e.style.display = show ? '' : 'none';
}

function toggleMultiple(tab)
{
    var len = tab.length;

    for (var i = 0; i < len; i++)
        if (tab[i].style)
            toggle(tab[i], tab[i].style.display == 'none');
}

/**
* Show dynamicaly an element by changing the sytle "display" property
* depending on the option selected in a select.
*
* @param string $select_id id of the select who controls the display
* @param string $elem_id prefix id of the elements controlled by the select
*   the real id must be : 'elem_id'+nb with nb the corresponding number in the
*   select (starting with 0).
*/
function showElemFromSelect(select_id, elem_id)
{
	var select = document.getElementById(select_id);
	for (var i = 0; i < select.length; ++i)
	{
	    var elem = document.getElementById(elem_id + select.options[i].value);
		if (elem != null)
			toggle(elem, i == select.selectedIndex);
	}
}

/**
* Get all div with specified name and for each one (by id), toggle their visibility
*/
function openCloseAllDiv(name, option)
{
	var tab = $('*[name='+name+']');
	for (var i = 0; i < tab.length; ++i)
		toggle(tab[i], option);
}

/**
* Toggle the value of the element id_button between text1 and text2
*/
function toggleElemValue(id_button, text1, text2)
{
	var obj = document.getElementById(id_button);
	if (obj)
		obj.value = ((!obj.value || obj.value == text2) ? text1 : text2);
}

function addBookmark(url, title)
{
	if (window.sidebar)
		return window.sidebar.addPanel(title, url, "");
	else if ( window.external )
		return window.external.AddFavorite( url, title);
	else if (window.opera && window.print)
		return true;
	return true;
}

function isBrowserClosed()
{
    var browserWindowWidth = 0;
    var browserWindowHeight = 0;
    // gets the width and height of the browser window
    if (parseInt(navigator.appVersion) > 3)
    {
        if (navigator.appName == "Netscape")
        {
            browserWindowWidth = window.innerWidth;
            browserWindowHeight = window.innerHeight;
        }
        if (navigator.appName.indexOf("Microsoft") !=- 1)
        {
            browserWindowWidth = top.window.document.body.offsetWidth;
            browserWindowHeight = top.window.document.body.offsetHeight;
        }
    }
    // checks if the X button was closed
    // if event.clientY < 0, then click was on the browser menu area
    // if event.screenX > (browserWindowWidth - 25), the X button was clicked
    // use screenX if working with multiple frames
    return (event.clientY < 0 && event.screenX > (browserWindowWidth - 25)) ? true : false;
}

function goodbye(){
   if (isBrowserClosed())
   {

if(navigator.appName == "Microsoft Internet Explorer"){
	 if(confirm("Would you like to add Mini Keep to your faverate?"))
	 {
 	 	 title = "Mini Keep Online Shop"; 
	 	 url = "http://www.minikeep.com";
		addBookmark(url, title);
	 }
}
     }
}

function writeBookmarkLink(url, title, text, img)
{
	var insert = '';
	if (img)
		insert = writeBookmarkLinkObject(url, title, '<img src="' + img + '" alt="' + escape(text) + '" title="' + escape(text) + '" />') + '&nbsp';
	insert += writeBookmarkLinkObject(url, title, text);
	return document.write(insert);
}

function writeBookmarkLinkObject(url, title, insert)
{
	if (window.sidebar)
		return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');
	else if (window.external)
		return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');
	else if (window.opera && window.print)
		return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');
}

