// Creating custom :external selector
$.expr[':'].external = function(obj){
    return !obj.href.match(/^mailto\:/)
            && (obj.hostname != location.hostname);
};

$.expr[':'].mailto = function(obj){
    return obj.href.match(/^mailto\:/);
};

$(document).ready(function(){
	
	//$(".openit").parents("li").addClass("open");
	
	$("a[href$='.pdf']").addClass("pdflink");
	$("a[href$='.doc']").addClass("doclink");
	$("a[href$='.ppt']").addClass("pptlink");
	$("a:external:not(#footer a, #bloglinks a, .posted a, #footer a, .testimonial a, a#featured, .pullquote a)").addClass("extlink");
	$("a:external").attr("target", "_blank");
	$("a:mailto").addClass("maillink");
		
	$("#sideright > ul > li:not(.open)").find("ul").hide();
	
	$("#sideright a.catlink").click(function () {
		if($(this).parent("li").hasClass("closed")){
      		$(this).parent("li").find("ul").show();
      		$(this).parent("li").addClass("open");
      		$(this).parent("li").removeClass("closed");
		}else{
			$(this).parent("li").find("ul").hide();
      		$(this).parent("li").addClass("closed");
      		$(this).parent("li").removeClass("open");
		}
		return false;
    });
    
    $("#caselink a").toggle(function(){
    	$("#casetext").slideDown("slow");
    	$(this).addClass("open").text("Click to close the case study...");
    },function(){
    	$("#casetext").slideUp("slow");
    	$(this).removeClass("open").text("Click for a bpc case study on this client...");
    });
    
    $("#servicebox p span:last").hide();
		    
});
