function popup(a,n,b,c) {
yeni=window.open(a,n,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,dependent=no,resizable=yes,width="+b+",height="+c+",left=0,top=0");
if(navigator.appName == "Microsoft Internet Explorer" &&
  parseInt(navigator.appVersion) >= 4) {
      yeni.focus();
      } else {
      if(navigator.appName != "Microsoft Internet Explorer")
      yeni.focus(); }
}

function buyuk_resim(){
    var i;
    var indis = -1;
    var p ;
    var b;
    b = document.getElementById("URUN_IMG").src.split("/");
    p = b[b.length-1];
    for(i=0;i<=resimler.length-1;i++){
//        alert(resimler[i]+' '+p);
        if (resimler[i] != '' && p == resimler[i]){
            indis = i;
        }
    }
//    alert(indis);
    if (indis > -1 && bresimler[indis] != ''){
        popup('buyuk_resim.php?img=' + bresimler[indis],'BR',500,400);
    }
}
function submit_form(form_name, page, sortby)
    {
       document.getElementById("p").value = page;
       document.getElementById(form_name).submit();
    }
function renkler(gelen){
    if (gelen != ""){
        document.getElementById("URUN_IMG").src = "images/urun/" + resimler[gelen];
    }else{
        document.getElementById("URUN_IMG").src = "images/urun/" + "";
    }
    document.getElementById("RENK_ID").value = gelen;
}
function ekle(){
    upd = -1;
    if (!isNaN(document.frm_detail.SERI_ADET.value) && document.frm_detail.SERI_ADET.value != '' && document.frm_detail.SERI_ADET.value >0){
            for(i=0;i<=document.frm_detail.FRM_RENK.options.length-1;i++){
                if (document.frm_detail.RENK_ID.value == document.frm_detail.FRM_RENK.options[i].value && document.frm_detail.SERI.value == document.frm_detail.FRM_NUMARA.options[i].value){
                   upd = i; 
                }
            }
            if (upd > -1){
                adt = (Math.round(document.frm_detail.FRM_ADET.options[upd].value*100)/100) + (Math.round(document.frm_detail.SERI_ADET.value*100)/100);
                document.frm_detail.FRM_ADET.options[upd] = new Option(adt,adt);
            }else{
                document.frm_detail.FRM_RENK.options[document.frm_detail.FRM_RENK.options.length] = new Option(document.frm_detail.RENK_ID.options[document.frm_detail.RENK_ID.options.selectedIndex].text,document.frm_detail.RENK_ID.value);
                document.frm_detail.FRM_NUMARA.options[document.frm_detail.FRM_NUMARA.options.length] = new Option(document.frm_detail.SERI.options[document.frm_detail.SERI.options.selectedIndex].text,document.frm_detail.SERI.value);
                document.frm_detail.FRM_ADET.options[document.frm_detail.FRM_ADET.options.length] = new Option(document.frm_detail.SERI_ADET.value,document.frm_detail.SERI_ADET.value);
            }
            document.frm_detail.SERI.value = '';
            document.frm_detail.SERI_ADET.value = '';
    }
    for(s=0;s<=numaralar.length-1;s++){
            if (document.getElementById("CHK"+numaralar[s]).checked){
                upd = -1 ;
                for(i=0;i<=document.frm_detail.FRM_RENK.options.length-1;i++){
                    if (document.frm_detail.RENK_ID.value == document.frm_detail.FRM_RENK.options[i].value && document.getElementById("CHK"+numaralar[s]).value == document.frm_detail.FRM_NUMARA.options[i].value){
                       upd = i; 
                    }
                }
                if (document.getElementById("NUMARA_ADET"+numaralar[s]).value > 0){
                    if (upd > -1){
                        adt = (Math.round(document.frm_detail.FRM_ADET.options[upd].value*100)/100) + (Math.round(document.getElementById("NUMARA_ADET"+numaralar[s]).value*100)/100);
                        document.frm_detail.FRM_ADET.options[upd] = new Option(adt,adt);
                    }else{
                        document.frm_detail.FRM_RENK.options[document.frm_detail.FRM_RENK.options.length] = new Option(document.frm_detail.RENK_ID.options[document.frm_detail.RENK_ID.options.selectedIndex].text,document.frm_detail.RENK_ID.value);
                        document.frm_detail.FRM_NUMARA.options[document.frm_detail.FRM_NUMARA.options.length] = new Option(document.getElementById("CHK"+numaralar[s]).value,document.getElementById("CHK"+numaralar[s]).value);
                        document.frm_detail.FRM_ADET.options[document.frm_detail.FRM_ADET.options.length] = new Option(document.getElementById("NUMARA_ADET"+numaralar[s]).value,document.getElementById("NUMARA_ADET"+numaralar[s]).value);
                    }
                }
            }
    }
    for(s=0;s<=numaralar.length-1;s++){
        document.getElementById("CHK"+numaralar[s]).checked = false;
        document.getElementById("NUMARA_ADET"+numaralar[s]).value = '';
    }

}    
function sil(){
    if (document.frm_detail.FRM_RENK.options.selectedIndex == -1 && document.frm_detail.FRM_NUMARA.options.selectedIndex == -1 && document.frm_detail.FRM_ADET.options.selectedIndex == -1){
        alert("Lütfen silinecek satırı seçiniz.");
    }else{
        if (document.frm_detail.FRM_RENK.options.selectedIndex != -1){
            indx = document.frm_detail.FRM_RENK.options.selectedIndex;
        }else if (document.frm_detail.FRM_NUMARA.options.selectedIndex != -1){ 
            indx = document.frm_detail.FRM_NUMARA.options.selectedIndex;
        }else if (document.frm_detail.FRM_ADET.options.selectedIndex != -1){
            indx = document.frm_detail.FRM_ADET.options.selectedIndex;
        }
        document.frm_detail.FRM_RENK.options[indx] = null;
        document.frm_detail.FRM_NUMARA.options[indx] = null;
        document.frm_detail.FRM_ADET.options[indx] = null;
    }
}
function sbmt_sepet(){
    var virgul = "";
    if (document.frm_detail.FRM_RENK.options.length == 0){
        alert("Lütfen seçimlerinizi bildiriniz. Renk, Numara, Adet");
    }else{
            document.frm_detail.FRM_RENK_STR.value = '';
            document.frm_detail.FRM_NUMARA_STR.value = '';
            document.frm_detail.FRM_ADET_STR.value = '';
        for(i=0;i<=document.frm_detail.FRM_RENK.options.length-1;i++){
            //alert(document.frm_detail.FRM_RENK.options[i].value);
            document.frm_detail.FRM_RENK_STR.value = document.frm_detail.FRM_RENK_STR.value + virgul + document.frm_detail.FRM_RENK.options[i].value ;
            document.frm_detail.FRM_NUMARA_STR.value = document.frm_detail.FRM_NUMARA_STR.value + virgul + document.frm_detail.FRM_NUMARA.options[i].value ;
            document.frm_detail.FRM_ADET_STR.value = document.frm_detail.FRM_ADET_STR.value + virgul + document.frm_detail.FRM_ADET.options[i].value ;
            virgul = ",";
        }
        //alert(document.frm_detail.FRM_RENK_STR.value);
        document.frm_detail.submit();
    }
}
