var rtimer = true;
var df = 0;
var ty = 0;
var typa;


	var mouse="out";
		var bName = navigator.appName;
		var bVer = parseInt(navigator.appVersion);
		var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
		var click="no";
		var ghex="empty";
		var timer;
	
		function findPosX(obj)
		{
			var curleft = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curleft += obj.offsetLeft
					obj = obj.offsetParent;
				}
			}
			else if (obj.x)
				curleft += obj.x;
				return curleft;
		}

		function findPosY(obj)
		{
			var curtop = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curtop += obj.offsetTop
					obj = obj.offsetParent;
				}
			}
			else if (obj.y)
			curtop += obj.y;
			return curtop;
		}		
	
		function showtab(e,cvv,tbb)
		{
			
   		var buta = document.getElementById(cvv);
			var posx = findPosX(buta);
			var posy = findPosY(buta);

			var tabid = document.getElementById(tbb);
		 	tabid.style.display = "block";
			tabid.style.position = "absolute";
			tabid.style.left = posx+5;
			tabid.style.top = posy+25;

			if(timer)
			    clearTimeout(timer);
		}

		function showval(gg,rr,bb,hxx,cvv)
		{
          
       mouse="in";
			click="no";
			var hexid = document.getElementById(hxx);
		
     	var hval=""+deciToHex(gg)+deciToHex(rr)+deciToHex(bb);
			hexid.value=hval;
			var dispid = document.getElementById(cvv);
			dispid.style.backgroundColor="#"+hval;
			
		}

		function clicked(gg,rr,bb,hxx,cvv,tbb,r,g,b)
		{
			  document.getElementById(r).value=gg;
		    document.getElementById(g).value=rr;
		    document.getElementById(b).value=bb;
  	
   	if(r=="tr1" ){
    	var r11 = deciToHex(document.xxx.v11.value);
    	var g11 = deciToHex(document.xxx.v12.value);
	    var b11 = deciToHex(document.xxx.v13.value);

  var ssd = "#"+r11+g11+b11;
	document.xxx.sd.style.color = ssd;
	document.xxx.v11.style.backgroundColor = "#"+r11+"0000";
	document.xxx.v12.style.backgroundColor = "#00"+g11+"00";
	document.xxx.v13.style.backgroundColor = "#0000"+b11;
	document.xxx.v14.value = ssd;
	}
	else if(r=="r" ){
	var r11 = deciToHex(document.xxx.v31.value);
	var g11 = deciToHex(document.xxx.v32.value);
	var b11 = deciToHex(document.xxx.v33.value);
	var ssd = "#"+r11+g11+b11;
	var ssdd = document.getElementById("dum");
	//ssdd.setAttribute("bgcolor",ssd);
	ssdd.style.backgroundColor = ssd;
	document.xxx.v31.style.backgroundColor = "#"+r11+"0000";
	document.xxx.v32.style.backgroundColor = "#00"+g11+"00";
	document.xxx.v33.style.backgroundColor = "#0000"+b11;
	document.xxx.v34.value = ssd;
	}
	else {
	var r11 = deciToHex(document.xxx.v1.value);
	var g11 = deciToHex(document.xxx.v2.value);
	var b11 = deciToHex(document.xxx.v3.value);
	var ssd = "#"+r11+g11+b11;
	document.xxx.sd.style.backgroundColor = ssd;
	document.xxx.v1.style.backgroundColor = "#"+r11+"0000";
	document.xxx.v2.style.backgroundColor = "#00"+g11+"00";
	document.xxx.v3.style.backgroundColor = "#0000"+b11;
	document.xxx.v4.value = ssd;
	}
     
  	mouse="in";
			click="yes";
			var hexid = document.getElementById(hxx);
			var hval=""+deciToHex(gg)+deciToHex(rr)+deciToHex(bb);
			hexid.value=hval;
			var dispid = document.getElementById(cvv);
			dispid.style.backgroundColor="#"+hval;
			var tabid = document.getElementById(tbb);
			tabid.style.display = "none";
			ghex=hexid.value;
	 }
		
		function deltab(hxx,cvv,tbb)
		{
		      timer =window.setTimeout(function() { blotab(hxx,cvv,tbb); },300);
		}
		
		function deltaba(hxx,cvv,tbb)
		{
			mouse = "out";
		 timer = window.setTimeout(function() { blotab(hxx,cvv,tbb); },300);
	 //window.setTimeout("fnHide2(" + oToHide.id + ")", 3000);
  	}
	 function blotab(hxx,cvv,tbb)
		{
		 if(mouse=="out" && click=="no")
			{
				var tabid = document.getElementById(tbb);
				tabid.style.display = "none";
				var hexid = document.getElementById(hxx);
				hexid.value="AA6600";
				var dispid = document.getElementById(cvv);
				dispid.style.backgroundColor="#AA6600";

			}
			
			if(mouse=="out" && click=="yes")
			{
				var tabid = document.getElementById(tbb);
				tabid.style.display = "none";
				var hexid = document.getElementById(hxx).value;
				var gg = hexid.substr(0,2);
				var rr = hexid.substr(2,2);
				var bb = hexid.substr(4,2);
				var hval=""+deciToHex(gg)+deciToHex(rr)+deciToHex(bb);
				var dispid = document.getElementById(cvv);
				dispid.style.backgroundColor="#"+hval;
			}
			
			
			if(mouse=="out" && click=="no" && ghex != "empty")
			{
				var tabid = document.getElementById(tbb);
				tabid.style.display = "none";
				var hexid = document.getElementById(hxx);
				hexid.value=ghex;
				var dispid = document.getElementById(cvv);
				dispid.style.backgroundColor="#"+ghex;
			
			}
		}
	






