// Author: http://teenv.net 
// 11/06/2009
// Images from ...
	//<![CDATA[
		var baseFolder = 'icons/';
		var ymCode = new Array();		
		ymCode[1] = "X(";
		ymCode[2] = ":D";
		ymCode[3] = ':">';
		ymCode[4] = ":-/";
		ymCode[5] = "B-)";
		ymCode[6] = ">:)";
		ymCode[7] = ":)";
		ymCode[8] = ":-*";
		ymCode[9] = ":))";
		ymCode[10] = ":|";
		ymCode[11] = ":(";
		ymCode[12] = ":-&";
		ymCode[13] = ":->";
		ymCode[14] = ":-O";
		ymCode[15] = ":-?";
		ymCode[16] = ":P";
		ymCode[17] = ":((";
		ymCode[18] = ";)";
		ymCode[19] = ":-S";
		ymCode[20] = "(:|";


		createSelector = function(){			
			 for(i=1;i<ymCode.length;i++)
			 {			 		
				img = baseFolder+i+'.png';				
			   $('#iSelector').append("<a id=\'"+ymCode[i]+"\'><img src="+img+" alt=\'"+ymCode[i]+"\'/></a>");			 
			 }		
		};

		createWorkSpace = function(){

			preview = '<table><tr>';
			for(i=1;i<=95;i++)
			{			
				img = baseFolder+'4.png';

				preview += "<a id=\'"+ymCode[4]+"\'><img src="+img+" id='"+ymCode[4]+"'/></a>";	
				if (i % 19 == 0)
				{
					preview += "</tr><tr>";
				}

			}
			preview += '</tr></table>';			
			$('#workPreview').html(preview);
			$('#selectedIcon').html("<a id=\'"+ymCode[i]+"\'><img src="+img+" id='"+ymCode[4]+"'/></a>");

		};

		createBgSelector	= function(){
			 for(i=1;i<ymCode.length;i++)
			 {			 		
				img = baseFolder+i+'.png';				
			   $('#bgSelector').append("<a id=\'"+ymCode[i]+"\'><img src="+img+" alt=\'"+i+"\'/></a>");			 
			 }		

		};

		selectIcon = function(){
			$('#iSelector a').click(function() {			  
			  //alert(this.id);
			  txt = $(this).html();			  
			  $('#selectedIcon').html("<a id=\'"+this.id+"\'>"+txt+"</a>");
			});		
		};

		changeIcon = function(){
			$('#workPreview a').click(function() {
				iconId = $('#selectedIcon a').attr('id');

			  $(this).attr('id',iconId);
			  $(this).html($('#selectedIcon a').html());		

			});	

		};		
		changeBg	= function(imgId){	

				preview = '<table><tr>';
				img = baseFolder+imgId+'.png';
				for(i=1;i<=95;i++)
				{					
					preview += "<a id='"+ymCode[imgId]+"'><img src="+img+" alt=\'"+ymCode[imgId]+"\'/></a>";	
					if (i % 19 == 0)
					{
						preview += "</tr><tr>";
					}	
				}
				preview += '</tr></table>';				
				$('#workPreview').html(preview);	
				changeIcon();	

		};
		createCode	= function(){
			//alert('start createCode');
			var txt = '';


			$("#workPreview a").each(function() {
				//alert(this.id);				
				txt += this.id;
			});

			$('#displayCode').html('<textarea>'+txt+'</textarea>');
		};
		$(document).ready(function() {

			createSelector();
			createBgSelector();
			selectIcon();
			createWorkSpace();
			changeIcon();
			$('#bgSelector img').click(function() {	
				Id = $(this).attr("alt");				
				changeBg(Id);
			});			
			$('#submit').click(function() {
				createCode();
			});
			

		});
		//]]>