﻿
var mode = 1 

var FarsiCode   = new Array(63,1568,1569,1570,1571,1572,1573,109,104,102,1577,106,101,113,112,111,110,98,118,99,115,97,119,113,120,122,117,121,1595,1596,1597,1598,1599,1600,116,114,91,103,108,107,105,76,100,132,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1623,1625,1626,1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1643,1644,1645,1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,128,1663,1664,1665,1666,1667,1668,1669,125,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,124,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,39,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,100)
var EnglishCode = new Array(1711,40,41,42,43,1608,45,46,47,48,49,50,51,52,53,54,55,56,57,58,1603,60,61,62,1567,64,1588,1584,1586,1610,1579,1576,1604,1570,1607,1578,1606,1605,1574,1583,1582,1581,1590,1602,1587,1601,85,1585,1589,1591,1594,1592,1580,1688,1670,94,95,1662,1588,1584,1586,1610,1579,1576,1604,1575,1607,1578,1606,1605,1574,1583,1582,1581,1590,1602,1587,1601,1593,1585,1589,1591,1594,1592)

function SearchBox(o, m, ln)
	{
	
		var defText = new Array("جستجو", "Search");
		if(m==1)
		{
			if(o.value == defText[ln])
				o.value = "";
		}
		else if(m==2)
		{
			if(o.value == "")
				o.value = defText[ln];
		}
	}


function SetTitleMainForm(param)
{
	parent.parent.document.title = param;	
}

function CloseWindow()
{
  window.close();
}

function FarsiKeyDown(){
	if ( (window.event.altKey) && (window.event.keyCode == 120) ){
		if ( mode == 0 ){
			mode = 1 
			//window.defaultStatus="Farsi Mode"	
			document.geClassElementById("Top1_IMGLang").src = "/JBIS/Images/farsi.gif";
		}
		else{
		 	mode = 0 
			//window.defaultStatus="Normal Mode (English)" 
			document.geClassElementById("Top1_IMGLang").src = "/JBIS/Images/english.gif";
		}	
		window.event.returnValue = false 
	return
	} 
	window.event.returnValue = true 
}
	

function MakeFarsiKey(FarsiIt){
	if ( FarsiIt==1 )
	{
		if ( mode == 0 )
		{
			mode = 1;
			//window.defaultStatus="Farsi Mode"	
			document.geClassElementById("Top1_IMGLang").src = "/JBIS/Images/farsi.gif";
		}
	}
	else
	{
		if ( mode == 1 )
		{
		 	mode = 0;
			//window.defaultStatus="Normal Mode (English)" 
			document.geClassElementById("Top1_IMGLang").src = "/JBIS/Images/english.gif";
		}
	}	
	return;
}

function FarsiKeyPress(){
	var key 
	key = window.event.keyCode
	//alert(key);
	//if( key > 127  return
	if (key==46)
	{
		window.event.returnValue= true
		return;
	}
	if (mode == 1)  if((key>38)&&(key<123)) window.event.keyCode=EnglishCode[key-39];
	if ((mode == 1) && (key==1740) ) window.event.keyCode=1610;
	if ( mode == 0) if((key>1566)&&(key<1741))window.event.keyCode=FarsiCode[key-1567];     
	if ((mode == 0) && (key==1610)) window.event.keyCode=100;
	window.event.returnValue= true
//	alert(key+" "+window.event.keyCode);
}

function ImgTopClick(atd,aimg)
{
alert(500);

	//if (atd.style.display == "none")
	if (atd.style.visibility == "hidden")
	
	{
		atd.style.visibility = "visible";
		atd.style.display= "";
		
		aimg.src = "/JBIS/images/chevronUp.gif";
//		aimg.alt = "بستن";
	}
	else
	{
		atd.style.visibility = "hidden";
		atd.style.display= "none";
		aimg.src = "/JBIS/images/chevronDown.gif";
//		aimg.alt = "گشودن";
	}
}
//----------------------------------------------
function windowModal2(windowpath,w,h,obj)
{
	wr = window.showModalDialog(windowpath,obj,'help:no;dialogHeight:'+h+'pt;dialogWidth:'+w+'pt;center:yes;resizable:no;status:no;');
	//wr = window.open(windowpath);
	//win = window.open(windowpath);
	return wr;	
	//if (win==null)alert('بر روي كامپيوتر شما برنامه اي به نام Ad Blocker نصب است كه جلوي نمايش گزارش وضعيت را مي گيرد');

}

