//Style Sheet Switcher version 1.1 Oct 10th, 2006
//Author: Dynamic Drive: http://www.dynamicdrive.com
//Usage terms: http://www.dynamicdrive.com/notice.htm

var manual_or_random = "manual" //"manual" or "random"
var randomsetting="3 days" //"eachtime", "sessiononly", or "x days (replace x with desired integer)". Only applicable if mode is random.

//////No need to edit beyond here//////////////

function getCookie(Name) { 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
}

function setCookie(name, value, days) {
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

function deleteCookie(name){
setCookie(name, "moot")
}


function setStylesheet(title, randomize){ //Main stylesheet switcher function. Second parameter if defined causes a random alternate stylesheet (including none) to be enabled
var i, cacheobj, altsheets=[""]
for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
if(cacheobj.getAttribute("rel").toLowerCase()=="alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
cacheobj.disabled = true
altsheets.push(cacheobj) //store reference to alt stylesheets inside array
if(cacheobj.getAttribute("title") == title) //enable alternate stylesheet with title that matches parameter
cacheobj.disabled = false //enable chosen style sheet
}
}
if (typeof randomize!="undefined"){ //if second paramter is defined, randomly enable an alt style sheet (includes non)
var randomnumber=Math.floor(Math.random()*altsheets.length)
altsheets[randomnumber].disabled=false
}
return (typeof randomize!="undefined" && altsheets[randomnumber]!="")? altsheets[randomnumber].getAttribute("title") : "" //if in "random" mode, return "title" of randomly enabled alt stylesheet
}

function chooseStyle(styletitle, days){ //Interface function to switch style sheets plus save "title" attr of selected stylesheet to cookie
if (document.getElementById){
setStylesheet(styletitle)
setCookie("mysheet", styletitle, days)
}
}

function indicateSelected(element){ //Optional function that shows which style sheet is currently selected within group of radio buttons or select menu
if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){ //if element is a radio button or select menu
var element=(element.type=="select-one") ? element.options : element
for (var i=0; i<element.length; i++){
if (element[i].value==selectedtitle){ //if match found between form element value and cookie value
if (element[i].tagName=="OPTION") //if this is a select menu
element[i].selected=true
else //else if it's a radio button
element[i].checked=true
break
}
}
}
}

if (manual_or_random=="manual"){ //IF MANUAL MODE
var selectedtitle=getCookie("mysheet")
if (document.getElementById && selectedtitle!=null) //load user chosen style sheet from cookie if there is one stored
setStylesheet(selectedtitle)
}
else if (manual_or_random=="random"){ //IF AUTO RANDOM MODE
if (randomsetting=="eachtime")
setStylesheet("", "random")
else if (randomsetting=="sessiononly"){ //if "sessiononly" setting
if (getCookie("mysheet_s")==null) //if "mysheet_s" session cookie is empty
document.cookie="mysheet_s="+setStylesheet("", "random")+"; path=/" //activate random alt stylesheet while remembering its "title" value
else
setStylesheet(getCookie("mysheet_s")) //just activate random alt stylesheet stored in cookie
}
else if (randomsetting.search(/^[1-9]+ days/i)!=-1){ //if "x days" setting
if (getCookie("mysheet_r")==null || parseInt(getCookie("mysheet_r_days"))!=parseInt(randomsetting)){ //if "mysheet_r" cookie is empty or admin has changed number of days to persist in "x days" variable
setCookie("mysheet_r", setStylesheet("", "random"), parseInt(randomsetting)) //activate random alt stylesheet while remembering its "title" value
setCookie("mysheet_r_days", randomsetting, parseInt(randomsetting)) //Also remember the number of days to persist per the "x days" variable
}
else
setStylesheet(getCookie("mysheet_r")) //just activate random alt stylesheet stored in cookie
} 
}

