// script_v01.js for www.ku24.com - SA 03/04/2003// script_v01.js for www.ku24.com - SA 04/04/2003// script_v01.js for www.ku24.com - SA 05/04/2003// script_v01.js for www.ku24.com - SA 06/04/2003// script_v01.js for www.ku24.com - SA 07/05/2003// removed some cruft - SA 22/03/2004// added checkAndAdjustLayout() etc - SA 01/04/2004// almost complete rewrite of css handlers for slippy reflow with mulitple styles - SA 04/04/2004// cleaning up code and deleting cruft - SA 10/04/2004// ----------------------------------------------------------------------------// CSS STYLE AND LAYOUT HANDLERSvar current_style = "not yet set";var current_layout = "not yet set";function switchLayoutTo(some_layout) { // - SA 05/04/2004    // based on the style switcher code setActiveStyleSheet()    //    if (document.getElementsByTagName) {        var i, a;        for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {            if (a.getAttribute("rel")                    && a.getAttribute("rel").indexOf("style") != -1                    && a.getAttribute("title")                    // the following line is an optimisation for better dispay in Mozilla - SA 10/04/2004                    // the current style now doesn't get switched off and then back on again - SA 10/04/2004                    && a.getAttribute("title") != current_style) {                a.disabled = true; // i.e. switch it off                if (a.getAttribute("title") == some_layout) {                    a.disabled = false; // i.e. switch it on                }            }        }        current_layout = some_layout;    }}function checkAndAdjustLayout() { // - SA 03/04/2004    // a dhtml solution for having a liquid layout for standard width windows and a fixed-width layout for wide windows    //    if (document.body) {        window_width = document.body.offsetWidth;        if ("style_print" == current_style) {            // if the current style is PRINT then don't reset the layout            // this is so someone can click thru the site printing each page without having the stylesheet reset on them        } else if ((window_width > 858) && three_column_document) {            // an abritrary size. if it's changed here change it in the css            switchLayoutTo('layout_three_column_set_width');        } else if (window_width > 858) {            // an abritrary size. if it's changed here change it in the css            switchLayoutTo('layout_two_column_set_width');        } else if ((window_width > 800) && three_column_document) {            // i.e. wider than a 800px wide screen            switchLayoutTo('layout_three_column');        } else if (window_width > 800) {            // i.e. wider than a 800px wide screen            switchLayoutTo('layout_two_column_set_width');        } else if ((window_width > 750) && three_column_document) {            // i.e. wider than a 800px wide screen            switchLayoutTo('layout_two_column_set_width');        } else if (window_width > 480) {            // i.e. wider than a 540px wide screen            switchLayoutTo(null);            // i.e. "layout_two_column" here excluded because it is @included in null.css - SA 12/04/2004        } else {            // i.e. narrower than a 540px wide screen            switchLayoutTo('layout_one_column');        }    }}function switchStyleTo(some_style) { // - SA 05/04/2004    // based on the style switcher code setActiveStyleSheet()    //    if (document.getElementsByTagName) {        var i, a;        for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {            if (a.getAttribute("rel")                    && a.getAttribute("rel").indexOf("style") != -1                    && a.getAttribute("title")) {                a.disabled = true; // i.e. switch it off                if (a.getAttribute("title") == some_style                        || a.getAttribute("title") == current_layout) {                    a.disabled = false; // i.e. switch it on                }            }        }        current_style = some_style;        checkAndAdjustLayout();     }}function switchStyleToPrint() { // - SA 05/04/2004    // based on the style switcher code setActiveStyleSheet()    //    if (document.getElementsByTagName) {        var i, a;        for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {            if (a.getAttribute("rel")                    && a.getAttribute("rel").indexOf("style") != -1                    && a.getAttribute("title")) {                a.disabled = true; // i.e. switch it off                if (a.getAttribute("title") == "style_print") {                    a.disabled = false; // i.e. switch it on                }            }        }        current_style = "style_print";        current_layout = "layouts off for print css";    }}function createCookie(name, value, days) {    if (days) {        var date = new Date();        date.setTime(date.getTime()+(days*24*60*60*1000));        var expires = "; expires="+date.toGMTString();    }    else expires = "";    document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name) {    var nameEQ = name + "=";    var ca = document.cookie.split(';');    for (var i=0;i < ca.length;i++) {        var c = ca[i];        while (c.charAt(0)==' ') c = c.substring(1,c.length);        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);    }    return null;}function setInitialStyleSheets() { // - SA 05/04/2004    //    if (document.getElementsByTagName) {        var style_cookie = readCookie("Ku24_style");        var layout_cookie = readCookie("Ku24_layout");                // if there no cookies with the previous settings then set some defaults        current_style = style_cookie ? style_cookie : "style_default";        current_layout = layout_cookie ? layout_cookie : "layout_two_column";                switchStyleTo(current_style);        // switchLayoutTo(current_layout); no need to do this as switchStyleTo() will adjust the layout    }}function saveFinalStyleSheets() { // - updated SA 05/04/2004    //    createCookie("Ku24_style", current_style, 365);    createCookie("Ku24_layout", current_layout, 365);}setInitialStyleSheets();// i think this is repeated from the window.onload to paint the stylesheet in earlier where possible - SA 06/04/2003window.onload = function(e) {    // mac IE 5.0: having an onLoad call in the body tag causes this window.onload not to trigger, hence bugs - SA 03/04/2003    setInitialStyleSheets();    window.defaultStatus=' '; // specific to Ku24.com}window.onresize = function(e) { // - SA 01/04/2004    checkAndAdjustLayout();}window.onunload = function(e) {    saveFinalStyleSheets();}// ----------------------------------------------------------------------------// STATUS MESSAGE HANDLERSfunction setStatusMessage(a_lovely_little_message) { // v01 - SA 06/04/2003    //    window.status = a_lovely_little_message;}function onmouseoverStyleMessage(this_style, a_little_message) { // v01a - SA 06/04/2003    //    if (this_style != current_style) {        setStatusMessage(a_little_message);    } else {        setStatusMessage(current_style_message);    }}function onclickStyleMessage(this_style) { // v01a - SA 06/04/2003    //    if (this_style == current_style) {        setStatusMessage(current_style_message);    } else {        setStatusMessage("");    }}// ----------------------------------------------------------------------------// DIV HIGHLIGHTING HANDLERSfunction highlightOn(some_div) { // - SA 09/04/2004    //    some_div.className = "highlighted";}function highlightOff(some_div) { // - SA 09/04/2004    //    some_div.className = "highlightable";}