function reduce(ss,typ)
{
	rtimer = true;
	var docc = eval("document.xxx.v"+ss);
	df = docc.value;
	ty = ss;
	typa = typ;

	if(ty == 21)
		setTimeout('fonat()',30);
	else
		setTimeout('runner()',10);
}

function fonat()
{
	if(rtimer){
		if(typa == "up")
			df = parseInt(df)+1;
		else if(typa == "down")
			df = parseInt(df)-1;


		if(df < 25 && df > 0){
			var docc = eval("document.xxx.v"+ty);
			docc.value = df;
			setTimeout('fonat()',100);
		}
	}
	document.xxx.sd.style.fontSize = df;
}

function fontfa()
{
	var eds = document.xxx.r23.value;
	document.xxx.sd.style.fontFamily = eds;
		
}

function fonst()
{
	document.xxx.sd.style.fontWeight = "normal"; 
	document.xxx.sd.style.fontStyle = "normal"; 
	var eds = document.xxx.r22.value;
	if(eds == 2){
		document.xxx.sd.style.fontWeight = "bold"; }
	else if(eds == 3){
		document.xxx.sd.style.fontStyle = "italic"; }
	else if(eds == 4){
		document.xxx.sd.style.fontWeight = "bold";
		document.xxx.sd.style.fontStyle = "italic"; }
		
}

function runner()
{

	if(rtimer)
	{
		if(typa == "up")
			df = parseInt(df)+1;
		else if(typa == "down")
			df = parseInt(df)-1;

		if(df < 256 && df > 0)
		{
			var docc = eval("document.xxx.v"+ty);
			docc.value = df;
			setTimeout('runner()',20);
		}
	}
	
	if(ty == 11 || ty == 12 || ty == 13 ){
	var r = deciToHex(document.xxx.v11.value);
	var g = deciToHex(document.xxx.v12.value);
	var b = deciToHex(document.xxx.v13.value);
	//alert(r+"###"+g+"##"+b);
  
  var ssd = "#"+r+g+b;
	document.xxx.sd.style.color = ssd;
	document.xxx.v11.style.backgroundColor = "#"+r+"0000";
	document.xxx.v12.style.backgroundColor = "#00"+g+"00";
	document.xxx.v13.style.backgroundColor = "#0000"+b;
	document.xxx.v14.value = ssd;
	}
	else if(ty == 31 || ty == 32 || ty == 33 ){
	var r = deciToHex(document.xxx.v31.value);
	var g = deciToHex(document.xxx.v32.value);
	var b = deciToHex(document.xxx.v33.value);
	var ssd = "#"+r+g+b;
	var ssdd = document.getElementById("dum");
	//ssdd.setAttribute("bgcolor",ssd);
	ssdd.style.backgroundColor = ssd;
	document.xxx.v31.style.backgroundColor = "#"+r+"0000";
	document.xxx.v32.style.backgroundColor = "#00"+g+"00";
	document.xxx.v33.style.backgroundColor = "#0000"+b;
	document.xxx.v34.value = ssd;
	}
	else{
	var r = deciToHex(document.xxx.v1.value);
	var g = deciToHex(document.xxx.v2.value);
	var b = deciToHex(document.xxx.v3.value);
	var ssd = "#"+r+g+b;
	document.xxx.sd.style.backgroundColor = ssd;
	document.xxx.v1.style.backgroundColor = "#"+r+"0000";
	document.xxx.v2.style.backgroundColor = "#00"+g+"00";
	document.xxx.v3.style.backgroundColor = "#0000"+b;
	document.xxx.v4.value = ssd;
	}
}

function increase(df)
{
	if(df != 0)
	{
		df=df-1;
		document.xxx.sd.value = df;
		document.xxx.p1.onmousedown = reduce(df);
	}
}

function stop()
{
	rtimer=false;
}

function getHexNum(num)
{
	ar1 = new Array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15');
	ar2 = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
	if(num > 15){
		return num;
	}else	{
		red = ar2[num];
		return red;
	}
}


function deciToHex(arg)
{
	res2 = 999;
	args = arg;
	while(args>15){
		arg1=parseInt(args/16);
		arg2=args%16;
		arg2=getHexNum(arg2);
		args=arg1;

		if(res2 == 999){
			res2=arg2.toString();}
		else{
			res2=arg2.toString()+res2.toString();}
	}
	if(args<16 && res2 != 999){
		def = getHexNum(args);
		res2=def+res2.toString();
	}
	 else if(res2 == 999){
		if(args < 16)
			res2= getHexNum(args);
		else
			res2= 1;
	}

	if(res2.length == 1)
		  res2 = "0"+res2;

	return res2;
}

