// encryption and decryption
//Message Encrypter- By Naresh Hotchandani (nhotchandani@rediffmail.com)
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com for this script and more 

  len=0;
	
  function CalcKey()
	{
		len=0;
		//var temp=document.Encrypt.Key.value;
		var temp="slscorp";
		
		for(i=0;i<temp.length;i++)
		{
			len=len+temp.charCodeAt(i);
		}
		if(len==0)
		{
			alert('Please Enter the appropriate Key');
			//document.Encrypt.Key.focus();
		}
		return len;
	}

 function Encryption(text)
 {

	CalcKey();
	//document.Encrypt.Encrypted.value="";
	//var txt=document.Encrypt.normal.value;
	var txt = text.value;
	//alert(txt);
	var net="";
	var fin=0;
	
	if(len>0)
	{
	
		if(txt.length>0)
		{
			for(i=0;i<txt.length;i++)
			{
				fin=txt.charCodeAt(i)+len;
			
				if(fin>99)
				{
					net=net+fin;
				}
				else
				{
					net=net+'0'+fin;
				}
				}
			
			//document.Encrypt.Encrypted.value=net;
			//document.Encrypt.normal.value="";
			}
		else
		{
			//alert('Please Enter the Text to be Encrypted');
			//document.Encrypt.normal.focus();
		}
	
	}
	return net;
}

function Decryption(text)
{
	//var txt=document.Encrypt.Encrypted.value;
	var txt= text.toString();
	var j=3;
	var temp1;
	var res="";

	CalcKey();

	if(len>0)
	{
		if(txt.length>0)
		{
			for(i=0;i<txt.length;i+=3)
			{
				var temp=txt.substring(i,j);
				temp1=(parseInt(temp)-len);
				var t=unescape('%'+temp1.toString(16));
				if(t=='%d' || t=='%a')
				{
					res=res+' ';
				}
				else
				{
					res=res+t
				} 
				j+=3;
		   }
			//document.Encrypt.normal.value=res;
			//document.Encrypt.Encrypted.value="";
		}
		else
		{
			alert('Please Enter the Encrypted Text');
			//document.Encrypt.Encrypted.focus();
		}
	}
	return res;
}