//function setPageMode(modeType)
//{
//    if (modeType == 2)
//    {
//        return SetDeletePageMode(true);
//    }
//    
//    switch(modeType) 
//    {
//        case 0:
//            NewPageMode()
//            if (document.all['btnDel'] != null)
//            {
//                document.all['btnDel'].disabled = true;
//            }
//            if (document.all['btnEdit'] != null)
//            {
//                document.all['btnEdit'].disabled = true;
//            }
//            break;
//        case 1:
//            EditPageMode()
//            if (document.all['btnEdit'] != null)
//            {
//                document.all['btnEdit'].disabled = true;
//            }
//            break;
//    }
//    if (document.all['btnOk'] != null)
//    {
//        document.all['btnOk'].disabled = false;
//    }
//}

//function KeyCodeValidate(type)
//{
//	if (type == null) return;
//	var kc = event.keyCode;
//	
//	if ((kc == 27) || (kc == 13))
//		return;
//	//alert(kc);	
//	switch(type)
//	{
//		case "None"  : return;
//		case "Digit" :
//			if ((kc >= 48) && (kc <= 57))
//				return;
//				break;
//		case "Decimal" :
//			if (kc==46) 
//			{
//				if (event.srcElement.value.indexOf(".") == -1)
//					return;
//			}
//			else
//			{
//				if ((kc >= 48) && (kc <= 57))
//				{
//					var dotindx = event.srcElement.value.indexOf(".")
//					if (dotindx == -1)
//					{
//						return;
//					}
//					else
//					{
//						if (event.srcElement.value.substring(dotindx).length < 4)
//							return;
//					}	
//				}
//			}
//			break;
//	}
//	
//	event.keyCode = '';
//	return;
//}



//function SeTrimString(s)
//{
//    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
//    return (m == null) ? "" : m[1];
//}

//function GetElementValue(id) {
//    
//	var elm = document.all[id];
//    if (elm.tagName == "INPUT")
//    {
//		return elm.value;
//	}
//    if (elm.tagName == "SELECT")
//    {
//		if (elm.selectedIndex == -1) return "-1";
//		return elm.options[elm.selectedIndex].value;
//	}	
//}

//function ShowMessageBox(message,btnTypes,icon)
//{
//	var paramsDialog = new Object();
//	paramsDialog.Buttons = btnTypes;
//	paramsDialog.Message = message;
//	paramsDialog.Icon = icon;
//	return window.showModalDialog("../../msg.htm",paramsDialog,"dialogHeight: 250px; dialogWidth: 450px; center: Yes; help: No; resizable: No; status: No;scroll:no;");
//}

//function ViewPageMode()
//{
//    LockPageControls(true);
//    SetPageMode(-1);
//}

//function NewPageMode()
//{
//    clearPageControls();
//    LockPageControls(false);
//    SetPageMode(0);
//}

//function EditPageMode()
//{
//    LockPageControls(false);
//    SetPageMode(1);
//}

//function SetDeletePageMode(showMessage)
//{
//   if ((typeof(showMessage) == "undefined") || (showMessage == false))
//   {
//        SetPageMode(2);
//        return true;
//   }
//   
//   var btnCode = ShowMessageBox("آ يا از حذف اطلاعات اطمينان دار يد." , "2,3","0");
//   if (btnCode == "2")
//   {
//        SetPageMode(2);
//        return true;
//   }
//   else
//        return false;      
//}

//function clearPageControls()
//{
//    ClearTextBoxControls();
//    ClearSelectControls();
//}

//function LockPageControls(locked)
//{
//    LockTextBoxControls(locked);
//    LockSelectControls(locked);
//}

//function ClearTextBoxControls()
//{
//	var ctrls = document.all.tags("INPUT");
//	
//	for(ind = 0 ; ind < ctrls.length ; ind++)
//	{
//	    if(ctrls[ind].type == "text")
//	    {   
//	        var sedb = getSeTextBoxBySubElm(ctrls[ind]);
//	        if(sedb != null)
//	        {
//               sedb.SetText(""); 	    
//	        }
//	    }
//	}

//	ctrls = document.all.tags("TEXTAREA");
//	
//	for(ind = 0 ; ind < ctrls.length ; ind++)
//	{
//        var sedb = getSeTextBoxBySubElm(ctrls[ind]);
//        if(sedb != null)
//        {
//           sedb.SetText(""); 	    
//        }
//	}
//}

//function ClearSelectControls()
//{
//	var ctrls = document.all.tags("SELECT");
//	
//	for(ind = 0 ; ind < ctrls.length ; ind++)
//	{
//        var sedb = getSeTextBoxBySubElm(ctrls[ind]);
//        if(sedb != null)
//        {
//           sedb.SetText(""); 	    
//        }
//	}
//}

