function pac(url,w,h)
{
    var w = window.open(url, "win", "height="+ h +",width="+ w +",resizable=no,scrollbars=no,status");
}


function CheckCb(obj,who,cbdelname)
{
//Sipariş girişinde textboxın yada dropdownun değeri değişirse o satırın başındaki
//checkbox işaretlenir.

var cbname;
//if(obj.value!=0)
//{
cbname=obj.id.replace(who,cbdelname);
document.getElementById(cbname).checked=true;
document.getElementById(cbname).disabled=false;

//}
}
function SetDeleteChecked(obj)
{
//Silinmek üzere seçilmiş satırlar
var ara,HidSatir;
if(obj.value==0)return false; //Kayıtlı veri değilse.
ara=','+obj.value+',';//yazılacak değer
if(eval(obj).checked==true)//Delete checkbox seçili ise
{   
	HidSatir=eval(document.all('_ctl0:ContentPlaceHolder1:HidDelSatir'));//Güncelle gizli bilgi
	if (HidSatir.value.indexOf(ara,0)==-1)//yazılacak değer gizli bilgide yoksa
	{
		if (isBlank(HidSatir.value)){HidSatir.value=','};//gizli bilgi boşsa virgül konuyor
		HidSatir.value=HidSatir.value+obj.value+',';//gizli bilgiye değer ekleniyor
	}
}
else//checkboxın seçimi kaldırılırsa
{
HidSatir=eval(document.all('_ctl0:ContentPlaceHolder1:HidDelSatir'));//Güncelle gizli bilgi
if (HidSatir.value.indexOf(ara,0)>-1)//yazılacak değer gizli bilgide varsa
{
HidSatir.value=HidSatir.value.replace(ara,',');
}
}
}
function removeRowFromTable(tblName)
{
    var tbl = document.getElementById(tblName);
	var lastRow = tbl.rows.length;
	var Satir =document.all("_ctl0:ContentPlaceHolder1:hidRealSatir").value*1;
	if(lastRow>Satir+1)if (lastRow > 1) {tbl.deleteRow(lastRow - 1);
	document.all("_ctl0:ContentPlaceHolder1:hidSatir").value=Satir;}
}
/********************************/
function LenControl(Object,maxLength,txtsayac) 
{ 
    /*Gelen multiline kontrolün istenen uzunluğa kadar yazılabilmesini sağlar*/
    objectValue = Object.value;
    objectValueLength= objectValue.length;
    if (objectValueLength > maxLength ) Object.value=objectValue.substring(0,maxLength);
    document.all(txtsayac).value = (maxLength - Object.value.length);
    Object.focus(); 
}
/********************************************/
function CheckPage(maxCount,txtTool)
{   
	var PageNumber;
	var Check;
	if(document.all(txtTool).disabled==true) return false;
	PageNumber=document.all(txtTool).value;
	Check=false;
	if(PageNumber==''){
		alert('1 ile '+maxCount+' arasında bir sayı girmelisiniz!');
		document.all(txtTool).focus();
		Check=true;
	}
	if(PageNumber<1&&Check==false){
		alert('1 ile '+maxCount+' arasında bir sayı girmelisiniz!');
		document.all(txtTool).focus();
		Check=true;
	}
	if(PageNumber>maxCount&&Check==false){
		alert('1 ile '+maxCount+' arasında bir sayı girmelisiniz!');
		document.all(txtTool).focus();
		Check=true;
	}	
	if(Check==true)	return false;
	else return true;
}
/********************************************/	
function gundoldur(){
	var g_yil=document.forms[0].txtyil.value;
	var g_ay=document.forms[0].dday.options[document.forms[0].dday.selectedIndex].value;
	var gun = document.forms[0].ddgun.options[document.forms[0].ddgun.selectedIndex].value;
   if(g_ay=="01" || g_ay=="03" || g_ay=="05" || g_ay=="07" || g_ay=="08" || g_ay=="10" || g_ay=="12")
		g_ay=31;
   else if (g_ay=="04" || g_ay=="06" || g_ay=="09" || g_ay=="11")
	    g_ay=30;
   else if (g_yil % 4== 0)
	    g_ay=29;
   else g_ay=28;
   document.forms[0].ddgun.options.length=0;
   for(i=1;i<=g_ay;i++){	
	  var neway = document.createElement("OPTION")
	  if (i < 10) {
		  neway.text	= '0' + i;
		  neway.value = '0' + i;
	  } else {
	      neway.text= i;
		  neway.value = i;
	  }	
	 if(navigator.appName!="Netscape")	document.forms[0].ddgun.options.add(neway)
	 if(navigator.appName=="Netscape"){
		a = document.forms[0].ddgun.options.length;
		document.forms[0].ddgun.options.length = a + 1;
		document.forms[0].ddgun.options[a] = neway;
	  }										
    }
	document.forms[0].elements['ddgun'].selectedIndex = document.forms[0].ddgun.options.length-1;
	//document.forms[0].ddgun.selectedIndex = document.forms[0].ddgun.options.length-1;
	document.forms[0].ddgun.options[document.forms[0].ddgun.options.length-1].selected = true;
	if (document.forms[0].ddgun.options.length > gun)document.forms[0].ddgun.value = gun;
}
/********************************************/	
function show_calendar(strField){ 
  var t=parent.screenTop+parent.parent.screenTop-5;
  PencereAc('DatePicker.aspx?field=' + strField, 'calendarPopup', 220, 200,'no','no',self.screenLeft,t);
 }
