function insert_img(url)
{ 
	url = "<img src=" + url + " width=" + widthimg + " name='image' id='image'>";
	if(document.getElementById){
		document.getElementById("htmlebis").innerHTML=url;
		document.getElementById("htmlebis").focus();
	}
}

function DemoCouleur(champ,demo){
	var str=champ.value;
	//str=str.toUpperCase().replace(/[^0-9A-F]/,"");
	if (str.length>1){
		txtdemo = document.all? eval("document.all."+demo) : document.getElementById(demo);
		txtdemo.style.color = str;
	}
	//champ.value=str;
	document.getElementById("txtcolor").value = str;
}

function color (ColorVal) {
	document.mycustom.txtcolor.value = ColorVal;
}




function DemoCouleurb(champ,demo){
	var str=champ.value;
	//str=str.toUpperCase().replace(/[^0-9A-F]/,"");
	if (str.length>1){
		txtdemo = document.all? eval("document.all."+demo) : document.getElementById(demo);
		txtdemo.style.color = str;
	}
	//champ.value=str;
	document.getElementById("txtcolorb").value = str;
}

function colorb (ColorVal) {
	document.mycustom.txtcolorb.value = ColorVal;
}

function DemoCouleurc(champ,demo){
	var str=champ.value;
	//str=str.toUpperCase().replace(/[^0-9A-F]/,"");
	if (str.length>1){
		txtdemo = document.all? eval("document.all."+demo) : document.getElementById(demo);
		txtdemo.style.color = str;
	}
	//champ.value=str;
	document.getElementById("txtcolorc").value = str;
}

function colorc (ColorVal) {
	document.mycustom.txtcolorc.value = ColorVal;
}


function DemoPolice(champ,demo){
	var str=champ.value;
	txtdemo=document.all? eval("document.all."+demo) : document.getElementById(demo);
	txtdemo.style.fontFamily=str;
	//alert(str);
	//alert(txtdemo.style.fontFamily);
	//txtdemo.style.fontFamily='Arial';
}
		

function DemoSize(champ,demo){
	var str=champ.value;
	txtdemo=document.all? eval("document.all."+demo) : document.getElementById(demo);
	if(str.indexOf('px')==-1)	
		str +='px';
	txtdemo.style.fontSize=str;
}

function DemoPosition(champ,demo){
	var str=champ.value;
	txtdemo=document.all? eval("document.all."+demo) : document.getElementById(demo);
	txtdemo.style.textAlign=str;
  
}

function DemoPositionVertic(champ,demo){
	var str=champ.value;
	txtdemo=document.all? eval("document.all."+demo) : document.getElementById(demo);
	txtdemo.style.textValign=str;
  
}


function insertImg()
{
	window.open('library.php','winimg','resizable=yes,scrollbars=yes,top=50,left=50,width=500,height=500');
}
function insertMyImg()
{
	window.open('custommyimg.php','winmyimg','resizable=yes,scrollbars=yes,top=50,left=50,width=500,height=200');
}


function f1(demo)
{ 
	demo = demo.replace(/(\r\n|\n|\r)/g, '<br />');
	if(document.getElementById)
		//document.all.htmle.innerHTML=demo;
		document.getElementById("htmle").innerHTML=demo;
}
var max=50;

function f2(demo)
{ 
	demo = demo.replace(/(\r\n|\n|\r)/g, '<br />');
	if(document.getElementById)
		document.getElementById("htmlf").innerHTML=demo;
}
var max=50;

function f3(demo)
{ 
	demo = demo.replace(/(\r\n|\n|\r)/g, '<br />');
	if(document.getElementById)
		document.getElementById("htmlg").innerHTML=demo;
}
var max=200;


if(!widthimg)
var widthimg= 295 ;

function augmente() {
	if(document.getElementById("image")){
		widthimg=widthimg+10;
		document.getElementById("image").width = widthimg;
	}
}

function diminue() {
	if(document.getElementById("image")){
		widthimg=widthimg-10;
		document.getElementById("image").width = widthimg;
	}
}


