
function expToggle(x1, theID) {
	var expTogglee = document.getElementById('togglee-' + x1);
	var expToggler = document.getElementById('toggler-' + x1);
	var elementTest = theID.substring(0, 1);
    
	if (expTogglee.style.display =='block' && elementTest == 't') {
		expTogglee.style.display='none';
		expToggler.style.backgroundImage='url(/themes/site_themes/default/imagesglobal/newsletter/bg_showstory.gif)';
		expToggler.style.backgroundRepeat='no-repeat';
		
		
	} else {
		expTogglee.style.display ='block';
		expToggler.style.backgroundImage='url(/themes/site_themes/default/imagesglobal/newsletter/bg_hidestory.gif)';
		expToggler.style.backgroundRepeat='no-repeat';
	}
}

function expToggleNew(x1, theID) {
	var expTogglee = document.getElementById('togglee-' + x1);
	var expToggler = document.getElementById('toggler-' + x1);
    
	if (expTogglee.style.display =='block') {
		expTogglee.style.display='none';
		expToggler.style.backgroundImage='url(/themes/site_themes/default/imagesglobal/icon_plus_blue.gif)';
		expToggler.style.backgroundRepeat='no-repeat';
		
		
	} else {
		expTogglee.style.display ='block';
		expToggler.style.backgroundImage='url(/themes/site_themes/default/imagesglobal/icon_minus_blue.gif)';
		expToggler.style.backgroundRepeat='no-repeat';
	}
}
function goToNewsletterStory() {
	var theRef = "";
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++) {
		hash = hashes[i].split('#');
		
			if(hash[1] == "") {
				hash[1] = "top";	
			}
			theRef = hash[1];
			theRef = theRef.substring(4,6);
			linkToGoTo = "div#togglee-" + theRef;
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
	}	
}


function filterMembers() {
	
$("select#memberSections").change( function() { 
																							
	var showRowsClass = $("select#memberSections").val();
	//alert(showRowsClass);
	var finalshowRowsClass = 'tr.' + showRowsClass;

	if($("select#memberSections").val() == "0") {
		$("tr:gt(0)").each(function(i){
			$(this).show();
		});
	} else {
		$("tr:gt(0)").each(function(i){
			$(this).hide();
		});
		
		$(finalshowRowsClass).each(function(i){
			$(this).show()
		});
		
	}
		
	showRowsClass = null;
	finalshowRowsClass = '';
									
	} );	
}

function getQuickLinks() {
	var theLink = '';
	var h2OffsetTopArrayValues = new Array();
	
	// get all the h2.highlight
	$("h2.highlight").each(function(i){
		theLink += '<li class="ql"><a href="#">' + $(this).html() + '</a></li>\n' ;	
		var targetOffset = $(this).offset().top;
		h2OffsetTopArrayValues[i] = targetOffset;
	});
	
	//output the quicklinks
	$("#q-links").html(theLink);
	
	//loop through quicklinks and bind click function
	$("li.ql").each(function(i){
							 
		$(this).click(function() {
		//alert(i);
           $('html, body').animate({scrollTop: h2OffsetTopArrayValues[i]}, 400);
		   $('div#quicklinks').animate({scrollTop: h2OffsetTopArrayValues[i]}, 400);
           return false;
         });
	});
}

function makeEs() {
	$(".make-e").each(function(i){				   
							   
		var string = $(this).html();
		string = jQuery.trim(string);
		
		string = string.replace('[', '');
		string = string.replace(']', '');
		
		var theName = string.split(" ");
		//alert(theName[0]);
		
		string = string.replace(' at ', '@');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' ', '');
		
		if(string.indexOf("-") != -1) {
			alert('found -');	
		}
		
		var finalString = "<a href='mailto:" + string + "' title='Send email'>" + theName[0] + "</a>";
		//alert(finalString);
		$(this).html(finalString);
		$(this).addClass("text-initial");
	});
}

function makeEsFullName() {
	$(".make-e-fullname").each(function(i){				   
							   
		var string = $(this).html();
		string = jQuery.trim(string);
		
		string = string.replace('[', '');
		string = string.replace(']', '');
		
		var theName = string.split(" ");
		//alert(theName[0]);
		
		var firstName = theName[0];
		var lastName = theName[1];
		
		
		
		/*
		
		string = string.replace(' at ', '@');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' ', '');
		
		if(string.indexOf("-") != -1) {
			alert('found -');	
		}
		
		var finalString = "<a href='mailto:" + string + "' title='Send email'>" + theName[0] + "</a>";
		//alert(finalString);
		$(this).html(finalString);
		$(this).addClass("text-initial");
		
		*/
	});
}

function makeEsNoName() {
	$(".make-e-no-name").each(function(i){				   
							   
		var string = $(this).html();
		string = jQuery.trim(string);
		
		string = string.replace('[', '');
		string = string.replace(']', '');
		string = string.replace(' at ', '@');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' ', '');
		
		var finalString = "<a href='mailto:" + string + "' title='Send email'>" + string + "</a>";
		//alert(finalString);
		$(this).html(finalString);
	});
}

function makeMemberEmail() {
	$(".make-e-member").each(function(i){				   
							   
		var string = $(this).html();		
		string = jQuery.trim(string);
		
		string = string.replace(' at ', '@');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' dot ', '.');
		string = string.replace(' ', '');
		string = string.replace(' ', '');
		string = string.replace(' ', '');
		string = string.replace(' ', '');
		string = string.replace(' ', '');
		string = string.replace(' ', '');
		
		var textInLink = "Email&nbsp;link";
		
		var finalMailTo = "[<a href='mailto:" + string + "' title='Send email to " + string + "'>" + textInLink + "</a>]";
		$(this).html(finalMailTo);
	});
}
