// JavaScript Document

$(function() {		
	$('#side_nav_list li').click(function() {
		$('#foxyshop_ajax_box').html("<div style='margin:10px;'>Loading…</div>");
		//$(this).children("a").prepend("&#x25B6; ");
		var link=$(this).children("a").attr('href');
		$(this).children("ul:first").slideToggle();
		$('#foxyshop_ajax_box').fadeOut().load(link + ' #foxyshop_container', function() { 
			$('#foxyshop_ajax_box').fadeIn(800, function() {
				$('#left_sidebar').height($('#main_container').outerHeight(true)+6);
				$('#side_nav').height($('#main_container').outerHeight(true));
			});
		});
		return false;
	});
	
	$('#main_content p').addClass("dontend");
	
	$('#main_content').columnize({columns: 2});
	$('#srv_content').columnize({columns: 2});
	
	$('.request_quote, .contact_us').click(function() {
		$('#black_out').fadeIn();
		$('#light_box').fadeIn();
		$('#light_box').load(document_root + '/contact_form.php?subject=' + escape($(this).attr("id")));
	});
	
	$('#black_out').click(function() {
		$('#black_out').fadeOut();
		$('#light_box').fadeOut();
	});
	
	$('#search').focus(function() {
		$(this).val("");
	});
	
	$('#search').blur(function() {
		if($(this).val()==="") {
			$(this).val("type here to search");
		}
	});
	
	$('#left_sidebar').height($('#main_container').outerHeight(true) + 160);
	$('#side_nav').height($('#main_container').outerHeight(true) + 154);
	
	$(".text_input").live("focus", function(e) {
		$(this).css("background-color", "#ffffff");
	});
	
	$("#formCSS_twoCol").live("submit", function(e) {
		var has_error=false;
		$('.required').each(function() {	
			$(this).css("background-color", "#ffffff");
			if($(this).val()=="") {
				$(this).css("background-color", "#91b1e0");
				has_error=true;
			}			
		});
		
		if(has_error) {
			e.preventDefault();
		}
	});
});