/*
* jQuery SuperBox! 0.9.1
* Copyright (c) 2009 Pierre Bertet (pierrebertet.net)
* Licensed under the MIT (MIT-LICENSE.txt)
*
*/
(function(i) {
    var l, t, r, q, a, p, h, o, j, w, b = { boxId: "superbox", boxClasses: "", overlayOpacity: 0.8, boxWidth: "600", boxHeight: "400", loadTxt: "Loading...", closeTxt: "x", prevTxt: "Previous", nextTxt: "Next", beforeShow: function() { } }, x = {}, m = false, s = i([]);
    i.superbox = function() {
        w = i.extend({}, b, i.superbox.settings); if (i.browser.msie && i.browser.version < 7) {
            s = s.add("select")
        } n(); z()
    }; function z() {
        i("a[rel^=superbox],area[rel^=superbox]").each(function() {
            var D = i(this), F = D.attr("rel"), B = F.match(/^superbox\[([^#\.\]]+)/)[1], E = F.replace("superbox", "").match(/([#\.][^#\.\]]+)/g) || [], C = w.boxId, A = w.boxClasses;
            this._relSettings = F.replace("superbox[" + B + E.join("") + "]", ""); i.each(E, function(G, H) {
                if (H.substr(0, 1) == "#") {
                    C = H.substr(1)
                } else { if (H.substr(0, 1) == ".") { A += " " + H.substr(1) } } 
            }); if (B.search(/^image|gallery|iframe|content|ajax$/) != -1) {
                D.superbox(B, { boxId: C, boxClasses: A })
            } 
        })
    } i.fn.superbox = function(B, A) { A = i.extend({}, w, A); i.superbox[B](this, A) }; i.extend(i.superbox, { image: function(C, A, B) {
        var E = f(C.get(0)), D = false;
        if (E && B == "gallery") { D = E[1] } else { if (E) { D = E[0] } } C.click(function(F) {
            F.preventDefault();
            k(); if (B == "gallery") { c(C, E[0]) } y(function() {
                var H = false, G; if (D) { H = D.split("x") } G = i('<img src="' + C.attr("href") + '" title="' + (C.attr("title") || C.text()) + '" />');
                G.load(function() { g(G, H); e({ boxClasses: "image " + A.boxClasses, boxId: A.boxId }); u() }).appendTo($innerbox)
            })
        })
    }, gallery: function(B, A) {
        var C = f(B.get(0)); if (!x[C[0]]) { x[C[0]] = [] } x[C[0]].push(B);
        B.get(0)._superboxGroupKey = (x[C[0]].length - 1); i.superbox.image(B, A, "gallery")
    }, iframe: function(B, A) {
        var C = f(B.get(0));
        B.click(function(D) {
            D.preventDefault(); k(); y(function() {
                var F = false, E; if (C) {
                    F = C[0].split("x")
                } A = i.extend({}, A, { boxWidth: F[0] || A.boxWidth, boxHeight: F[1] || A.boxHeight }); E = i('<iframe src="' + B.attr("href") + '" name="' + B.attr("href") + '" frameborder="0" scrolling="auto" hspace="0" width="' + A.boxWidth + '" height="' + A.boxHeight + '"></iframe>');
                E.load(function() {
                    q.width(A.boxWidth + "px"); $innerbox.height(A.boxHeight + "px"); e({ boxClasses: "iframe " + A.boxClasses, boxId: A.boxId });
                    u()
                }).appendTo($innerbox)
            })
        })
    }, content: function(B, A) {
        var C = f(B.get(0)); B.click(function(D) {
            D.preventDefault();
            k(); y(function() {
                var E = false; if (C) { E = C[0].split("x") } A = i.extend({}, A, { boxWidth: E[0] || A.boxWidth, boxHeight: E[1] || A.boxHeight });
                q.width(A.boxWidth + "px"); $innerbox.height(A.boxHeight + "px"); i(B.attr("href")).clone().appendTo($innerbox).show();
                e({ boxClasses: "content " + A.boxClasses, boxId: A.boxId }); u()
            })
        })
    }, ajax: function(B, A) {
        var C = f(B.get(0));
        B.click(function(D) {
            D.preventDefault(); k(); y(function() {
                var E = false; if (C && C[3]) {
                    E = C[3].split("x")
                } A = i.extend({}, A, { boxWidth: E[0] || A.boxWidth, boxHeight: E[1] || A.boxHeight }); q.width(A.boxWidth + "px");
                $innerbox.height(A.boxHeight + "px"); i.get(C[2], function(F) {
                    i(F).appendTo($innerbox)
                }); e({ boxClasses: "ajax " + A.boxClasses, boxId: A.boxId }); u()
            })
        })
    } 
    }); function f(A) {
        return A._relSettings.match(/([^\[\]]+)/g)
    } function g(A, B) {
        q.width(A.width() + ($innerbox.css("paddingLeft").slice(0, -2) - 0) + ($innerbox.css("paddingRight").slice(0, -2) - 0));
        $innerbox.height(A.height()); if (B && B[0] != "") { q.width(B[0] + "px") } if (B && B[1] != "" && B[1] > A.height()) {
            $innerbox.height(B[1] + "px")
        } 
    } function c(C, D) {
        h.show(); m = true; var A = C.get(0)._superboxGroupKey + 1, B = A - 2; if (x[D][A]) {
            o.removeClass("disabled").unbind("click").bind("click", function() {
                x[D][A].click()
            })
        } else { o.addClass("disabled").unbind("click") } if (x[D][B]) {
            j.removeClass("disabled").unbind("click").bind("click", function() {
                x[D][B].click()
            })
        } else { j.addClass("disabled").unbind("click") } 
    } function e(A) {
        q.attr("id", A.boxId).attr("class", A.boxClasses)
    } function d() {
        i(document).unbind("keydown"); p.hide(); h.hide(); t.hide().css({ position: "fixed", top: 0 });
        $innerbox.empty()
    } function v(A) { d(); l.fadeOut(300, function() { s.show() }); m = false } function y(B) {
        var A = function() {
            if (i.browser.msie && i.browser.version < 7) {
                t.css({ position: "absolute", top: "100%" })
            } s.hide(); p.show(); B()
        }; if (m) { l.css("opacity", w.overlayOpacity).show(); A() } else {
            l.css("opacity", 0).show().fadeTo(300, w.overlayOpacity, A)
        } 
    } function k() {
        t.show(); $innerbox.empty(); q.css({ position: "absolute", top: "-99999px" })
    } function u(A, B) {
        p.hide(); i(document).unbind("keydown").bind("keydown", function(C) {
            if (C.keyCode == 27) {
                v()
            } if (C.keyCode == 39 && o.is(":visible")) { o.click() } if (C.keyCode == 37 && j.is(":visible")) {
                j.click()
            } 
        }); q.css({ position: "static", top: 0, opacity: 0 }); if (i.browser.msie && i.browser.version < 8) {
            q.css({ position: "relative", top: "-100%" });
            if (i.browser.msie && i.browser.version < 7) { t.css({ position: "absolute", top: "100%" }) } 
        } if (i(window).height() < t.height()) {
            t.css({ position: "absolute", top: (t.offset().top + 10) + "px" })
        } w.beforeShow(); q.fadeTo(300, 1)
    } function n() {
        if (!i.superbox.elementsReady) {
            l = i('<div id="superbox-overlay"></div>').appendTo("body").hide();
            t = i('<div id="superbox-wrapper"></div>').appendTo("body").hide(); r = i('<div id="superbox-container"></div>').appendTo(t);
            q = i('<div id="superbox"></div>').appendTo(r); $innerbox = i('<div id="superbox-innerbox"></div>').appendTo(q);
            h = i('<p class="nextprev"></p>').appendTo(q).hide(); j = i('<a class="prev"><strong><span>' + w.prevTxt + "</span></strong></a>").appendTo(h);
            o = i('<a class="next"><strong><span>' + w.nextTxt + "</span></strong></a>").appendTo(h);
            a = i('<p class="close"><a><strong><span>' + w.closeTxt + "</span></strong></a></p>").prependTo(q).find("a");
            p = i('<p class="loading">' + w.loadTxt + "</p>").appendTo(r).hide(); l.add(t).add(a).click(function() {
                v()
            }); q.click(function(A) { A.stopPropagation() }); i.superbox.elementsReady = true
        } 
    } 
})(jQuery);
$(function() { $.superbox(); $('a[href^="http://"]').attr('target', '_blank'); $('#social').hover(function() { $(this).stop().animate({ top: 0 + "px" }, 300); }, function() { $(this).animate({ top: -100 + "px" }, 500); }); });