function recup_data()
{
	var edt = document.getElementById("htmle");
	var hidden = document.getElementById("htmlehidden");
	hidden.value = edt.innerHTML;
}
function recup_data_f()
{
	var edtf = document.getElementById("htmlf");
	var hidden = document.getElementById("htmlfhidden");
	hidden.value = edtf.innerHTML;
}
function recup_data_g()
{
	var edtg = document.getElementById("htmlg");
	var hidden = document.getElementById("htmlghidden");
	hidden.value = edtg.innerHTML;
}

function recup_data_img()
{
	var edtbis = document.getElementById("htmlebis");
	var hidden = document.getElementById("htmlebishidden");
	hidden.value = edtbis.innerHTML;
}


N = (document.all) ? 0 : 1; 
clicEnCours = false;
position_x = 0;
position_y = 0;
netscape = false; 
if (navigator.appName.substring(0,8) == "Netscape")
{ 
  	netscape = true;
} 


function boutonPresse() 
{
  	origine_x = x - position_x;
  	origine_y = y - position_y;
  	clicEnCours = true;
}

function boutonRelache()
{
  	clicEnCours = false;
}

function deplacementSouris(e)
{
	try{
		x = (netscape) ? e.pageX : event.x + document.body.scrollLeft;
		y = (netscape) ? e.pageY : event.y + document.body.scrollTop;
	
		if (clicEnCours && document.getElementById)
		{
			position_x = x - origine_x;
			position_y = y - origine_y;
			document.getElementById("htmlebis").style.left = position_x
			document.getElementById("htmlebis").style.top = position_y
		}
	}
	catch(err)
	{
		//alert(err + ' ' + e);
	}
}

if (netscape)
{
  	document.captureEvents(Event.MOUSEMOVE);
}

document.onmousemove = deplacementSouris;

function recup_coord_top()
{
	Top=document.getElementById("htmlebis").style.top;
	var hidden = document.getElementById("tophidden");
	hidden.value = Top;
}

function getLeftPosition(obj)
{
	if(document.getElementById(obj))
	{
		leftPosition = document.getElementById(obj).style.left;
		/*
		if(navigator.appName=='Microsoft Internet Explorer')
		{
			lp = leftPosition.replace(/px/,"");
			//alert(leftPosition+' - '+lp);
			
			fsize = document.getElementById(obj).style.fontSize;
			fsize = fsize.replace(/px/,"");
			
			leftPosition = (parseInt(lp)+68-parseInt(fsize))+'px';
			//leftPosition = (parseInt(lp)+52)+'px';
		}
		//alert(leftPosition);
		*/
		return leftPosition;
	}
}

function recup_coord_left()
{
	leftPosition = document.getElementById("htmlebis").style.left;
	/*
	//leftPosition = document.getElementById("image").style.left;
	if(navigator.appName=='Microsoft Internet Explorer')
	{
		lp = leftPosition.replace(/px/,"");
		//alert(leftPosition+' - '+lp);
		leftPosition = (parseInt(lp)+69)+'px';
	}*/
	document.getElementById("lefthidden").value = leftPosition;
}

function recup_coord_topa()
{
	Top=document.getElementById("htmle").style.top;
	var hidden = document.getElementById("tophiddena");
	hidden.value = Top;
}

function recup_coord_lefta()
{
	document.getElementById("lefthiddena").value = getLeftPosition("htmle");
}

function recup_coord_topf()
{
	Top=document.getElementById("htmlf").style.top;
	var hidden = document.getElementById("tophiddenf");
	hidden.value = Top;
}
function recup_coord_leftf()
{
	document.getElementById("lefthiddenf").value = getLeftPosition("htmlf");
}

function recup_coord_topg()
{
	Top=document.getElementById("htmlg").style.top;
	var hidden = document.getElementById("tophiddeng");
	hidden.value = Top;
}

function recup_coord_leftg()
{
	document.getElementById("lefthiddeng").value = getLeftPosition("htmlg");
}


function verif_formulaire()
{

	if(document.mycustom.comment.value.length>30)
 	{
   		alert("Texte limité à 1 ligne - 30 caractères");
   		document.mycustom.comment.focus();
   		return false;
  	}
	//return false;
}



function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent){
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
	}
    else if(obj.y){
        curtop += obj.y;
	}
    return curtop;
}
