// doc ready
$(document).ready(function() {
    $(function() {
    initLightbox();
    $.ajaxSetup({
        // Disable caching of AJAX responses */ 
        cache: false
    }); 

    });
});

// colour switchers
function loadPSPGoPrices(type)
{
	$("#theprices").load('/wp-content/themes/consoletheme/pricestablepspgo.php?type=' + type);
}
function loadPSPPrices(type) {
    $("#theprices").load('/wp-content/themes/consoletheme/pricestablepsp3000.php?type=' + type);
}
function loadWiiPrices(type) {
    $("#theprices").load('/wp-content/themes/consoletheme/pricestablewii.php?type=' + type);
}
function loadWiiFitPlusPrices(type) {
    $("#theprices").load('/wp-content/themes/consoletheme/pricestablewiifitplus.php?type=' + type);
}
function loadXboxPrices(type) {
    $("#theprices").load('/wp-content/themes/consoletheme/pricestablexbox.php?type=' + type);
}
function loadPS3SlimPrices(type) {
    $("#theprices").load('/wp-content/themes/consoletheme/pricestableps3slim.php?type=' + type);
}
function loadPSMovePrices(type) {
    $("#theprices").load('/wp-content/themes/consoletheme/pricestableplaystationmove.php?type=' + type);
}
function loadXboxSlimPrices(type) {
    $("#theprices").load('/wp-content/themes/consoletheme/pricestablexbox360slim.php?type=' + type);
}

// format switcher
function loadConsolePrices(type) {
    var pathname = window.location.pathname;
    $("#theprices").load(pathname + '?mode=prices&type=' + type);
}

// lightbox
var rels = new Array();
function relsContains(test) {
    for (x in rels) {
        if (rels[x] == test) return true;
    }
    return false;
}
function initLightbox() {
    var anchors = document.getElementsByTagName('a');
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        var relAttribute = String(anchor.getAttribute('rel'));
        if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))) {
            if (!relsContains(relAttribute)) {
                rels.push(relAttribute);
            }
        }
    }
    for (x in rels) {
        $("a[rel=" + rels[x] + "]").lightBox();
    }
}