//function LockTextBoxControls(locked)
//{
//	var ctrls = document.all.tags("INPUT");
//	
//	for(ind = 0 ; ind < ctrls.length ; ind++)
//	{   
//	    if((ctrls[ind].type == "text") || (ctrls[ind].type == "password"))
//	    {   
//	        try{
//	            var sedb = getSeTextBoxBySubElm(ctrls[ind]);
//	            if((sedb != null) && (sedb.ReadOnly == "False"))
//	            {  
//                   sedb.SetReadOnly(locked); 	    
//	            }
//	        }
//	        catch(e){}
//	    }
//	}

//	ctrls = document.all.tags("TEXTAREA");
//	
//	for(ind = 0 ; ind < ctrls.length ; ind++)
//	{
//        var sedb = getSeTextBoxBySubElm(ctrls[ind]);
//        if((sedb != null) && (sedb.ReadOnly == "False" ) && (sedb.TextType != "LookUp"))
//        {  
//           sedb.SetReadOnly(locked); 	    
//        }
//	}

//}

//function LockSelectControls(locked)
//{
//	var ctrls = document.all.tags("Select");
//	
//	for(ind = 0 ; ind < ctrls.length ; ind++)
//	{
//        var sedb = getSeTextBoxBySubElm(ctrls[ind]);
//        if(sedb != null)
//        {
//           sedb.SetReadOnly(locked); 	    
//        }
//	}
//}

//function GetPageMode()
//{
//	if (document.all['hdnSePageMode'] != null)
//	{
//	    return parseInt(document.all['hdnSePageMode'].value);
//	}
//	else return 1;
//}

//function SetPageMode(mode)
//{
//	document.all['hdnSePageMode'].value = mode;
//}

//function GetSeGridCellValue(gridId,rowIndex,cellIndex)
//{
//    var segrd = document.all[gridId];
//    if(typeof(segrd) == "object")
//    {
//        return SeTrimString(segrd.rows[rowIndex].cells[cellIndex].innerText);
//    }
//    return null;
//}

//function GetSeGridSelectedIndex(gridId)
//{
//    var segrd = document.all[gridId];
//    if(typeof(segrd) == "object")
//    {
//        return parseInt(document.all[gridId+"_selIndx"].value);
//    }
//    return null;
//}




//function ShowWindow(isModal,UrlPage,ModalWith,ModalHeight)
//{
//    if (isModal)
//        return window.showModalDialog(UrlPage,"","dialogHeight: "+ModalHeight+"px; dialogWidth: "+ModalWith+"px; center: Yes; help: No; resizable: No; status: No;scroll:no;");
//}


//function windowKeyPressHndl()
//{
//    if (event.keyCode == 27)
//    {
//        if(typeof(window.parent) == "object")
//            window.close()
//    }

//    if (event.keyCode == 13)
//    {
//        try
//        {
//            var defbtn = eval('SeDefaultButton');
//            document.all[defbtn].click();
//        }
//        catch(e){}
//    }
//}

//function InitSePage()
//{

//    try
//    {
//        var defbtn = eval('SeDefaultButton');
//        document.all[defbtn].setActive();
//    }
//    catch(e){}
//}

//    var gridCntrl ='' ;
//    var gridCntrl1 = 0 ;
//    var callscroll = false
//    var sElem = '';
//    var sto = null;
//    function apllayScroll(segid)
//    {
//        if (callscroll == false)
//        {
//            callscroll = true
//            sElem = event.srcElement.componentFromPoint(
//                  event.clientX,
//                  event.clientY
//               );
//           sto = setTimeout("scrollIt('"+segid+"')", 5);
//        }
//    }
//    function scrollIt(segid)
//    {
//        callscroll = false;
//        clearTimeout(sto);
//            switch(SeTrimString(sElem.toString()))
//            {
//                case "scrollbarPageRight":
//                        document.all[segid+"_Clms"].doScroll("pageRight");
//                    break;
//                case "scrollbarRight":
//                        document.all[segid+"_Clms"].doScroll("scrollbarRight");
//                    break;
//                case "scrollbarPageLeft":
//                        document.all[segid+"_Clms"].doScroll("pageLeft");
//                    break;
//                case "scrollbarLeft":
//                    document.all[segid+"_Clms"].doScroll("scrollbarLeft");
//                    break;
//                case "scrollbarHThumb" :
//                    if (document.all['fff'].scrollLeft == 0)
//                    {
//                        document.all[segid+"_Clms"].doScroll("pageLeft");
//                    }
//                    else
//                    {
//                        document.all[segid+"_Clms"].doScroll("pageRight");
//                    }    
//                break;        
//            }
//    }

function ShowWindow(isModal,UrlPage,ModalWith,ModalHeight)
{
    if (isModal)
        return window.showModalDialog(UrlPage,"","dialogHeight: "+ModalHeight+"px; dialogWidth: "+ModalWith+"px; center: Yes; help: No; resizable: No; status: no; refresh: yes;scroll:no;");
    else 
        redirect(UrlPage);
}


function windowKeyPressHndl()
{
    if (event.keyCode == 27)
    {
        if(typeof(window.parent) == "object")
            window.close()
    }

    if (event.keyCode == 13)
    {
        try
        {
            var defbtn = eval('SeDefaultButton');
            document.all[defbtn].click();
        }
        catch(e){}
    }
}
