$(document).ready(function() {
	
	$('a.open-new-window, ul.links a').click(function() {
		window.open(this.href);
		return false;
	});
	
	if(typeof sIFR == "function"){
	//if (!sIFR.UA.bHasTransparencySupport) return false;
	// This is the preferred "named argument" syntax
		sIFR.replaceElement(named({
			sSelector:"div#banner .h1",
			sFlashSrc:URL+"/javascript/sIFR2/eras-medium.swf",
			sColor:"#ffffff",
			sWmode: 'transparent'
		}));
		sIFR.replaceElement(named({
			sSelector:"div#inner-content .h1",
			sFlashSrc:URL+"/javascript/sIFR2/eras-medium.swf",
			sColor:"#000",
			sWmode: 'transparent'
		}));
	};
	
	$('body.faqs').each(function(index) {
		var id = window.location.hash.substr(1);
		var dt = $('#'+id);
		var dd = dt.next('dd');
		dt.wrap('<div id="div-'+id+'" class="blue-border"></div>');
		$('#div-'+id).append(dd);
	});
	
	if ($('ul.navigation li:has(a)').length == 0) {
		$('ul.navigation li').each(function(index) {
			$(this).addClass(this.id+'-disabled');
		});
	}
	
	$('div.panel p:last').addClass('no-margin-bottom');
	
	$('div#header li.search a').click(function() {
		$(this).hide();
		$('div#search-box').show().find('input').focus();
		return false;
	});
	
	$('div#search-box').click(function() {
		$(this).find('input').focus();
	});
	
	$('div#search-box input').blur(function() {
		$('div#header li.search a').show();
		$('div#search-box').hide();
	});
	
	/*$('body.faqs ul.service h3').each(function(index) {
		
		$('body.faqs ul.service dl').hide();
		
		var id = this.id.split('-')[1];
		var a = document.createElement('A');
		a.href = 'javascript:void(0)';
		a.innerHTML = this.innerHTML;
		$(a).toggle(function() {
			this.className = 'arrow-on';
			$('ul#'+id+' dl').slideDown('fast');
		}, function() {
			this.className = 'arrow-off';
			$('ul#'+id+' dl').slideUp('fast');
		});
		
		$(this).html(a);
	});*/
	
});

function findValue(li) {

	if( li == null ) return false;
	
	// if coming from an AJAX call
	if( !!li.extra ) var sValue = li.extra[0];
	
	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue
	
	return sValue;
}

function selectItem(li) {
	window.location.href = findValue(li);
}

function formatItem(row) {
	return '<strong><a href='+row[1]+'>'+row[0]+'</a></strong>';
}
