//stretches the page to the bottom of the browser
// div = div to target to stretch page (typically div id="content")
function fillPage(div) {
	//gets the target div
	var targetDiv =  document.getElementById(div);
	//gets the height of the client window
	var winHeight = document.documentElement.clientHeight;
	//support checks
	if(document.getElementById && document.getElementsByTagName) {
		//gets height of web page itself (area btw body tags; this area may be smaller or larger than winHeight)
		var bodyHeight = document.getElementsByTagName("body")[0].clientHeight
		//gets the difference in height btw page and window
		var diff = winHeight - bodyHeight;
		//if a +ve difference, page is smaller than win and should be stretched
		if(diff > 0) {
			//stretches the targetted div by the difference in height (must also include the target div's own height)
			targetDiv.style.height = targetDiv.offsetHeight + diff + "px";
		}
	}
	
	//ensures main (#menu; left-hand) menu doesn't overlap contact info on bottom left
	//works by comparing the heights of #menu and #content, and making #content longer than #main if it's shorter
	var content = document.getElementById("content");
	var menu = document.getElementById("menu");
	if(content.offsetHeight < menu.offsetHeight) {
		content.style.height = content.offsetHeight + 150 + "px";	
	}
	
}

/*inserts Flash onto the page (used to avoid IE "Click to activate..." nag	
ran = total # of random #'s to choose from (0 = always)
flaFile = path to swf
w = swf width
h = swf height
fv = flashVars
div = div containing swf
killTime = time to keep fla onscreen (0 = permanent) */
function insertFla(ran, flaFile, w, h, fv, div, killTime) {
	//randomly adds fla
	//setTimeout used to delay this slightly to let FlashVars load
	if(Math.floor(Math.random()*ran) == 0) { window.setTimeout('addFla("' + flaFile + '",' + w + ',' + h + ',"' + fv + '","' + div + '",' + killTime +')',1); }
	//addFla(flaFile, w, h, fv, div, killTime
}

//uses swfobject (downloaded online)
function addFla(flaFile, w, h, fv, div, killTime) {
	var so1 = new SWFObject(flaFile, "swfHeader", w, h, "7", "#FFFFFF");
	so1.addParam("movie", flaFile); 
	so1.addParam("wmode", "transparent");
	so1.addParam("FlashVars", fv);  
	so1.write(div);
	window.setTimeout("killFla('" + div + "'," + killTime + ")",killTime);	
}

//added so user can still click on header after killTime seconds in FF
function killFla(div, killTime) {
	if(killTime > 0) {
		document.getElementById(div).innerHTML = "";
	}
}


function verifyPassword(pwd1,pwd2)
{
   if (pwd1 != pwd2)
   {
        window.alert("Your password do not match, Please re-verify them");
   } else 
   {
   
        return;
   }

}

function check_date(d)
{
  var strMistakes="";

  var datePattern = /^\d{4}-\d{2}-\d{2}$/gi;
  var testDate = true;
  if (String(d).match(datePattern) == null) testDate = false;

  if (testDate)
  {
   var theDate, theMonth, theYear
     
   theDate = parseInt(d.substr(8,2));
   theMonth = parseInt(d.substr(5,2));
   theYear = parseInt(d.substr(0,4));
     
   if (theMonth < 0 || theMonth > 12) strMistakes = "Month is invalid\n";
   if (theDate < 0 || theDate > 31) strMistakes = "Date is invalid\n";  
   
   if (theDate >= 1 && theDate <= 31)
   {
    if (theMonth == 2)
    {
     if (theYear % 4 == 0)
     {
      if (theDate < 0 || theDate > 29) strMistakes = "Date is invalid\n";
     }
     else
     {
      if (theDate < 0 || theDate > 28) strMistakes = "Date is invalid\n";
     }
    }
   }
  }
  else
  {
   strMistakes = "Date format is invalid\n";
  }
  if (strMistakes != "")
  {
     alert(strMistakes);
     d.value = "";
     
  }  
  return strMistakes;
}