/********************************************/	
function onlyCurrency(key)
{
    if(key==44)//, ise yes
	    event.returnValue = true;
    else if(key==46)//. ise no
	    event.returnValue = false; 
    else if (key<48 || key> 57) //sayı dışı ise no 
	    event.returnValue = false;
}
/********************************************/	
function onlympCurrency(key)
{
    if(key==45)//- ise yes
    	event.returnValue = true;
    else if(key==44)//, ise yes
	    event.returnValue = true;
    else if(key==46)//. ise no
	    event.returnValue = false; 
    else if (key<48 || key> 57) //sayı dışı ise no 
	    event.returnValue = false;
}
/********************************************/	
function karakterkontrol(code)
{
	//sadece karakter
    if(code==199||code==214||code==220||code==231||code==246||code==252||code==286||code==287||code==304||code==305||code==350||code==351)
    return true;
    if (code < 65)
		if (code!=32)
			return false;
	if (code >90){
		if(code<97)	return false;
		else if(code>122) return false;
	}
	return true;
}
//*****************************************    
function Checkvirgul(objvl,type)
{ 
    if(type==1) objvl=objvl.replace(',','.');
    else if(type==2) objvl=objvl.replace('.',',');
    else if(type==3) objvl=objvl.replace('.','');
    return 	objvl;
}
//****************************************
//*****************************************
function rnd(sayi,yuvarla)
{
  var carp=10;
  for(i=0;i<yuvarla-1;i++)
    carp=carp*10;
  var s=sayi;
  if (yuvarla>0) s=sayi*carp;
  s=Math.round(s)
  if (yuvarla>0) s=s/carp;    
  return s;
}
//****************************************
function CheckHane(objvl){//küsürat tek hane ise iki hane yapar.
	objvl=Checkvirgul(objvl,3);//.ları kaldır
   	objvl=Checkvirgul(objvl,2);//noktaları virgül yap.
   var virgul=objvl.indexOf(",",0);
   if(virgul!=-1)  {
     var son=objvl.substring(virgul+1,objvl.length);  
     if(son.length==1) return objvl+"0";
    }
 return objvl;
 }
  
 //*****************************************
function PencereAc(Pagestr,PageName,w,h,r,s,l,t){
	window.open(Pagestr,PageName,'toolbar=no, resizable='+r+', scrollbars='+s+',width=' + w + ', height='+ h +',left='+ l +',top='+ t);
}
/********************************************/	
function openModulDialog(url,dialogWidth,dialogHeight) {
	returnValue=window.showModalDialog(url, window,"dialogHeight: " + dialogHeight + "px; dialogWidth: " + dialogWidth + "px; center: yes; help: no; status: no;close:no;scroll:auto;")
}
/********************************************/
function openModulDialog2(url,dialogWidth,dialogHeight,l,t) {
	returnValue=window.showModalDialog(url, window,"dialogHeight: " + dialogHeight + "px; dialogWidth: " + dialogWidth + "px; center: yes; help: no; status: no;close:no,left="+ l +",top="+ t)
}
/********************************************/	

