﻿$(document).ready(function() {

    $("div.revealEvent").css("display", "none");

    $("div.pEvent").each(function() {
        var showThis = $(this).find("div.revealEvent");
        
        $(this).find("a.pEventTitle").toggle(function() {   
            showThis.animate({ height: 'show', opacity: 'show' }, 750);
        }, function() {
            showThis.animate({ height: 'hide', opacity: 'hide' }, 750);
        });
    });
    
    // map bits //////////////////////////////////////////////////////////////////
    
    // hide all the breakdowns and h4s
        $("div#breakdowns").children().css("display", "none");
        $("div#breakdowns h4").css("display", "none");
        
    // return false on links
    $(".treeMap").click(function(){
		return false;
	});
    
    // style the breakdowns
        $(".positionBreaks").css("position", "absolute")
        .css("width", "300px")
        .css("z-index", "999999")
        .css("background-color", "#fefded")
        .css("font-size", "0.9em")
        .css("border", "1px solid #f0c78b");
    
    // North East
        $("div#breakNorthEast").css("top", "300px");
        $("div#breakNorthEast").css("left", "30px");
        
        $("#positionNorthEast").hover(function() {
		    $("div#breakNorthEast").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakNorthEast").animate({opacity: "hide"}, "fast");
	    });
	    
	// Scotland
        $("div#breakScotland").css("top", "300px");
        $("div#breakScotland").css("left", "230px");
        
        $("#positionScotland").hover(function() {
		    $("div#breakScotland").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakScotland").animate({opacity: "hide"}, "fast");
	    });
	    
	// Northen Ireland
        $("div#breakNorthernIreland").css("top", "370px");
        $("div#breakNorthernIreland").css("left", "120px");
        
        $("#positionNorthernIreland").hover(function() {
		    $("div#breakNorthernIreland").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakNorthernIreland").animate({opacity: "hide"}, "fast");
	    });
	    
	// North West
        $("div#breakNorthWest").css("top", "420px");
        $("div#breakNorthWest").css("left", "4px");
        
        $("#positionNorthWest").hover(function() {
		    $("div#breakNorthWest").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakNorthWest").animate({opacity: "hide"}, "fast");
	    });
	    
	// Yorkshire
        $("div#breakYorkshire").css("top", "410px");
        $("div#breakYorkshire").css("left", "100px");
        
        $("#positionYorkshire").hover(function() {
		    $("div#breakYorkshire").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakYorkshire").animate({opacity: "hide"}, "fast");
	    });
	    
	// East Midlands
        $("div#breakEastMidlands").css("top", "460px");
        $("div#breakEastMidlands").css("left", "130px");
        
        $("#positionEastMidlands").hover(function() {
		    $("div#breakEastMidlands").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakEastMidlands").animate({opacity: "hide"}, "fast");
	    });
	    
	// West Midlands
        $("div#breakWestMidlands").css("top", "495px");
        $("div#breakWestMidlands").css("left", "35px");
        
        $("#positionWestMidlands").hover(function() {
		    $("div#breakWestMidlands").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakWestMidlands").animate({opacity: "hide"}, "fast");
	    });
	
	// Eastern England
        $("div#breakEasternEngland").css("top", "520px");
        $("div#breakEasternEngland").css("left", "170px");
        
        $("#positionEasternEngland").hover(function() {
		    $("div#breakEasternEngland").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakEasternEngland").animate({opacity: "hide"}, "fast");
	    });
	    
	// Wales
        $("div#breakWales").css("top", "510px");
        $("div#breakWales").css("left", "4px");
        
        $("#positionWales").hover(function() {
		    $("div#breakWales").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakWales").animate({opacity: "hide"}, "fast");
	    });
	    
	// London
        $("div#breakLondon").css("top", "595px");
        $("div#breakLondon").css("left", "110px");
        
        $("#positionLondon").hover(function() {
		    $("div#breakLondon").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakLondon").animate({opacity: "hide"}, "fast");
	    });
	    
	 // South West
        $("div#breakSouthWest").css("top", "645px");
        $("div#breakSouthWest").css("left", "4px");
        
        $("#positionSouthWest").hover(function() {
		    $("div#breakSouthWest").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakSouthWest").animate({opacity: "hide"}, "fast");
	    });
	    
	 // South East
        $("div#breakSouthEast").css("top", "625px");
        $("div#breakSouthEast").css("left", "70px");
        
        $("#positionSouthEast").hover(function() {
		    $("div#breakSouthEast").animate({opacity: "show"}, "slow");
	    }, function() {
		    $("div#breakSouthEast").animate({opacity: "hide"}, "fast");
	    });
});