$(document).ready(function(){
		
	if ($(window).width() > 480) {
		// active states
		var url_str = window.location.href;
		var cur_url = url_str.split('/');
		$('.main_nav a img').each(function(){
			btn_href = $(this).parent().attr('href').substr(1);
			if (btn_href == cur_url[cur_url.length-1]) {
				this.src = this.src.replace('.png', '_roll.png');
			}
		});
		// nav rolls
		$('.main_nav a img').hover(
			function(){
				btn_href = $(this).parent().attr('href').substr(1);
				if (btn_href != cur_url[cur_url.length-1]) {
					this.src = this.src.replace('.png', '_roll.png');
				}
			},
			function(){
				if (btn_href != cur_url[cur_url.length-1]) {
					this.src = this.src.replace('_roll.png', '.png');
				}
			}
		);
	}
	
	// drop-down nav for mobile
	$('a.menu').click(function(e){
		$('.main_nav').toggle();
		e.preventDefault();
	})
	
	// misc. mobile stuff
	if ($(window).width() < 481) {
		setTimeout(function(){ window.scrollTo(0, 1); }, 1000);
		$('img[src="/images/Q4_chart.jpg"]').hide();
		var url_str = window.location.href;
		var cur_url = url_str.split('/');
		if (cur_url[cur_url.length-1] == 'direct-tv-deals.html') {
			$('.features_01').hide();
		}
	}
	
	// toggle package details for mobile
	$('.mob_pkg_wrapper .more').click(function(e){
		$(this).parent().siblings('.details').toggle();
		$(this).toggleClass('hide_details');
		e.preventDefault();
	})
	
	// geo locations as select menu...
	var geo_url = new Array();
	var geo_state = new Array();
	$('#geoLinkListTable tr td a').each(function(i){
		geo_url[i] = $(this).attr('href');
		geo_state[i] = $(this).text();
		$('#geoLinkListMenu').append('<option value="' + geo_url[i]+ '">' + geo_state[i] + '</option>');
	});
	$("#geoLinkListMenu").change(function(){
		window.location = $("#geoLinkListMenu option:selected").val();
	});
	// and UL's for additional geo pages
	var geo_city = new Array();
	$('<ul class="geo_list mobile">').insertAfter('#top_cities');
	$('<ul class="geo_list mobile">').insertAfter('#localCitiesTable');
	$('#top_cities tr td, #localCitiesTable tr td').each(function(i){
		geo_city[i] = $(this).html();
		$('.geo_list').append('<li>' + geo_city[i] + '</li>');
	});
	
	// tooltips
	$(function() {
		$(".tooltip p").hoverIntent({ over: toolTipShow, interval: 200, out: toolTipHide });
	});
	function toolTipShow() { $(this).next().show(); }
	function toolTipHide() { $(this).next().hide(); }
	
	// insert trademark
	$('.tm').each(function(){
		var content = $(this).html();
		$(this).html(content + '&trade;');
	});

});

// click clear function for contact form
function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}
	
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}
