var menu_delay = 0;
jQuery.noConflict();

function showSubMenu(entry) {
	if (entry != "about") jQuery("#about_list").slideUp('slow');
	if (entry != "services") jQuery("#services_list").slideUp('slow');
	if (entry != "team") jQuery("#team_list").slideUp('slow');
	if (entry != "career") jQuery("#career_list").slideUp('slow');
	
	setTimeout("jQuery('#" + entry + "_list').slideDown('slow')", menu_delay);
	menu_delay = 400;
}

function showForm() {
	jQuery("#send_cv_div").slideToggle('slow');
}

function email_validate(str){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)) return true;
	return false;
}

function formValidate(form) {
	if (jQuery.trim(form.name_.value) == '') {
		alert("Please, type your name!");
		return false;
	}

	if (jQuery.trim(form.email_.value) == '') {
		alert("Please, type your e-mail!");
		return false;
	}
	
	if (!email_validate(jQuery.trim(form.email_.value))) {
		alert("Please, type correct format e-mail!");
		return false;
	}

	if (jQuery.trim(form.cv.value) == '') {
		alert("Please, choose CV to upload!");
		return false;
	}

	if (jQuery.trim(form.message_.value) == '') {
		alert("Please, type some message text!");
		return false;
	}
	
	if (jQuery.trim(form.security_code.value) == '') {
		alert("Please, provide security code from image!");
		return false;
	}

	return true;
}

function sendMessage(form) {
	if (!formValidate(form)) return false;
	jQuery.ajax({
		type: "POST",
		data: jQuery(form).serialize(),
		cache: false,
		url: "send_mail.php?action=send_mail",
		success: function(response){
			alert(response);
			closePTT();
		},
		error: function(){
			alert('Could not send message...');
		}
	});

}

/*
 $.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form') return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea') this.value = '';
		else if (type == 'checkbox' || type == 'radio') this.checked = false;
		else if (tag == 'select') this.selectedIndex = -1;
	});
};
*/
/*
function loadPage(page, title) {
	
	var current_page = '';
	
	if ($('#home_link').attr('className') == 'act') current_page = 'home';
	else if ($('#employers_link').attr('className') == 'act') current_page = 'employers';
	else if ($('#employees_link').attr('className') == 'act') current_page = 'employers';
	else if ($('#learners_link').attr('className') == 'act') current_page = 'learners';
	else if ($('#contact_link').attr('className') == 'act') current_page = 'contact';
	else if ($('#faq_link').attr('className') == 'act') current_page = 'faq';
	else if ($('#charity_link').attr('className') == 'act') current_page = 'charity';
	else if ($('#blog_link').attr('className') == 'act') current_page = 'blog';
	
	if (page == current_page) return true;
	
	$('#' + current_page + '_link').removeClass('act');
	
	document.title = 'MYULO - ' + title;
	
	if (page == 'home')	{
		$('#home_link').addClass('act');
		$('#body').load('index.php?notemplate');
	} else if (page == 'myaccount')	{
		//$('#home_link').addClass('act');
		$('#body').load('myaccount.php?notemplate');
	} else if (page == 'myaccountedit')	{
		//$('#home_link').addClass('act');
		$('#user_menu').html('<div style="float: left;"><img left;" src="images/ajax-loader.gif" border="0" alt="Loading..." /></div><div style="float: left;">Loading form...</div>');
		$('#body').load('myaccount.php?action=edit&notemplate');
	} else if (page == 'postad') {
		//$('#home_link').addClass('act');
		$('#user_actions').html('<div style="float: left;"><img src="images/ajax-loader.gif" border="0" alt="Loading..." /></div><div style="float: left;">Loading form...</div>');
		$('#body').load('postad.php?notemplate');
	} else if (page == 'myaccountpostadok') {
		//$('#home_link').addClass('act');
		$('#body').load('myaccount.php?notemplate&postadok');
	} else if (page == 'addpost') {
		$('#add_post_link').html('<div style="float: left;"><img left;" src="images/ajax-loader.gif" border="0" alt="Loading..." /></div><div style="float: left;">Loading add post form...</div><br clear="all" />');
		$('#body').load('addpost.php');
	} else if (page.indexOf('editpost') > -1) {
		$('#add_comment_link').html('<div style="float: left;"><img left;" src="images/ajax-loader.gif" border="0" alt="Loading..." /></div><div style="float: left;">Loading edit post form...</div><br clear="all" />');
		$('#body').load(page);
	} else if (page == 'blog') {
		$('#blog_link').addClass('act');
		$('#body').load('blog.php?notemplate');
	}
}
*/
