/*
  var ulkeObj = $g('op_ulke_' + cid);
  if(typeof ulkeObj == 'object')
  {
    MIT.EVNT.add(ulkeObj, 'change', function(){loadProvinceOptions(this.value, cid);})
    */
function loadCountryOptions(id, pid, tid, did, txt)
{
  txt = typeof(txt) == 'string' ? txt : '-- seçiniz --';
  if($g('op_il_' + pid) != null)
  {
    MIT.EVNT.add($g('op_ulke_' + id), 'change', function(){loadProvinceOptions(this.value, pid, tid, did, txt);});
    $g('op_il_' + pid).innerHTML = '';
  }
  if($g('op_ilce_' + tid) != null)
  {
    $g('op_ilce_' + tid).innerHTML = '';
  }
  if($g('op_semt_' + did) != null)
  {
    $g('op_semt_' + did).innerHTML = '';
  }
  selectText('op_ulke_' + id, 'Yükleniyor...');
  MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=getcountry&txt=' + txt, onLoadParam:'op_ulke_' + id, onLoad:initSelectLoaded});
}

function loadProvinceOptions(cid, id, tid, did, txt)
{
  txt = typeof(txt) == 'string' ? txt : '-- seçiniz --';
  if($g('op_ilce_' + tid) != null)
  {
    MIT.EVNT.add($g('op_il_' + id), 'change', function(){loadTownOptions(this.value, tid, did, txt);});
  }
  if(cid)
  {
    selectText('op_il_' + id, 'Yükleniyor...');
    if($g('op_ilce_' + tid) != null)
    {
      $g('op_ilce_' + tid).innerHTML = '';
    }
    if($g('op_semt_' + did) != null)
    {
      $g('op_semt_' + did).innerHTML = '';
    }
    MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=getprovince&cid=' + cid + '&txt=' + txt, onLoadParam:'op_il_' + id, onLoad:initSelectLoaded});
  }
}

function loadProvinceOptionsAndSelect(cid, id, tid, did, pid, txt)
{
	txt = typeof(txt) == 'string' ? txt : '-- seçiniz --';
  if($g('op_ilce_' + tid) != null)
  {
    MIT.EVNT.add($g('op_il_' + id), 'change', function(){loadTownOptions(this.value, tid, did, txt);});
  }
  if(cid)
  {
    selectText('op_il_' + id, 'Yükleniyor...');
    if($g('op_ilce_' + tid) != null)
    {
      $g('op_ilce_' + tid).innerHTML = '';
    }
    if($g('op_semt_' + did) != null)
    {
      $g('op_semt_' + did).innerHTML = '';
    }
    MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=getprovince&cid=' + cid + '&txt=' + txt, onLoadParam:'op_il_' + id + ', ' + pid, onLoad:initSelectLoadedAndSelect});
  }
}

function loadTownOptions(pid, id, did, txt)
{
  txt = typeof(txt) == 'string' ? txt : '-- seçiniz --';
  if($g('op_semt_' + did) != null)
  {
    MIT.EVNT.add($g('op_ilce_' + id), 'change', function(){loadDistrictOptions(this.value, did, txt);});
  }
  if(pid)
  {
    selectText('op_ilce_' + id, 'Yükleniyor...');
    if($g('op_semt_' + did) != null)
    {
      $g('op_semt_' + did).innerHTML = '';
    }
    MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=gettown&pid=' + pid + '&txt=' + txt, onLoadParam:'op_ilce_' + id, onLoad:initSelectLoaded});
  }
}

function loadTownOptionsAndSelect(pid, id, did, tid, txt)
{
  txt = typeof(txt) == 'string' ? txt : '-- seçiniz --';
  if($g('op_semt_' + did) != null)
  {
    MIT.EVNT.add($g('op_ilce_' + id), 'change', function(){loadDistrictOptions(this.value, did, txt);});
  }
  if(pid)
  {
    selectText('op_ilce_' + id, 'Yükleniyor...');
    if($g('op_semt_' + did) != null)
    {
      $g('op_semt_' + did).innerHTML = '';
    }
    MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=gettown&pid=' + pid + '&txt=' + txt, onLoadParam:'op_ilce_' + id + ',' + tid, onLoad:initSelectLoadedAndSelect});
  }
}

function loadDistrictOptions(tid, id, txt)
{
  txt = typeof(txt) == 'string' ? txt : '-- seçiniz --';
  var distObj = $g('op_semt_' + id);
  if(tid)
  {
    selectText('op_semt_' + id, 'Yükleniyor...');
    MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=getdistrict&tid=' + tid + '&txt=' + txt, onLoadParam:'op_semt_' + id, onLoad:initSelectLoaded});
  }
}

function loadDistrictOptionsAndSelect(tid, id, did, txt)
{
  txt = typeof(txt) == 'string' ? txt : '-- seçiniz --';
  var distObj = $g('op_semt_' + id);
  if(tid)
  {
    selectText('op_semt_' + id, 'Yükleniyor...');
    MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=getdistrict&tid=' + tid + '&txt=' + txt, onLoadParam:'op_semt_' + id + ',' + did, onLoad:initSelectLoadedAndSelect});
  }
}

function loadOptions(id, opID)
{
  //alert(id + ', ' + opID);
  MIT.FESA.doReq({url:'/ap/fesa.router.php?cmd=getopts&opid=' + id, onLoadParam:opID, onLoad:initSelectLoaded});
}
var _loaded = false;
function initSelectLoaded(opID, opts)
{
	_loaded = false;
  try
  {
    var selObj = $g(opID);
  }
  finally
  {
    selObj.innerHTML = '';
    if(!opts) return false;
    eval('var opObj = ' + opts + ';');
    for (op in opObj)
    {
      var newOption = $c('option');
      newOption.value = op;
      newOption.innerHTML = opObj[op];
      selObj.appendChild(newOption);
    }
  }
  _loaded = true;
}

function initSelectLoadedAndSelect(opIDX, opts)
{
  opIDXArr          = opIDX.split(',');
  opID              = opIDXArr[0];
  sid               = opIDXArr[1];

	_loaded = false;
  try
  {
    var selObj = $g(opID);
  }
  finally
  {
    selObj.innerHTML = '';
    if(!opts) return false;
    eval('var opObj = ' + opts + ';');
    for (op in opObj)
    {
      var newOption = $c('option');
      newOption.value = op;
      if(sid == op)
      {
      	newOption.selected = true;
      }
      newOption.innerHTML = opObj[op];
      selObj.appendChild(newOption);
    }
  }
  _loaded = true;
}

function selectText(opID, text)
{
  var selObj = $g(opID);
  selObj.innerHTML = '<option>' + text + '</option>';
}

acik_liste='id_liste';
function liste_sekme(x)
{
	$g(acik_liste).style.display='none';
	$g('td_'+acik_liste).className='liste';
	$g(x).style.display='';
	$g('td_'+x).className='liste selected';
	acik_liste=x;
}


var fixTiny = function(properties) {
    var properties = properties || new Object();
    var instance = properties.instance || 'mce_editor_0';
    tinyMCE.execInstanceCommand(instance,'mceCleanup');
    tinyMCE.triggerSave(true,true);
    return true;
}


var select_marked_model_opened_marks = {};

function select_marked_model_func(ths)
{
  var objHtml = document.getElementById('select_marked_model');
  arrHTML = [];
  arrHTML.push('<select>');
  arrHTML.push('<option>Yükleniyor...</select>');
  arrHTML.push('</select>');
  objHtml.innerHTML = arrHTML.join('');
}
