var formSubmitValue = 'processing...' // this is the global onclick value of a form submit button

function downloadPlugin(theUrl) {
  theNewWin = window.open(theUrl,'plugin','width=800,height=560,scrollbars=yes,resizable=yes,location=yes,toolbar=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

//function downloadPlugin() { // currently for development
//  document.getElementById('flashObject').style.visibility='visible';
//  document.getElementById('link01').style.display='none';
//  document.getElementById('link02').style.display='';
//}

//function removePlugin() { // currently for development
//  document.getElementById('flashObject').style.visibility='hidden';
//  document.getElementById('link01').style.display='';
//  document.getElementById('link02').style.display='none';
//}

function turnMeOff(id) { // for development only
  document.getElementById(id).style.display="none";
}

function popArticle(theUrl) { // standard content popup for articles
  theNewWin = window.open(theUrl,'emeraldArticle','width=640,height=500,scrollbars=yes,resizable=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

function popApplyNowForm(theUrl) { // standard popup for job applications
  theNewWin = window.open(theUrl,'emeraldApplyNow','width=600,height=580,scrollbars=yes,resizable=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

function popCalculator(theUrl) { // standard content popup for calculators
  theNewWin = window.open(theUrl,'emeraldCalculator','width=640,height=500,scrollbars=yes,resizable=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

function popContactUsForm(theUrl) { // standard popup for the contact form
  theNewWin = window.open(theUrl,'emeraldContactUs','width=600,height=580,scrollbars=yes,resizable=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

function popEseminar(theUrl) { // standard content popup for eSeminars
  theNewWin = window.open(theUrl,'emeraldEseminar','width=623,height=536,resizable=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

function popForm(theUrl,theClass) { // standard content popup for standard forms
  if (theClass == 'quoteRequest') {
    theNewWin = window.open(theUrl,'emeraldForm','width=560,height=500,scrollbars=yes,resizable=yes');
  }
  else {
    theNewWin = window.open(theUrl,'emeraldForm','width=540,height=500,scrollbars=yes,resizable=yes');
  }
  theNewWin.focus(); // if the window exists, bring it to the front
}

function popNewsletter(theUrl) { // standard content popup for newsletters
  theNewWin = window.open(theUrl,'emeraldNewsletter','width=640,height=500,scrollbars=yes,resizable=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

function popSeminarSignupForm(theUrl) { // standard popup for seminar sign ups
  theNewWin = window.open(theUrl,'emeraldSeminarSignup','width=600,height=580,scrollbars=yes,resizable=yes');
  theNewWin.focus(); // if the window exists, bring it to the front
}

function printPage() {
  window.print();
}

/*///////////////////   iFrames and Navigation   ///////////////////*/

function hideIBuffer() { // iBuffer is the spacer image placeholder for the iFrame, show one, hide the other
if (document.getElementById('iBuffer')){
  document.getElementById('iBuffer').style.display='none';
  }
}

function showIBuffer() { // iBuffer is the spacer image placeholder for the iFrame show one, hide the other
if (document.getElementById('iBuffer')){
  document.getElementById('iBuffer').style.display='';
  }
}

function hideIframe() { // iFrame will cause the DDM to freak,...if there's an iFrame, we hide it on DDM mouseover
if (document.getElementById('marketWatch_iContent')){
  document.getElementById('marketWatch_iContent').style.display='none';
showIBuffer();
  }
if (document.getElementById('glossary_iContent')){
  document.getElementById('glossary_iContent').style.display='none';
showIBuffer();
  }
}

function showIframe() { // on DDM mouseout, if there's an iFrame, we show it.
if (document.getElementById('marketWatch_iContent')){
document.getElementById('marketWatch_iContent').style.display='';
hideIBuffer();
  }
if (document.getElementById('glossary_iContent')){
document.getElementById('glossary_iContent').style.display='';
hideIBuffer();
  }
}

function marketWatch_iFrameGo(url) {
if (document.getElementById('marketWatch_iContent')){
  showIframe(); // unhides the iFrame so we can target it.
  document.getElementById('marketWatch_iContent').src=url; // iFrame target (client side...we don't want to refresh the page!)
  }
else {window.location='subMarketWatch.cfm?url=' +url; // iFrame target (CF handled...server side)
  }
}
/*///////////////////   function for removing HTML declared borders from tables in custom forms in IE   ///////////////////*/
function unBorderTables() {
  for (i=0;i<=29;i++) {
    if(document.getElementsByTagName("table")[i])
    document.getElementsByTagName("table")[i].border=0;
  }
}
/*///////////////////   legacy scripts for backward compatibility   ///////////////////*/

function open_window(url) {
  mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=400,height=335');  
}

function new_window(url,wx,hx) {
  newwin = window.open(url,"win",'toolbar=0,location=0,directories=0,scrollbars=1,resizable=1,status=1,menubar=0,width='+wx+',height='+hx);  
}


/*///////////////////   new standard pop-up window code   ///////////////////*/

var NewBox = null; 

function infobox(strURL, strWidth, strHeight) { 
 if (NewBox != null && !NewBox.closed) 
   NewBox.close(); 
 var strOptions=""; 
   strOptions="toolbar=0,directories=0,status=1,menubar=0,resizable=1,"+ 
     "scrollbars=1,location=0,height="+strHeight+",width="+strWidth; 
 NewBox = window.open(strURL, 'NewBox', strOptions); 
 NewBox.focus(); 
}

function open_windowMainNav(url) 
{
myMainNavwin = window.open(url,"win",'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=600,height=450,left=1,top=1');  
}

/*///////////////////   tooltip pop-up box code   ///////////////////*/

function getElementById(id) {
  if (document.getElementById) {
    return document.getElementById(id);
  } else if (document.all) {
    return eval("document.all." + id);
  } else if (document.layers) {
    return eval("document.layers." + id);
  } else{
    return null;
  }
}

function infoLink(theId,which,event){
  if(which=="over"){
    getElementById(theId).style.display="";
    drawBox(event,theId)
  } else {
    getElementById(theId).style.display="none";
  }
}

function drawBox(event,target) {
  var y = event.clientY;
  var scrollY = (window.pageYOffset) ? window.pageYOffset : document.body.scrollTop;
  getElementById(target).style.top = y + scrollY + 20 + "px";
}
