var popupWin;

/***********************************/
//         function init()
/***********************************/
function init()
{ document.getElementById('barchart').scrollTop=20;
  swapBarchart();
}

function swapBarchart()
{ var barchart=document.getElementById('barchart');
  if(barchart.scrollTop==0)
    barchart.scrollTop=20;
  else
    barchart.scrollTop=0;
  setTimeout("swapBarchart()", 35000);
}

/***************************************/
/*            imgChange()              */
/***************************************/
function imgChange(imgName, imgSrc)
{ if(document.images)
  { document.images[imgName].src = imgSrc;
  }
}

/***************************************/
//           closePopup()
/***************************************/
function closePopup()
{ if(popupWin)
    popupWin.close();
}

/***************************************/
//         openPopupWindow()
/***************************************/
function openPopupWindow(addr, winwidth, winheight, ststus, leftpos, toppos, scrollbar, tool_bar)
{ closePopup();

	if(ststus != 'yes')
    ststus = 'no';
	if(scrollbar != 'yes')
    scrollbar = 'no';
	if(tool_bar != 'yes')
    tool_bar = 'no';

	if(!leftpos)
	{ var scrwidth  = screen.availWidth
    leftpos= (scrwidth/2) -(winwidth/2);
  }
  if(!toppos)
  { var scrheight = screen.availHeight
    toppos = (scrheight/2)-(winheight/2);
  }

  popupWin = window.open(
  addr
  , 'popupWin'
  , config='width='+winwidth
  +',height='+winheight
  +',left='+leftpos
  +',top='+ toppos
  +',modal=yes' 
  +',toolbar='+tool_bar+', menubar=no, '
  +',scrollbars='+scrollbar+', resizable=no, '
  +',location=no, directories=no, status=' + ststus );
  
  popupWin.focus();
}

function ValidateMailingList(theForm)
{ // first name
  if(theForm.mail_name.value=="")
  { alert("Please enter your name.      ");
    theForm.mail_name.focus();
    theForm.mail_name.select();
    return false;
  }

  // email
  var theStr = new String(theForm.mail_email.value);
  var index  = theStr.indexOf("@");
  var pindex = theStr.indexOf(".",index);

  if (theStr == "")
  { alert("Please enter a valid email address.      ");
    theForm.mail_email.focus();
    theForm.mail_email.select();
    return false;
  }
  else if(theStr.indexOf("@") <= 0)
  { alert("Please enter a valid Email Address.      \n\n"
        + "( yourname@yourdomain.com )" );
    theForm.mail_email.focus();
    theForm.mail_email.select();
    return false;
  }
  else if ( !((pindex > index+1) && (theStr.length > pindex+1)) )
  { alert("Please enter a valid Email Address.      \n\n"
        + "( yourname@yourdomain.com )" );
    theForm.mail_email.focus();
    theForm.mail_email.select();
    return false;
  }
  return true;
}


/***************************************/
//           deleteMailingList()
/***************************************/
function deleteMailer(list_id, email )
{ 
	var resure = confirm("Are you sure you want to delete this list item ["+ list_id +"]?      \n\n" + email );
  if(resure)
    window.location = rootpath + directory + '/exec_remove_mailing_list_entry.php' + query_str
                                              												+ '&list_id=' + list_id;

    																																
}