/**
 * FILENAME: creditFile.js
 * AUTHOR: Ashley Barrett (ashley.barret@rgroup.co.uk)
 * CREATED: 11/12/2009
 * COMMENTS: A javascript file to deal with making the credit file portions appear and hide.
 * */
$(function(){
	if($(".accHistory")){
		$(".accHistory").css("display","none");
	}

	if($(".searchResults")){
		$(".searchResults").css("display","none");
	}

	$(".creditFileSection").each(function(){
		if($(this).find(".expandCreditFileSection").size() > 0){
			var text = $(this).find(".expandCreditFileSection").text();
			var newText = text.replace("These are your","Show me my"); 
			$(this).find(".expandCreditFileSection").text(newText);
		}
	});

	$(".expandCreditFileSection").click(function(){
		var parent = $(this).parent();
		var classes = parent.attr("class").split(" ");

		$("."+classes[1]).find(".searchResults").toggle('fast',function(){
		
			if($("."+classes[1]).find(".expandCreditFileSection").text().substring(0, 4) != "Hide"){
				var text = $("."+classes[1]).find(".expandCreditFileSection").text();
				var newText = text.replace("Show me my","Hide my"); 
				$("."+classes[1]).find(".expandCreditFileSection").text(newText);
			}
			else{
				var text = $("."+classes[1]).find(".expandCreditFileSection").text();
				var newText = text.replace("Hide my","Show me my"); 
				$("."+classes[1]).find(".expandCreditFileSection").text(newText);
			}
				
		});
		
		if($("."+classes[1]+" .accHistory"))
		{
			$("."+classes[1]).find(".accHistory").toggle();
		}
		
		return false;
	});
});

