function fixMenuSpan() {
	$('#nav li.li1').each( function(){
		var a = $(this).children('a');
		var contents = a.children('span').text();
		a.html(contents+' <span class="arrow">&nbsp;</span>');
	});
}

function checkNewsletter() {
	var check = true;
	var a = 'To join the Travel To Wellness family please enter:';
	var email = $('#ttw_email').val();
	var pc = $('#ttw_pc').val();
	var filter	= /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;	
	if(filter.test(email)){
		var n = email.split('@');
		$('#ttw_firstName').val(n[0]);
		$('#ttw_lastName').val(n[1]);
	} else {
		a += '\ra valid email address';
		check = false;
	}
	if(pc.length == 0 || pc == 'Postal Code / Zip ') {
		a += '\ryour Postal or Zip Code.';
		check = false;
	}
	if (!check) {
		alert(a);
	}
	return check;
}

function contentScroll(){
	var thisPage = window.location.pathname.substring(1);
//	alert(thisPage);
	$('#content a[href*="#"]').each( function(){
		//get the href
		var theHREF = $(this).attr('href');
		var targetName = theHREF.substr(theHREF.search('#')+1);
		//only apply fix if the link is on the same page
		if(theHREF.indexOf(thisPage) != -1){
			//get the target
			var theTarget = $('a[name="'+targetName+'"]');
			//make it a block level element to get the offset to work
			theTarget.css('display','block');
			var theTop = theTarget.offset();
	
			//remove the href from the original so that we can avoid the placement issue.
			$(this).attr('href', 'javascript:;');
			
			//bind the click to the element
			$(this).click(function(){
				$(document).scrollTop(theTop.top);
			});
		}
	});
}

 function hashMargins(){
	var u = window.location.hash;
	if(u.length > 0){
//		alert(u);
		ct = 3350; //we have no idea why this number works, but it does!
		$(".section-holder").css({
			'overflow': 'visible',
			'margin-top': ct,
			'margin-bottom': -ct
		});
		$(".block-holder").css({
			'overflow': 'visible',
			'margin-top': ct-18,
			'margin-bottom': -ct+18
		});
	}
 }
$(document).ready( function(){
	fixMenuSpan();
	//contentScroll();
});
//window.onload = hashMargins;

