        function getParameterValue(pname, url) {
            pname = pname.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + pname + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var value = regex.exec(url);
            return value;
          }        
        function OnNewClick(grid) {
            if (grid == null) return;
           grid.AddNewRow();
        }

        function OnEditClick(grid) {
            if (grid == null) return;
            var index = grid.GetFocusedRowIndex();
            grid.StartEditRow(index);
        }

        function OnSaveClick(grid) {
            if (grid == null) return;
            grid.UpdateEdit();                        
        }

        function OnCancelClick(grid) {
            if (grid == null) return;
            grid.CancelEdit();
        }

        function OnDeleteClick(grid) {
        	 if (confirm('Silmeye devam etmek istiyor musunuz')) {
        	 	 if (grid == null) return;
        	 	 var index = grid.GetFocusedRowIndex();
        	 	 grid.DeleteRow(index);
        	 }
        }
        function OnDeleteRow(grid, index) {
        	 if (confirm('Silmeye devam etmek istiyor musunuz')) {
        	 	 if (grid == null) return;        	 	 
        	 	 grid.DeleteRow(index);
        	 }
		  }
        function PopUpShow(ImgPopUp,url,img) {
            img.SetImageUrl(url);
            ImgPopUp.Show();
          }
        function buttonKontrol() {
          	 var kod = getParameterValue('kod', window.location.href);
          	 //var item = navBar.GetItemByName("delete");
          	 //item.SetEnabled(false);
          	 //var item1 = navBar.GetItemByName("update");
          	 //item1.SetEnabled(false);
          	 var url = window.location.href;
				 if (url.indexOf("Giris.aspx") == -1) {
				 	 if (kod != null) {
				 	 	 if (kod[1] != 27 && kod[1] != 25) {
				 	 	 	 document.getElementById('controlButtonPanel').style.visibility = 'visible';
				 	 	 	 document.getElementById('controlButtonPanel').style.display = 'block';
				 	 	 	 return;
				 	 	 }

				 	 }
          	 } 	 			 
          	 
          	 /*if (kod[1] == 43) {
          	 	 addBtn.SetEnabled(false);
          	 	 var item = navBar.GetItemByName("delete");
          	 	 item.SetEnabled(true);
          	 	 var item1 = navBar.GetItemByName("update");
          	 	 item1.SetEnabled(true);
          	 }	*/
          	 
        }
        function getGrid() {
          	 var kod = getParameterValue('kod', window.location.href);
          	 if (kod == null) return null;
          	 var obj = kodInfo(kod[1], true);
          	 return obj.grid;
        }
        function kodInfo(kod, isGrid) {
        	 if (kod == '11') return { grid: isGrid? firma : null, url: 'Firma' };
        	 if (kod == '12') return { grid: isGrid? haber : null, url: 'Haberler'};
        	 if (kod == '13') return { grid: isGrid? duyuru : null, url: 'Duyuru' };
        	 if (kod == '14') return { grid: isGrid? sss : null, url: 'Sss' };
        	 if (kod == '15') return { grid: isGrid? hakkimizda : null, url: 'FirmaAbout' };
        	 if (kod == '16') return { grid: isGrid? sozlesme : null, url: 'Sozlesmeler' };
        	 if (kod == '17') return { grid: isGrid? bayi : null, url: 'Bayiler' };
        	 if (kod == '18') return { grid: isGrid? sgrup : null, url: 'FirmaGruplari' };
        	 if (kod == '19') return { grid: isGrid? baslik : null, url: 'Baslik' };
        	 if (kod == '21') return { grid: isGrid? kategori: null, url: 'Kategoriler' };
        	 if (kod == '22') return { grid: isGrid? urunler : null, url: 'Urunler' };
        	 if (kod == '23') return { grid: isGrid? urunfiyat : null, url: 'UrunFiyat' };
        	 if (kod == '24') return { grid: isGrid? urungecmis : null, url: 'UrunGecmis' };
        	 if (kod == '25') return { grid: isGrid? urunyetki: null, url: 'UrunYetkileri'};
        	 if (kod == '26') return { grid: isGrid? urunOneri : null, url: 'UrunOneri' };
        	 if (kod == '27') return { grid: null, url: 'ReferansYukle' };
        	 if (kod == '28') return { grid: isGrid? referans : null, url: 'Referans' };
        	 if (kod == '29') return { grid: isGrid? urunyorum : null, url: 'UrunYorum' };
        	 if (kod == '31') return { grid: isGrid? iletisim : null, url: 'IletisimForm' };
        	 if (kod == '32') return { grid: isGrid? bankForm : null, url: 'BankaHesap' };
        	 if (kod == '33') return { grid: isGrid? bankIliski : null, url: 'HesapIliski' };
        	 if (kod == '34') return { grid: isGrid? iletForm : null, url: 'IletisimForm' };
        	 if (kod == '35') return { grid: isGrid? Ziyaretci : null, url: 'ZiyaretciDefteri' };
        	 if (kod == '41') return { grid: isGrid? forumanabaslik : null, url: 'FormAnaBaslik' };
        	 if (kod == '42') return { grid: isGrid? forumaltbaslik : null, url: 'FormAltBaslik' };
        	 if (kod == '43') return { grid: isGrid? kullanici:null , url: 'Kullanici' };
        	 return {grid: null, url: ''}    
		  }
