function getValidationSet(form) {
	// a thin function to return arrays of required fields by form name. used to supplement validate() function.
	
	if (form.name == "uform") {
		var aValSet = new Array('username','pword','pword2','email', 'fname','lname','address','city','pcode','phone');
	}
	
	
	return (aValSet);

}




function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
        var pluginsArrayLength = navigator.plugins.length;
        // for each plugin...
        for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
            // loop through all desired names and check each against the current plugin name
            var numFound = 0;
            for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
                // if desired plugin name is found in either plugin name or description
                if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
                    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
                    // this name was found
                    numFound++;
                }   
            }
            // now that we have checked all the required names against this one plugin,
            // if the number we found matches the total number provided then we were successful
            if(numFound == daPlugins.length) {
                pluginFound = true;
                // if we've found the plugin, we can stop looking through at the rest of the plugins
                break;
            }
        }
    }
    return pluginFound;
}

 

function target_blank () {  

	// replaces target="_blank" attribute for XHTML1.1 ccompliance. 
	// usage: add 'class="target_blank"' to the anchor tag

 
	href = document.getElementsByTagName("a");
  

	for (i in href)
	{ 
	  if (href[i].className == 'target_blank') 
		 href[i].onclick = function() { window.open(this.href); return false; }
	}
}


function validate(form) {
	var bValidForm = true;
	var bValidEmail = true;
	var bValidPassword  = true;
	var sErrorMsg = 'Please fill out all of the required fields.';
	
	var aRequired = getValidationSet(form);
	
	for (i in aRequired) {
	
		field = aRequired[i];
		
		changeColor(field,'#000000');
				
		if (form[field].value == '' || form[field].value == 'REQUIRED') {
			bValidForm = false;
			changeColor(field,'#FF0000');
			form[field].value = 'REQUIRED';
		}
	}
	
	// specific checks. since they're common, they're left in the main function.
	
	if (form['email']) {
		bValidEmail= checkEmail(form,'email'); // can be expanded later to include more specific validation checks
		sErrorMsg = bValidEmail ? sErrorMsg : "Your email address is invalid. Please re-enter";
	}
	
	if (form['pword'] && form['pword2']) {
		bValidPassword =  form['pword'].value == form['pword2'].value ? 1 : 0;
		sErrorMsg = bValidPassword ? sErrorMsg : "Passwords do not match. Please Re-enter.";
		
		if (!bValidPassword) {
			form['pword'].value = '';
			form['pword2'].value = '';

		}
	}

		
	
	if (bValidForm && bValidEmail && bValidPassword) {		
		return true;
	} else {
		alert (sErrorMsg);
		return false;
	}
	
}

function checkEmail(o,id) {
	changeColor(id,'#000000');		
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(o[id].value)) {
		return true;
	} 
	
	changeColor(id,'#FF0000');
	return false;
}

function changeColor(id,color) {

	if(document.getElementById(id)) {
		document.getElementById(id).style.color = color;
	}
}

function checkUser(o,id) {		
	//		aUsers = new Array(<?php if ($dbmode) {echo(getUsers()); } ?>);
					
	//		changeColor(id,'#000000');		
			
	//		for (x in aUsers) {
	//			if (aUsers[x] == o[id].value) {
	//				changeColor(id,'#FF0000');
	//				return false;
					
	//			}
				
	//		}
	
	return true;			
}

function toggle( nodeid ) {
	targetId = "c" + nodeid;
	imageId = "i" + nodeid;

	if ( document.getElementById ) {
		target = document.getElementById( targetId );
		ielement = document.getElementById( imageId );
		if ( target.style.display == "block" ) {
			target.style.display = "none";
			
			if (ielement.src) {
				ielement.src = "/misc/menu-collapsed.png";
			}
		} else {
			target.style.display = "block";
			if (ielement.src) {
				ielement.src = "/misc/menu-expanded.png";
			}

		}
	}
}

//-Urchin Tracking Module(UTM),$Revision: 1.3 $,Copyright 2002 Urchin Software Corporation-
var __utm1,__utm2,__utm3,__utmi,__utmn,__utmd,__utmu,__utmp,__utmr;
__utm1 = document.cookie.indexOf("__utm1=");
__utm2 = document.cookie.indexOf("__utm2=");
__utm3 = document.cookie.indexOf("__utm3=");
__utmn = Math.round(Math.random() * 4294967295);
__utmd = new Date();
__utmu = Math.round(__utmd.getTime()/1000);
if ((__utm1 < 0) || (__utm2 < 0)) {
 document.cookie="__utm1="+__utmn+"."+__utmu+"; path=/; expires=Sun, 18 Jan 2038 00:00:00 GMT";
 document.cookie="__utm2="+__utmu+"; path=/; expires=Sun, 18 Jan 2038 00:00:00 GMT";
 document.cookie="__utm3="+__utmu+"; path=/;";
} else if (__utm3 < 0) {
 document.cookie="__utm2="+__utmu+"; path=/; expires=Sun, 18 Jan 2038 00:00:00 GMT";
 document.cookie="__utm3="+__utmu+"; path=/;";
}
__utmr = document.referrer;
if (!__utmr) {__utmr = "-";}
else {
 __utmp = __utmr.indexOf(document.domain);
 if ((__utmp >= 0) && (__utmp <= 8)) __utmr = 0;
}
var __utmi = new Image(1,1);
__utmi.src ="/__utm.gif?utmn="+__utmn+"&utmr="+__utmr;
