var lock_min_ilk=5;//locklana islemleri için tanimlandi her lock sayfasinda tekrar deger atancak
//lock control scriptleri
//lock_min_ilk bu degisken header da tanimlandi 
var lock_sec = 00;   // set the seconds
var lock_min = lock_min_ilk;   // set the minutes

var time_max_lock_sayisi=5;
var time_lock_sayisi=1; 
var lock_timer; 
function LockCountDown(dgr) 
	{
		if(dgr){ lock_min=lock_min_ilk; lock_sec=00;  }
		  lock_sec--;
		  if (lock_sec == -01) {
			lock_sec = 59;
			lock_min = lock_min - 1;
		  } else {
		   lock_min = lock_min;
		  }
		if (lock_sec<=9) { lock_sec = "0" + lock_sec; }
		  time = (lock_min<=9 ? "0" + lock_min : lock_min) + " dk " + lock_sec + " sn ";
		$('#span_oto_kalan_sure').html(lock_sec + " sn ");
		  lock_timer=window.setTimeout("LockCountDown(0);", 1000);
		 
		if(lock_min=='00' && lock_sec=='15'){
			LockIslemiSor();
		}
		if(lock_min == '00' && lock_sec == '02') { 
			lock_sec = "00"; 
			LockDialogKapat();
			window.clearTimeout(lock_timer); 
		}
	}
function LockIslemiSor()
	{
		if(time_lock_sayisi>=time_max_lock_sayisi){
			msg_display_alert("Maksimum Veri Kilitleme Say&#305;s&#305;na Ula&#351;t&#305;n&#305;z S&uuml;reyi Daha Fazla Uzatamazs&#305;n&#305;z ");
			window.clearTimeout(lock_timer);
			return false;
		}
		loading_close();
		var lock_mn_=lock_min_ilk+1;
		$('#spn_lock_ilk_min').html(lock_mn_);
		$(function(){
		   $('#lock_dialog_sor').dialog({
			  autoOpen: false,
			  modal   :true,
			  width:500,
			  buttons : {
				"HAYIR" : function(){
						AjaxLockDialogNo();
						$(this).dialog("close");
			  },
			   "EVET" : function() {
					  AjaxLockDialogYes();
					  $(this).dialog("close");
				}
		   }
		  });
		});
	  $("#lock_dialog_sor").dialog( "option", "closeOnEscape", false );// ESC tusunu kapat
	  $('#lock_dialog_sor').dialog('open');
	  loading_close();
	  return true;
	}
function LockDialogKapat()
	{
		$('#lock_dialog_sor').dialog("close");
	}	
function AjaxLockDialogNo()
	{
		window.clearTimeout(lock_timer);
	}
//lock control sciptleri
function EnglishChar(e,no_space)
	{
		
		var nesne = e.target ? e.target : e.srcElement;
		
		var basilantus = e.charCode == undefined ? e.keyCode : e.charCode; 
		//alert(basilantus);
		var str = String.fromCharCode(basilantus);
		if(nesne.value==''&&basilantus==32){
			nesne.value=jQuery.trim(nesne.value);return false;
		}
		if(basilantus==0) return true;
		else if (basilantus == 105) { str = '\u0130';basilantus =105;}
		else if (basilantus == 39) {str = String.fromCharCode(96);basilantus =96;}
		if (no_space && basilantus==32)return false;
		if ((basilantus < 96 || basilantus > 122) && !isTRChar(basilantus)) return true; 
	
			switch(basilantus){
				case 231: case 199://ç,Ç					
					str = String.fromCharCode(67);
				break; case 246: case 214://ö, Ö
					str = String.fromCharCode(79);
				break; case 252: case 220://ü,Ü
					str = String.fromCharCode(85);
				break; case 287: case 286://g,G
					str = String.fromCharCode(71);
				break; case 105: case 304: case 305: //küçük i,büyük i,kücük I
					str = String.fromCharCode(73);
				break; case 351: case 350: //s,S
					str = String.fromCharCode(83);
				break;
			}			

		
		if(nesne.value.length==nesne.maxLength) return false;
		if (nesne.createTextRange) {			
			e.keyCode = str.toLowerCase().charCodeAt(0);
			return true; 
		} else { 
			var startpos = nesne.selectionStart;
			var endpos = nesne.selectionEnd; 			
			nesne.value = nesne.value.substr(0, startpos) + str.toLowerCase() + nesne.value.substr(endpos); 
			nesne.setSelectionRange(startpos + 1, startpos + 1);
			return false; 
		} 		
	}