function windowModal4(windowpath,w,h,obj)
{
	wr = window.showModalDialog(windowpath,obj,'help:no;dialogHeight:'+h+'pt;dialogWidth:'+w+'pt;center:yes;resizable:yes;status:no;maximize:yes;minimize:yes;scrollbars:yes');
	//wr = window.open(windowpath);
	//win = window.open(windowpath);
	return wr;	
	//if (win==null)alert('بر روي كامپيوتر شما برنامه اي به نام Ad Blocker نصب است كه جلوي نمايش گزارش وضعيت را مي گيرد');

}
//----------------------------------------------
function windowModal2Maximize(windowpath,w,h,obj)
{
	wr = window.showModalDialog(windowpath,obj,'help:no;dialogHeight:'+h+'pt;dialogWidth:'+w+'pt;center:yes;resizable:yes;status:no;maximize:yes;minimize:yes;');
		return wr;	
	
}
//----------------------------------------------
function windowModal3(windowpath,w,h,obj)
{
	wr = window.showModalDialog(windowpath,obj,'help:no;dialogHeight:'+h+'pt;dialogWidth:'+w+'pt;center:yes;resizable:yes;status:no;');
	return wr;	


}
//----------------------------------------------
/*
var PrevSelect = -2;
function TableClick(i,j,grid)
{
		if (i==-1) return;
		if (PrevSelect != -2)
		{
			//grid.rows(PrevSelect).style.backgroundColor = '#ffffff';//'#fff7e7';
			//grid.rows(PrevSelect).style.color = '#003399';
			k = (PrevSelect % 2);
			
			if(k==0)grid.rows(PrevSelect).className = 'GridAlternating';
			else grid.rows(PrevSelect).className = 'GridItem';
			
		}
		PrevSelect = i+1;
		//grid.rows(i+1).style.backgroundColor = '#f5f5dc';
		//grid.rows(i+1).style.color = '#20b2aa';
		grid.rows(i+1).className = 'GridRowSelected';
		document.getElementById("Erorr1_SelectedRowId").value = grid.rows(PrevSelect).cells(0).innerText;
}

*/
function ForceFarsiNum()
{
	if ((window.event.keyCode >= 48) && (window.event.keyCode <=57))
	{
		window.event.keyCode = window.event.keyCode + 1728;
	}
	else if (window.event.keyCode == 46)
	{
	}
	else
	{
		window.event.keyCode = 0;
	}
}

function ForceFarsiNum1()
{
	if ((window.event.keyCode >= 48) && (window.event.keyCode <=57))
	{
		window.event.keyCode = window.event.keyCode + 1728;
	}
}

function ForceFarsiDate()
{
	if ((window.event.keyCode >= 48) && (window.event.keyCode <=57))
	{
		window.event.keyCode = window.event.keyCode + 1728;
	}
	else if ((window.event.keyCode == 47)) //  '/' char
	{
		//don't change key code
	}
	else
	{
		window.event.keyCode = 0;
	}
}
function ForceFarsiDate1()
{
	if ((window.event.keyCode >= 48) && (window.event.keyCode <=57))
	{
		window.event.keyCode = window.event.keyCode + 1728;
	}
	else if ((window.event.keyCode == 47)) //  '/' char
	{
		//don't change key code
	}
	else
	{
		window.event.keyCode = 0;
	}
}


function MakeEnglishDate(s)
{
	var s2="";
	for (i=0;i<s.length;i++)
	{
		c = s.charCodeAt(i);
		if ((c>=1776) && (c<=1785))
		{
			c = c - 1728;
		}
		
		s2 +=  String.fromCharCode(c);
	}
	return s2;
}

function MakeEnglishDate1(s)
{
	var s2="";
	for (i=0;i<s.length;i++)
	{
		c = s.charCodeAt(i);
		if ((c>=1776) && (c<=1785))
		{
			c = c - 1728;
		}
		
		s2 +=  String.fromCharCode(c);
	}
	return s2;
}

function MakeFarsiNum(s)
{
	var s2="";
	for (i=0;i<s.length;i++)
	{
		c = s.charCodeAt(i);
		if ((c>=48) && (c<=57))
		{
			c = c + 1728;
		}
		
		s2 +=  String.fromCharCode(c);
	}
	//alert(s2);
	return s2;
}

function MakeEnglishNum(s)
{
	return MakeEnglishDate(s);
}


