var orgData=null;
var orgClass=null;
function convertData(obj)
{
	if(obj.value>0)
	{
		backup();
	}
	if(obj.value==1)
	{
		convertTtf2ps();
	}
	else if(obj.value==2)
	{
		convertPs2ttf();
	}
	else if(obj.value==3)
	{
		convertTtf2ps();
		chanakya2unicode();
	}
	else if(obj.value==4)
	{
		convertTtf2ps();
		chanakya2unicode();
		unicode2krutidev();
		document.getElementById('data').className='krutiHindiFonts';
		document.getElementById('fontList').value='krutiHindiFonts';
	}
	else if(obj.value==5)
	{
		krutidev2unicode();
		unicode2chanakya();
		document.getElementById('data').className='chankyaHindiFont';
		document.getElementById('fontList').value='chankyaHindiFont';

	}
	else if(obj.value==6)
	{
		krutidev2unicode();
	}
	else if(obj.value==7)
	{
		unicode2chanakya();
		document.getElementById('data').className='chankyaHindiFont';
		document.getElementById('fontList').value='chankyaHindiFont';
	}
	else if(obj.value==8)
	{
		unicode2krutidev();
		document.getElementById('data').className='krutiHindiFonts';
		document.getElementById('fontList').value='krutiHindiFonts';
	}


}
function backup()
{
	if(orgData==null)
	{
		orgData=document.getElementById('data').value;
		document.getElementById('restoreLink').innerHTML="Restore";
	}
	if(orgClass==null)
	{
		orgClass=document.getElementById('data').className;
	}
}
function restore()
{
	if(orgData!=null)
	{
		document.getElementById('data').value=orgData;
		document.getElementById('restoreLink').innerHTML="";
		orgData=null;
	}
	if(orgClass!=null)
	{
		document.getElementById('data').className=orgClass;
		document.getElementById('fontList').value=orgClass;
		orgClass=null;
	}
	
}
function convertTtf2ps()
{
	backup();
	var str=document.getElementById('data').value;
	var output='';
	var lenght=str.length;
	
	for(var i=0;i<str.length;i++)
	{
		var ch=str[i];
		var chn=ch.charCodeAt(0);
		if(chn == 61569)
		{
			ch=String.fromCharCode(129);
		}
		else if(chn== 61581)
		{
				ch=String.fromCharCode(141);
		}
		else if(chn== 61583)
		{
			ch=String.fromCharCode(143);
		}
		else if(chn== 61584)
		{
				ch=String.fromCharCode(144);
		}
		output+=ch;
	}
	document.getElementById('data').value=output;
}

function convertPs2ttf()
{
	backup();
	var str=document.getElementById('data').value;
	var output='';
	var lenght=str.length;
	
	for(var i=0;i<str.length;i++)
	{
		var ch=str[i];
		var chn=ch.charCodeAt(0);
		if(chn == 129)
		{
			ch=String.fromCharCode(61569);
		}
		else if(chn== 141)
		{
				ch=String.fromCharCode(61581);
		}
		else if(chn== 143)
		{
			ch=String.fromCharCode(61583);
		}
		else if(chn== 144)
		{
				ch=String.fromCharCode(61584);
		}
		output+=ch;
	}
	document.getElementById('data').value=output;
}


//convert_Chanakya_to_Unicode() ;
//convert_Unicode_to_Krutidev010() ;
