

// --------- Image Rollover Scripts for Navigation ---------
// SCRIPT: Switches graphics when mouse is hovered over them
function SwitchImg()
{ // Change graphic when mouse is hovered over
  var rem, keep=0, store, obj, switcher=new Array, history=document.Data;
    for (rem=0; rem < (SwitchImg.arguments.length-2); rem+=3) {
        store = SwitchImg.arguments[(navigator.appName == 'Netscape')?rem:rem+1];
    if ((store.indexOf('document.layers[')==0 && document.layers==null) ||
        (store.indexOf('document.all[')==0 && document.all==null))
         store = 'document'+store.substring(store.lastIndexOf('.'),store.length);
         obj = eval(store);
    if (obj != null) {
           switcher[keep++] = obj;
      switcher[keep++] = (history==null || history[keep-1]!=obj)?obj.src:history[keep];
      obj.src = SwitchImg.arguments[rem+2];
  } }
  document.Data = switcher;
} // Change graphic when mouse is hovered over


// Restore graphic when mouse is moved off the image
function RestoreImg() {
  if (document.Data != null)
    for (var rem=0; rem<(document.Data.length-1); rem+=2)
      document.Data[rem].src=document.Data[rem+1];
} // Restore graphic when mouse is moved off the image
// --------- Image Rollover Script for Navigation ---------


// --------- View Article Photos & Cutlines ---------
// This function opens a new, centered window that displays photos with their cutlines
function slideshow (gid, proofed) {

  // Size of our window
  width = 525; height = 440;

  // x and y offset... this calculation helps us center the box on screen
  xOff = (screen.width - width)/2;
  yOff = (screen.height - height)/2;

  // Open the window with the given attributes
  vw_slideshow = window.open ('slideshow.php?article_id=' + gid + '&proofed=' + proofed,'vw_slideshow','width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,status=0,resizable=1,top=' + yOff + ',left=' + xOff );

  // Ensure this new window has the user's attention (takes focus)
  vw_slideshow.focus ();

}
// --------- View Article Photos & Cutlines ---------


// --------- Window Pop-Up Controls for Opinion Polls ---------
// SCRIPT: Opens a small window with poll results
function ShowWebPoll () {
  pollwin = window.open('','pollwin','width=400,height=325,status=no,scrollbars=yes,resizable=yes,toolbar=no');
  document.forms["WebPoll"].reset();
  document.forms["WebPoll"].submit();
}


// SCRIPT: Opens a small window with poll results (with user's vote)
function VoteWebPoll () {
  pollwin = window.open('','pollwin','width=400,height=325,status=no,scrollbars=yes,resizable=yes,toolbar=no');
  document.forms["WebPoll"].submit();
}


// SCRIPT: Opens a window for rasterised display ads (ROP, Classified displays)
function OpenAPopUp (width, height, url) { bigwidth = false; bigheight = false;

  // Adjustment for display ads that are larger than the screen
  if (width >= screen.width) { width = screen.width*.85; bigwidth = true;}
  if (height >= screen.height) { height = screen.height*.85; bigheight = true;}

  // Add padding to the popup dimensions (only if smaller than screen dimensions)
  if (bigwidth == false) { width=width+40; }
  if (bigheight == false ) { height=height+85; }

  // Vertical and Horizontal offset (centers ad on screen)
  var winleft = (screen.width - width) / 2;
  var wintop = (screen.height - height) / 2;

  adPopUpWin = eval("window.open('" + url + "','adPopUpWin','width=" + width + ",height=" + height + ", top=" + wintop + ",left=" + winleft + ",status=no,scrollbars=yes,resizable=yes,toolbar=no')");
}


// SCRIPT: Opens a small window with poll results (via poll archives)
function ShowOldWebPoll ($url) {
  pollwin = window.open($url,'pollwin','width=400,height=325,status=no,scrollbars=yes,resizable=yes,toolbar=no');
}


// --------- Checks or Unchecks all Specified Checkboxes ---------
// SCRIPT: Check or uncheck checkboxes ( pf="string match" and ck="1" (check) or "0" (uncheck) )
// If pf="all" then ck applies to all checkboxes in the form
function checkall (pf,ck) {
  cbox=document.getElementsByTagName('INPUT');
  for (i=0; i<cbox.length; i++){
    if (cbox[i].type=='checkbox'){
      if (pf == "all") {
        if (ck == "1") { cbox[i].checked = true; } else { cbox[i].checked = null; }
        continue;
      }
      if (cbox[i].name.indexOf(pf) > -1) {
        if (ck == "1") { cbox[i].checked = true; } else { cbox[i].checked = null; }
        continue;
      }
    }
  }
}


// --------- Resets Advanced Search Options Form ---------
// SCRIPT: Asks user if changes to form should be lost (reset). OK = Reset, cancel = nothing
function resetSearchOptions () {
  input_box=confirm("Are you sure you want to discard all current changes?");

  if (input_box==true)
  {
  document.searchoptions.reset();
  }

}

// --------- Reset Search ---------
// SCRIPT: Asks user if they want to lose search customizations. OK = New search, cancel = nothing
function resetSearch (url) {
  input_box=confirm("Are you sure you want to reset your search?\nYou will lose any search customizations you have made!\n(Search query will not be reset)");

  if (input_box==true)
  {
  location.href = url;
  }

}

