/* prechargement */
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

/* menu entete */
function changeImages(img_id, img_url)
{
	if (document.images && (preloadFlag == true)) 
	{
		
		document.getElementById(img_id).src = img_url;
	  //alert(img_url);
  }
}







/* prechargement */

var preloadFlag = false;

function preloadImages() {

	if (document.images) {
		panier_over = newImage("/themes/osetoys/img/detail_panier_over.png");
		continuer_over = newImage("/themes/osetoys/img/fr/btn-continue_over.gif");
		continuer_over = newImage("/themes/osetoys/img/fr/bt_commander_over.gif");
		//validerinfo_over = newImage("/themes/osetoys/img/fr/btn-create-account2_over");
		//next_over = newImage("/themes/osetoys/img/fr/btn-next_over");
		//previous_over = newImage("/themes/osetoys/img/fr/btn-previous_over");
		
		
		preloadFlag = true;
	}

}

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';
}

/**
* 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 = document.getElementsByName(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(string, link)
{
	if (window.sidebar)
		window.sidebar.addPanel(string, link, "");
	else if (document.all)
		window.external.AddFavorite(link, string);
	else
		return true;
}