function DateValidator(source, arguments)
{

	var s = MakeEnglishDate(arguments.Value);
//	var s = arguments.Value;
	//alert(s);
	if (s=="")
	{
		arguments.IsValid = true;
		return;
	}	
	
	var ss = s.split("/");
	//only 3 part
	
	if (ss.length != 3)
	{
		arguments.IsValid = false;
		return;
	}
	
	
	if ((ss[1].length>2) || (ss[2].length>2) || (ss[0].length > 4))
	{
		arguments.IsValid = false;
		return;
	}
	
	if (ss[0]=='08') ss[0]='8';
	if (ss[0]=='09') ss[0]='9';
	if (ss[1]=='08') ss[1]='8';
	if (ss[1]=='09') ss[1]='9';
	if (ss[2]=='08') ss[2]='8';
	if (ss[2]=='09') ss[2]='9';
	var dday = parseInt(ss[2]);
	var dmonth = parseInt(ss[1]);
	var dyear = parseInt(ss[0]);
	
	
	if ((isNaN(dday)) || (isNaN(dmonth)) || (isNaN(dyear)))
	{
		arguments.IsValid = false;
		return;
	}
	
	if (ss[0].length==3)
	{
		arguments.IsValid = false;
		return;
	}
	
	if (ss[0].length==4)
	{
		if ((dyear<1300) || (dyear>1490))
		{
			arguments.IsValid = false;
			return;
		}
	}
	
	if ((dmonth<1) || (dmonth>12))
	{
		arguments.IsValid = false;
		return;
	}

	
	if ((dday<1) || (dday>31))
	{
		arguments.IsValid = false;
		return;
	}
	

	if ((dmonth>=7) && (dmonth<=11))
	{
		if (dday > 30)
		{
			arguments.IsValid = false;
			return;
		}	
	}
	
		if (dmonth==12)
	{
		if (dday > 30)
		{
			arguments.IsValid = false;
			return;
		}	
	}
	
	arguments.IsValid = true;
	return;
}
/************************* OpenSearchForm *************************************************/
var winSearchResult

function OpenSearchForm(FormName){

	SearchWinName = FormName;

	winSearch = window.open("../SearchForms/"+FormName+".Aspx",'','scrollbars=yes,height=650,width=650,resizable=yes', false);
	//winSearch = window.open("SearchForms/SupplierSearchForm.aspx");
	winSearch.focus();
/*	
var param = new Object()
    param.caller = window;
	
	winSearchResult = window.showModalDialog("../SearchForms/"+FormName+".Aspx", param);
	alert("befor GetSelected");
	GetSelected();
	alert("after GetSelected");
*/	
}

function OpenSearchForm2(ButnName, FormName){

	SearchBtnName = ButnName;
	SearchWinName = FormName;
	winSearch = window.open("../SearchForms/"+FormName+".Aspx",'','scrollbars=yes,height=650,width=650,resizable=yes', false);
	winSearch.focus();
/*	
var param = new Object()
    param.caller = window;

	winSearchResult = window.showModalDialog("../SearchForms/"+FormName+".Aspx", param);
	alert("befor GetSelected");
	GetSelected();
	alert("after GetSelected");
*/
}
/************************* LIST BOX *************************************************/
function WriteOptionsToHiddenEdit(_objCBox, _objEditBox)
{
/*str = ""; 
if(_obj.length > 0) str = _obj.options[0].value;
for( i=1; i<_obj.length; i++)
	str += " , " +_obj.options[i].value;
document.geClassElementById("editChecks").value = str;
*/
	str = ""; 
	if(_objCBox.length > 0) str = _objCBox.options[0].value;
	for( i=1; i<_objCBox.length; i++)
		str += " , " +_objCBox.options[i].value; 
		
	_objEditBox.value = str;
}
//function AddOption(_obj, _text, _value){

	//_obj.length ++;
	//_obj.options[_obj.length - 1].text  = _text;	
	//_obj.options[_obj.length - 1].value = _value;
	
	//_obj.selectedIndex = _obj.length - 1;

//}
function DelOption(s){
	_obj= document.geClassElementById(s);
	index =	_obj.selectedIndex;
	if (index > -1)
	{
		_obj.options[index] = null;
	}
	
	if(_obj.length > 0)
	{	
		if( index - 1 >= 0 )
			_obj.selectedIndex = index-1;
		else 
			_obj.selectedIndex = 0;
	}
	
	//_obj.options[index].value = "null";
	//_obj.options[index].text = "null";
}

