﻿var chr_code = new Array(
	64830,64830,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,
	1570,1574,1575,1576,1578,1579,1580,1581,1582,1583,1584,1585,
	1586,1587,1588,1589,1590,1591,1592,1593,1594,1600,1601,1602,1603,
	1604,1605,1606,1607,1608,1609,1610,1662,1670,1688,1711,1740,
	64241,64242,64243,64244,1705
			);


function Achk(chr)
{
var flag=1;

for(var i=0;i<chr_code.length;++i)
   if (chr == chr_code[i])
       flag=0;

return flag;

}

function cor_bug_char(str)
{
var i,j;
var cnv_str="";
var code_str="";

for (i=0;i<str.length;++i)
{
if ((str.charCodeAt(i)==1610) || (str.charCodeAt(i)==1740))
{
	if (i==str.length-1)   
	cnv_str+="ی";
	else
	{
		if (Achk(str.charCodeAt(i+1)))
		cnv_str+="ی";
		else
		cnv_str+="ي";
	}
}
else  if ((str.charCodeAt(i)==64241) || (str.charCodeAt(i)==64242) || (str.charCodeAt(i)==64243) || (str.charCodeAt(i)==64244) || (str.charCodeAt(i)==1705) || (str.charCodeAt(i)==1603))
cnv_str+="ک";

else 
cnv_str+=str.charAt(i)
}

return cnv_str;
}

function gosearch()
{
	srt=document.all.form1.stext.value;
	if ( (document.all.form1.stext.value!="") && (document.all.form1.stext.value!=" ") && (CheckName(srt)) )
	{
		temp=cor_bug_char(document.all.form1.stext.value);
 		document.all.form1.stext.value=temp;
		document.all.form1.action="main.asp";
		document.all.form1.submit();
	}
	else
	{alert("Illegal Character[s]");}
}

function GO()
{
	srt=document.all.form1.stext.value;
	if ( (document.all.form1.stext.value!="") && (document.all.form1.stext.value!=" ") && (CheckName(srt)) )
	{
		temp=cor_bug_char(document.all.form1.stext.value);
 		document.all.form1.stext.value=temp;
		document.all.form1.action="main.asp";
		document.all.form1.submit();
	}
	else
	{alert("Illegal Character[s]");}
}

function CheckName(str) {
	var re;
	re = /["']/gi;
	if (re.test(str)) return false;	
	else 
	return true;
}
