var base = "/";$(function() {
	$("select:not(#products)").selectBox();
  $("input.uni").uniform();
	$('#searchinput').focus(function() {
		if($(this).val() == "search") $(this).addClass('typing').val('');
	});
	$('#searchinput').blur(function() {
		if($(this).val() == "") $(this).removeClass('typing').val('search');
	});
	
	// manufacturing locations 
	$('.viewcerts').click(function() {
		$(this).parent().next().slideToggle();
		return false;
	});
	
	$('#contact_form label').click(function() {
		if($(this).parent('span').length > 0) {
			$(this).next().focus();
		}
	});
	$('#contact_form input').each(function() {
		// for initial page load
		if($(this).val() > '' && $(this).prev('label').length > 0) {
			$(this).prev().css({right:'45px', left:'auto', textAlign:'right'});
		}
	});
	$('#contact_form input').change(function() {
		if($(this).prev('label').length > 0) {
			$(this).prev().css({right:'45px', left:'auto', textAlign:'right'});
		}
	});
	$('#contact_form input').focus(function() {
		if($(this).prev('label').length > 0) {
			$(this).prev().css({right:'45px', left:'auto', textAlign:'right'});
		}
	});
	$('#contact_form textarea').focus(function() {
		if($(this).prev('label').length > 0) {
			$(this).prev().hide();
		}
	});
	$('#contact_form input').blur(function() {
		if($(this).prev('label').length > 0 && $(this).val() == '') {
			$(this).prev().css({right:'auto', left:'8px', textAlign:'auto'});
		}
	});
	$('#contact_form textarea').blur(function() {
		if($(this).prev('label').length > 0 && $(this).val() == '') {
			$(this).prev().show();
		}
	});
	$('#chat, .chat').click(function() {
		_gaq.push(['_setCustomVar',1,'Live Chat '+window.location.pathname,1]);
		_gaq.push(['_trackEvent','Live Chat','Click']);															 
		window.open("https://server.iad.liveperson.net/hc/86968872/?cmd=file&file=visitorWantsToChat&site=86968872&byhref=1",'PorexChat','width=500,height=500');
		return false;
	});
	$('#module-faqs strong').next('div').hide();
	$('#module-faqs strong').click(function() {$(this).next().slideToggle();});
	$('.watch').fancybox({'width'	: '600'});
	
	$('a[href$=".pdf"]').click(function() {
			_gaq.push(['_trackEvent', 'PDF Download', 'click', $(this).html()]);
	}); 
	$('a[href^="mailto:"]').click(function() {
		var href = $(this).attr('href');
		domain = href.substring(href.indexOf('@')+1);
		_gaq.push(['_trackEvent', 'Email', 'click', domain]);
	});
});
			

function goTo(url) {
	window.location = url;
}