/**************************************************************************/
function CallParentSelected()
{
  window.opener.GetSelected();
/*  alert("CallParentSelected 1");
  dialogArguments.caller.GetSelected();
  dialogArguments.caller.document.geClassElementById("editProjectCode").value = "done"
  
  alert("CallParentSelected 2");
  
  var arrResult = new Array();
  arrResult[0] = document.geClassElementById("editResultId").value;
  arrResult[1] = document.geClassElementById("editResultName").value;  
  window.resultValue = arrResult;
  //window.close();
  */
}

function fillData(s)
{
	_valueId = winSearch.document.geClassElementById("editResultId").value;
	/////_valueId = winSearchResult[0];
	_valueText = winSearch.document.geClassElementById("editResultName").value;
	/////_valueText = winSearchResult[1];
	
 switch(s){
 	case "WebForm1" :{
		document.geClassElementById("T1").value = _valueId;
		document.geClassElementById("T2").value = _valueText;
		break;
			}
			
 	case "FinancialMailA" :{ 
			_objCBox   = document.geClassElementById("LBOXCheck");
			AddOption(_objCBox,MakeFarsiNum(_valueText),_valueId);
			
			_objEditBox = document.geClassElementById("editChecks");
			WriteOptionsToHiddenEdit(_objCBox, _objEditBox)
			break;
			}
 	case "FinancialMailB" :{ 
			_objCBox   = document.geClassElementById("LBOXCheck");
			AddOption(_objCBox,MakeFarsiNum(_valueText),_valueId);

			_objEditBox = document.geClassElementById("editChecks");
			WriteOptionsToHiddenEdit(_objCBox, _objEditBox)
			break;
			}			
			
 	case "SendTitle" :{
			_obj   = document.geClassElementById("LBOXPROJECTTITLE");
			AddOption(_obj,_valueText,_valueId);

			break;
			}
/*	case "IndContractFormProjectTitle" :{

		document.geClassElementById("editProjectId").value = _valueId;
		document.geClassElementById("editProjectTitle").value = _valueText;

		break;

			}
*//*	case "IndContractFormProposalCode" :{
		
		document.geClassElementById("editProposalId").value = _valueId;
		document.geClassElementById("editProposalCode").value = _valueText;
		break;

			}
*//*	case "IndContractFormResearcherCode" :{
		
		document.geClassElementById("editResearcherId").value = _valueId;
		document.geClassElementById("editResearcherCode").value = _valueText;
		break;

			}
*//*	case "IndContractFormSupplierCode" :{
		
		document.geClassElementById("editSupplierId").value = _valueId;
		document.geClassElementById("editSupplierCode").value = _valueText;
		break;

			}
*/
//
	case "ContractPhaseFormContractTitle" :{

		document.geClassElementById("editContractId").value = _valueId;
		document.geClassElementById("editContractTitle").value = _valueText;
		
		_objSource = winSearch.document.geClassElementById("cboxReportPhase");
		_objDestin = document.geClassElementById("cboxReportPhase");
		for(i=_objDestin.length-1; i>=0;i--)
			_objDestin.options[i] = null;
		AddOption(_objDestin, "", "0");
		for(j=0; j<_objSource.length; j++)
			AddOption(_objDestin, _objSource.options[j].text, _objSource.options[j].value);
			
		if(_objDestin.length > 0)
		{
			_objDestin.selectedIndex = 0;
			//document.geClassElementById("editContractPhaseId").value = _objDestin.value;
		}
//		else 
//			document.geClassElementById("editContractPhaseId").value = "0";

		break;}

	case "MailFormProjectTitle" :{
	
		document.geClassElementById("editProjectId").value = _valueId;
		document.geClassElementById("editProjectTitle").value = _valueText;

		break;}

	case "ProposalFormResearcherCode" :{

		document.geClassElementById("editResearcherId").value = _valueId;
		document.geClassElementById("editResearcherCode").value = _valueText;
		break;
	
	}
	case "RSContractFormResearcherCode" :{
		document.geClassElementById("editResearcherId").value = _valueId;
		document.geClassElementById("editResearcherCode").value = _valueText;
		break;

	}
	case "ProjectReportFormProjectTitle" :{
	
		document.geClassElementById("EditContractId").value = _valueId;
		document.geClassElementById("EditContractCode").value = _valueText;

		_objSource = winSearch.document.geClassElementById("cboxPhases");
		_objDestin = document.geClassElementById("cboxContractPhases");
		for(i=_objDestin.length-1; i>=0;i--)
			_objDestin.options[i] = null;
		AddOption(_objDestin, "", "0");
		for(j=0; j<_objSource.length; j++)
			AddOption(_objDestin, _objSource.options[j].text, _objSource.options[j].value);
			
		if(_objDestin.length > 0)
		{
			_objDestin.selectedIndex = 0;
			document.geClassElementById("editContractPhaseId").value = _objDestin.value;
		}
		else 
			document.geClassElementById("editContractPhaseId").value = "0";
		
		break;}
	case "GoodBillFormProjectTitle" :{

		document.geClassElementById("EditContractID").value = _valueId;
		document.geClassElementById("EditContractCode").value = _valueText;
		break;	
	
	}
	case "RevolvingFundFormProjectTitle" :{
	
		document.geClassElementById("EditContractID").value = _valueId;
		document.geClassElementById("EditContractCode").value = _valueText;
		break;	
	
	}
	case "RevolvingFundFormCheckCode" :{

		document.geClassElementById("EditCheckID").value = _valueId;
		document.geClassElementById("EditCheckCode").value = _valueText;
		break;	

	}
	case "ContractReportResearcherCode" :{
	
		document.geClassElementById("editResearcherId").value = _valueId;
		document.geClassElementById("editResearcherCode").value = _valueText;
		break;
	
	}

	case "ContractReportIndContResearcherCode" :{

		document.geClassElementById("editIndContResearcherId").value = _valueId;
		document.geClassElementById("editIndContResearcherCode").value = _valueText;
		break;
	
	}
	case "ContractReportIndContSupplierCode" :{
	
		document.geClassElementById("editIndContSupplierId").value = _valueId;
		document.geClassElementById("editIndContSupplierCode").value = _valueText;
		break;
	}
	case "ContractReportRSContSupplierCode" :{
	
		document.geClassElementById("editRSContResearcherId").value = _valueId;
		document.geClassElementById("editRSContResearcherCode").value = _valueText;
		break;
	}
	case "ContractReportProposalSupplierCode" :{
	
		document.geClassElementById("editPropResearcherId").value = _valueId;
		document.geClassElementById("editPropResearcherCode").value = _valueText;
		break;	
	}
	
	case "ContractReportOtherReport" : {
	
		document.geClassElementById("EditOtherProjID").value = _valueId;
		document.geClassElementById("EditOtherProjTitle").value = _valueText;
		break;		
	}
	
	case "AdminReportSuppliersSupplierCode" :{
	
		document.geClassElementById("editSupplierId").value = _valueId;
		document.geClassElementById("editSupplierCode").value = _valueText;
		break;	
	}
	case "FinnancialReportCheckPrjCode" :{
	
		document.geClassElementById("editCheckPrjId").value = _valueId;
		document.geClassElementById("editCheckPrjCode").value = _valueText;
		break;	
	}
	case "FinnancialReportInvCheckCheckCode" :{
	
		document.geClassElementById("EditInvCheckId").value = _valueId;
		document.geClassElementById("EditInvCheckCode").value = _valueText;
		break;	
	}
	case "FinnancialReportFinnMailAFinnMailACode" :{

		document.geClassElementById("EditFinnMailAId").value = _valueId;
		document.geClassElementById("EditFinnMailACode").value = _valueText;
		break;	
	}
	case "FinnancialReportFinnMailBFinnMailBCode" :{

		document.geClassElementById("EditFinMailBId").value = _valueId;
		document.geClassElementById("EditFinMailBCode").value = _valueText;
		break;	
	}
	case "FinnancialReportChkReciptMailBCode" :{

		document.geClassElementById("EditChkReciptMailBId").value = _valueId;
		document.geClassElementById("EditChkReciptMailBCode").value = _valueText;
		break;	
	}
	case "FinnancialReportChkReciptCheckCode" :{

		document.geClassElementById("EditChkReciptChkId").value = _valueId;
		document.geClassElementById("EditChkReciptChkCode").value = _valueText;
		break;	
	}
	case "FinnancialReportGoodBillPrjID" :{

		document.geClassElementById("EditGoodBillProjectId").value = _valueId;
		document.geClassElementById("EditGoodBillProjectCode").value = _valueText;
		break;	
  	}
	case "FinnancialReportRevolvFundPrjID" :{
	
		document.geClassElementById("EditRevolvProjectId").value = _valueId;
		document.geClassElementById("EditRevolvProjectCode").value = _valueText;
		break;	
	}
	case "FinnancialReportOtherProjID" :{
	
		document.geClassElementById("EditOtherProjId").value = _valueId;
		document.geClassElementById("EditOtherProjCode").value = _valueText;
		break;	
	}
	case "FinnancialReportOtherResearcherID" :{
		document.geClassElementById("EditOtherResearcherId").value = _valueId;
		document.geClassElementById("EditOtherResearcherCode").value = _valueText;
		break;	
	}
	case "ProposalFormProjectTitle" : {
		document.geClassElementById("editProjectId").value = _valueId;
		document.geClassElementById("editProjectTitle").value = _valueText;
		break;	
	}
	case "IndContractFormSupplierCode" :{
		document.geClassElementById("editSupplierId").value = _valueId;
		document.geClassElementById("editSupplierCode").value = _valueText;
		break;		
	}
	case "IndContractFormContractTitle" :{
		document.geClassElementById("editContractId").value = _valueId;
		document.geClassElementById("editContractTitle").value = _valueText;
		break;	
	}
	case "IndContractFormProjectCode" :{
		document.geClassElementById("editProjectId").value = _valueId;
		document.geClassElementById("editProjectCode").value = _valueText;
		_valueId1 = winSearch.document.geClassElementById("editSupplierId").value;
		_valueText1 = winSearch.document.geClassElementById("editSupplierName").value;
		document.geClassElementById("editSupplierId").value = _valueId1;
		document.geClassElementById("editSupplierCode").value = _valueText1;
		
		
		break;	
	}
	case "RSContractFormRSContractTitle":{ 
		document.geClassElementById("editRSContractId").value = _valueId;
		document.geClassElementById("editRSContractTitle").value = _valueText;
		break;	
	}
	case "RSContractFormProjectCode" :{
		document.geClassElementById("editProjectId").value = _valueId;
		document.geClassElementById("editProjectCode").value = _valueText;
		break;	
	}
	case "RSContractFormResearcherCode" :{
		document.geClassElementById("editResearcherId").value = _valueId;
		document.geClassElementById("editResearcherCode").value = _valueText;
		break;	
	}
	case "RSContractFormProposalRegCode" :{

		document.geClassElementById("editProposalId").value = _valueId;
		document.geClassElementById("editProposalCode").value = _valueText;
		break;	
	}
	case "ProjectFormSupplierCode" :{
	
		document.geClassElementById("editSupplierId").value = _valueId;
		document.geClassElementById("editSupplierName").value = _valueText;
		
		break;	
	}
	case "ProjectFormProposalId" :{
	
		document.geClassElementById("editSupplierId").value = _valueId;
		document.geClassElementById("editSupplierName").value = _valueText;
		
		break;	
	}
	case "IndContractFormProposalCode" :{
	
		document.geClassElementById("editProposalId").value = _valueId;
		document.geClassElementById("editProposalCode").value = _valueText;
		
		break;	
	}
	case "ContractFormContractCode" :{

		document.geClassElementById("editContractId").value = _valueId;
		document.geClassElementById("editContractTitle").value = _valueText;
		
		break;	
	}
	case "CheckInfoSearchFormIndContactId" :{

		document.geClassElementById("editContract_Id").value = _valueId;
		document.geClassElementById("EditContractTitle").value = _valueText;
		
		break;	
	}
	case "CheckInfoSearchFormResearcherId" :{

		document.geClassElementById("editResearcherId").value = _valueId;
		document.geClassElementById("EDITDARVACHEH").value = _valueText;
		break;	
	}
	case "ProposalSearchFormResearcherId" :{

		document.geClassElementById("editResearcherId").value = _valueId;
		document.geClassElementById("editResearcherCode").value = _valueText;
		break;	
	}
	case "ProposalSearchFormProjectId" :{

		document.geClassElementById("editProjectId").value = _valueId;
		document.geClassElementById("editProjectCode").value = _valueText;
		break;	
	}	
	case "CheckInfoFormResearcherId" :{
	
		document.geClassElementById("editDarVachehId").value = _valueId;
		document.geClassElementById("EDITDARVACHEH").value = _valueText;
		break;		
	}
	case "CheckInfoFormBankBranchId" :{
	
		document.geClassElementById("EDITBANKBranchNoId").value = _valueId;
		document.geClassElementById("EDITBANKBranchNo").value = _valueText;
		break;		
	}
	case "CheckInfoFormContractId" :{
	
		document.geClassElementById("EditContractID").value = _valueId;
		document.geClassElementById("EditContract_ID").value = _valueText;

		_objSource = winSearch.document.geClassElementById("cboxPhases");
		_objDestin = document.geClassElementById("cboxContractPhases");
		
		for(i=_objDestin.length-1; i>=0; i--)
			_objDestin.options[i] = null;

		AddOption(_objDestin, "", "0");
		for(j=0; j<_objSource.length; j++)
			AddOption(_objDestin, _objSource.options[j].text, _objSource.options[j].value);
		
		
		
		if(_objDestin.length > 0)
		{	
			_objDestin.selectedIndex = 0;
			document.geClassElementById("editContractPhaseId").value = _objDestin.value;
		}
		else 
		{
			document.geClassElementById("editContractPhaseId").value = "0";		
		}		
		break;		
	}
	case "InventoryFormCheckCode" :{
	
		document.geClassElementById("EditCheck_ID").value = _valueId;
		document.geClassElementById("EditCheckCode").value = _valueText;
		break;			
	}
	case "FinnancialFormCheckInfo" :{
	
		document.geClassElementById("EditCheck_ID").value = _valueId;
		document.geClassElementById("EditCheckCode").value = _valueText;
		break;				
	}
	case "ProjectGroupAddResearcher" :{
			_objCBox   = document.geClassElementById("lboxResearchers");
			AddOption(_objCBox,_valueText,_valueId);
			
			_objEditBox = document.geClassElementById("editResearchers");
			WriteOptionsToHiddenEdit(_objCBox, _objEditBox)
			break;
	}

	
  }
	winSearch.close();	
}

