function objGet(x) {
	if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);
	else if (Boolean(document.ids)) return eval('document.ids.'+x);
	else return null;
}

function toggleDiv(a){
  var e=objGet(a);
  var l=objGet('showhide');
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block";
    l.innerHTML = '<a href="javascript:;" onclick="toggleDiv(\'form_ad_search\')">'+hdsrch+'</a>';
  } else {
    e.style.display="none";
    l.innerHTML = '<a href="javascript:;" onclick="toggleDiv(\'form_ad_search\')">'+shsrch+'</a>';
  }
  return false;
}

function hideAllButThis(a) {
  var tabs = document.getElementsByTagName('table');
  var it = objGet(a);
  var showit = (it.style.display=="block")?"none":"block";
  
  for(var i=0; i<tabs.length; i++) 
    if (tabs[i].id.indexOf('adsetup')>-1)
    {
    
        //if(tabs[i].style.display=="block"){
          tabs[i].style.display="none"
        //} else {
        //  tabs[i].style.display="block"
        //}
    }
  it.style.display=showit
  return false;
}

function switchClass(obj,style1,style2) {
  if (obj.className == style1 ) {
    obj.className = style2
  } else {
    obj.className = style1
  }
  return false;
}

function checkMaxLength(Event, Object, MaxLen) 
{ 
  var isOK = (Object.value.length <= MaxLen)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40));
  if (!isOK ) {
    alert(MaxExceeded + ' ' + MaxLen); 
    Object.value = Object.value.substr(0, MaxLen); 
  } 
  return isOK;
}

function openNewWin (url, fixwin) {
  var prop = (fixwin)?'directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0':'';
  window.open (url,'gwin',prop);
  
  return false;
} 

function refreshList (thefield, theindex, selectedidx) {
  //alert (thefield+", "+thelist+", "+theindex); return true;
  var o=objGet(thefield);
  var i=0;
  var lst = prange[theindex];
  o.options.length=0;
  for (idx in lst) {
    o.options[i++] = new Option(lst[idx],idx);
  }
  o.selectedIndex = selectedidx;
  return false;
}

function changeImgSrc (idx,image,mode)
{
  var obj=objGet(image+idx);
  if (obj)
  {
    srcname = mode+''+idx;
    if (window[srcname].complete && window[srcname].width>0)
    {
      obj.src = window[srcname].src;
    }
  }
  
  return false;
}

