function form_path_prefix()
{
	if(location.pathname.split('/').length > 3)
	{
		return "../";
	}	
	else return "/";
}

$(document).ready(function() {
	//right box open first item
	
	var prefix = form_path_prefix();
	
	//Original
	$("#quote_accordion .first").css({background:"#1fae82 url("+prefix+"media/images/quote_accordion.jpg) left bottom no-repeat"}).next("div.quote_body").slideToggle(300).siblings("div.quote_body").slideUp("fast");

	//right box click function
	$("#quote_accordion .quote_head ").click(function() {
		if($(this).css('background'))
		{
			if($(this).css("background").indexOf('bottom')!=-1)
				$url = "url("+prefix+"media/images/quote_accordion.jpg) no-repeat";
			else $url = "url("+prefix+"media/images/quote_accordion.jpg) left bottom no-repeat";
		}
		else $url = "url("+prefix+"media/images/quote_accordion.jpg) left bottom no-repeat";
			
		$(this).css({background:$url}).next("div.quote_body").slideToggle(300).siblings("div.quote_body").slideUp("fast");
		$(this).siblings().css({background:"url("+prefix+"media/images/quote_accordion.jpg) no-repeat"});	
		$("#quote_accordion .quote_body").css({background:"#40b290 url("+prefix+"media/images/green_accordion_tile.jpg) repeat-x"});
	});


        //Modified (for quote_and_call.php and online_quote_request_quote.php)
        $("#quote_accordion_modified .first").css({background:"#1fae82 url("+prefix+"media/images/quote_accordion.jpg) left bottom no-repeat"}).next("div.quote_body").slideToggle(300);

        //right box click function
	$("#quote_accordion_modified .quote_head ").click(function() {
		expanded = false;

                if($(this).css('background'))
		{
			expanded = ($(this).css("background").indexOf('bottom')!=-1);
		} else expanded = false;

                if (expanded) { //Must contract
                    $url = "url("+prefix+"media/images/quote_accordion.jpg) no-repeat";
                    $(this).css({background:$url}).next("div.quote_body").slideToggle(300)
                } else { //Must expand, contract siblings
                    $url = "url("+prefix+"media/images/quote_accordion.jpg) left bottom no-repeat";
                    $(this).css({background:$url}).next("div.quote_body").slideToggle(300).siblings("div.quote_body").slideUp("fast");
                    $(this).siblings().css({background:"url("+prefix+"media/images/quote_accordion.jpg) no-repeat"});
                }
		
		$("#quote_accordion_modified .quote_body").css({background:"#40b290 url("+prefix+"media/images/green_accordion_tile.jpg) repeat-x"});
	});

	
	//FAQ accordion
	$("#FAQ_accordion .first").css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"}).next("div.menu_body").slideToggle(300).siblings("div.FAQ_body").slideUp("fast");

	//left navigation click function
	$("#FAQ_accordion .FAQ_head ").click(function() {		
		$(this).css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"}).next("div.FAQ_body").slideToggle(300).siblings("div.FAQ_body").slideUp("fast");
		$(this).siblings().css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"});	
		$("#FAQ_accordion .FAQ_body").css({background:"#fff"});
	});		
	
	//FAQ accordion
	$("#FAQ_accordion2 .first").css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"}).next("div.menu_body").slideToggle(300).siblings("div.FAQ_body").slideUp("fast");

	//left navigation click function
	$("#FAQ_accordion2 .FAQ_head ").click(function() {		
		$(this).css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"}).next("div.FAQ_body").slideToggle(300).siblings("div.FAQ_body").slideUp("fast");
		$(this).siblings().css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"});	
		$("#FAQ_accordion2 .FAQ_body").css({background:"#fff"});
	});		
	
	//FAQ accordion
	$("#FAQ_accordion3 .first").css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"}).next("div.menu_body").slideToggle(300).siblings("div.FAQ_body").slideUp("fast");

	//left navigation click function
	$("#FAQ_accordion3 .FAQ_head ").click(function() {		
		$(this).css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"}).next("div.FAQ_body").slideToggle(300).siblings("div.FAQ_body").slideUp("fast");
		$(this).siblings().css({background:"#fff url("+prefix+"media/images/FAQ_tile.jpg) bottom repeat-x"});	
		$("#FAQ_accordion3 .FAQ_body").css({background:"#fff"});
	});		


});	