function KeyHandler()
{
	//alert("fgfgfg");
}

//-----------------------------------------------
function windowModal1(windowpath,w,h)
{
	wr = window.showModalDialog(windowpath,'','help:no;dialogHeight:'+h+'pt;dialogWidth:'+w+'pt;center:yes;resizable:yes;status:no;');
	
	return wr;	
}

//----------------------------------------------
var PrevSelect = -2;
function TableClick(i,j,grid)
{
		if (i==-1) return;
		if (PrevSelect != -2)
		{
			//grid.rows(PrevSelect).style.backgroundColor = '#ffffff';//'#fff7e7';
			//grid.rows(PrevSelect).style.color = '#003399';
			k = (PrevSelect % 2);
			
			if(k==0)grid.rows(PrevSelect).className = 'GridAlternating';
			else grid.rows(PrevSelect).className = 'GridItem';
			
		}
		PrevSelect = i+1;
		//grid.rows(i+1).style.backgroundColor = '#f5f5dc';
		//grid.rows(i+1).style.color = '#20b2aa';
		grid.rows(i+1).className = 'GridRowSelected';
		document.getElementById("Erorr1_SelectedRowId").value = grid.rows(PrevSelect).cells(0).innerText;
}

//client row click function
// gridName + SelectedRowId hidden field must be in page
var prevRowSelect = -2;
var SelectedRowIndex;

