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 urlEncode(str) {
    str = escape(str);
    str = str.replace(new RegExp('\\+', 'g'), '%2B');
    return str.replace(new RegExp('%20', 'g'), '+');
}
/*****************/
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 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;
}
/*****************/
/****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;
}
/*****************/
/*****************/
/*****************/
/*****************/
/*****************/
function NewWindow(mypage, myname, w, h, scroll,r) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+r;
    win = window.open(mypage, myname, winprops);
    if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
/*****************/
function checkKey(key)
{//Sayfada entera basılınca hangi butonun aktiflenceğini belirler.
	var Btn =null;
	Btn=document.all('btnNext');
	if(key==13){
	if(Btn!=null) document.all('btnNext').focus();}
}
/*****************/
function openModulDialog(WhichPage,Title,dialogWidth,dialogHeight,Scr) {
	url=WhichPage+'?Title='+Title+'&Scr='+Scr;
	returnValue=showModalDialog(url, window,"dialogHeight: " + dialogHeight + "px; dialogWidth: " + dialogWidth + "px;status:no;help:no;close:no;scroll:no");
}
/*****************/
function openModulDialog2(url,Title,dialogWidth,dialogHeight) {
	returnValue=showModalDialog(url, window,"dialogHeight: " + dialogHeight + "px; dialogWidth: " + dialogWidth + "px;status:no;help:no;close:no;scroll:no");
}
/*****************/
function openModulDialogwithScroll(url, Title, dialogWidth, dialogHeight) {
    returnValue = showModalDialog(url, window, "dialogHeight: " + dialogHeight + "px; dialogWidth: " + dialogWidth + "px;status:no;help:no;close:no;scroll:auto");
}
/*****************/				
function onlyNumeric(field)
{
    streng = field.value;
    newstreng = '';
    for (i = 0; i < streng.length; i++){
      thischar = field.value.substring(i, i+1)
      if (thischar == ',' || thischar == '1' || thischar == '2' || thischar == '3' || thischar == '4' || thischar == '5' || thischar == '6' || thischar == '7' || thischar == '8' || thischar == '9' || thischar == '0')
         newstreng = newstreng + streng.substring(i, i+1);
    }
    field.value = newstreng;
}
/*****************/
function SetBR(obj)
{
    if(event.keyCode==13)obj.value=obj.value+'vbCrLf';
}
/*****************/
function Sayi()
{
	if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;
}
/*****************/
function Karakter()
{
	if ((event.keyCode < 65 || event.keyCode > 90)&&(event.keyCode < 97 || event.keyCode > 122)&&(event.keyCode!=252)&&(event.keyCode!=305)&&(event.keyCode!=287)&&(event.keyCode!=351)&&(event.keyCode!=231)&&(event.keyCode!=246)&&(event.keyCode!=220)&&(event.keyCode!=304)&&(event.keyCode!=286)&&(event.keyCode!=350)&&(event.keyCode!=199)&&(event.keyCode!=214)) event.returnValue = false;
}
/*****************/
function zorunluBir(obj)
{
    if(obj.value=="0")  obj.value="1";
	
}
/*****************/
function ZeroAdetAlert(obj)
{
    if((obj.value=="0")){
        alert("Bu ürüne ait hiç adet belirtmediniz.!");
        obj.value="1";
    }
	
}
/*****************/
function SetDelete(obj,hidobj)
{
    //seçilmiş satırlar
    var ara,HidSatir;
    if(obj.value==0)return false;
    ara=','+obj.value+',';//yazılacak değer
    if(eval(obj).checked==true)//seçim mevcutsa 
    {
         HidSatir=eval(document.all(hidobj));//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(hidobj));//Güncelle gizli bilgi
        if (HidSatir.value.indexOf(ara,0)!=-1) HidSatir.value=HidSatir.value.replace(ara,',');
    }
}
/*****************/
function isBlank(obj)
{
    //Gelen nesnenin boş olma bilgisini gönderir.
    if(obj.length==0) return true;
    return false;
}
/*****************/
function HaberAc(NewsID) {
    //document.getElementById('divPasifEkran').style.display='block';
    openModulDialog2("ModalNews.aspx?ID=" + NewsID, "", 560, 400);
}