function BuyukHarf(e,dil)  
	{		
		if(!dil) dil='tr';
		
		if(dil==2)dil='en';//ajax modalda kullanildi 
		
		var nesne = e.target ? e.target : e.srcElement;
		
		var basilantus = e.charCode == undefined ? e.keyCode : e.charCode; 
		//alert(basilantus);
		var str = String.fromCharCode(basilantus);
		if(nesne.value==''&&basilantus==32){
			nesne.value=jQuery.trim(nesne.value);return false;
		}
		if(basilantus==0) return true;
		else if (basilantus == 105) { str = '\u0130';basilantus =105;}
		else if (basilantus == 39) {str = String.fromCharCode(96);basilantus =96;}
		
		if ((basilantus < 96 || basilantus > 122) && !isTRChar(basilantus) && dil=='tr') return true; 
			
		if(dil=='en'){
			switch(basilantus){
				case 231: case 199://ç,Ç					
					str = String.fromCharCode(67);
				break; case 246: case 214://ö, Ö
					str = String.fromCharCode(79);
				break; case 252: case 220://ü,Ü
					str = String.fromCharCode(85);
				break; case 287: case 286://g,G
					str = String.fromCharCode(71);
				break; case 105: case 304: case 305: //küçük i,büyük i,kücük I
					str = String.fromCharCode(73);
				break; case 351: case 350: //s,S
					str = String.fromCharCode(83);
				break;
			}			
		}
		
		if(nesne.value.length==nesne.maxLength) return false;
		if (nesne.createTextRange) {			
			e.keyCode = str.toUpperCase().charCodeAt(0);
			return true; 
		} else { 
			var startpos = nesne.selectionStart;
			var endpos = nesne.selectionEnd; 			
			nesne.value = nesne.value.substr(0, startpos) + str.toUpperCase() + nesne.value.substr(endpos); 
			nesne.setSelectionRange(startpos + 1, startpos + 1);
			return false; 
		} 		
	}
function isTRChar(key) {var trchar = [231, 246, 252, 287, 305, 351]; for (var i = 0; i < trchar.length; i++) {if (trchar[i] == key) return true; } return false; }
function BuyukHarfBlur(e, clear) {var nesne = e.target ? e.target : e.srcElement; var val = nesne.value; val = val.replace(/i/g, "\u0130").replace(/^\s+|\s+$/g, ""); if (clear) val = val.replace(/\s{2,}/g, " "); nesne.value = val.toUpperCase(); } /** 
 * End BuyukHarf()
 */
 
function OnlYNumbers(idd) 
	{
		var tus=document.getElementById(idd).value;
		kk=tus.split("");
		new_val='';
		for(var i=0;i<tus.length;i++)
			for(var j=0;j<=9;j++)
			  if(kk[i]==j||kk[i]==',')if(!(i==0&&j==0))
			   new_val+=''+kk[i];
			new_val=parseInt(new_val,10);
			document.getElementById(idd).value=new_val;
	}

function displayError(formNode, validators)
	{
		var messageStr="";
		for(var i=0;i<validators.length;i++){
			messageStr='* '+validators[i].message;
		}		
		DisplayAlert('AlertBox',alertSize('Width')/2,alertSize('Height')/2,'&#304;&#350;LEM&#304;N&#304;Z GERÇEKLE&#350;MED&#304;! <br/><hr width=50%/><br/>'+messageStr,0);
	}
function yetki_uyari()
	{
		DisplayAlert('AlertBox',0,0,'YETKI UYARISI! <br/><hr width=50%/><br/>Bu mod&uuml;l&uuml; kullanma yetkiniz verilmemistir!',700);	
	}
function DisplayAlert(id,left,top,msg,timer) 
	{		
		loading_close();
		$('#'+id+'_msg').html(msg);   
		$("#"+id).dialog("open");
		if(timer>0){
			setTimeout(function(){
				$("#"+id).dialog("close");
			},timer);
		}
	}
function zeroPad(num,count)
{
	var numZeropad = num + '';
	while(numZeropad.length < count) {
		numZeropad = "0" + numZeropad;
	}
	return numZeropad;
}
function alertSize(type)
	{
		  /*
		  var myWidth = 0, myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		  }
		  */
		  if(type=="Width") return $(document).width(); else if(type=="Height") return $(document).height(); else return false;
	}
