// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function isValidEmail(email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (reg.test(email) == false) {
		return false;
	}
	return true;
}


function setTab(idx) {
	var tds = $('.menubar td');
	tds.removeClass('current');
	$(tds[idx]).addClass('current');
}

function setMenu(param) {
	switch (param) {
		case 'index':
			$('#submenu').html('&nbsp;');
			setTab(0);
			break;
		case 'power':
		case 'power-why':
		case 'power-about':
		case 'power-withus':
		case 'power-different':
			setTab(1);
			$('#submenu').load('/menu/power');
			break;
		case 'services':
		case 'services-bw':
		case 'services-fc':
		case 'services-specialty':
		case 'services-editorial':
		case 'services-marketing':
		case 'services-addon':
			setTab(2);
			$('#submenu').load('/menu/services');
			break;
		case 'testimonial':
		case 'testimonial-editorial':
		case 'testimonial-marketing':
			$('#submenu').load('/menu/testimonials');
			setTab(3);
			break;
		case 'faq':
			$('#submenu').html('&nbsp;');
			setTab(4);
			break;
	}
}

function setContent(param) {
	if (param == 'index') {
		$('#content').load('/content/home');
	} else if (param == 'power') {
		$('#content').load('/content/power');
	} else if (param == 'power-why') {
		$('#content').load('/content/power-why-selfpublish');
	} else if (param == 'power-about') {
		$('#content').load('/content/power-about');
	} else if (param == 'power-withus') {
		$('#content').load('/content/power-withus');
	} else if (param == 'power-different') {
		$('#content').load('/content/power-different');
	} else if (param == 'services') {
		$('#content').load('/content/services');
	} else if (param == 'services-bw') {
		$('#content').load('/content/services-bw');
	} else if (param == 'services-fc') {
		$('#content').load('/content/services-fc');
	} else if (param == 'services-specialty') {
		$('#content').load('/content/services-specialty');
	} else if (param == 'services-marketing') {
		$('#content').load('/content/services-marketing');
	} else if (param == 'services-addon') {
		$('#content').load('/content/services-addon');
	} else if (param == 'services-editorial') {
		$('#content').load('/content/services-editorial');
	} else if (param == 'testimonial') {
		$('#content').load('/content/testimonial');
	} else if (param == 'testimonial-editorial') {
		$('#content').load('/content/testimonial-editorial');
	} else if (param == 'testimonial-marketing') {
		$('#content').load('/content/testimonial-marketing');
	} else if (param == 'faq') {
		$('#content').load('/content/faq');
	}
	
	setMenu(param);
}