$(document).ready(function() {	// WORKS...

	$('#states a').click(function() {

   	// var rel = document.location.hash.substring(1);

   	var rel = $(this).attr("rel");

   	var state = $(this).text();

   	var ciPreBidCount = $('#'+rel+'-civilPreBidCount').text();

   	var ciPreBidValue = $('#'+rel+'-civilPreBidValue').text();

   	var ciBiddingCount = $('#'+rel+'-civilBiddingCount').text();

   	var ciBiddingValue = $('#'+rel+'-civilBiddingValue').text();

   	var ciPostBidCount = $('#'+rel+'-civilPostBidCount').text();

   	var ciPostBidValue = $('#'+rel+'-civilPostBidValue').text();

   	var ciCountTotal = $('#'+rel+'-civilCountTotal').text();

   	var ciValueTotal = $('#'+rel+'-civilValueTotal').text();

   	var coPreBidCount = $('#'+rel+'-commercialPreBidCount').text();

   	var coPreBidValue = $('#'+rel+'-commercialPreBidValue').text();

   	var coBiddingCount = $('#'+rel+'-commercialBiddingCount').text();

   	var coBiddingValue = $('#'+rel+'-commercialBiddingValue').text();

   	var coPostBidCount = $('#'+rel+'-commercialPostBidCount').text();

   	var coPostBidValue = $('#'+rel+'-commercialPostBidValue').text();

   	var coCountTotal = $('#'+rel+'-commercialCountTotal').text();

   	var coValueTotal = $('#'+rel+'-commercialValueTotal').text();

   	// alert(cPreBidCount);

   	$('#state').empty().append(state);



   	// $('#state').empty().append('<a href="/regions/' + state.replace(' ','-') + '/">' + state + '</a>');



   	$('#civilPreBidCount').empty().append(ciPreBidCount);

   	$('#civilPreBidValue').empty().append(ciPreBidValue);

   	$('#civilBiddingCount').empty().append(ciBiddingCount);

   	$('#civilBiddingValue').empty().append(ciBiddingValue);

   	$('#civilPostBidCount').empty().append(ciPostBidCount);

   	$('#civilPostBidValue').empty().append(ciPostBidValue);

   	$('#civilCountTotal').empty().append(ciCountTotal);

   	$('#civilValueTotal').empty().append(ciValueTotal);

   

   	$('#commercialPreBidCount').empty().append(coPreBidCount);

   	$('#commercialPreBidValue').empty().append(coPreBidValue);

   	$('#commercialBiddingCount').empty().append(coBiddingCount);

   	$('#commercialBiddingValue').empty().append(coBiddingValue);

   	$('#commercialPostBidCount').empty().append(coPostBidCount);

   	$('#commercialPostBidValue').empty().append(coPostBidValue);

   	$('#commercialCountTotal').empty().append(coCountTotal);

   	$('#commercialValueTotal').empty().append(coValueTotal);

      var tempState = state.replace(' ','-').toLowerCase(); 

   	$('#teaserMore').empty().append('<span class="goToState"><a class="ext-link" href="/regions/' + tempState.replace(' ','-') + '/">View ' + state + ' Projects</a></span>');



   	return false;

	});

	$('#sum-type').tabs();

	$('#toggle-format').click(function() {

		var cls = $(this).attr("class");

		if(cls == 'toggle-off') {

			$(this).addClass("toggle-on");

			$(this).removeClass("toggle-off");

		$('#toggle-format').fadeOut('slow', function() {

				$(this).html("collapse").fadeIn('slow');

			}); 

			} else {

			$(this).removeClass("toggle-on");

			$(this).addClass("toggle-off");

		$('#toggle-format').fadeOut('slow', function() {

				$(this).html("expand").fadeIn('slow');

			}); 

		}

		$('#codes').slideToggle('slow');

		return false;

	});

	$('#toggle-product').click(function() {

		var cls = $(this).attr("class");

		if(cls == 'toggle-on') {

			$(this).addClass("toggle-off");

		$('#toggle-product').fadeOut('slow', function() {

				$(this).html("expand").fadeIn('slow');

			}); 

			} else {

			$(this).removeClass("toggle-off");

		$('#toggle-product').fadeOut('slow', function() {

				$(this).html("collapse").fadeIn('slow');

			}); 

		}

		$('#projects').slideToggle('slow');

		return false;

	});

	$('#toggle-buyerzone').click(function() {

		var cls = $(this).attr("class");

		if(cls == 'toggle-off') {

			$(this).addClass("toggle-on");

			$(this).removeClass("toggle-off");

		$('#toggle-buyerzone').fadeOut('slow', function() {

				$(this).html("collapse").fadeIn('slow');

			}); 

			} else {

			$(this).removeClass("toggle-on");

			$(this).addClass("toggle-off");

		$('#toggle-buyerzone').fadeOut('slow', function() {

				$(this).html("expand").fadeIn('slow');

			}); 

		}

		$('#buyerzone').slideToggle('slow');

		return false;

	});

	$('#column h3 a').click(function() {

		var rel = $(this).attr("rel");

		var cls = $(this).attr("class");

		if(cls != '') {

			$(this).toggleClass("catOn")					

		}

		$('#' + rel + '-list').slideToggle();

		return false;

 	});

	// $('#codes h6 a').click(function() {

	// 	var rel = $(this).attr("rel");

	// 	var cls = $(this).attr("class");

	// 	if(cls != '') {

	// 		$(this).toggleClass("catOn")					

	// 	}

	// 	$('#' + rel).slideToggle();

	// 	return false;

	// });

	$('#codes h6').click(function() {

		$(this).toggleClass("h6on")

			.siblings('h6').removeClass("h6on");

		$(this).next('ul').slideToggle()

		.siblings('ul:visible').slideUp();

		return false;

	});

			// $('#search-drawer').slideDown('slow');			

			// $('#search a').click(function() {

			// 	$('#search-box').slideToggle('slow');

			// 	return false;

			// });

});