function MM_swapImgRestore() 
	{ //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
function MM_preloadImages() 
	{ //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

function MM_findObj(n, d) 
	{ //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

function MM_swapImage() 
	{ //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	} 
function OpenRequestedPopup(strUrl, strTarget,windowWidth,windowHeight)
  {
		  
		  var WindowObjectReferenceOfRequestedPopup, WindowObjectReferenceOfIntermediaryPopup;

		  var windowWidth, windowHeight, windowLeft, windowTop;
		
		  if(windowWidth>0 && windowHeight>0){
		  	windowTop=0;
			windowLeft=0;			
		  }else if(typeof window.screenX == "number" && typeof window.innerWidth == "number") {
			  windowWidth = window.innerWidth * .68;
			  windowHeight = window.innerHeight * .68;
			  windowLeft = window.screenX + window.innerWidth * .16;
			  windowTop = window.screenY + window.innerHeight * .16;
		  }else if(typeof window.screenTop == "number" && typeof document.documentElement.offsetHeight == "number") {
			  windowWidth = document.documentElement.offsetWidth * .68;
			  windowHeight = document.documentElement.offsetHeight * .68;
			  windowLeft = window.screenLeft + document.documentElement.offsetWidth * .16;
			  windowTop = window.screenTop - 50;
		  }else {
			  windowWidth = 500;
			  windowHeight = 250;
			  windowLeft = 60;
			  windowTop = 40;
		  };  /* The above code is just to define reasonable sizes and initial positions to the popup to be. */
		
		  if (WindowObjectReferenceOfRequestedPopup == null || WindowObjectReferenceOfRequestedPopup.closed)  {
				WindowObjectReferenceOfRequestedPopup = window.open(strUrl, strTarget, "top=" + windowTop + ",left=" + windowLeft + ",width=" + windowWidth + ",height=" + windowHeight + ",menubar=no,toolbar=no,location=no,resizable=no,scrollbars,status");
		  }else {
			    if(WindowObjectReferenceOfRequestedPopup.focus){
						WindowObjectReferenceOfRequestedPopup.focus();
				 };
		  };  /* The above 9 lines of code creates the popup; if the popup is already opened, then it is only brought on top. This feature is possible only if the user allows it via the setting Edit/Preferences.../category:Advanced/Scripts & Plugins/Allow webpages to:/Raise or lower windows  */
  		//ekleyen faust
		if (window.focus) {WindowObjectReferenceOfRequestedPopup.focus()}
  }
function date_time(browser)
 {
	if(browser=="Explorer"){
		var dateNow = new Date();
		var year = dateNow.getYear();
		var month = dateNow.getMonth() + 1;
		var date = dateNow.getDate();
		var saat = dateNow.getHours();
		var dk = dateNow.getMinutes();
		yearString = year;
		monthString = month;
		dateString = date;
		timeString= dk;
		if(year < 10)yearString = '0' + year.toString();
		if(month < 10)	monthString = '0' + month.toString();
		if(date < 10)dateString = '0' + date.toString();
		if(saat == 0) saat = 12;
		if(dk <= 9) dk = '0' + dk.toString();
		return dateString  +'/'+ monthString +'/'+ yearString+' '+saat+':'+dk;
	}else{
		var dateNow = new Date();
		var yil = 2000 + dateNow.getYear()%100;
		var ay = dateNow.getMonth()+1;
		var gun = dateNow.getDate();
		var saat = dateNow.getHours();
		var dk = dateNow.getMinutes();
		yearString = yil;
		monthString = ay;
		dateString = gun;
		if(year < 10)yearString = '0' + year.toString();
		if(month < 10)	monthString = '0' + month.toString();
		if(date < 10)dateString = '0' + date.toString();
		if(saat == 0) saat = 12;
		if(dk <= 9) dk = '0' + dk.toString();
		return dateString  +'/'+ monthString +'/'+ yearString+' '+saat+':'+dk;
	}
 }
function print_table(tableId,usrName,allContent)
  {
	loading_close();
	var tarih=' | &Ccedil;&#305;kt&#305; Tarihi: '+date_time(BrowserDetect.browser);

	var sayfa = window.open('','','width='+alertSize('Width')+',height='+alertSize('Height')/1.2+',menubar=no,toolbar=no,location=no,resizable=no,scrollbars,status');
	sayfa.document.open('text/html');
	sayfa.document.write('<HTML><HEAD>');
	sayfa.document.write('<META http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE8\" />');
	sayfa.document.write('<LINK href=\"css/styles_for_print.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen,print\"/>');	
	sayfa.document.write('<script type=\"text/javascript\" src=\"Scripts/jquery-1.4.4.min.js\"></script>');
	sayfa.document.write('<script language=\"javascript\">');
	sayfa.document.write('jQuery(document).ready(function($){$(\'button,input,select\').css({\'display\':\'none\'}); $(\'.pager\').css({\'display\':\'none\'});});');
	sayfa.document.write('window.onload = function(){window.print();};');
	sayfa.document.write('</script>');
	sayfa.document.write('<TITLE></TITLE>');
	sayfa.document.write('</HEAD><BODY class=\"body\">');
	var str = document.getElementById('print_box_'+tableId).innerHTML;		
	sayfa.document.write(str);	
	sayfa.document.write('</BODY></HTML>');	
	sayfa.document.close();
	//sayfa.document.getElementById(tableId).style.width='100%';
	if(!allContent && false){
		var theadCols=$('#'+tableId+'>thead>tr>th').length;
		var rowCount = $('#'+tableId+'>tbody>tr').length;
		var colCount = $('#'+tableId+'>tbody>tr>td').length;
		//kaç page break atilacak?
		var satir=49; //tek sayfaya kaç satir sigiyor?
		var pageBreaks = parseInt(parseFloat(rowCount,10)/satir,10);
		if(pageBreaks>0){
			for (var p=1;p<=pageBreaks;p++){				
				var row2 = tbl.insertRow(satir*p);
				row2.insertCell(0);
				row2.cells[0].colSpan=colCount;
				row2.cells[0].innerHTML='<div align="center" class="odd">'+p+' / '+(pageBreaks+1)+' | &Ccedil;&#305;kt&#305; Alan: '+usrName+tarih+'</div>';
				row2.style.pageBreakAfter='always';
				/***** Generate Header per page ******/
				var row1 = tbl.insertRow((satir*p)+1);
				for (var h=0;h<theadCols;h++){
					row1.insertCell(h);			
					row1.cells[h].innerHTML=thead.getElementsByTagName('TR')[0].getElementsByTagName('TH')[h].innerHTML.toUpperCase();
					row1.cells[h].className='Jsheader';
				}
				/*************************************/	
			}
		}else p=1;
		/**** En Son *****/
		if(p==(pageBreaks+1)) pbrkStr=''; else pbrkStr='page-break-after:always';
		var pbrkStr='<div align="center" class="odd" style="'+pbrkStr+'">Sayfa: '+(p)+' / '+(pageBreaks+1)+' | &Ccedil;&#305;kt&#305; Alan: '+usrName+tarih+'</div>';
		jQuery(document).ready(function($){
			$('#'+tableId+' > tbody').append('<tr><td colspan=\"'+colCount+'\">'+pbrkStr+'</td></tr>');
		});
		/*****************/
	}
	sayfa.print();
	//sayfa.close();
  }
function print_all(strid)
	{
		var prtContent = document.getElementById(strid);
		var WinPrint = window.open('','','width='+alertSize('Width')+',height='+alertSize('Height')/1.2+',menubar=no,toolbar=no,location=no,resizable=no,scrollbars,status');
		/*
		OpenRequestedPopup('', '',alertSize('Width'),alertSize('Height')/1.2);			
		*/
		WinPrint.document.open('text/html');
		WinPrint.document.write('<HTML><HEAD>');
		WinPrint.document.write('<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE8\" />');
		WinPrint.document.write('<link href=\"css/styles_for_print.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen,print\"/>');	
		WinPrint.document.write('<script type=\"text/javascript\" src=\"Scripts/jquery-1.4.4.min.js\"></script>');
		WinPrint.document.write('<script language=\"javascript\">');
		WinPrint.document.write('jQuery(document).ready(function($){$(\'button,input,select,.pager\').css(\'display\',\'none\');});');
		WinPrint.document.write('window.onload = function(){window.print();};');
		WinPrint.document.write('</script>');
		WinPrint.document.write('</script>');	
		WinPrint.document.write('<TITLE></TITLE>');
		WinPrint.document.write('</HEAD><BODY class=\"body\">');
		WinPrint.document.write(prtContent.innerHTML);
		WinPrint.document.write('</BODY></HTML>');
		WinPrint.document.close();
		WinPrint.print();
		
		//WinPrint.close();
	}
function aktar(isim,id,id2,id3)
	{
		var boxLength = document.getElementById(id3).length;
		var selectedItem = document.getElementById(id2).selectedIndex;
		var txt = document.getElementById(id2).options[selectedItem].text;
		var dgr = document.getElementById(id2).options[selectedItem].value;
		var i;
		var isNew = true;
		if (boxLength > 0) {
			for (i = 0; i < boxLength; i++) {
				thisitem = document.getElementById(id3).options[i].text;
				if (thisitem == txt) {
					isNew = false;
					break;
				}
			}
		} 
		if (isNew) {
			newoption = new Option(txt, dgr, false, false);
			document.getElementById(id3).options[boxLength] = newoption;
			document.getElementById(id).value += dgr+',';	
		}
	}
function tumunu_aktar(id1,id2,id3)
	{
		var len1=document.getElementById(id1).length;
		var len2=document.getElementById(id2).length;
		if(len2>0){//once olanlari hepsini silll
			for(i=len2;i>=0;i--){
				document.getElementById(id2).options[i] = null;
			}
			document.getElementById(id3).value='';//hidden de tutulani temizle
		}
		if(len1>0){//hepsini ekleee
			for(i=0;i<len1;i++){
				document.getElementById(id2).options[i]=new Option(document.getElementById(id1).options[i].text,document.getElementById(id1).options[i].value,false,false);
				document.getElementById(id3).value+=document.getElementById(id2).options[i].value+',';
			}
		}
	}
	
function tumunu_sil(id2,id3)
	{
		var len2=document.getElementById(id2).length;
		if(len2>0){//once olanlari hepsini silll
			for(i=len2;i>=0;i--){
				document.getElementById(id2).options[i] = null;
			}
			document.getElementById(id3).value='';//hidden de tutulani temizle
		}
	
	}
function sil(id3,id)
	{
		var boxLength = document.getElementById(id3).length;
		if(id!='') document.getElementById(id).value='';
		arrSelected = new Array();
		var count = 0,strValues='';
		for (i = 0; i < boxLength; i++) {
			if (document.getElementById(id3).options[i].selected) {
				arrSelected[count] = document.getElementById(id3).options[i].value;		
			}		
			count++;
		}
		
		var x;
		for (i = 0; i < boxLength; i++) {
			for (x = 0; x < arrSelected.length; x++) {
				if (document.getElementById(id3).options[i].value == arrSelected[x]) {
					document.getElementById(id3).options[i] = null;
				}						
			}
			boxLength = document.getElementById(id3).length;
		}
		
		
		count = 0;
		if (boxLength != 0) {
			for (i = 0; i < boxLength; i++) {
				if (count == 0) {
					strValues = document.getElementById(id3).options[i].value;
				}else {
					strValues += ','+document.getElementById(id3).options[i].value;
				}
				count++;
		   }
		}
		if(id!=''){
			if (strValues.length == 0) {
				return false;
			}else {
				document.getElementById(id).value=strValues+',';	
				return true;
			}
		}
	}
var BrowserDetect = {
		init: function () {
			this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
			this.version = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "an unknown version";
			this.OS = this.searchString(this.dataOS) || "an unknown OS";
		},
		searchString: function (data) {
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1)
						return data[i].identity;
				}
				else if (dataProp)
					return data[i].identity;
			}
		},
		searchVersion: function (dataString) {
			var index = dataString.indexOf(this.versionSearchString);
			if (index == -1) return;
			return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
		},
		dataBrowser: [
			{
				string: navigator.userAgent,
				subString: "Chrome",
				identity: "Chrome"
			},
			{ 	string: navigator.userAgent,
				subString: "OmniWeb",
				versionSearch: "OmniWeb/",
				identity: "OmniWeb"
			},
			{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari",
				versionSearch: "Version"
			},
			{
				prop: window.opera,
				identity: "Opera"
			},
			{
				string: navigator.vendor,
				subString: "iCab",
				identity: "iCab"
			},
			{
				string: navigator.vendor,
				subString: "KDE",
				identity: "Konqueror"
			},
			{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},
			{
				string: navigator.vendor,
				subString: "Camino",
				identity: "Camino"
			},
			{		// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"

			},
			{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},
			{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			},
			{ 		// for older Netscapes (4-)
				string: navigator.userAgent,
				subString: "Mozilla",
				identity: "Netscape",
				versionSearch: "Mozilla"
			}
		],
		dataOS : [
			{
				string: navigator.platform,
				subString: "Win",
				identity: "Windows"
			},
			{
				string: navigator.platform,
				subString: "Mac",
				identity: "Mac"
			},
			{
				   string: navigator.userAgent,
				   subString: "iPhone",
				   identity: "iPhone/iPod"
			},
			{
				string: navigator.platform,
				subString: "Linux",
				identity: "Linux"
			}
		]
	
};
BrowserDetect.init();

function pencere(sayfa,w,h,browser,toolbar) 
	{
		var tool="no";
		if(toolbar=="yes")
			tool="yes";
			
		loading_close();
		
		if(browser=="Explorer"){
			var heightspeed = 35;
			var widthspeed = 35;
			var leftdist = 0;
			var topdist = 0;
			if(w>0)	var winwidth = w - leftdist; else var winwidth = 500 - leftdist;
			if(h>0)	var winheight = h - topdist; else var winheight = 400 - topdist; 
			var sizer = window.open('','','left='+leftdist+',top='+topdist+',width='+winwidth+',height='+winheight+',scrollbars=yes, location=no, status=yes, toolbar='+tool+',menubar=no');
			sizer.location = sayfa;
		}else{			
			OpenRequestedPopup(sayfa, 'TargetRequestedPopupWindow' ,w, h,tool);
		}
	}
function submitter(url,targetS,wwidth,wheight)
	{
		document.form1.action=url;
		document.form1.target=targetS;
		document.form1.encoding='multipart/form-data';
		loading_close();
		document.form1.submit(targetS=window.open(url,targetS,'left='+alertSize('Width')/3+',top='+alertSize('Height')/3+',width='+wwidth+',height='+wheight+',menubar=no,toolbar=no,location=no,resizable=yes,scrollbars,status'));
		document.form1.action='';
		document.form1.target='';
	}
function parent_set(parentObjId,documentObjId)
	{
		loading_close();
		var onceki= window.opener.document.getElementById(parentObjId).value;
		var gelen= document.getElementById(documentObjId).value;
		var deger=gelen.toString().substr(0,gelen.length-1);


		window.opener.document.getElementById(parentObjId).value='';//----silll
		window.opener.document.getElementById(parentObjId).value=deger;
	
	}
	
function tc_no_kontrol(tc_id,msg_ek)
	{ 
		if(msg_ek=="")msg_ek='';
		if (document.getElementById(tc_id).value== ""){
			DisplayAlert('AlertBox',alertSize('Width')/3,alertSize('Height')/3,' L&uuml;tfen '+msg_ek+' T.C. No Giriniz');
			return false;
		}
		if (document.getElementById(tc_id).value!= ""){ 
			var tckimlikno; 
			tckimlikno = document.getElementById(tc_id).value;
				if ((tckimlikno!="") && (tckimlikno.length!=11)){ 
					DisplayAlert('AlertBox',alertSize('Width')/3,alertSize('Height')/3,msg_ek+' TC Kimlik Numaran&#305;z 11 haneli rakam olmal&#305;d&#305;r.');
					return false; 
				} 
			  if (tckimlikno!="") { 
				Tmp = Math.floor(parseInt(tckimlikno)/100); 
				Tmp1 = Math.floor(parseInt(tckimlikno)/100); 
				int1=parseInt(tckimlikno.substring(0, 1)); 
				int2=parseInt(tckimlikno.substring(1, 2)); 
				int3=parseInt(tckimlikno.substring(2, 3)); 
				int4=parseInt(tckimlikno.substring(3, 4)); 
				int5=parseInt(tckimlikno.substring(4, 5)); 
				int6=parseInt(tckimlikno.substring(5, 6)); 
				int7=parseInt(tckimlikno.substring(6, 7)); 
				int8=parseInt(tckimlikno.substring(7, 8)); 
				int9=parseInt(tckimlikno.substring(8, 9)); 
				odd_sum=int9+int7+int5+int3+int1; 
				even_sum=int8+int6+int4+int2; 
				total = odd_sum*3+even_sum; 
				ChkDigit1 = (10-(total % 10)) % 10; 
				odd_sum = ChkDigit1+int8+int6+int4+int2; 
				even_sum = int9+int7+int5+int3+int1; 
				total = odd_sum*3+even_sum; 
				ChkDigit2 = (10-(total % 10)) % 10; 
				Tmp=Tmp*100+ChkDigit1*10+ChkDigit2; 
				
					if (Tmp!=tckimlikno) { 
						DisplayAlert('AlertBox',alertSize('Width')/3,alertSize('Height')/3," Girmi&#351; Oldu&#287;unuz "+msg_ek+" T.C. Kimlik Numaras&#305; Yanl&#305;&#351; L&uuml;tfen Tekrar Giriniz"); 
						return false; 
					} 
			} 
		} 
	 return true;
	}
	
function tarih_sayi_cevir(deger)// dd/mm/yyyy ---- to yyyymmdd
	{
		var cevap=deger.substr(6,10)+""+deger.substr(3,2)+""+deger.substr(0,2);
		return cevap;
	}
function tarih_karsilastir(val,tarih2)//  dd/mm/yyyy tarihini bugunun tarihiyle kontrol etmek içinn tarih 2 varsa onunla karsilastirir
	{
		var deger1=parseInt(tarih_sayi_cevir(val),10);
		var tarih;
		if(tarih2==undefined) tarih=tarih_sayi_cevir(BuGuN_TaRihi);
		else tarih=tarih_sayi_cevir(tarih2);
		if(deger1<tarih ) return -1;// karsilastirilan tarih dun ve oncesii
		if(deger1==tarih) return 0; // karsilastirilan tarih bugun
		if(deger1>tarih ) return 1; // karsilastirilan tarih yarin ve sonrasi
	}
function tarih_uyum_kontrol(tarih)//  dd/mm/yyyy 
	{
		if(parseInt(tarih.length,10)==10){
			var val=tarih_sayi_cevir(tarih);// dd/mm/yyyy ----- to yyyymmdd
			var yil=parseInt(val.substr(0,4),10);
			var ay =parseInt(val.substr(4,2),10);
			var gun=parseInt(val.substr(6,2),10);
				if((ay==4 || ay==6 || ay==9 || ay==11) && !(gun>=1 && gun<=30)){
					// Gün Ve Ay Tarihleri Uyumsuz
					return 2; 
				}
				if(ay>12 || ay<1 ){
					// Ay De&#287;erini Kontrol ediniz
					return 3;
					}
				if(gun>31 || gun<1){
					//  Gün De&#287;erini Kontrol ediniz
					return 4; 
				}
				if(((yil%4)==0) && (ay==2) &&(gun>29) ){
					//  &#350;ubat Ay&#305; 30 dan Kü&ccedil;ük Olacak
					return 5; 
				}
				if(((yil%4)!=0) && (ay==2) &&(gun>28) ){
					//  &#350;ubat Ay&#305; 29 dan Kü&ccedil;ük Olacak
					return 6; 
				}
			return 1;//tarih dogru ve tam 
		}else{
			return 7;//girilen tarih eksik 
		}

	}
function span_cevap_islem(islem,check,idd)
	{
		if(islem){
			if(check){
				$(document).ready(function(){
				$("#"+idd).css({"background-image":"url('images/validyes.png')"});
										   });
			}else {
				$("#"+idd).css({"background-image":"url('images/validno.png')"});
			}
		}else{
			$("#"+idd).css({"background-image": "none"});	
		}
	}	
function min_max_filer(This,e)
	{
		return dFilter (e.keyCode, This, '########');
	}
function loading_close()
	{
		if($('#WaitBox').dialog('isOpen')){
			$('#WaitBox').dialog('close');
		}
	}
function loading_open()
	{   
		$('#WaitBox').dialog('open');
	}
function form_temizle(form) {
	  // iterate over all of the inputs for the form
	  // element that was passed in
	  $(':input', form).each(function() {
		 var type = this.type;
		 var tag = this.tagName.toLowerCase(); // normalize case
		 // it's ok to reset the value attr of text inputs,
		 // password inputs, and textareas
		 if (type == 'text' || type == 'password' || tag == 'textarea')
		   this.value = "";
		 // checkboxes and radios need to have their checked state cleared
		 // but should *not* have their 'value' changed
		 else if (type == 'checkbox' || type == 'radio')
		   this.checked = false;
		 // select elements need to have their 'selectedIndex' property set to -1
		 // (this works for both single and multiple select elements)
		 else if (tag == 'select')
		   this.selectedIndex = 0;
	  });
}
//spnra buraya headerda yaptigin degisiklikleri eklee 
function ajax_birey_valid_run()
	{
		$(document).ready(function(){
			$("input[type=text], textarea").each( function(){
				var islem=$(this).attr("jbirey");
				switch(islem){
					case 'rakam':
						$(this).format({precision: 0,autofix:true});
						break;
					case 'rakam ve sayim':
						$(this).format({precision: 0,autofix:true});
							var mx=$(this).attr("maxlength");
							span_id='span_counter_'+this.id;
							if(mx>0){
							 $(this).after("<span class='span-add-text-counter' id='"+span_id+"'></span>");
							 $(this).charCounter(mx,{format:'( %1 )',container: "#"+span_id});
							}
						break;
					case 'fiyat':
						$(this).format({precision: 2,decimal:',',autofix:true});
						break;
					case 'fiyat_3':
						$(this).format({precision: 3,decimal:',',autofix:true});
						break;
					case 'sayim':
							var mx=$(this).attr("maxlength");
							span_id='span_counter_'+this.id;
							if(mx>0){
							 $(this).after("<span class='span-add-text-counter' id='"+span_id+"'></span>");
							 $(this).charCounter(mx,{format:'( %1 )',container: "#"+span_id});
							}
						break;
				case 'tarih':
						 $(this).mask("99/99/9999");
				break;
				case 'datepick'://buraya daha sonra min max date ekleee 
					  $(this).datepick();
					  $(this).mask("99/99/9999");
				break;
				case 'telefon':
					   $(this).mask("(999) 999 99 99");
				break;
				case 'saat':
					   $(this).mask("99:99");
				break;
				}
			});
		});
	}
// not deger gelen sayi checkbox in jbirey_ degerini belirlemek için 
// yalnizca checkboxta var radio butonuna eklenmedi 
function check_radio_button(deger)//  bu fonksiyon değiştirildi bazı yerler çalışmayabilir çalışması için jbirey='check' eklenmesi gerekkkk  
	{
		var kontrol=parseInt(deger,10);
		if(isNaN(kontrol))kontrol=0;
	    $(document).ready(function(){
				
				$("input:radio").each(function() {
					var islem=$("#img"+this.id).attr("jbirey");
					if(kontrol==2)islem=$("#img"+this.id).attr("jbirey_2");
					if(kontrol==3)islem=$("#img"+this.id).attr("jbirey_3");
					if(kontrol==4)islem=$("#img"+this.id).attr("jbirey_4");
					if(islem=='check'){						   
						this.style.display='none';
						(this.checked) ? $("#img"+this.id).addClass('imgchecked') : $("#img"+this.id).removeClass('imgchecked');
					}
				});
				$("input:checkbox").each( function() {
					var islem=$("#img"+this.id).attr("jbirey");
					if(kontrol==2)islem=$("#img"+this.id).attr("jbirey_2");
					if(kontrol==3)islem=$("#img"+this.id).attr("jbirey_3");
					if(kontrol==4)islem=$("#img"+this.id).attr("jbirey_4");
					if(islem=='check'){
						this.style.display='none';
						(this.checked) ? $("#img"+this.id).addClass('imgchecked') : $("#img"+this.id).removeClass('imgchecked');
					}
				});
				
				// function to 'check' the fake ones and their matching checkboxes
				$(".imgcheck").click(function(){
					var islem=$(this).attr("jbirey");
					if(kontrol==2)islem=$(this).attr("jbirey_2");
					if(kontrol==3)islem=$(this).attr("jbirey_3");
					if(kontrol==4)islem=$(this).attr("jbirey_4");
					//	alert(islem);
					if(islem=='check'){
						var id=this.id.replace('img','');
						($(this).hasClass('imgchecked')) ? $(this).removeClass('imgchecked') : $(this).addClass('imgchecked');
						 if(!$("#"+id).is(':checked')) $("#"+id).attr("checked",true);else $("#"+id).attr("checked",false);
						$("#"+this.id.replace('img','')).trigger("click");
						 if(!$("#"+id).is(':checked')) $("#"+id).attr("checked",true);else $("#"+id).attr("checked",false);
					}
					return false;
				});
				
				$(".imgradiocheck").click(function(){	
					var islem=$(this).attr("jbirey");
					if(kontrol==2)islem=$(this).attr("jbirey_2");
					if(kontrol==3)islem=$(this).attr("jbirey_3");
					if(kontrol==4)islem=$(this).attr("jbirey_4");
					if(islem=='check'){
					   $('a.imgradiocheck.[title='+this.title+']').removeClass('imgchecked');
					   ($(this).hasClass('imgchecked')) ? $(this).removeClass('imgchecked') : $(this).addClass('imgchecked');
					   $("#"+this.id.replace('img','')).trigger("click");
					}
				   return false;
				});
		});
	}
function msg_display_alert(msg)
	{
		DisplayAlert('AlertBox',alertSize('Width')/3,alertSize('Height')/3,'&#304;&#350;LEM&#304;N&#304;Z GERK&Ccedil;EKLE&#350;MED&#304; ! <br/><hr width=50%/><br/>'+msg,0);
	}
function ajax_run_ogrenci_resim()
	{
		$(document).ready(function(){
			$('div.hariciLink').cluetip({width:'160px', cursor: 'pointer'});
		});
	}
function MyArrayList()
	{
		this.indis=0;
		this.data=new Array();
		this.init=function(){
			indis=0;
		}
		
		this.add=function(val){
			var k=0,j=0;
			for(var i in this.data)
				{
					if(val==this.data[i])k=1;
					j++;
				}
			if(k==0)this.data[j]=val;
		}
		this.remove=function(val){
			var temp=new Array();
			var j=0;

			for(var i in this.data)	
				{
					if(val!=this.data[i]){
						temp[j]=this.data[i];
						j++;
					}
				}
			this.data=temp;
		}
		this.removeAll=function(){
			var tmp=new Array();
			this.data=tmp;
		}
		this.get=function(){
			return this.data;
		}
		this.size=function(){
			this.data.length;
		}
	}
/**
*
*  Base64 encode / decode
*
**/
 
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
