
function byId(id){
	return document.getElementById(id);
}


function modheader(sender){
	var im = sender.src;
	var he = document.getElementById("header");
	he.style.backgroundImage = "url("+im+")";
	var myid = sender.id;
	var inpu= document.getElementById("dd_"+myid);
	inpu.checked = true;
}



function create_dlg(node){
    var divc  = document.createElement('div');
//  divc.style.display = "none";
  divc.id = "dlg_"+node;
  divc.style.left = "0px";
  divc.style.display = "none";
  divc.align = "center";
  divc.style.zIndex = "99799";
  divc.style.top = "0px";
  divc.style.position = "absolute";
//  divc.style.padding = "10px 0 0 0";
  // add element
  
  // add font
  var font  = document.createElement('div');
  font.id = "font_"+node;
  font.style.position = "absolute";
  font.style.zIndex = "99800";
  font.style.backgroundColor = "rgb(0, 0, 0)";
  font.style.opacity = "0.7";
  font.style.top = "0px";
  font.style.left = "0px";
  // top a setter

  
  var h = 0;
  var w = 0;
  if (document.width)
  	w = document.width;
//alert(w);
  if (document.height)
    h = document.height;
	if (document.all) {
	  if (document.body.clientHeight) {
		  h = document.body.clientHeight ;
		  w = document.body.clientWidth ;
		}    
		else {
		}
	}
  
  

  var element = document.getElementById(node);
  // create dic cont
  element.style.zIndex = "99801";
//  element.style.top = "0px";
  element.style.position = "absolute";
  element.style.left = "0px";	
  element.style.width = w.toString()+' px';
  element.style.minWidth = w+'px';
  element.style.height = h+'px';
  element.style.minHeight = h+'px';
  font.style.width = w +'px';
  font.style.minWidth = w +'px';
  font.style.height = h+'px';
  font.style.minHeight = h+'px';
  divc.style.width = w+'px';
  divc.style.minWidth = w+'px';
  divc.style.height = h+'px';
  divc.style.minHeight = h+'px';

  var px  = document.createElement('div');
  px.style.left = w;
  px.style.top = h;
  
  divc.appendChild(font);
  divc.appendChild(element);
//  divc.appendChild(px);
  
  var clone = divc;
  var html = document.getElementsByTagName("body");
  html[0].appendChild(clone);

}
function show_dlg(node){
 var divc  = document.getElementById( "dlg_"+node);
 divc.style.display = "block";
}
function hide_dlg(node){
 var divc  = document.getElementById( "dlg_"+node);
  divc.style.display = "none";
}


function init_import(){
	if (document.getElementById("import_iframe")){
		create_dlg('import_iframe');
	}
}
function init_mininav(){
	if (document.getElementById("galerie_fullscreen")){
		create_dlg('galerie_fullscreen');
		run_wait_slide();
	}
}

var ieme_img = 0;
function loadimagecomment(id){
	// check si page galerie
	
	if (document.getElementById("addcommentaire") == null)
		return ;
	// get idb
	
	var iddiv = document.getElementById("myid_"+id);
	if (iddiv){
	}else{
//		alert('erreor no id '+id);
		return;
	}
	var num = iddiv.className;
	//set valeur id
	ieme_img = num;
	while (document.getElementById('comment_ici_ajax').firstChild)
		document.getElementById('comment_ici_ajax').removeChild(document.getElementById('comment_ici_ajax').firstChild) ;	
	var p = document.createElement("p")	;
	p.style.height = "100px";
	p.style.width = "200px";
	p.id = "tobeedited3";
	p.innerHTML = "Cliquez ici";
	document.getElementById('comment_ici_ajax').appendChild(p);
	new Ajax.InPlaceEditor($('tobeedited3'), '/blog/gallerie/actioncommentaire?action=add&id='+num, {
		rows:5,
		cols:20,
		ajaxOptions: {method: 'get',onComplete: update_com} //override so we can use a static for the result
		});

	// set commentaire 
	getcom(num);
}

function update_com(originalRequest){
	getcom(ieme_img);
}
function getcom(id)
    {
        var url = 'http://www.rendezvousjardin.com/blog/gallerie/listcommentaire.php';
        var pars = 'id=' + id ;
        
        var myAjax = new Ajax.Request(
            url,
            {
                method: 'get',
                parameters: pars,
                onComplete: showResponse
            });
        
    }

    function showResponse(originalRequest){
        $('listcom').innerHTML = originalRequest.responseText;
    }