function RowClick(grid,row)
{
	var GridSize = document.all.DBNavigator1_txtGridSize.value;
	SelectedRowIndex = row;
	if (row==-1) return;
	if (prevRowSelect != -2)
	{
		k = (prevRowSelect % 2);
		
		if (k==0) grid.rows(prevRowSelect).className = 'GridAlternating';
		else grid.rows(prevRowSelect).className = 'GridItem';
	}
	prevRowSelect = row+1;
	grid.rows(row+1).className = 'GridRowSelected';
	document.getElementById(grid.id+"Serial").value = grid.rows(prevRowSelect).cells(0).innerText;
	// عدد 10 مساوي اندازه صفحه مي باشد
	//var index = (parseInt(document.all.DBNavigator1_lblCurrentPage.value) - 1) * 10;
	var index = (parseInt(document.all.DBNavigator1_lblCurrentPage.value) - 1) * GridSize;
	document.all.DBNavigator1_lblCurrentItem.value = (prevRowSelect + index);	
}

/*function RowClick3(grid,row)
{

	//var GridSize = document.all.txtGridSize.value;
	var GridSize = 10;
	SelectedRowIndex = row;
	if (row==-1) return;
	if (prevRowSelect != -2)
	{
		k = (prevRowSelect % 2);
		
		if (k==0) grid.rows(prevRowSelect).className = 'GridAlternating';
		else grid.rows(prevRowSelect).className = 'GridItem';
	}
	prevRowSelect = row+1;
	grid.rows(row+1).className = 'GridRowSelected';
	document.getElementById(grid.id+"Serial").value = grid.rows(prevRowSelect).cells(0).innerText;
	// عدد 10 مساوي اندازه صفحه مي باشد
	//var index = (parseInt(document.all.DBNavigator1_lblCurrentPage.value) - 1) * 10;
	var index = (parseInt(document.all.lblCurrentPage.value) - 1) * GridSize;
	document.all.lblCurrentItem.value = (prevRowSelect + index);	
}

function GridKeyUp3(grid,row)
{
	var key; 
	key = window.event.keyCode;
	if (key == 38)
	{
		if ( SelectedRowIndex > 0)	
			SelectedRowIndex = SelectedRowIndex -1;
		RowClick(grid, SelectedRowIndex);
	}
	else if (key == 40)
	{
		if ( SelectedRowIndex < document.all.DataGrid1.rows.length - 2)
			SelectedRowIndex = SelectedRowIndex + 1
		RowClick3(grid, SelectedRowIndex);	
	}
	
}*/

