function toggleTextOut(e,txtval) {
	if(e.value=="") e.value = txtval;

}
function toggleTextIn(e,txtval) {
	if(e.value==txtval) e.value="";
	else e.select();
}

$(document).ready(function(){
	$('ul.tab-finance-calc li:first-child').addClass('first');
	$('ul.tab-finance-calc li:last-child').addClass('last');
	$('#nav-global li:last-child').addClass('last');
	$('ul.tab-finance-calc li:last-child').addClass('last');
	$('table.career-listing tr:last-child').addClass('last');
	$('#paging span a:first-child').addClass('first');
	$('.press-listing li:first-child').addClass('first');
	$('.search-results li:first-child').addClass('first');
	$('ul.faq-sub-links li:last-child').addClass('last');
	$('.glossary-list li:last-child').addClass('last');
	$('.faq-listing li:last-child').addClass('last');
	$('.sitemap-wrap li:last-child').addClass('last');
	$('.sitemap-wrap div h3:last-child').addClass('last');
	$('.tab-content table tr:last-child').addClass('last');
	$('#nav-top li.current').next('li').css('background','none');
	$('#nav-top li').hover(
			function(){
			$(this).next('li').addClass('next-item');
			},function(){
			$(this).next('li').removeClass('next-item');
			});
	$(".swap").hover(
			function(){
				if($(this).attr("src").indexOf("-on") == -1) {
				var newSrc = $(this).attr("src").replace(".gif","-on.gif");
				$(this).attr("src",newSrc);
				}},
				function(){
				if($(this).attr("src").indexOf(".gif") != -1) {
				var oldSrc = $(this).attr("src").replace("-on.gif",".gif");
				$(this).attr("src",oldSrc);
				}
				});
	
	// Faq
	$(".faq-listing li h6").click(function() {
		$(".faq-listing li h6").removeClass('selected');
		if($(this).next('div').is(':visible')) {
			$(this).next('div').slideUp('slow');
			$(this).removeClass('selected');
			return false;
		} else {
			$(this).addClass('selected');
			$('.faq-listing li').children('div').slideUp('slow');
			$(this).next('div').slideDown('slow');
			return false;
		}
	});
	
	// accordian
	$(".listing-inner li h3").click(function() {
		$(".listing-inner li h3").removeClass('selected');
			$(".listing-inner li").removeClass('current');
		if($(this).next('div').is(':visible')) {
			$(this).next('div').slideUp('slow');
			$(this).removeClass('selected');
			$(this).parent('li').removeClass('current');
			return false;
		} else {
			$(this).addClass('selected');
			$(this).parent('li').addClass('current');
			$('.listing-inner li').children('div').slideUp('slow');
			$(this).next('div').slideDown('slow');
			return false;
		}
	});
	
	// show/hide Footer 
	$('a.toggle-footer').toggle(function() {
		$('#main-footer').slideUp('slow');
		$(this).addClass('open').removeClass('close');
	}, function(){
		$('#main-footer').slideDown('slow');
		$(this).addClass('close').removeClass('open');
	});
	
	// Tabs
	$('ul.tab li h4 a').click(function(){
		var idName = $(this).attr('class');
		divVisible = $('#'+idName).is(':visible');
		if( !divVisible ){
			$('ul.tab li').each(function(){
				$(this).removeClass('current');
				$('#'+($(this).children('h4').children('a').attr('class'))).hide();
			});
			$(this).parent('h4').parent('li').addClass('current');
			$('#'+idName).show();
		}
	});
	
	// Tab - Finance calculator
	$('.tab-finance-calc li h4 a').click(function(){
		var idName = $(this).attr('class');
		divVisible = $('#'+idName).is(':visible');
		if( !divVisible ){
			$('ul.tab-finance-calc li').each(function(){
				$(this).removeClass('current');
				$('#'+($(this).children('h4').children('a').attr('class'))).hide();
			});
			$(this).parent('h4').parent('li').addClass('current');
			$('#'+idName).show();
		}
	});

});


function GetData(id)
{
	var content = document.getElementById(id);
	if(content == null)
		return("");
	return(content.innerHTML);
}
function Print(printPage, id, title)
{
	//window.print();
	if(title == '')
		title = document.title;
	var url = printPage + "?id=" + id + "&title=" + title
	var p = window.open(url, "print", "width=602, height=600, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, fullscreen=no");
}

function PrintThisPage(id, printId){
	var content = document.getElementById(printId);
	if(content == null)
		return;
	if(window.opener == null)
		return;
	var html = window.opener.GetData(id);
	html = DisableHyperlinks(html);
	content.innerHTML = html;

	window.print();
}

function DisableHyperlinks(html)
{
	return(html.replace(/href\s*=\s*\"*[^\">]*"/ig,"href=\"#\""));
}