$(document).ready(function() {
	function popupsized(ff, toscroll, w, h){
		window.open(ff,"","toolbar=no,directories=no,resizable=no,scrollbars="+toscroll+",location=no,menubar=no,width="+w+",height="+h+",top=0,left=0");
	}

	$('#as_sitesearch').val(location.host);

	function clearText(thefield) {
		// Get the default value if not set yet
		if (!thefield.defaultvalue) {
			thefield.defaultvalue = thefield.value;
		}
		if (thefield.defaultValue == thefield.value) {
			thefield.value = "";
		} else if (thefield.value == "") {
			thefield.value = thefield.defaultValue;
		}
	}

	var search_default_value = $("input[id$='_SearchTB']").val();
    $("input[id$='_SearchTB']").focus(function() {
        if ($(this).val() == search_default_value) {
            $(this).val("");
        }
    });
    $("input[id$='_SearchTB']").blur(function() {
        if ($(this).val() == "") {
            $(this).val(search_default_value);
        }
    });
	
	
	$('.faq_item').hide();
	
	$(".equal-drops").equalHeights();
	$(".equal-drops-support").equalHeights();
	$(".equal-interiors").equalHeights();
	$(".live-demo").equalHeights();
	
	// faq expand q&a
    var minHeight = $("#info").height();
	var maxHeight = $("#info").height();
	//$(".equal-interiors").equalHeights();
    $('a.faq_link').click(function() {
		$(this).parent().find('.faq_item').slideToggle('fast', function(){
			//minHeight = $("#info").height();
			//maxHeight = $("#info").height();
			//alert($("#info").height());
			//$(".equal-interiors").equalHeights(minHeight, maxHeight);
			newHeight = $("#info").height();
			//$("#info").height(minHeight);
			$("#secondary-nav").height(newHeight);
			//alert(minHeight + "," + maxHeight);
			//$(".equal-interiors").equalHeights();
			//$(".equal-interiors").equalHeights(minHeight, minHeight);
		});
		
        return false;
    });
	$('a.opener').click(function() {
		var showIt = $(this).attr('rel');
		$('.opener').removeClass('on');
		$(this).toggleClass('on');
		//alert(showIt);
		$('.faq_item').hide();
		$('div.'+showIt).slideToggle('fast', function(){
			newHeight = $("#info").height();
			$("#secondary-nav").height(newHeight);
		});
		
        return false;
    });
	$('a[rel="business-benefits"]').addClass('on');
	$('div.business-benefits').show();
	newHeight = $("#info").height();
	$("#secondary-nav").height(newHeight);
	
	
	// fix IE last-child selector
	$("#subnav ul li:last-child").addClass('last-child');
	$("nav ul li:last-child").addClass('last-child');
	$("div.drop-cols:last-child").addClass('last-child');
	$("div.extras ul li:last-child").addClass('last-child');
	$("div.single ul li:last-child").addClass('last-child');
	$("section#blurbs div:last-child").addClass('last-child');
	
	// cross browser fix for main nav dropdown corner graphics
	// implemented mainly for Safari and Firefox on Mac
	var product_corner_right = $("li.product a.main-nav").width() + 31; // + padding + half of border
	$('li.product span.corner').css({'right':'-'+product_corner_right+'px'});
	var support_corner_right = $("li.support a.main-nav").width() + 31; // + padding + half of border
	$('li.support span.corner').css({'right':'-'+support_corner_right+'px'});
	var partners_corner_right = $("li.partners a.main-nav").width() + 31; // + padding + half of border
	$('li.partners span.corner').css({'right':'-'+partners_corner_right+'px'});
	var community_corner_right = $("li.community a.main-nav").width() + 31; // + padding + half of border
	$('li.community span.corner').css({'right':'-'+community_corner_right+'px'});
	
	$('nav > ul > li').append('<span class="ie8_joiner"></span>');
	
	//var newBanner = $('#banner img').get();
	//$('#banner').html(newBanner);
	
	// filter locations page {
	$('#filter').click(function() {
		//alert("Filter!");
		var showThis = $("#select-office").val();
  		//alert(showThis);
		// hide all
    	$(".directory").hide();
    	// show current
		$(".filtered").show();
		var htmlString = $("#"+showThis+"").html();
		//alert(htmlString);
		//$(".filtered .dir-item").html(htmlString);
	});
	
		
/* JQUERY CYCLE V2.99 */
/* ----------------------------------------- */
	/*
	$('#slider').cycle({
		fx: 'scrollLeft, scrollDown, scrollRight, scrollUp, scrollLeft, scrollDown, scrollRight',
		randomizeEffects: 1,
		startingSlide: 0, //zero based
		speed: 1000,
		timeout: 6000,
		pager: '.pagination',
		pause: 1,
		pauseOnPagerHover: 1
	});
*/

});
