function addView(listViewName)
{
	var wnd = window.open("index_popup.php?md=Affiliate_Merchants_Views_ListViews&action=add&listViewName="+escape(listViewName)+"&<?=SID?>","EditView","scrollbars=1, top=100, left=100, width=550, height=500, status=0")
    wnd.focus(); 
}

function editView(ID, listViewName)
{
	var wnd = window.open("index_popup.php?md=Affiliate_Merchants_Views_ListViews&action=edit&vid="+ID+"&listViewName="+escape(listViewName)+"&<?=SID?>","EditView","scrollbars=1, top=100, left=100, width=550, height=500, status=0")
    wnd.focus(); 
}

function deleteView(ID, listViewName, confirmText)
{
    if(confirm(confirmText))
    {
        var wnd = window.open("index_popup.php?md=Affiliate_Merchants_Views_ListViews&action=delete&vid="+ID+"&listViewName="+escape(listViewName)+"&<?=SID?>","EditView","scrollbars=1, top=100, left=100, width=200, height=100, status=0")
        wnd.focus();
    }
}

function submitView()
{
    FilterForm.submit();
}

function performAction(sel)
{
  if(sel.value!='-')
  {
    eval(sel.value);
  }
  sel.selectedIndex = 0;
}

function checkAllItems()
{
  var checks = document.all("itemschecked");
  if(typeof(checks) == 'undefined') return;

  checkedAllItems = !checkedAllItems;
  
  if(checks.length > 0)
  {
    for (var b = 0; b < checks.length; b++)
    {
      if(checkedAllItems == true)
        checks[b].checked = true;
      else
        checks[b].checked = false;
    }
  }
  else
  {
    if(checkedAllItems == true)
      checks.checked = true;
    else
      checks.checked = false;
  }
  
  var buttons = document.all("checkItemsButton");
  if(typeof(buttons) == 'undefined') return;
  if(buttons.length > 0)
  {
    for (var b = 0; b < buttons.length; b++)
    {
      if(checkedAllItems == true)
        buttons[b].value = '[  ]';
      else
        buttons[b].value = '[X]';
    }
  }
  else
  {
    if(checkedAllItems == true)
      buttons.value = '[  ]';
    else
      buttons.value = '[X]';
  }
}


function addAffiliate()
{
	var wnd = window.open("index_popup.php?md=AffiliateManager&action=add"+"&<?=SID?>","AddAffiliate","scrollbars=1, top=100, left=100, width=500, height=560, status=0");
    wnd.focus(); 
}

var treeopened = null;
function openMenuItems(myId) 
{
    if (document.getElementById) 
    {
        var elem = document.getElementById (myId);
        if (elem && elem.className) 
        {
            elem.className = (elem.className == 'leftMenuTableOpened') ? 'leftMenuTableClosed' : 'leftMenuTableOpened';
        }
    }
    
    return false;
}


function showListOptions()
{
	if(document.getElementById)
	{
			if(document.getElementById("view_av_options").style.display=="block")
			{
				document.getElementById("view_av_options").style.display="none";
			}
			else
			{
				document.getElementById("view_av_options").style.display="block";
			}
	}
}

function showPopupHelp(helpID)
{
	var wnd = window.open("index_popup.php?md=QUnit_Help_Help&hid="+helpID+"&<?=SID?>","helpwnd","scrollbars=1, top=100, left=100, width=350, height=250, status=0");
    wnd.focus();
}




function _obj(id) {
    ret = null;
    if (document.getElementById) {
        ret = document.getElementById(id);
    } else if (document.all) {
        ret = document.all[id];
    }
    return ret;
}

function mover(name) {
    if(_obj(name+'_')) {
        _obj(name+'_').style.visibility = 'visible';
    }
    if(_obj(name)) {
        _obj(name).className = 'subMenuActive';
    }
    if(_obj('a'+name)) {
        _obj(name).className = 'subMenuActive';
    }
}
function mout(name) {
    if(_obj(name+'_')) {
        _obj(name+'_').style.visibility = 'hidden';
    }
    if(_obj(name)) {
        _obj(name).className = 'subMenuPassive';
    }
    if(_obj('a'+name)) {
        _obj(name).className = 'subMenuPassive';
    }
}
function mover0(name) {
    if(_obj('lng')) {
        _obj('lng').style.visibility = 'hidden';
    }
    if(_obj(name+'_')) {
        _obj(name+'_').style.visibility = 'visible';
    }
    if(_obj(name)) {
     _obj(name).className = 'menuActive';
//      _obj(name).style.background = '#0066CC';
    }
}
function mout0(name) {
    if(_obj('lng')) {
        _obj('lng').style.visibility = 'visible';
    }
    if(_obj(name+'_')) {
        _obj(name+'_').style.visibility = 'hidden';
    }
    if(_obj(name)) {
    _obj(name).className = 'menuPasive';
//      _obj(name).style.background = '#003399';
    }
}

moverLindex = 'xxx';
smoverLindex = 'xxx';
function moverL(name) {
    if(_obj(moverLindex)) {
        _obj(moverLindex).style.background = '#EEEEEE';
        _obj(moverLindex).style.color = 'Black';
    }
    if(_obj('a'+moverLindex)) {
        _obj('a'+moverLindex).style.color = 'Black';
    }
    if(_obj(smoverLindex)) {
        _obj(smoverLindex).style.background = '#DDDDDD';
        _obj(smoverLindex).style.color = 'Black';
    }
    if(_obj('a'+smoverLindex)) {
        _obj('a'+smoverLindex).style.color = 'Black';
    }
    
    moverLindex = name;
    smoverLindex = 'xxx';
    
    if(_obj(name)) {
        _obj(name).style.background = '#0066CC';
        _obj(name).style.color = 'White';
    }
    if(_obj('a'+name)) {
        _obj('a'+name).style.color = 'White';
    }
}
function smoverL(name) {
    if(_obj(moverLindex)) {
        _obj(moverLindex).style.background = '#EEEEEE';
        _obj(moverLindex).style.color = 'Black';
    }
    if(_obj('a'+moverLindex)) {
        _obj('a'+moverLindex).style.color = 'Black';
    }
    if(_obj(smoverLindex)) {
        _obj(smoverLindex).style.background = '#DDDDDD';
        _obj(smoverLindex).style.color = 'Black';
    }
    if(_obj('a'+smoverLindex)) {
        _obj('a'+smoverLindex).style.color = 'Black';
    }
    
    moverLindex = 'xxx';
    smoverLindex = name;
    
    if(_obj(name)) {
        _obj(name).style.background = '#0066CC';
        _obj(name).style.color = 'White';
    }
    if(_obj('a'+name)) {
        _obj('a'+name).style.color = 'White';
    }
}
function moutL(name) {
    if(_obj(name)) {
        _obj(name).style.background = '#EEEEEE';
        _obj(name).style.color = 'Black';
    }
    if(_obj('a'+name)) {
        _obj('a'+name).style.color = 'Black';
    }
}
function smoutL(name) {
    if(_obj(name)) {
        _obj(name).style.background = '#DDDDDD';
        _obj(name).style.color = 'Black';
    }
    if(_obj('a'+name)) {
        _obj('a'+name).style.color = 'Black';
    }
}

function openItem(myId) 
{
    if (document.getElementById) 
    {
        var elem = document.getElementById (myId);
        if (elem && elem.className) 
        {
            elem.className = (elem.className == 'tableOpened') ? 'tableClosed' : 'tableOpened';
        }
    }
    
    return false;
}
