
function photo(url)
{
	var photo = getElem("id", "photo");
	photo.src = url;
}
function updateCatAddAnnonce(cat,i)
{
 document.addAnnonce.annonce_categories.value=cat;
}
function loadCity(url,country_id)
{
    if (country_id!=0) {
	url = url + '?country_id=' + country_id;
	new Ajax.Updater('zone_city', url, {asynchronous:true, evalScripts:false})
    } else {
    	document.getElementById('zone_city').innerHTML='<br>';
    }
}

function loadCategories2(url,url2, categories_id)
{
url = url + '?categories_id=' + categories_id;
url2 = url2 + '?categories_id=' + categories_id;
new Ajax.Updater('zone_categories2', url, {asynchronous:true, evalScripts:false})
new Ajax.Updater('zone_options', url2, {asynchronous:true, evalScripts:false})
}
function loadCategories3(url,url2,categories_id)
{
url = url + '?categories_id=' + categories_id;
url2 = url2 + '?categories_id=' + categories_id;
document.addAnnonce.annonce_categories_id_2.value=categories_id;
new Ajax.Updater('zone_categories3', url, {asynchronous:true, evalScripts:false})
new Ajax.Updater('zone_options', url2, {asynchronous:true, evalScripts:false})
}
function loadCategories4(url,url2,categories_id)
{
url = url + '?categories_id=' + categories_id;
url2 = url2 + '?categories_id=' + categories_id;
document.addAnnonce.annonce_categories_id_3.value=categories_id;
new Ajax.Updater('zone_categories4', url, {asynchronous:true, evalScripts:false})
new Ajax.Updater('zone_options', url2, {asynchronous:true, evalScripts:false})
}
function loadCategories5(url,url2,categories_id)
{
url = url + '?categories_id=' + categories_id;
url2 = url2 + '?categories_id=' + categories_id;
document.addAnnonce.annonce_categories_id_4.value=categories_id;
new Ajax.Updater('zone_categories5', url, {asynchronous:true, evalScripts:false})
new Ajax.Updater('zone_options', url2, {asynchronous:true, evalScripts:false})
}
function loadCategories6(url,url2,categories_id)
{
url = url + '?categories_id=' + categories_id;
url2 = url2 + '?categories_id=' + categories_id;
document.addAnnonce.annonce_categories_id_5.value=categories_id;
new Ajax.Updater('zone_categories6', url, {asynchronous:true, evalScripts:false})
new Ajax.Updater('zone_options', url2, {asynchronous:true, evalScripts:false})
}
function showZoneLivraison(show)
{
  if (show)
  {
    document.getElementById('zone_livraison').style.display='block';
  }
  else {
    document.getElementById('zone_livraison').style.display='none';
  }
}
function loadOptions(url,categories_id)
{       
url = url + '?categories_id=' + categories_id;                                                                                                                                      
new Ajax.Updater('zone_options', url, {asynchronous:true, evalScripts:false})
}
function loadInputOptions(option_id,i) {
 document.addAnnonce.elements['annonce_option_'+i].value=option_id;
}
function showZoneSubmit(show)
{
alert(show);
  if (show)
  {
    document.getElementById('zone_submit').style.display='block';
  }
  else {
    document.getElementById('zone_submit').style.display='none';
  }
}

//Calcul de la hauteur d'une iframe
function haut( obj ){
  var h;
  // calcul de la hauteur du contenu suivant le navigateur:
  if (document.documentElement.clientHeight) {
  
    if (navigator.appName=="Microsoft Internet Explorer") {
      h = document.getElementById(obj).document.documentElement.clientHeight;
    } else {
      h = document.getElementById(obj).contentDocument.documentElement.clientHeight;
    }
    
  }
  if (typeof(window.innerHeight)=='number') 
    h = document.getElementById(obj).contentDocument.body.innerHeight;
    
  if (document.body.clientHeight && navigator.appName!="Microsoft Internet Explorer") 
    h = document.getElementById(obj).contentDocument.body.clientHeight;
                                                                                                                                                                                      // Ajustement de la hauteur de frame:
  alert('hauteur='+h);
  document.getElementById(obj).style.height = h + 25 + "px";
} 

function iFrameHeight() {
	var h = 0;
	if ( !document.all ) {
		h = document.getElementById('fram').contentDocument.height;
document.getElementById('fram').style.height = h + 60 + 'px';
	} else if( document.all ) {
		h = document.frames('fram').document.body.scrollHeight;
document.all.blockrandom.style.height = h + 20 + 'px';
	}
}


function autofitIframe2(id){
	if(document.getElementById){
			//ter =  this.document.body.offsetHeight+ 20 + 'px';
			ne =  this.document.documentElement.scrollHeight + 20 + 'px';
			if (ne<20) { ne=50; }	
				
			parent.document.getElementById(id).style.height = ne;	
		 parent.document.getElementById(id).style.height = this.document.documentElement.offsetHeight + 0 + 'px'; 
	}
}

function autofitIframe(id)
{ //BUT: Ajuster la hauteur du frame en fonction de son contenu interne
 //Source: http://www.geekforum.com/forum/forum_posts.asp?TID=347&PN=1&TPN=3
  var newheight;
 
  if (navigator.appName != "Microsoft Internet Explorer" && !window.opera && !document.mimeType && document.all && document.getElementById){
		/* parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px"; */
		newheight=document.getElementById(id).contentWindow.document.body.offsetHeight;
		if (newheight<20) { newheight=50; } //bug ie qd on a juste 1 ligne
		document.getElementById(id).style.height= (newheight) + "px";
  }else if(document.getElementById){
		/* $('fram').style.height = document.body.offsetHeight+"px"; */
		/*newheight=document.getElementById(id).contentWindow.document.body.scrollHeight; */
  }
}

/*function autofitIframe(id){ // v.1.0
	//copyright 2004 Eddie Traversa http://www.dhtmlnirvana.com/
	if (!window.opera && !document.mimeType && document.all && document.getElementById){
		parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px"
	}else if(document.getElementById) {
		hauteur = this.document.body.scrollHeight + 20px;
		parent.document.getElementById(id).style.height=hauteur+"px"
	}
}*/

function countChar(thisArea, max, thisField)
{
	strLen = thisArea.value.length
	charsLeft = 0;
	
	if (strLen > max )
	{
		thisArea.value = thisArea.value.substring(0, max);
		charsLeft = max;
		alert ("La saisie dépasse " + max + " caractères !");								
	}
	else
	{
		charsLeft = strLen;
	}	
	
	thisField.value = charsLeft;
}


