function $(id) {return document.getElementById(id)}

function show_hide_switch(clq)
{
	if ( ($(clq).style.display)==("block") )
	{
		$(clq).style.display="none";
	}
	else
	{
		$(clq).style.display="block";
	}
}

function hide_show(clq1,clq)
{
	$(clq1).style.display="none";
	$(clq).style.display="block";

}

function show(clq)
{
	if( $(clq) )
	{
		$(clq).style.display="block";
	}
}
function hide(clq)
{
	$(clq).style.display="none";
}

function getOptionsInsert()
  {
  var x=document.getElementById("products");
  for (i=0;i<x.length;i++)
    {
	if(x.options[i].selected){

		insertOption(x.options[i].text,x.options[i].value,"category");
		removeOption("products",x.options[i].value);
		}

    }
  }

 function getOptionsRemove()
  {
  var x=document.getElementById("category");
  for (i=0;i<x.length;i++)
    {
	if(x.options[i].selected)
		{

		insertOption(x.options[i].text,x.options[i].value,"products");
		removeOption("category",x.options[i].value);
		}
    }
  }


  function insertOption(text,val,id)
  {
  var y=document.createElement('option');
  y.text=text;
  y.value=val;

  var x=document.getElementById(id);
  try
    {
    x.add(y,null); // standards compliant
    }
  catch(ex)
    {
    x.add(y); // IE only
    }
	 if(id == "category"){
		var str		= $("idsprod").value;
		$("idsprod").value =  str + val+"#";
		}
  }

 function removeOption(id,val)
  {
	  if(id == "category"){
		  	var str		= $("idsprod").value;
			if(str.match(val))
				{
				val = val +'#';
				$("idsprod").value = str.replace(val,"");
				}
	  }
  var x=document.getElementById(id)
  x.remove(x.selectedIndex)
  }
/*
	*	make the ligne on/of
	*/
	function On_Off_Ligne(obj,dir,id)
	{
		var  dd_name = "work_area"+id

		if (dir=='over')	{obj.className='on'}
		else
		if ($(dd_name).style.display!='block'){obj.className='off'}
	}

	/*
	*	show / hide event info in events page
	*/

/*
	*	show / hide event info in events page
	*/
	function SwitchEventInfo(id)
	{
		var dds = document.getElementsByTagName("dd")

		var  dd_name = "work_area"+id
		var  dd_ligne = "dd_ligne"+id

		// we hide/show
		if ($(dd_name).style.display == 'none')
		{
			$(dd_name).style.display = 'block';
			if($(dd_ligne))
			$(dd_ligne).className='on';
		}
		else
		{
			$(dd_name).style.display = 'none';
			if($(dd_ligne))
			$(dd_ligne).className='off';
		}

		// we close all other div inactives
		for (i=0;i<dds.length;i++)
		{
			myString = dds[i].id;
			if (myString.match(/^work_area(.*)/) && myString!=dd_name)
			{
				dds[i].style.display = 'none'
				//$(dd_ligne).className='off';
			}
		}
	}

//----- begin clear text field
function clearDefaultValue(element) {
    if (element.value == element.defaultValue) element.value = '';
}
//----- end clear text field
//----- begin show value text field
function showDefaultValue(element) {
    if (element.value == '') element.value = element.defaultValue;
}
//----- end clear text field
function popTerms() {
	var pTerms = window.open("templates/terms.php", "terms", "width=600,height=500,scrollbars=1,toolbar=0,menubar=0,status=0,resizable=1,left=100,top=100");
	pTerms.focus();
}