$(setupPage);
var twistiesOpen = false;
function setupPage(){

$(".seatRegion").each(function() {initialiseRegionPod(this)});
$(".seatType").each(function() {initialiseSeatTypePod(this)});
$("#hideTwisties").hide();
$(".showHidelink").click(function() {
toggleTwisties();
});
}
function initialiseRegionPod(currentPod) {

$("span.openTwisty", currentPod).attr('class', 'closedTwisty');


$(".topic", currentPod).hide();



if(currentPod.id) {
$("h2", currentPod).bind("click", function(e) {toggleRegion(currentPod.id); this.blur(); return(false);});
}
}
function initialiseSeatTypePod(currentPod) {

$(".content", currentPod).hide();


$("span.openTwisty", currentPod).attr('class', 'closedTwisty');

if(currentPod.id) {
$("h3", currentPod).bind("click", function(e) {toggleSeatType(currentPod.id); this.blur(); return(false);});
}
}
function toggleRegion(element) {

if($("#" + element + " .topic:visible").length > 0) {
$("#" + element + " h2 span").attr('class', 'closedTwisty');
}

else {
$("#" + element + " h2 span").attr('class', 'openTwisty');
}

$("#" + element + " .topic").slideToggle();

}
function toggleSeatType(element) {

if($("#" + element + " .content:visible").length > 0) {
$("#" + element + " h3 span").attr('class', 'closedTwisty');
}

else {
$("#" + element + " h3 span").attr('class', 'openTwisty');
}

$("#" + element + " .content").slideToggle();
}
function openAll (){

$(".topic").slideDown();
$(".content").slideDown();
$(".seatRegion span").addClass("openTwisty").removeClass("closedTwisty");

}
function closeAll(){

$(".topic").slideUp();
$(".content").slideUp();
$(".seatRegion span").addClass("closedTwisty").removeClass("openTwisty");
}
function toggleTwisties() {

twistiesOpen = !twistiesOpen;
if (twistiesOpen == true)
{
openAll();
$("#showTwisties").hide();
$("#hideTwisties").show();
}
else {
closeAll();
$("#showTwisties").show();
$("#hideTwisties").hide();
}
}

