	// JavaScript Document JQuery for image replacement

$(document).ready(function(){
						     
    //Get the current pages heading text.
    $("#vmMainPage > h3 a").remove();
	$("#vmMainPage > h3").css({"font-size":"16px", "padding":"0 0 20px 30px"});
	$("#vmMainPage #product_list > br").remove();
    var pictureArea = $("div.buttons_heading");
	
    // Store the original document title
    self.$originalTitle = $(document).attr('title');	
    var currentPageName = self.$originalTitle;
	var newTitle;
	
	//Add a list all products link to details page
	 $('.pathway.breadcrumbs').before('<span class="listAllCrumb"><a href="index.php?page=shop.browse&category=&option=com_virtuemart&Itemid=1">List all Items</a> &#124;</span>');

    /* Add a banner to the appropriate page */
	
	//subHeadingFrame.png
	
	 /*(currentPageName == "Animal") || (currentPageName == "Fairytale") || (currentPageName == "Hollywood") || (currentPageName == "60s") || 
																												 (currentPageName == "70s") || (currentPageName == "80s") ||
	   (currentPageName == "Groups & Pairs") || (currentPageName == "Christmas") || (currentPageName == "Horror") || (currentPageName == "Back In Time") || 
	   (currentPageName == "Sexy") ||
	   (currentPageName == "Arabian") || (currentPageName == "Australia Day") || (currentPageName == "Childrens") || (currentPageName == "Cowboys and Indians") || 
	   (currentPageName == "Egyptian") || (currentPageName == "Full Body Suits") || (currentPageName == "Gangster's Paradise") || 
	   (currentPageName == "Medieval/Renaissance") || 
	   (currentPageName == "Occasions") || (currentPageName == "4th July") || (currentPageName == "Oktoberfest") || (currentPageName == "Halloween and Horror") || 
	   (currentPageName == "St. Patrick's Day") || (currentPageName == "Occupations and Uniforms") || (currentPageName == "A-Z") || (currentPageName == "Pirates") || 
	   (currentPageName == "Rock Stars") || 
	   (currentPageName == "Roman") || (currentPageName == "Bollywood") ||	   
	   (currentPageName == "Costumes") (currentPageName == "Arabian / Bollywood")*/ 
    
    if((currentPageName != "Costume Viewer-Do not Edit Unless Logged in as 'raw'") || (currentPageName != "Costumes")){
		
	//replace the html for the button_heading div with the photoFrame.
    $(pictureArea).html("&nbsp;");
	
	    //Style the costume categories products that will include a banner.
	    $("#vmMainPage h3:first").addClass("subHeadingFrame");
		$("#vmMainPage #product_list > div").addClass("addAnchor");
		$(".addAnchor").prepend("<a>");
		$(".addAnchor > a").addClass("overlayAnchor");
		$("#vmMainPage #product_list > div a").each(function(){
			var productLink = $(this).parent().find("div > a").attr("href");
			var productName = $(this).parent().find("div h3 a").html();
			
			$(this).attr({href: productLink, title: productName});	
		});
		
		//Change the Browser title
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range"; 
		$(document).attr('title', newTitle);
		
    } else { //Effect other pages
	
	     $("div.buttons_heading").remove();
		
		//Style the search Page product items.
		$(pictureArea).html(' ');	
		$("#vmMainPage #product_list > div").addClass("addAnchor");
		$(".addAnchor").prepend("<a>");
		$(".addAnchor > a").addClass("overlayAnchor");
		$("#vmMainPage #product_list > div a").each(function(){	
			var productLink = $(this).parent().find("div h2 a").attr("href");
			var productName = $(this).parent().find("div h2 a").html();
			$(this).attr({href: productLink, title: productName});
		});		
	}

switch(currentPageName){
	case "The Costume Company":
	     newTitle = "The Costume Company";
		 $('.listAllCrumb').hide();
		$(document).attr('title', newTitle);
	    break;	
	case "Animal":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_animals.jpg", alt: currentPageName});
	    break;
	case "Fairytale":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_fairytale.jpg", alt: currentPageName});
	    break;
	case "Hollywood":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_hollywood.jpg", alt: currentPageName});
	    break;
	case "60s":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_60s.jpg", alt: currentPageName});
	    break;
	case "70s":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_70s.jpg", alt: currentPageName});
	    break;
	case "80s":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_80s.jpg", alt: currentPageName});
	    break;
	case "P-Party":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_pparty.jpg", alt: currentPageName});
	    break;
	case "Groups & Pairs":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_groupsAndPairs.jpg", alt: currentPageName});
	    break;
	case "Christmas":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_christmas.jpg", alt: currentPageName});
	    break;
	case "Horror":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_horror.jpg", alt: currentPageName});
	    break;
	case "General":
	    $("#staticInnerFrame img").attr({src: "images/costumes/main_general.jpg", alt: currentPageName});
	    break;
	case "Advanced Search":
	    /*   Add class to the Search Content Area */
	    newTitle = "The Costume Company | " + currentPageName;
		$(document).attr('title', newTitle);
		$("#vmMainPage").addClass("narrowContent");
		$(".narrowContent > br").remove();
	    break;
	case "Browse":
	    /*   Add class to the Search Content Area */
	    newTitle = "The Costume Company | " + currentPageName + " All Products";
		$('.listAllCrumb').hide();
		$(document).attr('title', newTitle);
	    break;
	case "Costumes":
		newTitle = "The Costume Company | " + currentPageName + " Range";
		$(document).attr('title', newTitle);
		$("#vmMainPage").addClass("costumeCategories");
		$('.listAllCrumb').hide();
		$("#staticInnerFrame img").attr({src: "images/costumes/main_off.jpg", alt: currentPageName});
		break;
	case "A-Z":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#vmMainPage").addClass("costumeCategories");
		break;
	case "Back In Time":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#vmMainPage").addClass("costumeCategories");
		$("#staticInnerFrame img").attr({src: "images/costumes/main_backInTime.jpg", alt: currentPageName});
		break;
	case "Sexy":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_sexy.jpg", alt: currentPageName});
		break;
	case "Arabian":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_arabian.jpg", alt: currentPageName});
		break;
	case "Australia Day":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_australiaDay.jpg", alt: currentPageName});
		break;
	case "Childrens":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_childrens.jpg", alt: currentPageName});
		break;
	case "Cowboys and Indians":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_cowboysAndIndians.jpg", alt: currentPageName});
		break;
	case "Egyptian":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_egyptian.jpg", alt: currentPageName});
		break;
	case "Full Body Suits":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_fullBodySuits.jpg", alt: currentPageName});
		break;
	case "Gangster's Paradise":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_gangstersParadise.jpg", alt: currentPageName});
		break;
	case "Medieval/Renaissance":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_medieval.jpg", alt: currentPageName});
		break;
	case "Occasions":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#vmMainPage").addClass("costumeCategories");
		$("#staticInnerFrame img").attr({src: "images/costumes/main_occasions.jpg", alt: currentPageName});
		break;
	case "4th July":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_4thJuly.jpg", alt: currentPageName});
		break;
	case "Oktoberfest":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_oktoberfest.jpg", alt: currentPageName});
		break;
	case "Halloween and Horror":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_halloweenAndHorror.jpg", alt: currentPageName});
		break;
	case "St. Patrick's Day":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_stPatricksDay.jpg", alt: currentPageName});
		break;
	case "Occupations and Uniforms":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_occupations.jpg", alt: currentPageName});
		break;
	case "Pirates":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_pirates.jpg", alt: currentPageName});
		break;
	case "Rock Stars":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_rockStars.jpg", alt: currentPageName});
		break;
	case "Roman":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_roman.jpg", alt: currentPageName});
		break;
	case "Bollywood":
	    newTitle = "The Costume Company | " + currentPageName + " Costume Range";
		$(document).attr('title', newTitle);
		$("#staticInnerFrame img").attr({src: "images/costumes/main_bollywood.jpg", alt: currentPageName});
		break;
	case "Contact Us":
	    $('.listAllCrumb').hide();
		newTitle = "The Costume Company | Contact Us";
		$(document).attr('title', newTitle);
	    break;
	
	//Accessories
	case "Accessories":
	    newTitle = "The Costume Company | " + currentPageName + " Range";
		$('.listAllCrumb').hide();
		$(document).attr('title', newTitle);
		$("#vmMainPage").addClass("costumeCategories");
		break;
	default:
	    
	    break;
}

    /* 
	    PRODUCT DETAIL SCRIPT 
	*/
	var productImageWidth = 379;
	var productImageHeight = 599;
	var imageTitle = $("#vmMainPage #productDetailPage #productDetailImage a").attr("title");
	var imageSource = $("#vmMainPage #productDetailPage #productDetailImage a").attr("href");
	$("#vmMainPage #productDetailPage #productDetailImage a").remove();
	$("#vmMainPage #productDetailPage #productDetailImage").prepend("<img />")
	$("#vmMainPage #productDetailPage #productDetailImage img").attr({alt: imageTitle, title: imageTitle, src: imageSource, width: productImageWidth, height: productImageHeight})
	
	/* Product Detail Terms of Use*/
	var hideShow = ".hideShowButton";
	var button = "#termsOfUseButton";
	var buttonSmall = "#termsOfUseButton small";
    var container = "#termsOfUseContainer";
	$(container).hide();
	$(button).toggle(function(){
		$(container).show();
		$(buttonSmall).html("&#187;&nbsp;hide");
	}, function(){
		$(container).hide();
		$(buttonSmall).html("&#187;&nbsp;show");
	});
    $(hideShow).css({cursor: "pointer"});
	
	/* Change call for pricing link*/

	$("a").each(function(){
	    var subLinkCall = $(this).html();
		if(subLinkCall == "Call for Pricing"){
		    $(this).hide();
		}
	 });
	
    var linkCall = $("div#productPrice a").html();
	if (linkCall == "Call for Pricing"){
	    $("div#productPrice a").attr("href", "index.php?option=com_content&view=article&id=46&Itemid=56").show();
	}    

});
