sfHover = function() {
   var sfEls = document.getElementById("nav").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"), "");
      }
   }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//AJAX CALL WITH PROTOTYPE

function ajax_loadContent(where, url){
	new Ajax.Request(url,
		{
			method:'get',
			onSuccess: function(req){
				document.getElementById(where).innerHTML = req.responseText;
			},
			onFailure: function(){
				document.getElementById(where).innerHTML = "<p style='text-align:center;'>Error while loading ajax response</p>";
			}
		}
	);
}
function ajax_addContent(where, url){
	new Ajax.Request(url,
		{
			method:'get',
			onSuccess: function(req){
				document.getElementById(where).innerHTML = req.responseText
			}
		}
	);
}

// FORM VALIDATION

function validateForm(formname) { 
	var valid=new Validation(formname,{onSubmit:false,useTitles:true});
	Validation.addAllThese([
		['validate-number-1-5', 'You must choose a number between 1 and 5', {
			min : 1, 
			max : 5,
			include : ['validate-number']
		}],
		['validate-nospecial', 'No special character allowed', {
			pattern : new RegExp("^[a-zA-Zz0-9-_]+$","gi")
		}]
	]);
	if(valid.validate()){
		return true;
	}
}

