// TABBED BROWSING	
$(document).ready(function(){
	$('ul.tabNav a').click(function() {
		var curChildIndex = $(this).parent().prevAll().length + 1;
		$(this).parent().parent().children('.current').removeClass('current');
		$(this).parent().addClass('current');
		$(this).parent().parent().next('.tabContainer').children('.current').slideUp('fast',function() {
			$(this).removeClass('current');
			$(this).parent().children('div:nth-child('+curChildIndex+')').slideDown('normal',function() {
				$(this).addClass('current');
			});
		});
		return false;								
	});
});

// BOOKMARK THIS PAGE
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

// EMAIL THIS PAGE
function mailpage()
	{
		mail_str = "mailto:?subject=Check out the SD Instruments " + document.title + " page";
		mail_str += "&body=I thought you might be interested in the " + document.title;
		mail_str += ". You can view it at, " + location.href;
		location.href = mail_str;
}

//START CRM
function startCrm() {
	document.getElementById('err_r_first_name').style.background='transparent';
	document.getElementById('err_r_last_name').style.background='transparent';
	document.getElementById('err_r_phone').style.background='transparent';
	document.getElementById('err_r_email').style.background='transparent';

	var formStatus = 'pass';

	if (document.quote_request_form.first_name.value == '') {
		formStatus = 'fail';
		document.getElementById('err_r_first_name').style.background='pink';
	}

	if (document.quote_request_form.last_name.value == '') {
		formStatus = 'fail';
		document.getElementById('err_r_last_name').style.background='pink';
	}

	if (document.quote_request_form.phone.value == '') {
		formStatus = 'fail';
		document.getElementById('err_r_phone').style.background='pink';
	}

	if (document.quote_request_form.email.value == '') {
		formStatus = 'fail';
		document.getElementById('err_r_email').style.background='pink';
	}

	if (formStatus == 'pass') {
		var fName = document.quote_request_form.first_name.value;
		var lName = document.quote_request_form.last_name.value;
		var phone = document.quote_request_form.phone.value;
		var email = document.quote_request_form.email.value;

		//document.getElementById('crm_start').src='/crm_start.asp?first_name=' + fName + '&last_name=' + lName + '&phone=' + phone + '&email=' + email;

		var screenW = screen.width - 200;
		var screenH = screen.height - 200;
		var posLeft = 0;
		var posTop = 0;
		
		if (screen) {
			posLeft = (screen.width / 2) - (screenW / 2);
			posTop = (screen.height / 2) - (screenH / 2);
		}


		var signupWindow=window.open('/quote-request-form/?first_name=' + fName + '&last_name=' + lName + '&phone=' + phone + '&email=' + email, 'form_spring', 'location=yes,resizable=yes,scrollbars=yes,width='+screenW+',height='+screenH+',left='+posLeft+',top='+posTop);
		signupWindow.focus();
		return true;

	}
	else {
		alert('Check the form for errors.  Highlighted fields are required');
		return false;
	}
}