$(function(){


    $("body").addIDs();

	$(".content_split_right .flv, .content_split_right .quote, .content_right .quote").hide();

    var blogContent = $(".blogFeed").html();
        $("#blogFeed").html(blogContent);
        
    $(".breadcrumb").each(function(){
        var charReplace = $(this).html();
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        charReplace = charReplace.replace("&gt;","|");
        $(this).html(charReplace);
    });
    
    $(".navigation td:last .divide").attr("style","display: none;");

    $(".case_studies .case_study a:first, .content .news .article a:first").attr("style","padding-top: 0px;");
    
   

	$(".quote").each(function(){
		$("p:first",this).wrapInner("<div class='open'></div>").addClass("close");
		$("p:last",this).addClass("quote_name");
	});
	
	
	$(".Phuse_Search_Button").click(function(){
	    var searchTerm = $(".Phuse_Search_TextQuery").attr("value");
	    location.href = "http://www.lamb-law.co.uk/searchresults.phuse?q="+searchTerm+"&rpp=10&t=0&sp=4";
    });
	


    
    $(".column .faq").hide();
    $(".column .faq:eq(0), .column .faq:eq(1), .column .faq:eq(2), .column .faq:eq(3), .column .faq:eq(4), .column .faq:eq(5)").show();
    $(".column .faq:eq(0)").attr("style","margin-top: -11px;");
    $(".column .faq:eq(5)").attr("style","border: none;");
    
    $(".paging a").each(function(){
        var getStyle = $(this).attr("style");
        if (getStyle=="font-weight: bold; text-decoration: underline;") {
            $(this).css("text-decoration","none").css("color","#ae178d").css("background","#ededed");
        }
    });
    
    $(".paging a").each(function(){
        $(this).html($(this).html().replace("Next &gt;","&gt;").replace("&lt; Prev","&lt;"));
    });
    
    var pagingItems = Math.ceil(eval($(".case_study, .content .article").length-5)/5);
    var countItems = 1;
    $(".paging").append("<strong>Page:</strong> ");
    while (countItems<=pagingItems+1) {
        $(".paging").append("<span id=\""+countItems+"\">"+countItems+"</span>");
        countItems++;
    }
    
    $(".paging span").click(function(){
        $(".paging span").removeClass("active");
        $(this).addClass("active");
        var pageNumber=$(this).attr("id")-1;
        $(".holder .case_study").animate({"top":"-"+eval(pageNumber*585)+"px"});
    });
    
    $(".paging span").click(function(){
        $(".paging span").removeClass("active");
        $(this).addClass("active");
        var pageNumber=$(this).attr("id")-1;
        $(".content .holder .article").animate({"top":"-"+eval(pageNumber*706)+"px"});
    });
    
    
    $(".refer tr:first").attr("style","padding-right: 28px;").addClass("first_tr");
    $(".refer tr:last").attr("style","float:right;");
    
    
    $(".container_left .mm_form tr, .refer tr").each(function(){
        $("td:first",this).addClass("label");
    });
    $(".container_left .mm_form tr, .refer tr").each(function(){
        $("td:last",this).addClass("input");
    });
    
    
    $(".container_left .mm_form .label, .refer .label").wrapInner("<div></div>");
    $(".container_left .mm_form input:last, .refer input:last").addClass("SubmitButton");
    $(".container_left .mm_form .input:last").attr("style","height: 40px;");
    
    $(".container_left .mm_form .input select").addClass("select");
    
    $(".ContBoxGrBgMdl .faq:first").attr("style","margin-top: -9px;");
    $(".ContBoxGrBgMdl .faq .desc").hide();
    $(".ContBoxGrBgMdl .faq").click(function(){
        if ($(this).children(".ContBoxGrBgMdl .desc").is(":visible")) {
            $(this).children(".ContBoxGrBgMdl .desc").slideUp();
            $(this).children(".ContBoxGrBgMdl .title").addClass("down");
        } else {
            $(this).children(".ContBoxGrBgMdl .desc").slideDown();
        }
    });
    

    $(".column .faqs .title h3").click(function(){
        var thisText = $(this).text();
        $.cookie("lamb_faq",thisText);
        window.location="services.aspx";
    });

    var getFAQ = $.cookie("lamb_faq");
    if (getFAQ) {
        var thisText = $.cookie("lamb_faq");
        $(".ContBoxGrBgMdl .faq .desc:first").hide();
        $(".faq h3:contains('"+thisText+"')").parent().parent().children(".desc").show();
        
        
        $(".column .faqs .desc").hide();
    }
    
    
    
    $(".content_split_right .flv:eq("+Math.floor(Math.random()*$(".content_split_right .flv").length)+")").show();
    $(".content_right .quote:eq("+Math.floor(Math.random()*$(" .content_right .quote").length)+")").show();
    $(".content_split_right .quote:eq("+Math.floor(Math.random()*$(".content_split_right .quote").length)+")").show();
	
	$("#real-people .flv, #testimonials .flv").show();

	
	

});
