	
	
	var newWin_doc = null;
	var newWin = null;
	var returnObj = null;
	var returnType = 0;
		
	function trim(strText) { 
    	while (strText.substring(0,1) == ' ') 
        	strText = strText.substring(1, strText.length);
    	while (strText.substring(strText.length-1,strText.length) == ' ')
        	strText = strText.substring(0, strText.length-1);
   		return strText;
	} 
    
	function verifycolor() {
		string = newWin_doc.getElementById('ColorHex').value;
		if (string == "") {alert("Invalid color!!!"); return null;};
		
		string = string.replace(/#/,"");
		string = trim(string); 
		if (string.length != 6) {alert("Invalid color!!!"); return null;};
	  	stdstr = '0123456789abcdefABCDEF';
	
	  	for (i=0; i<string.length; i++) {
	    	chr = string.charAt(i);
	   		if (stdstr.indexOf(chr) == -1) {alert("Invalid color!!!"); return null;};
	  	}
	  	return string;
	}
	
	function customcolor(){
		str = verifycolor();
		if (str != null){preview(str)};
	}
	
	function preview(color) { 
		//alert("testing" + color);
  		newWin_doc.getElementById('ColorPreview').style.backgroundColor = '' + color;
  		newWin_doc.getElementById('ColorHex').value = '' + color;
	}
	
	function returncolor() { 
  		color = verifycolor();
  		if (color == null) {alert("Invalid color!!!");}
  		else {
			if (returnType == 0) {
    			document.getElementById(returnObj).value = '' + color.toUpperCase();
			} else if (returnType == 1) {
				document.getElementById(returnObj).style.backgroundColor = '#' + color.toUpperCase();
			} else {
				document.getElementById(returnObj).value = '#' + color.toUpperCase();
				document.getElementById(returnObj).style.backgroundColor = '#' + color.toUpperCase();
			}
    		newWin.close(); 
  		}
	}

	function init(){
		var count = 0;
		var rbg = new Array("00", "33","66", "99", "cc","ff");
		var color = "000000";
		newWin_doc.write("<table class=\"mytable\"><tr>");
		for (var i=0; i<rbg.length; i++){
			for (var j=0; j<3; j++){
    			for (var k=0; k<rbg.length; k++){
					color = rbg[j] + rbg[k] + rbg[i];
    				newWin_doc.write("<td onmouseover=\"window.opener.preview('" + color + "');\" onclick=\"window.opener.returncolor();\" width=8 height=11 bgcolor=" + color + "> </td>");
					count++;
					if ((count % 18) == 0) {
						newWin_doc.write("</tr><tr>");
					}
				}
			}    		
		}
		for (var i=0; i<rbg.length; i++){
			for (var j=3; j<rbg.length; j++){
    			for (var k=0; k<rbg.length; k++){
					color = rbg[j] + rbg[k] + rbg[i];
    				newWin_doc.write("<td onmouseover=\"window.opener.preview('" + color + "');\" onclick=\"window.opener.returncolor();\" width=8 height=11 bgcolor=" + color + "> </td>");
					count++;
					if ((count % 18) == 0) {
						newWin_doc.write("</tr><tr>");
					}
				}
			}    		
		}
		newWin_doc.write("</tr></table>");
	}
	
function show_color_dialog(returnVar, type) {
	returnType = 0;
	newWin = window.open("", "ColorPicker", "width=251,height=215,status=no,resizable=no, scrollbars=no,top=200,left=300");
	newWin.opener = self;
	newWin_doc = newWin.document;
	returnObj = returnVar;
	if (type) {returnType = type;}
	
	newWin_doc.writeln('<html>');
	newWin_doc.writeln('<head>');
		newWin_doc.writeln('<title>Select Color</title>');
		newWin_doc.writeln('<style type="text/css"><!--');
		newWin_doc.writeln('.mytable     {border: 0px solid buttonface; margin: 0; padding: 0; spacing: 1px;};');
		newWin_doc.writeln('--></style>');
	newWin_doc.writeln('</head>');
	
	newWin_doc.writeln('<body bgcolor="#000000" style="margin: 3px;">');
	newWin_doc.writeln('<table border=0 cellspacing=0 cellpadding=4 width=100%>');
	 	newWin_doc.writeln('<tr>');
	  		newWin_doc.writeln('<td style="background-color: buttonface;" valign=center><div style="background-color: #000000; padding: 1; height: 21px; width: 50px"><div id="ColorPreview" style="height: 100%; width: 100%"></div></div></td>');
	  		newWin_doc.writeln('<td style="background-color: buttonface;" valign=center><input type="text" id="ColorHex" value="#000000" size=4 style="font-size: 11px"></td>');
	  		newWin_doc.writeln('<td style="background-color: buttonface;" valign=center><button onclick="window.opener.customcolor();">Göster</button></td>');
	  		newWin_doc.writeln('<td style="background-color: buttonface;" valign=center><button onclick="window.opener.returncolor();">Tamam</button></td>');
	 		newWin_doc.writeln(' <td style="background-color: buttonface;" width=100%></td>');
		newWin_doc.writeln('</tr>');
	newWin_doc.writeln('</table>');
	
	newWin_doc.writeln('<table><tr>');
		newWin_doc.writeln('<td>');
			newWin_doc.writeln('<table>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'000000\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#000000"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'333333\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#333333"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'666666\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#666666"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'999999\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#999999"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'cccccc\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#cccccc"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'ffffff\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#ffffff"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'ff0000\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#ff0000"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'00ff00\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#00ff00"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'0000ff\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#0000ff"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'ff00ff\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#ff00ff"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'ffff00\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#ffff00"> </td></tr>');
				newWin_doc.writeln('<tr><td onmouseover="window.opener.preview(\'00ffff\');" onclick="window.opener.returncolor();" width=8 height=11 bgcolor="#00ffff"> </td></tr>');
			newWin_doc.writeln('</table>');
		newWin_doc.writeln('</td>');
		newWin_doc.writeln('<td>');
		
		
			init();
			
			
		newWin_doc.writeln('</td>');
	newWin_doc.writeln('</tr></table>');
	
	newWin_doc.writeln('<div align="right"><font size="-2" face="Verdana"><a target="_blank" href="http://www.ozendizayn.com"><font color="#ffffff">OzenDizayn Renk Paketi 3.7</font></a>&nbsp;&nbsp;</font></div>');
	newWin_doc.writeln('</body>');
	newWin_doc.writeln('</html>');

	if(navigator.appName != "Microsoft Internet Explorer")
  	{
		newWin_doc.close();
  	}
}