/*****************/
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(btnname,key)
{//Sayfada entera basılınca hangi butonun aktiflenceğini belirler.body onkeydown

	var Btn =null;
	Btn=document.all(btnname);
	if(key==13){
	if(Btn!=null) Btn.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 == '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 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 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 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 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;
}
/*****************menuackapa*/
function setSubMenu(i){

	    for(j=1;j<100;j++){
			if(j==i)continue;
			if(!document.getElementById("SubMenu"+j) || !document.getElementById("Menu"+j))continue;
			subMenu=document.getElementById("SubMenu"+j);
			subMenu.style.display="none";
			subMenu.style.visibility="hidden";
		}
			
		subMenu=document.getElementById("SubMenu"+i);
		if(subMenu.style.display==""){
		    subMenu.style.display="none";
			subMenu.style.visibility="hidden";
		}else{
			subMenu.style.display="";
			subMenu.style.visibility="visible";
		}
       	
	}

function checkLen(obj,ln){
		    if(obj.value.length<ln) return true
		    else return false;
}
function UrunAc(PID,lang){
    openModulDialog2("ProductDetail.aspx?PID=" + PID + "&lang=" + lang ,"Urun Detay",650,350);
    return false;
}
function KatalogAc(PID,Kod){
    openModulDialog2("ProductPicture.aspx?PID=" + PID +"R99&Kod=" +Kod ,"Katalog Resim",1200,855);
    return false;
}
function SetValue(pagename,objname,hidobjname,objIdvalue,objvalue,Kapat,btn)
{ 
   var wndw;
    if (window.dialogArguments) wndw = window.dialogArguments;
    wndw.document.all(pagename+hidobjname).value=objIdvalue;
    wndw.document.all(pagename+objname).value=objvalue;
      
    if(wndw.document.all(pagename+btn)) wndw.document.all(pagename+btn).click();
    if(Kapat==1) self.close();
}

var W3CDOM = (document.createElement && document.getElementsByTagName);
function initCss() {
	if (!W3CDOM) return;
    var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if ((x[i].type != 'image')&&(x[i].type != 'submit')) x[i].className = 'tool';
		
	}
}
function initOnClickSelect() {
	if (!W3CDOM) return;
    var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if ((x[i].type != 'image')&&(x[i].type != 'submit')){ 
		       x[i].onclick=function () { this.select(); };
		}
		
	}
}
function show_calendar(strField){ 
  var t=parent.screenTop+parent.parent.screenTop-5;
  NewWindow('Tools/DatePicker.aspx?field=' + strField, 'calendarPopup', 220, 200,0,0);
 }
 
function ListeKayitAc(Tipi){
    openModulDialog2('ModalListeYonetim.aspx?Tipi='+Tipi,'Liste Yönetimi',500,600);
    return false;
}