function RowClick2(grid,row)
{
// Use This Function For Detail Function
	SelectedRowIndex2 = row;
	if (row==-1) return;
	if (prevRowSelect != -2)
	{
		k = (prevRowSelect % 2);
		
		if (k==0) grid.rows(prevRowSelect).className = 'GridAlternating';
		else grid.rows(prevRowSelect).className = 'GridItem';
	}
	prevRowSelect = row+1;
	grid.rows(row+1).className = 'GridRowSelected';
	document.getElementById(grid.id+"Serial").value = grid.rows(prevRowSelect).cells(0).innerText;
}


function GridKeyUp(grid,row)
{
	var key; 
	key = window.event.keyCode;
	if (key == 38)
	{
		if ( SelectedRowIndex > 0)	
			SelectedRowIndex = SelectedRowIndex -1;
		RowClick(grid, SelectedRowIndex);
	}
	else if (key == 40)
	{
		if ( SelectedRowIndex < document.all.DataGrid1.rows.length - 2)
			SelectedRowIndex = SelectedRowIndex + 1
		RowClick(grid, SelectedRowIndex);	
	}
	
}
var SelectedRowIndex1;
function GridKeyUp1(grid,row)
{
	var key; 
	key = window.event.keyCode;
	if (key == 38)
	{
		if ( SelectedRowIndex1 > 0)	
			SelectedRowIndex1 = SelectedRowIndex1 -1;
		RowClick1(grid,SelectedRowIndex1);
	}
	else if (key == 40)
	{
		if ( SelectedRowIndex1 < document.all.DataGrid1.rows.length - 2)
			SelectedRowIndex1 = SelectedRowIndex1 + 1
		RowClick1(grid,SelectedRowIndex1);	
	}
}

