// VARIABLES

var mEditableContent="";
aDurumDefault = new Array()
aDurumDefault["menu"] = "none"
aDurumDefault["edit"] = "none"

aDurum = new Array()
aDurum["none"] = "block"
aDurum["block"] = "none"

aBranchID = new Array()
aBranchID["none"] = "branch_open"
aBranchID["block"] = "branch_close"

aImgName = new Array()
aImgName["block"] = "branch_open"
aImgName["none"] = "branch_close"

var objAktif = null

function SHMenu(ID){
    nIDLength = ID.length+3
    obj = document.getElementById(ID)
	oMenu = document.getElementById("menu")
	nMenuItemNo = oMenu.childNodes.length
    oOk = document.getElementById(obj.id.replace('MI','ok'))
    //alert(oOk)    
	for(i=0; i<nMenuItemNo; i++){
		objChild = oMenu.childNodes[i]
		if(objChild.nodeType==1){
			if(objChild.id.match('\\'+ID+'-')){
                oOkChild = document.getElementById(objChild.id.replace('MI','ok'))
                if(obj.durum=="block")
                    objChild.style.display = aDurum[obj.durum]
                else
                    if(objChild.id.length==nIDLength)
				        objChild.style.display = aDurum[obj.durum]
                SHMenuChangeImg(oOkChild,obj.durum)
                objChild.durum = obj.durum
			}
		}            
	}
    obj.durum = aDurum[obj.durum]
    SHMenuChangeImg(oOk,obj.durum)
}

function SHMenuFindActive(ID){
    fGetID('MI_'+ID).firstChild.firstChild.firstChild.lastChild.firstChild.className='F11 CTuruncu'
}

function SH(div,durum){
    fGetID(div).style.display = durum
}

function SHMenuChangeImg(obj,durum){
    if(obj)
        if(obj.src.search("shim")<1)
            obj.src="img/alan_sol/"+aImgName[durum]+".gif"        
}

var sKeysPressed = ""
function fKeyPress(){
	sKeysPressed += event.keyCode
}

function fAL(){
	//if(sKeysPressed == sKeys)
		window.open('_admin_login.php','adminlogin','width=100, height=195');
}


// FUNCTIONS
function fGetID(ID){
    return document.getElementById(ID)
}

function fOnOff(ID,sLang,obj,durum){
  obj.firstChild.src = 'img/menu_ana_'+sLang+'/'+ID+'_'+durum+'.gif'  
}

function fAltMenuOn(obj){  
  fGetID(obj).style.display = "block"
  objAktif = fGetID(obj)
}

function fAltMenuOff(obj){
  if(objAktif)
    objAktif.style.display = "none"
}

function Jump(sayfa,deger,obj){
    if(obj.options[obj.selectedIndex].value)
        eval("self.location='"+sayfa+"?"+deger+"="+obj.options[obj.selectedIndex].value+"'")
}

function 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 ShowHide(oDiv,id){
    oDiv = id ? FindObj(oDiv) : oDiv
    durum = oDiv.style.display
	oDiv.style.display = (durum == "none" || !durum) ? "block" : "none"
	return false;
}

function Dialog(sayfa,tablo,kolon,kriter,id,obj,width,height){
    sayfa = "edit/"+sayfa+".php?tablo="+tablo+"&kolon="+kolon+"&kriter="+kriter+"&id="+id
    params = "dialogWidth:"+width+"px;dialogHeight:"+height+"px;help:no;scroll:no;status:no"
    return_value = showModalDialog(sayfa,obj,params);
    return false
}

function DialogSimple(sayfa,obj,width,height){
    params = "dialogWidth:"+width+"px;dialogHeight:"+height+"px;help:no;scroll:no;status:no"
    return_value = showModalDialog("edit/"+sayfa+".php",obj,params);
    return false
}

function Focus(obj){
    prev_back = obj.parentNode.style.backgroundColor
    obj.parentNode.style.backgroundColor = "#FFCC00"
}

function Blur(obj){
    obj.parentNode.style.backgroundColor = prev_back
}

function fFocus(obj){    
    obj.style.backgroundColor = "#FFFFC0"
}

function fBlur(obj){
    obj.style.backgroundColor = "#FFFFFF"
}

function fSil(id,no,obj){
	if(confirm('Kaydı silmek istediğinizden eminmisiniz..!?')){
    	location.href='icliman.php?ID='+id+'&sil='+no
      obj.removeNode(true)
    }
    else
        return false;
}

function fSilCift(tablo,id,obj,kriter){
	if(confirm('Kaydı silmek istediğinden eminmisin..!?')){
        if(confirm('SON KARARIN..!?')){
    	    edit_frame.location.href='edit/single_sil.php?tablo='+tablo+'&kriter='+kriter+'&id='+id
            obj.removeNode(true)
        }
    }
    else
        return false;
}

function fSilResim(sDir,sFileName,obj,onPath){
	var onPath = onPath
    if(confirm('Resmi silmek istediğinizden emin misiniz?')){
        edit_frame.location.href=onPath+'edit/resim_sil.php?sDir='+sDir+'&sFileName='+sFileName
        obj.removeNode(true)
    }
    else
        return false;
}

function FlashGoster(file,w,h){
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+w+'" height="'+h+'">')
    document.write('<param name=movie value="'+file+'">')
    document.write('<param name=quality value=high>')
    document.write('<param name=wmode value=transparent>')
    document.write('<embed src="'+file+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" wmode=transparent>')
    document.write('</embed>')
    document.write('</object>')
}


function fToEditGenel(obj,sTable,sKolonValue,mKriter,sKolonKriter){
    mEditableContent = obj.innerText
    objParent = obj.parentNode
    objParent.innerHTML = "<span id=\"d_Editable\" contentEditable=true onBlur=\"fToUnEditGenel(this,'"+sTable+"','"+sKolonValue+"','"+mKriter+"','"+sKolonKriter+"')\">"+mEditableContent+"</span>"
    objParent.firstChild.focus()
}

function fToUnEditGenel(obj,sTable,sKolonValue,mKriter,sKolonKriter){    
    objParent = obj.parentNode
    mValue = obj.innerText
    mNewContent = (mEditableContent != mValue) ? mValue : mEditableContent
    if(mEditableContent != mValue)
        xajax_fxSingleEdit(sTable,sKolonValue,mValue,mKriter,sKolonKriter)    
    objParent.innerHTML = "<a href=\"#\" onClick=\"fToEditGenel(this,'"+sTable+"','"+sKolonValue+"','"+mKriter+"','"+sKolonKriter+"'); return false\" title=\"Değiştir\" class=\"AdmGenel AdmEdit\">"+mValue+"</a>"
}


// TREE
/*
function fOpenClose(ID,objSelf){
    obj = fGetID('d_'+ID)
    if(obj){
        durum = obj.style.display ? obj.style.display : "none"    
        obj.style.display = aDurum[durum]        
        objSelf.className=objSelf.className.replace(aDurum[durum],durum)
        objSelf.nextSibling.className=objSelf.nextSibling.className.replace(aDurum[durum],durum)
    }
}
*/