function doNothing() { }

function BGNew(obj, new_style, message) { 
  obj.className = new_style; 
  window.status = message; 
}

function BGNew2(obj, new_style) { 
  obj.className = new_style;   
}

function setLinkMouseOver(obj, newClass, label) {
  obj.className = newClass;
  obj.style.cursor='pointer';
  setLabel(label);
}

function oc(a)
{
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}


function search(field) {  
  if (field.value.length > 0 && field.value != 'Search Site') {           
     return true;  
  } else {   
     return false;
  }
}

function searchSite(form) {
  field = form.searchPhrase;
  if (field.value.length > 0 && field.value != 'Search Site') {
     form.submit();
  } 
}

function setLinkMouseOut(obj, newClass) {
  obj.className = newClass;  
  clearLabel();
}

function clearLabel() {
  window.status = "";
}

function setLabel(label) { 
  window.status = label;
}

function newWindowCustom(mypage, myname, scroll, w, h) {
        var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=1';
	win = window.open(mypage, myname, winprops);
        win.focus();
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function newWindowClone(mypage, myname, scroll) {
    win = window.open(mypage);
    win.focus();
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function newWindowLarge(mypage, myname, scroll) {
	var w = 490;
	var h = 770;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=1'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
  //return win;
}

function newWindowSmall(mypage, myname, scroll) {
	var w = 400;
	var h = 320;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
  //return win;
}

function clearSearchBox(field) {
  if (field.value == "Search Site") {
    field.value = "";
  }  
}

function frameAdjust() {
  var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
  if (document.getElementById("Calendar") != null) {
      myFrame = document.getElementById("Calendar");
      if (IE6) {
        myFrame.style.position = 'absolute';
        myFrame.style.top = '225';
        myFrame.style.right = '0';    
        myFrame.style.left = '-272';
        myFrame.style.bottom = '0';
      } 
  }
}

function validateRequiredField(field) {
  var valid = false;
  
  if ((field.type == "checkbox" || field.type == "radio")) {
    if (field.checked) {
      valid = true;
    }
  } else {
    // text type field
    if (field.value != undefined && field.value != "undefined" &&
        field.value.length > 0) {
        valid = true;
    }

    if (field.style != undefined) {
      if (valid) {
        // reset border
        field.style.borderColor = "";
        field.style.borderStyle = "";
        field.style.borderWidth = "";
      } else {
        // mark field border as invalid
        field.style.borderColor = "red";
        field.style.borderStyle = "solid";
        field.style.borderWidth = "1px";
      }
    }
  }
 
  return valid;
}
 
function validateForm(form, msg) {
  // required fields in stored in hidden field "requiredFields" as
  // fieldname1,fieldname2,fieldname3
  var errorMsg = msg;
  if (errorMsg == undefined) {
    errorMsg = "Please enter ALL required fields.";
  } 

  var error = false;
  if (form.requiredFields != undefined) {
    var requiredFields = form.requiredFields.value.split(",");

    for (var i=0; i<requiredFields.length; i++) {
      var requiredFieldName = requiredFields[i];
      var requiredField = form[requiredFieldName];

      if (requiredField != undefined) {
        if (requiredField.length != undefined) {
          // multiple fields with this name (iterate thru them checking if
          // any are not empty)
          var subFieldError = true;
          for (j=0; j<requiredField.length; j++) {
            if (validateRequiredField(requiredField[j])) {
              subFieldError = false;
            }
          }
          if (subFieldError) {
            error = true;
          }
        } else {
          // single field name
          if (!validateRequiredField(requiredField)) {
            error = true;
          }
        }
      }
    }          
  }                
  
  
  if (error) {
      alert(errorMsg);
      return false;
  } else {
    if (form['Submit'] != undefined) {
      form['Submit'].disabled = true;
    }
    if (document.getElementById('submitMsg') != undefined) {
      document.getElementById('submitMsg').innerHTML = "Please wait, uploading file...";
    }
    return true;
  }
  
}

function viewMediaLogin(domain) {
    if (window.opener != null && !window.opener.closed) {
      window.opener.location.href= "http://"+domain+"/iv/cms/logon/access";
      window.close();
    } else {
      document.location.href= "http://"+domain+"/iv/cms/logon/access";
    }
}

function toggleTab(name, currentTab) {
  tab = document.getElementById(currentTab);
  tab_button =  document.getElementById(currentTab+'_tab');
  tab.style.display = 'none';
  //tab.style.visibility = 'collapse';
  tab_button.onmouseover = function() {
     BGNew(this,'TabOn','Tab');
     this.style.cursor='pointer';
  }
  tab_button.onmouseout = function() {
     BGNew(this,'TabOff','')
     this.style.cursor='default'
  }
  tab_button.className = "TabOff";

  tab_button =  document.getElementById(name+'_tab');

  tab_button.onmouseover = "";
  tab_button.onmouseout = "";
  tab_button.className = "TabOn";
  document.getElementById(name).style.display = 'inline';
  //document.getElementById(name).style.visibility = 'visible';
}

function displayContentPage(pageNum) {
  currentPage = document.getElementById("contentPage"+currentContentPage);
  currentPage.style.display = 'none';
  newPage = document.getElementById("contentPage"+pageNum);
  newPage.style.display = 'inline';  
  document.getElementById("pageNav"+currentContentPage).className = 'BackNext';
  document.getElementById("pageNav"+pageNum).className = 'BackNextOn';
  currentContentPage = pageNum;
  if (currentContentPage > 1) {
     /*if (document.getElementById("contentAuthor") != null) {
       document.getElementById("contentAuthor").style.display = 'none';
     }*/
     if (document.getElementById("datelineLocation") != null) {
       document.getElementById("datelineLocation").style.display = 'none';
     }
     document.getElementById("pageNum").style.display = 'inline';
     document.getElementById("pageNum").innerHTML = 'Viewing Page '+pageNum+" of "+totalContentPages;
  } else {
     /*if (document.getElementById("contentAuthor") != null) {
       document.getElementById("contentAuthor").style.display = 'inline';
     }*/
     if (document.getElementById("datelineLocation") != null) {
       document.getElementById("datelineLocation").style.display = 'inline';
     }
     document.getElementById("pageNum").style.display = 'none';
  }
  
  window.location.hash = 'contentTop';
  //scroll(0,250);
}

function nextContentPage() {
  if (currentContentPage < totalContentPages) {
    displayContentPage(currentContentPage+1);
  } 
}

function prevContentPage() {
  if (currentContentPage > 1) {
    displayContentPage(currentContentPage-1);
  }
}

function idleTimerExpired() {
    alert("Idle Timer Expired!\n\nClick OK to return to homepage.")
    resetIdleTimer();
    window.location.href = "/iv/homepage?rnd="+new Date().getTime();
}


