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

	if($('select#page_id').length > 0){
		$('select#page_id').change(function(){
			if($(this).val()!=""){
				window.location = "/?page_id="+$(this).val();
			}
		});
	}

	$( '#slides' ).slides({
		preload: false,
		effect: 'fade',
		fadeSpeed: 900,
		play: 5000,
		pause: 2500,
		pagination: false,
		generatePagination: false
	});


	if($('#single-post-cat').length > 0) {
		var cat_id = $('#single-post-cat').html();
		if(cat_id != 1 && cat_id != 3  && cat_id != 4 && cat_id != 5) {
			$('ul.topnav li.current_page_item').removeClass('current_page_item');
			$('ul.topnav li.page-item-862').addClass('current_page_item');
		}
	}
	if($('#single-post-cat').length > 0) {
		var cat_id = $('#single-post-cat').html();
		if(cat_id != 1 && cat_id != 3  && cat_id != 4 && cat_id != 5) {
			$('ul.topnav li.current_page_item').removeClass('current_page_item');
			$('ul.topnav li.page-item-862').addClass('current_page_item');
		}
	}

	if($('#cat-cat').length > 0) {
		var cat_id = $('#cat-cat').html();
		if(cat_id != 1 && cat_id != 3  && cat_id != 4 && cat_id != 5) {
			$('ul.topnav li.page-item-862').addClass('current_page_item');
		} else {
			$('ul.topnav li.page-item-37').addClass('current_page_item');
		}
	}
	if($(".page-id-2011 #left form").length>0){
		$(".page-id-2011 #left form").submit(function(){
			var myval = $("#pwbox-2011",this).val().toLowerCase();
			$("#pwbox-2011",this).val(myval);

		});
	}
	if($(".page-id-2011 #left").length>0){
		var newval = $(".page-id-2011 #left h1.hdrtxt").html().replace(/Protected: /,'');
		$(".page-id-2011 #left h1.hdrtxt").html(newval);
	}

	if( $('#geo_loc_vars').text().indexOf("Austin") >= 0 ) {
		$( "#tabs" ).tabs( { selected: 1 });
		load_iframe('#tabs-2','austin');
	} else if( $('#geo_loc_vars').text().indexOf("Houston") >= 0 ) {
		$( "#tabs" ).tabs( { selected: 2 });
		load_iframe('#tabs-3','houston');
	} else {
		$( "#tabs" ).tabs( { selected: 0 });
		load_iframe('#tabs-1','dallas');
	}
	//////
	$('a#dallas-map').click(function() {
		load_iframe('#tabs-1','dallas');
	});
	$('a#austin-map').click(function() {
		load_iframe('#tabs-2','austin');
	});
	$('a#houston-map').click(function() {
		load_iframe('#tabs-3','houston');
	});

	function load_iframe(tab_id, loc){
		$(tab_id+' iframe').attr('src', 'http://www.fcer.com/wp-content/themes/fcer/maps/area-map.php?width=324&height=340&iframe=true&market='+loc);
	}	
});
