// ===========================
// pk_javascript.js
// ===========================
//
//
// ==================================================================
// The following sets up the variables for the question and answer
// pop-up windows of the dykDisplay function.
  var dykmsg = new Array;
  var dykref = new Array;
  dykmsg[0] = "The most recent comprehensive Alberta Land-Use Plan is some 25 years old.";
  dykref[0] = "";
  dykmsg[1] = "Rough Fescue grass with its deep roots can collect and store more carbon in the soil than a forest, thus helping to reduce the possibility of global warming.";
  dykref[1] = "";
  dykmsg[2] = "More wildlife inhabit the rangelands of the Eastern Slopes than the adjacent National Parks.";
  dykref[2] = "";
  dykmsg[3] = "A study by the Alberta Research Council showed that flares can leave anywhere from 16 to 38 percent of the gases unburned, and can emit poisonous and cancer-causing chemicals.";
  dykref[3] = "Investigations of Flare Gas Emissions in Alberta, M. Strosher, Environmental Technologies, Alberta Research Council, November 1996.";
  dykmsg[4] = "Just 6 one-hundredths of one percent (0.06%) of Hydrogen Sulphide can kill a person. Any natural gas under the Pekisko Rangeland is expected to have up to 27% Hydrogen Sulphide content.";
  dykref[4] = "";
  dykmsg[5] = "The Pekisko Rangeland is one of the few remaining undamaged native grasslands; a heritage from the days of the bison.";
  dykref[5] = "";
  dykmsg[6] = "Only about 1% of the world's water is fresh and about 1/4 of that 1% is in Canada. However most of it is far from where it is most needed.";
  dykref[6] = "";
  dykmsg[7] = "Methane is 23 times more potent than Carbon Dioxide (CO<sub>2</sub>) as a greenhouse gas.";
  dykref[7] = "";
  dykmsg[8] = "The 2003 Alberta budget includes not a single measure of natural capital.";
  dykref[8] = "Alberta Finance, Budget 2003, 101-123";
  dykmsg[9] = "Research has shown that flares can release more than 250 hazardous air pollutants including poisonous and cancer-causing compounds such as benzene, toluene, ethyl benzene, xylenes, methane and hydrogen sulphide.";
  dykref[9] = "Investigations of Flare Gas Emissions in Alberta, M. Strosher, Environmental Technologies, Alberta Research Council, November 1996.";
  dykmsg[10] = "Alberta contains 255,287 square miles and the oil and gas industry has drilled approximately 600,000 wells in the province to date. We have more drill holes per square mile than Saudi Arabia.";
  dykref[10] = "";
  
//
// ==================================================================
// The following three functions deal with the graphical animation
// on the home page.

function homeWinanim() {
  // set the picture name and order
  pics = new Array(9);
  pics[0] = "pctr041";
  pics[1] = "pctr046";
  pics[2] = "pctr044";
  pics[3] = "pctr049";
  pics[4] = "pctr042";
  pics[5] = "pctr047";
  pics[6] = "pctr043";
  pics[7] = "pctr048";
  pics[8] = "pctr045";
  // initialize the counter
  ax = 0;
  setTimeout("rptpicslw()",4000);
}

function rptpicslw() {
  setptxt01.visibility = "visible";
  setptxt02.visibility = "visible";
  setptxt03.visibility = "visible";
  tmpnm = ("set"+pics[ax]);
  eval(tmpnm).visibility = "visible";
  ++ax;
  if(ax < 9) {
    //alert("ax is "+ax+" so replaying rptpicslw");
    setTimeout("rptpicslw()",2000);
  } else {
    setTimeout("rptpicorig()",6000);
  }
}

function rptpicorig() {
  //alert("setting picture back to original");
  setptxt02.visibility = "hidden";
  setptxt04.visibility = "visible";
  setpctr041.visibility = "hidden";
  setpctr042.visibility = "hidden";
  setpctr043.visibility = "hidden";
  setpctr044.visibility = "hidden";
  setpctr045.visibility = "hidden";
  setpctr046.visibility = "hidden";
  setpctr047.visibility = "hidden";
  setpctr048.visibility = "hidden";
  setpctr049.visibility = "hidden";
}

