var ParseUrl="http://home.versatel.nl/michelsimons/mirror/CreativeColors";

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


function PrintHeader()
 {
 document.write('<span Class="SubHeader">Swatches collection: <font color="#FA833A">' + SwatchPalette + '</font></span><br>');
 }

function BuildTable()
 {
 var LastItem = colors.length;
 var IndexCounter = 1;
 document.write('<span class="smallindenttext">' + colors.length + ' creative colors for Photoshop and Illustrator</span>');
 document.write('<table border="0" cellpadding="0" cellspacing="20" width="100%">'); 
 for (var x = 0; x <= LastItem-1 ; x++)
  {
    if (IndexCounter == 1) {document.write('<tr>');}
	    
		 if (colors[x] != "FFFFFF")
		 {document.write ('<td width="40" height="40"><div style="width:40px; height:40px; background-color: #' + colors[x] + '; color: #' + colors[x] + '; border: solid 1px;">&nbsp;</div></td>');}
		 else
		 {document.write ('<td width="40" height="40"><div style="width:40px; height:40px; background-color: #' + colors[x] + '; color: #C8CCD0; border: dotted 1px;">&nbsp;</div></td>');}
        IndexCounter++;
		
	if  (IndexCounter == 11){document.write('</tr>'); IndexCounter = 1;}
        }
    while (IndexCounter != 11 && IndexCounter != 1)
        {
	    document.write ('<td width="40" height="40"><div style="width:40px; height:40px; background-color:#FFFFFF; color: #FFFFFF; border: solid 1px;">&nbsp;</div></td>');
        IndexCounter++;
	    }
    if  (IndexCounter == 11){document.write('</tr>'); IndexCounter = 1;}
        document.write('</table>');
        }
		
	
function DownloadParser(FileName)
 {
  var SwatchFile = replace(FileName,' ','%20');
  SwatchFile = replace(SwatchFile,'.','');
  SwatchFile = replace(SwatchFile,',','');
  SwatchFile = replace(SwatchFile,"'","");
  SwatchFile = replace(SwatchFile,'"','');
  var PhotoshopLink = '<a href="'+ParseUrl + '/photoshop/'+SwatchFile+'.aco" onMouseover="ddrivetip(\'Download Photoshop Swatches Palette.\')" onMouseout="hideddrivetip()">';
  var IllustratorLink = '<a href="'+ParseUrl + '/illustrator/'+SwatchFile+'.ai" onMouseover="ddrivetip(\'Download Illustrator Swatches Palette.\')" onMouseout="hideddrivetip()">';
  document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
  ColorChartPreLink = 'onclick="popitup(\'./colorchart.php?SwatchName= ' + SwatchFile + '&ChartColors=' + colors + '\',800,600, \'Plan view trees\'); return false;"';
  var ColorChartLink = '<a href=# ' + ColorChartPreLink + ' onMouseover="ddrivetip(\'View Swatches Palette Color Chart.\')" onMouseout="hideddrivetip()"> <img src="./images/colorchart.gif" border="0"></a>';
  document.write('<tr class="text"><td align="right" width="28">'+ColorChartLink);
  document.write('</td>');
  document.write('<td align="center">');
  document.write('<img src="/core/images/photoshop.gif"> ' + PhotoshopLink + SwatchPalette + '.aco</a>');
  document.write('</td>');
  document.write('<td align="center">');
  document.write('<img src="/core/images/illustrator.gif"> ' + IllustratorLink + SwatchPalette + '.ai</a>');
  document.write('</td>');
  document.write('</tr>');
  document.write('</table>');
  document.write('<br><hr style="height:1px";><br><br>');
 }		 

