function showSection(secID,linkID){
	$("#philosophy").hide()
	$("#services").hide();
	$("#contact").hide();
	$("#testimonials").hide();
	
	$("#phil_link").removeClass('act');
	$("#work_link").removeClass('act');
	$("#video_link").removeClass('act');
	$("#serv_link").removeClass('act');
	$("#cont_link").removeClass('act');
	$("#testi_link").removeClass('act');
	
	if(secID != 'work' && secID != 'video' ){
		$("#"+secID).show();
	}
	
	$("#"+linkID).addClass('act');
	
}

//** MENU from SQUIDFINGERS*********************************************/

Menu = {timer : null, current : null};
Menu.getStyle = function(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}
Menu.show = function(name){
	if(this.timer) clearTimeout(this.timer);
	this.getStyle(name).display = "block";
	this.current = name;
	$("#work_link").addClass('act');
}
Menu.show2 = function(name){
	if(this.timer) clearTimeout(this.timer);
	this.getStyle(name).display = "block";
	this.current = name;
	$("#video_link").addClass('act');
}
Menu.hide = function(){
	this.timer = setTimeout("Menu.doHide()",50);
}
Menu.hide2 = function(){
	this.timer = setTimeout("Menu.doHide2()",50);
}
Menu.doHide = function(){
	if(this.current){
		this.getStyle(this.current).display = "none";
		this.current = null;
		$("#work_link").removeClass('act');
	}
}
Menu.doHide2 = function(){
	if(this.current){
		this.getStyle(this.current).display = "none";
		this.current = null;
		$("#video_link").removeClass('act');
	}	
}

//**** VALIDATION HELPERS *************************************************
//returns true if the string is empty
function isEmpty(str){
	return (str == null) || (str.length == 0);
}
// returns true if the string is a valid email
function isEmail(str){
	if(isEmpty(str)) return false;
	var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
	return re.test(str);
}
// returns true if the string only contains characters A-Z or a-z
function isAlpha(str){
	var re = /[^a-zA-Z]/g
	if (re.test(str)) return false;
	return true;
}
// returns true if the string only contains characters 0-9
function isNumeric(str){
	var re = /[\D]/g
	if (re.test(str)) return false;
	return true;
}
// returns true if the string only contains characters A-Z, a-z or 0-9
function isAlphaNumeric(str){
	var re = /[^a-zA-Z0-9]/g
	if (re.test(str)) return false;
	return true;
}
// returns true if the string only contains characters A-Z, a-z or 0-9 or . or #
function isAddress(str){
	var re = /[^a-zA-Z0-9\#\.]/g
	if (re.test(str)) return false;
	return true;
}
// returns true if the string's length equals "len"
function isLength(str, len){
	return str.length == len;
}
// returns true if the string's length is between "min" and "max"
function isLengthBetween(str, min, max){
	return (str.length >= min)&&(str.length <= max);
}
// returns true if the string is a US phone number formatted as...
// (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000
function isPhoneNumber(str){
	var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/
	return re.test(str);
}
// returns true if the string is a valid date formatted as...
// mm dd yyyy, mm/dd/yyyy, mm.dd.yyyy, mm-dd-yyyy
function isDate(str){
	var re = /^(\d{1,2})[\s\.\/-](\d{1,2})[\s\.\/-](\d{4})$/
	if (!re.test(str)) return false;
	var result = str.match(re);
	var m = parseInt(result[1]);
	var d = parseInt(result[2]);
	var y = parseInt(result[3]);
	if(m < 1 || m > 12 || y < 1900 || y > 2100) return false;
	if(m == 2){
		var days = ((y % 4) == 0) ? 29 : 28;
	}else if(m == 4 || m == 6 || m == 9 || m == 11){
		var days = 30;
	}else{
		var days = 31;
	}
	return (d >= 1 && d <= days);
}
// returns true if "str1" is the same as the "str2"
function isMatch(str1, str2){
	return str1 == str2;
}
// returns true if the string contains only whitespace
// cannot check a password type input for whitespace
function isWhitespace(str){ // NOT USED IN FORM VALIDATION
	var re = /[\S]/g
	if (re.test(str)) return false;
	return true;
}
// removes any whitespace from the string and returns the result
// the value of "replacement" will be used to replace the whitespace (optional)
function stripWhitespace(str, replacement){// NOT USED IN FORM VALIDATION
	if (replacement == null) replacement = '';
	var result = str;
	var re = /\s/g
	if(str.search(re) != -1){
		result = str.replace(re, replacement);
	}
	return result;
}
//VALIDATION FOR CONTACT FORM
function validate(){
	var this_form = document.contact;
	var err_count = 0;
	var err = "The following errors have occurred:\n";
	
		//VALIDATE NAME
		if(isEmpty(this_form.yourname.value) || this_form.yourname.value == this_form.yourname.title){
		err_count++;
		err += "Your name is required\n";
		}

		//VALIDATE EMAIL
		if(isEmpty(this_form.youremail.value) || !isEmail(this_form.youremail.value) || this_form.youremail.value != this_form.youremail2.value){
		err_count++;
		err += "Your email is required\n";
		}

		//VALIDATE MESSAGE
		if(isEmpty(this_form.yourmessage.value) || this_form.yourmessage.value == 'message'){
		err_count++;
		err += "A message is required\n";
		}

	//check for errors and alert the user, or submit the form
	if(err_count == 0){
		var nm = this_form.yourname.value;
		var em = this_form.youremail.value;
		var msg= this_form.yourmessage.value;
		
		sendMessage(nm,em,msg);
		return false;
	}else{
		alert(err);
		return false;
	}

}

//ajax function to send mail
function sendMessage(nm,em,msg){
	$.ajax({
	   type: "POST",
	   url: "ajax.sendmessage.php",
	   data: "name="+nm+"&email="+em+"&message="+msg,
	   success: function(msg){
	    //alert( "Data Saved: " + msg );
	   	$("#contactForm").html(msg);
	}
	 });

}