// ==================================================================
// This function swaps buttons to the down state. It is 
// necessary to account for browser differences.  For old
// browsers which have a problem defining the image object
// within a div tag it simply ignores the swap.

function pgSwapon(robtn) {
  nsrc = ("btn"+robtn+"_dn.src");
  bimg = ("btn"+robtn);
  if(document.images) {
    document.images[bimg].src = eval(nsrc);
  }
}

// ==================================================================
// This function swaps buttons to the up state. It is 
// necessary to account for browser differences. For old
// browsers which have a problem defining the image object
// within a div tag it simply ignores the swap.

function pgSwapoff(robtn) {
  var nsrc = ("btn"+robtn+"_up.src");
  var bimg = ("btn"+robtn);
  if(document.images) {
    document.images[bimg].src = eval(nsrc);
  } 
} 

// ==================================================================
// This function displays a 'Did You Know' message in a small 
// separate window. For simplicity (no server database) the
// few messages listed are stored as variables.

function dykDisplay() {
  if(window.dykWin) dykWin.close();

  pntr = parseInt((dykmsg.length)*Math.random());
  if(pntr >= dykmsg.length) pntr--;

  dykWin = window.open("","dykWin","location=no, status=no, scrollbars=no, menubar=no, resizable=no, width=350, height=425, top=100, left=100");

  if(navigator.appName.indexOf("Netscape") >= 0) {
    dykWin.document.write("<html><head><title>Did You Know?</title><link rel='stylesheet' href='pk_style_nn.css' type='text/css'></head><body bgcolor='#C0D0D8'>");
  } else {
    dykWin.document.write("<html><head><title>Did You Know?</title><link rel='stylesheet' href='pk_style_ie.css' type='text/css'></head><body bgcolor='#C0D0D8'>");
  }

  dykWin.document.write("<table width='100%' cellspacing='0' cellpadding='10' border='0'><tr><td align='center'><p class='head1lgvr'><b>Did you know?</b></p></td></tr><tr><td align='center'><table width='100%' bgcolor='#FFFFFF' cellspacing='0' cellpadding='20' border='3'><tr><td><p class='body1smar'><b>"+dykmsg[pntr]+"</b></p></td></tr></table>");

  if(dykref[pntr] == "") {
    dykWin.document.write("</td></tr></table>");
  } else {
    dykWin.document.write("</td></tr><tr><td align='center'><table width='88%' cellspacing='0' cellpadding='0' border='0'><tr><td align='center'><p class='body1tyvr'><b>Reference:</b> &nbsp; "+dykref[pntr]+"</p></td></tr></table></td></tr></table>");
  }
  dykWin.document.write("<br><div align='center'><a href='Javascript:window.close();'><img src='navkons/btn_closewin_01.gif' width='80' border='0'></a></div></body></html>");
  return;
}

// ==================================================================
// This function displays a narrow window and fills it with the
// webpage data from a specified local URL -  It is for larger
// content that requires a scrolling window.

function subwinDisplay(mylocalurl) {
  if(window.subWin) {
    subWin.close();
  }
  subWin = window.open(mylocalurl,"subWin","location=no, status=no, scrollbars=yes, menubar=no, resizable=yes, width=550, height=660, top=10, left=60");
  subWin.focus(); 
  return;
}

// ==================================================================
// This function displays a new window and fills it with the larger 
// download picture from a person's picture page.

