/////////////////////////////////
// BEGIN HR PRE-LOAD SCRIPT
// Pre-loads replaced "hr" elements after page load, so it doesn't interfere with other "onPageLoad" declarations
/////////////////////////////////
function fancyRules() { 
  if (!document.getElementsByTagName) return; 
          var hr = document.getElementsByTagName("hr");
  for (var i=0; i<hr.length; i++) { 
    var newhr = hr[i]; 
    var wrapdiv = document.createElement('div');
    wrapdiv.className = 'line';  
    newhr.parentNode.replaceChild(wrapdiv, newhr);  
    wrapdiv.appendChild(newhr);  
  } 
 } 

window.onload = fancyRules; 





/////////////////////////////////
// BEGIN POPUP WINDOW SCRIPT
// Construct HTML Link like this:
// <a href="link.html" onClick="openWin('link.html','','scrollbars=no,resizable=yes,location=no,menubar=no,width=150,height=100,top=50,left=50'); return false">LINK</a>
/////////////////////////////////
function openWin(location,winName,features) {
window.open(location,winName,features);
}





/////////////////////////////////
// BEGIN EASY POPUP WINDOW SCRIPT
// Construct easier HTML Link like this:
// <a href="link.html" onClick="openWin('link.html','','150','100','#FFFFFF'); return false">LINK</a>
/////////////////////////////////
// For popup windows with URL, Title, Size (W,H) and Background-Color parameter (5 parameters)
var newwindow;
var wheight = 0, wwidth = 0;

function popup5(url, title, iwidth, iheight, colour) {
var pwidth, pheight;


if ( !newwindow || newwindow.closed ) {
	pwidth=iwidth+30;
	pheight=iheight+30;
	newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',scrollbars=no,resizable=1,top=50,left=50,status=1 ');
	wheight=iheight;
	wwidth=iwidth;
}
 
if (wheight!=iheight || wwidth!=iwidth ) {
	pwidth=iwidth+30;
	pheight=iheight+90;
	if (version.substring(0,1)>3) { 	// check browser v4+ supporting JavaScript 1.2	
		newwindow.resizeTo(pwidth, pheight);
	}
	wheight=iheight;
	wwidth=iwidth;
}

newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + ' <\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<img src=' + url + '  title=\"' + title + '\"   alt=\"' + title + '\" >');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}





/////////////////////////////////
// BEGIN 'SUBMIT ONCE, THEN DISABLE SUBMIT FORM' SCRIPT
// © Dynamic Drive (www.dynamicdrive.com)
// Construct HTML Link like this:
// <form method="POST" onSubmit="submitonce(this)">
/////////////////////////////////
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}





/////////////////////////////////
// BEGIN STANDARD EMAIL FORM VALIDATION SCRIPT
// © Dynamic Drive (www.dynamicdrive.com)
// Visit Nav Surf at http://navsurf.com
// Construct FORM Link like this:
// <form method="POST" onsubmit="return checkContactForm(this);">
/////////////////////////////////
function checkContactForm(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("name", "email", "Comments");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Name", "Email", "Comments");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}





/////////////////////////////////
// BEGIN EMAIL VALIDATION SCRIPT
// © Dynamic Drive (www.dynamicdrive.com)
// Visit Nav Surf at http://navsurf.com
// Construct FORM Link like this:
// <form method="POST" onClick="return checkmail(this.form.email)">
/////////////////////////////////
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
   var returnval=emailfilter.test(e.value)
   if (returnval==false){
      alert(" - Please enter a valid email address.")
      e.select()
   }
   return returnval
}





/////////////////////////////////
// BEGIN JAVASCRIPT ROLLOVER AUTO-DETECTION SCRIPT
// Non-Obtrusive Image Swap Script by Hesido.com
// >> http://www.hesido.com/web.php?page=imageswapping#header <<
// Construct Image Link like this:
// <img src="image_nm.gif">
// That's it. This script will handle the rest. Just be sure your images are named with:
//    image_nm.jpg - Base image name
//    image_hv.jpg - Image name for hover
//    image_md.jpg - Image name for mouse-down
//    image_ou.jpg - Image name for mouse-out (when you want a separate image for mouse-out instead of restoring to original)
//    image_mu.jpg - Image name for mouse-up (when you want a separate image for mouse-up instead of restoring to original)/////////////////////////////////
//If the browser is W3 DOM compliant, execute setImageSwaps function
if (document.getElementsByTagName && document.getElementById) {
if (window.addEventListener) window.addEventListener('load', setImageSwaps, false);
else if (window.attachEvent) window.attachEvent('onload', setImageSwaps);
}

//When document loads, apply the prepareImageSwap function to various images with our desired settings
function setImageSwaps() {
//Mousedown, restore - for images in container with ID=example2
//prepareImageSwap('example2',true,true,true,true);
//Hover, mousedown, no restore - for images in container with ID=example3
//prepareImageSwap('example3',true,false,true,false);
//Hover with restore, most basic usage - for any image in document.body that are not yet processed (function accepts elements,too)
prepareImageSwap(document.body);
//Note that once an image is processed, it won't be processed again, so you should set more specific images first, e.g. document.body, as it is the grand
//container, has to be processed last.
}


//The following is the function that do the actual job

function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) {
//Do not delete these comments.
//Non-Obtrusive Image Swap Script by Hesido.com
//V1.1
//Attribution required on all accounts
	if (typeof(elem) == 'string') elem = document.getElementById(elem);
	if (elem == null) return;
	var regg = /(.*)(_nm\.)([^\.]{3,4})$/
	var prel = new Array(), img, imgList, imgsrc, mtchd;
	imgList = elem.getElementsByTagName('img');

	for (var i=0; img = imgList[i]; i++) {
		if (!img.rolloverSet && img.src.match(regg)) {
			mtchd = img.src.match(regg);
			img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3];
			img.outSRC = img.src;
			if (typeof(mouseOver) != 'undefined') {
				img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false;
				img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false;
				img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false;
				img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false;
				}
			if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;}
			if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;}
			if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;}
			if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;}
			img.rolloverSet = true;
		}
	}

	function preLoadImg(imgSrc) {
		prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc;
	}

}

function imgHoverSwap() {this.src = this.hoverSRC;}
function imgOutSwap() {this.src = this.outSRC;}
function imgMouseDownSwap() {this.src = this.mdownSRC;}
function imgMouseUpSwap() {this.src = this.mupSRC;}