var SelectedRowIndex2;
function GridKeyUp2(grid,row)
{
	var key; 
	key = window.event.keyCode;
	if (key == 38)
	{
		if ( SelectedRowIndex2 > 0)	
			SelectedRowIndex2 = SelectedRowIndex2 -1;
		RowClick2(grid,SelectedRowIndex2);
	}
	else if (key == 40)
	{
		if ( SelectedRowIndex2 <  document.getElementById(grid.id).rows.length - 2)
			SelectedRowIndex2 = SelectedRowIndex2 + 1
		RowClick2(grid,SelectedRowIndex2);	
	}
}

// عدم دسترسي به اطلاعات پرونده
function btnfrmMngrAccess_onclick() {
	Serial = document.all.ucFormManager1_txtDataSerial.value;
	obj = new Object();
	wr =  windowModal2('../DMS/PostAccessForm.aspx?FormName=FolderDataAccess&Serial='+Serial,600,400,obj);	
}


function navigatePage()
{
	var key 
	key = window.event.keyCode
	if (key!=13)
	{
		return true;
	}
	else 
	{
		__doPostBack('DBNavigator1$btnGo','')
		return false;
	}
}
function NavigateRow()
{
	var key 
	key = window.event.keyCode
	if (key!=13)
	{
		return true;
	}
	else 
	{
		__doPostBack('DBNavigator1$btnGoRow','')
		return false;
	}
}

function Print()
{
	window.print();
//	window.open('../DMS/DocumentResualtfrm.aspx?Serial=' + param,'','toolbar=yes,width=900,scrollbars=yes,resizable=yes,status=yes', false);      

}


function CheckReq(fname){
			if(document.getElementById(fname).value=='')
			{alert('لطفا اطلاعات مورد نیاز را تکمیل نمایید'); return false;}
			else return true;
		}