function picshowWin(picname,orientn,picdir) {
  if(window.bigpicWin) {
    bigpicWin.close();
  }
  if(picdir == "pp") {
    picpth = "images/";
  } else if(picdir == "mp") {
    picpth = "maps/";
  } else {
    picpth = "docs/";
  }
  if(orientn == "land") {
    ws = [620,525,20,10,560];
  } else if(orientn == "port") {
    ws = [420,700,10,70,360];
  } else {
    ws = [595,670,0,0,530];
  }
  winpar = ("'location=no, status=no, scrollbars=yes, menubar=no, resizable=no, width="+ws[0]+", height="+ws[1]+", top="+ws[2]+", left="+ws[3]+"'");
  bigpicWin = window.open('','popwinpic',winpar);
  bigpicWin.focus();
  bigpicWin.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><title>Picture Window</title></head>");
  //bigpicWin.document.onclick = noCapture(this);
  thepicture = "<img src='"+picpth+picname+"' width='"+ws[4]+"' />";
  bigpicWin.document.write("<body><table bgcolor='#FFFFFF' width='100%' cellspacing='0' cellpadding='10' border='3'><tr><td align='center'>"+thepicture+"</td></tr></table><br>");
  bigpicWin.document.write("<div align='center'><a href='Javascript:window.close();'><img src='navkons/btn_closewin_01.gif' width='90' border='0'></a></div></body></html>");
  return;
}

// ==================================================================
// This function displays the Alberta Government web page for 
// finding a person's MLA

function mlaDisplay() {
  mlaWin = window.open("http://www.assembly.ab.ca/net/index.aspx?p=mla_home&rnumber=&by=","mlaWin", "location=no, status=no, scrollbars=yes, menubar=no, resizable=no, width=800, height=600");
  return;
}

// ==================================================================
// This function checks missing fields in the 'Contact' Form
// on the pkcontact.html webpage

function valid_contact(pkcon) {
   if(pkcon.thefirstname.value == "") {
   alert("Please enter your First Name\nand Submit again");
   pkcon.thefirstname.focus();
   return false;
   }
   if(pkcon.thesurname.value == "") {
   alert("Please enter your Surname\nand Submit again");
   pkcon.thesurname.focus();
   return false;
   }
   if(pkcon.themail.value == "" || pkcon.themail.value != pkcon.checkmail.value) {
   alert("Please re-enter your email address\nand Submit again");
   pkcon.themail.focus();
   return false;
   }
   if(pkcon.thecomment.value == "") {
   alert("Please enter a comment\nand Submit again");
   pkcon.thecomment.focus();
   return false;
   }
   return true;
}

// ==================================================================
// This function checks missing fields in the 'Be a Friend' Form
// on the pkfriend.html webpage

function valid_friend(pkfrd) {
   if(pkfrd.thefirstname.value == "") {
   alert("Please enter your First Name\nand Submit again");
   pkfrd.thefirstname.focus();
   return false;
   }
   if(pkfrd.thesurname.value == "") {
   alert("Please enter your Surname\nand Submit again");
   pkfrd.thesurname.focus();
   return false;
   }
   if(pkfrd.themail.value == "" || pkfrd.themail.value != pkfrd.checkmail.value) {
   alert("Please re-enter your email address\nand Submit again");
   pkfrd.themail.focus();
   return false;
   }
   if(!pkfrd.thevoter[0].checked && !pkfrd.thevoter[1].checked ) {
   alert("Please tell us if you are over 18\nand Submit again");
   return false;
   }
   if(!pkfrd.thenews[0].checked && !pkfrd.thenews[1].checked ) {
   alert("Please tell us if you wish to\nreceive a newsletter\nand Submit again");
   return false;
   }
   return true;
}

// ==================================================================
// This function checks missing fields in the 'member login' Form
// on the pk_member_home.html webpage

function valid_memberlogin (checkit) {
	if(checkit.member_first.value == "")
	{
		alert("Please enter your first name as requested\nand Submit again.");
		return false;
	} else if(checkit.member_last.value == "") {
		alert("Please enter your surname as requested\nand Submit again.");
		return false;
	} else if(checkit.member_key.value == "") {
		alert("Please enter the required Login Key\nand Submit again.");
		return false;
	} else {
		return true;
	}
}

// ==================================================================
// This function displays a message saying that the requested function is not
// yet available.

function noPage() {
	alert("That particular function or page is not currently available!\nTry again later. Thanks.");
	return;
}

// ==================================================================