/* auteur: varman7 */
/* Date de création: 31/10/2003 */



function clearField(val) {
	if (document.getElementById("KEYWORD").value == val) document.getElementById("KEYWORD").value = "";
}


function SwapImage (b,s) {
	b.src = s;
}

function ShowHide(v,rep_image)
{
	for (var i=1;i<document.all.length;i++)
	{
		if (document.all[i].id.lastIndexOf("tr_"+v+"M") != -1)
		{
			if(document.all[i].style.display == 'block')
			{
				document.all[i].style.display = 'none';
			}
			else
			{
				document.all[i].style.display = 'block';
			}
		}
		
		if(document.all[i].src!=null)
		{
			// en php changer l'id des images en img_leblon de manière dynamique
				//		 et dans la fonction javascript ne tester que l'id et plus le src -->
	  		if (document.all[i].src.lastIndexOf("_08.gif") != -1 && document.all[i].id.lastIndexOf("img_"+v+"M")!=-1)
			{
				// trouver astuce pour reprendre ce qu'il y a devant / et juste changer ce qu'il y a apres
				document.all[i].src = rep_image+"/EDIT-TEMPLATE-content_08bis.gif";
			}
			else
			{
				
				if(document.all[i].src.lastIndexOf("_08bis.gif") != -1 && document.all[i].id.lastIndexOf("img_"+v+"M")!=-1)
				{
					document.all[i].src = rep_image+"/EDIT-TEMPLATE-content_08.gif";
				}
			}
  		}
		
	}
}


function showDet(com)
{
	for (var i=1;i<document.all.length;i++)
	{
		if (document.all[i].id.lastIndexOf("tr_"+com+"A") != -1)
		{
			if(document.all[i].style.display == 'inline')
			{
				document.all[i].style.display = 'none';
			}
			else
			{
				document.all[i].style.display = 'inline';
			}
		}
	}
}


function AskBeforeSubmit(formN,message)
{
	if (confirm(message+" ?")) 
	{
           document.forms[formN].submit();
       	}
	
}

// annulation d'une commande
function DelAnnonce(formN,message)
{
	if (confirm(message+" ?")) 
	{
           document.forms[formN].submit();
       	}
	
}


function ShowCards()
{

	if(document.getElementById("paiement").value=="2") 
		document.getElementById("cards").style.display='inline';
	else
		document.getElementById("cards").style.display='none';
}


/***********************************************
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Oct 21st, 2003.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)



function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined")
revivecontent()
}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate