$('html').addClass('js');
sfHover = function() {
	var sfEls = document.getElementById("top_navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

sfHoverLeftNav = function() {
	var sfElsLeftNav = document.getElementById("left_nav").getElementsByTagName("LI");
	for (var i=0; i<sfElsLeftNav.length; i++) {
	if (sfElsLeftNav[i].className!="current_dropdown"){
		sfElsLeftNav[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfElsLeftNav[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
		}
	else {
		sfElsLeftNav[i].onmouseover=function() {
			this.className+=" current_dropdown_sfhover";
		}
		sfElsLeftNav[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" current_dropdown_sfhover\\b"), "");
		}
		
	}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHoverLeftNav);

// contact page script

function isNum(s) {
	var c, i;
	if (s==null) return false;
	for (i=0;i<s.length;i++) {
		c=s.charAt(i); 
		if (((c>'9')||(c<'0'))&&(c!='.')&&(c!='-')) 
			return false;
	}
	return true;
}
function isBlank(s) {
	var c, i;
	if (s==null) return true;
	for (i=0;i<s.length;i++) {
		c=s.charAt(i); 
		if ((c!=' ')&&(c!='\n')&&(c!='\t')) 
			return false;
	}
	return true;
}
function CollectionChecked(collection) 
{
	for (var j = 0 ; j < collection.length ; j++)
	{
		var item = collection[j];
		if (item.checked)
			return true;
	}
	return false;
}
function validateEmail(sEmail)
{
	return ((sEmail.indexOf("\@") != -1) &&		// Contains a '@' character
	    	(sEmail.indexOf(".") != -1));		// Contains a '.' character
}
function VerifyForm() {
	var f = this;
	var i, e; 
	var empty_fields=''; 
	var errors=''; var msg='';
	var bad_emails='';
	var collections = new Object;
	for (i=0;i<f.length;i++)
	{
		e=f.elements[i];
		if(e.name!=null && e.name.length>0 && e.validate!=null)
		{
			if ((e.type=='textarea')||(e.type=='text'))
			{
				if (isBlank(e.value))
				{
					empty_fields += "\n    " + e.name;
					continue;
				}
				var hasmax = !isBlank(e.max);
				var hasmin = !isBlank(e.min);
				if (e.numeric||hasmax||hasmin)
				{
					var num=isNum(e.value);
					var v=(num)?parseFloat(e.value):0;
					if(!num||(hasmin&&v<e.min)||(hasmax&&v>e.max))
					{
						errors += '- the Field '+e.name+' must be a number';
						if (hasmin)
							errors += ' that is greater than ' + e.min;
						if (hasmax&&hasmin)
							errors += ' and less than '+e.max;
						else if (hasmax)
							errors += ' that is less than '+e.max;
						errors+='.\n';
					}
				}
			}
			
			if (e.type=='radio' || e.type=='checkbox')
			{
				if (collections[e.name] == null)
				{
					var collection = f[e.name];
					collections[e.name] = true;
					if (!CollectionChecked(collection))
						empty_fields += "\n  " + e.name;
				}
			}	
			
			if (e.is_email != null)
			{
			if (!validateEmail(e.value))
				{
				bad_emails+=e.name+'\n';
				//form.email_field_1.focus();
				//form.email_field_1.select();
				return false;
				}
			}			
		} 
	}
	
	if (!empty_fields&&!errors)
		return true;
	
	msg+='';
	if(empty_fields)
	{
		msg+='The following fields are required:'+empty_fields+'\n';
		if (errors)
			msg+='\n';
	}
	msg+=errors + '\n';
	if(bad_emails)
	{
		msg+='The following emails are not in the correct format: '+bad_emails;
	}
	alert(msg)
	return false;
}



function isNum(s) {
	var c, i;
	if (s==null) return false;
	for (i=0;i<s.length;i++) {
		c=s.charAt(i); 
		if (((c>'9')||(c<'0'))&&(c!='.')&&(c!='-')) 
			return false;
	}
	return true;
}
function isBlank(s) {
	var c, i;
	if (s==null) return true;
	for (i=0;i<s.length;i++) {
		c=s.charAt(i); 
		if ((c!=' ')&&(c!='\n')&&(c!='\t')) 
			return false;
	}
	return true;
}
function CollectionChecked(collection) 
{
	for (var j = 0 ; j < collection.length ; j++)
	{
		var item = collection[j];
		if (item.checked)
			return true;
	}
	return false;
}
function validateEmail(sEmail)
{
	return ((sEmail.indexOf("\@") != -1) &&		// Contains a '@' character
	    	(sEmail.indexOf(".") != -1));		// Contains a '.' character
}
function VerifyForm() {
	var f = this;
	var i, e; 
	var empty_fields=''; 
	var errors=''; var msg='';
	var bad_emails='';
	var collections = new Object;
	for (i=0;i<f.length;i++)
	{
		e=f.elements[i];
		if(e.name!=null && e.name.length>0 && e.validate!=null)
		{
			if ((e.type=='textarea')||(e.type=='text'))
			{
				if (isBlank(e.value))
				{
					empty_fields += "\n    " + e.name;
					continue;
				}
				var hasmax = !isBlank(e.max);
				var hasmin = !isBlank(e.min);
				if (e.numeric||hasmax||hasmin)
				{
					var num=isNum(e.value);
					var v=(num)?parseFloat(e.value):0;
					if(!num||(hasmin&&v<e.min)||(hasmax&&v>e.max))
					{
						errors += '- the Field '+e.name+' must be a number';
						if (hasmin)
							errors += ' that is greater than ' + e.min;
						if (hasmax&&hasmin)
							errors += ' and less than '+e.max;
						else if (hasmax)
							errors += ' that is less than '+e.max;
						errors+='.\n';
					}
				}
			}
			
			if (e.type=='radio' || e.type=='checkbox')
			{
				if (collections[e.name] == null)
				{
					var collection = f[e.name];
					collections[e.name] = true;
					if (!CollectionChecked(collection))
						empty_fields += "\n  " + e.name;
				}
			}	
			
			if (e.is_email != null)
			{
			if (!validateEmail(e.value))
				{
				bad_emails+=e.name+'\n';
				//form.email_field_1.focus();
				//form.email_field_1.select();
				return false;
				}
			}			
		} 
	}
	
	if (!empty_fields&&!errors)
		return true;
	
	msg+='';
	if(empty_fields)
	{
		msg+='The following fields are required:'+empty_fields+'\n';
		if (errors)
			msg+='\n';
	}
	msg+=errors + '\n';
	if(bad_emails)
	{
		msg+='The following emails are not in the correct format: '+bad_emails;
	}
	alert(msg)
	return false;
}

// aPad - create clickable blocks with class 'a_pad' */
function pad(){$('.link-pad').each(function(){var $url=$(this).find('a').attr('href');$(this).click(function(){window.location=$url;return false;});});};

