image0=new Image();
image0.src="http://colorpx.com/imgcolor/loader.gif";

function s_choice()
{
	if(document.getElementById('id_selcolor0').value=="2")
	{
		document.getElementById('id_selcolor0').value="1";
		document.getElementById('im_sel0').src='http://colorpx.com/imgcolor/color-t-0.png';	
		document.getElementById('i_d00').innerHTML='';	
		
		
	}
	else 
	{	
		document.getElementById('i_d00').style.display="inline";
		document.getElementById('id_selcolor0').value="2";
		document.getElementById('im_sel0').src='http://colorpx.com/imgcolor/color-t-1.png';
		
		document.getElementById('i_d00').innerHTML='<p style="text-align:left;width:725px;padding:5px 0px 5px 5px;margin:10px auto 0px auto;background-color:#D6E1FD;border:1px solid #C4D1F3;">&nbsp;<img src="imgcolor/info.gif" alt="" border="0" />&nbsp;Color selector : you can select a color on draw.To draw with this selected color, you need to unselect tools before.</p>';
		/*setTimeout('document.getElementById(\'i_d00\').style.display="none"',10000);*/
		
	}
}
function s_choice0()
{
	/*alert('a='+document.getElementById('im_sel0').src);*/
	if(document.getElementById('im_sel0').src=='http://colorpx.com/imgcolor/color-t-1.png')
	{
			document.getElementById('id_selcolor0').value="1";
			document.getElementById('im_sel0').src='http://colorpx.com/imgcolor/color-t-0.png';	
			document.getElementById('i_d00').innerHTML='';	
	}
}
function g0(urlpage,what)
{	
	if(window.XMLHttpRequest) obj1=new XMLHttpRequest();else if(window.ActiveXObject) obj1=new ActiveXObject("Microsoft.XMLHTTP");else return(false);
        obj1.open ('GET', urlpage, true);
        obj1.onreadystatechange = function() 
        {
         if(obj1.readyState==1) {document.getElementById(what).innerHTML="<img src='http://colorpx.com/imgcolor/loader.gif' alt='' />";}
         else if(obj1.readyState==4)
         {
                   if(obj1.status==200){document.getElementById(what).innerHTML=obj1.responseText;}
                   else if(obj1.status==404){document.getElementById(what).innerHTML = "Url BUG";}
                   else{document.getElementById(what).innerHTML = "Error : ".obj1.status;}
         }
        }
        obj1.send(null);
        return;
} 

function rgbConvert(str) {
   str = str.replace(/rgb\(|\)/g, "").split(",");
   str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
   str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
   str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
   str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
   str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
   str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];
   return ('#' + str.join(""));
}

function g1(urlpage,what)
{
	
	if(document.getElementById('id_selcolor0').value=="2")
	{
		var color1 = document.getElementById(what).style.backgroundColor; 
		
		/*alert('color1='+color1);*/
		
		
		if(color1!="")
		{
		var hexa_color1=rgbConvert(color1);
		/*alert('hexa_color1='+hexa_color1);*/	
		document.getElementById('cs').value=hexa_color1;
		document.getElementById('cs').style.backgroundColor=hexa_color1;
		}
		
		
		
	}
	else
	{
		document.getElementById('id_selected0').value=document.getElementById(what).value;
		
		document.getElementById(what).style.backgroundColor=document.getElementById('cs').value;
		if(window.XMLHttpRequest) obj1=new XMLHttpRequest();else if(window.ActiveXObject) obj1=new ActiveXObject("Microsoft.XMLHTTP");else return(false);
	        obj1.open ('GET', urlpage, true);
	        obj1.onreadystatechange = function() 
	        {
	         if(obj1.readyState==1) {document.getElementById(what).innerHTML="";}
	         else if(obj1.readyState==4)
	         {
	                   if(obj1.status==200){document.getElementById(what).innerHTML=obj1.responseText;}
	                   else if(obj1.status==404){document.getElementById(what).innerHTML = "Url BUG";}
	                   else{document.getElementById(what).innerHTML = "Error : ".obj1.status;}
	         }
	        }
	        obj1.send(null);
        }
        
        
        return;
        
        
        
} 	 
function goto(there) { document.location=there; }

function displayit(what) 
{
	thiselement = document.getElementById(what);
	if (thiselement.style.display=="none" || thiselement.style.display==""){thiselement.style.display="block";thiselement.focus();} 
	else {thiselement.style.display="none";}
}