function urlEncode(str){
    str=escape(str);
    str=str.replace(new RegExp('\\+','g'),'%2B');
    return str.replace(new RegExp('%20','g'),'+');
}
/********************************************/	
function isBlank(obj)
{
    //Gelen nesnenin boş olma bilgisini gönderir.
    if(obj.length==0) return true;
    return false;
}
/********************************************/	
function GetCACode(obj,type)
{//Cari Code obj ckod type=1 koda göre <>1 ada göre sorgu
   openModulDialog2('../tools/GetCurrentAccount.aspx?type='+ type+'&obj='+ obj+'&deger=' +document.all(obj).value,425,500,400,0);
   return false;
}
/********************************************/	
function GetGruplar(obj,type)
{//Depo,işlem kodu
   openModulDialog2('../tools/GetGroups.aspx?type='+ type +'&obj='+ obj+'&kod=' +document.all(obj).value,425,500,400,0);
   return false;
}
/********************************************/	
function CheckBarkod(brkd,PLSFMT)
{
    //satış girişindeki Barkodu kontrol eder.
     if(brkd.substring(0,1) == PLSFMT)//plasiyer tanımına uyuyor ise
     {          brkd=brkd.replace(PLSFMT,'');
                document.all("txtPlasiyer").value=brkd ;
                document.all("txtBarkod").value="";
                return false;
     } 
 }
/********************************************/	
function isBarkodblank()
{   //satış girişinde barkod alanının dolu olmasını kontrol eder.
    if (isBlank(document.all("txtBarkod").value)==true) {
        alert("Barkod girişi yapmadınız!");
        document.all("txtBarkod").focus();
        return false;
     }
    return true;
}
/********************************************/	
function UrunSorgula(barcode)
{  
    if (barcode!=''){
        alert("Ürün bulunamadı!");    
        document.all("txtBarkod").focus();
    }
/*guloğlu için değiştirildi*/
    /*if (barcode!='') parent.document.all("TDFind").innerHTML ="<IFRAME id='frOrta' name='frOrta' marginWidth='0' marginHeight='0' src='../Tools/Find_Result.aspx?Barkod="+urlEncode(barcode)+"' frameBorder=0 noResize width='100%' height=465></IFRAME>";
    else{
        alert("Sorgulayacağınız Ürünün kodunu giriniz !");    
        document.all("txtBarkod").focus();
    }*/
    return false;
}
/********************************************/	
function zorunluBir(obj)
{
    if(obj.value=="0")  obj.value="1";
}
/********************************************/	
function blocking(nr)
{
	if (document.layers){
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all){
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById){
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}
/********************************************/	
function GetStockCode2(obj)
{
    //Stok kodu sorgulama ekranını açarType=AS&Afiyat=1&liste="+liste
      openModulDialog2('../tools/GetStocks.aspx?obj='+ obj +"&Type=AS&Afiyat=1&liste=1",425,500,400,0);
      return false;
}
/********************************************/
function checkTarih(who)
{
	if(who.value.length==2)
		who.value=who.value+'/';
	if(who.value.length==5)
		who.value=who.value+'/';
	who.focus();
	
}
/****Stok KArtını açar*/
function StokDetay(Kod,Adi)
{
    var t=event.y+parent.screenTop+parent.parent.screenTop-5;
    openModulDialog2('StokKarti.aspx?MKod='+Kod+'&MAdi='+Adi,500,500,self.screenLeft,t);		
}
/***Barkod Bulunamadı*/
function BarkodBulunamadi()
{
    alert('Barkod bulunamadı!');
    var obj=null;
    obj=document.all('txtBarkod');
    if(obj!=null){ 
        obj.focus();
        UrunSorgula();
    }else{
        window.close();
    }
}
function CallPrint(strid)
{
 var prtContent = document.getElementById(strid);
 var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
 WinPrint.document.write(prtContent.innerHTML);
 WinPrint.document.close();
 WinPrint.focus();
 WinPrint.print();
 WinPrint.close();
 prtContent.innerHTML=strOldOne;
}
