﻿// Kainoto actions start
var currentTime = new Date();
var month = currentTime.getMonth()+1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();


function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function SetFeratelStartDate() {
    var TheDate = day + '/' + month + '/' + year;
    FeratelDatumPrihoda.value = TheDate;
}
function getSize(what) {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    if (what == "width") {
        return myWidth;
    }
    if (what == "Height") {
        return myHeight;
    }
    
}

function getSizeParentWindow(what) {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.parent.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.parent.innerWidth;
        myHeight = window.parent.innerHeight;
    } else if (document.documentElement && (document.parent.documentElement.clientWidth || document.parent.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.parent.documentElement.clientWidth;
        myHeight = document.parent.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.parent.body.clientWidth;
        myHeight = document.parent.body.clientHeight;
    }
    if (what == "width") {
        return myWidth;
    }
    if (what == "Height") {
        return myHeight;
    }
}

function popUp(URL) {
    newwindow=window.open(url,'name','height=1024,width=768');
	if (window.focus) {newwindow.focus()}
	return false;
}

function OpenPhotoDownLoadPanel(img) {
    document.getElementById('SelectedPhoto').value = img;
    document.getElementById('PhotoDownloadPanel').style.display = 'block';
}

function OpenPhotoDownload(size){
    LoadUserIframe('/PhotoDownload.aspx?size=' + size + '&img=' + document.getElementById('SelectedPhoto').value, 800, 600);
    var ApiOverlay = $("#UserOverlay").expose({ color: '#676767', onBeforeClose: function() { unLoadUserIframe(); } });
    document.getElementById('PhotoDownloadPanel').style.display = 'none';
    PhotoSlider.play();
}

function PhotosBigOpen(BigSrc, refreshImage) {
    var BigImg = document.getElementById('BigImg');
    BigImg.src = BigSrc;
    BigImg.style.display = 'block';
    
    var Wwidth = $(window).width();
    var scrollTop = $(window).scrollTop();
    var Wheight = $(window).height();
    var width = BigImg.clientWidth;
    var height = BigImg.clientHeight;
    
    if (Wwidth < width) {
        width = Wwidth;
    }

    if (Wheight < height) {
        height = Wheight;
    }

    var PosX = (Wwidth - width) / 2;
    var PosY = (Wheight - height) / 2;

    BigImg.style.width = width + 'px';
    BigImg.style.height = height + 'px';
    BigImg.style.left = PosX + 'px';
    BigImg.style.top = scrollTop + PosY + 'px';
    
    var PhotoOverlay = $("#BigImg").expose({ color: '#676767', onBeforeClose: function() { PhotosBigClose(); } });
    if (refreshImage == 'true') {
        BigImageLoadInterval = setInterval("ImageLoad('BigImg', '" + BigSrc + "')", 1000);
    }
    else {
        BigImageLoadInterval = setInterval(null, 100000);
    }
}

function ImageLoad(imgid, imgsrc) {
    newurl = imgsrc.replace("amp;counter=", "");
    random = new Date().getTime();
    var trickname = "&amp;counter=" + random;
    document.getElementById(imgid).src = newurl + '&amp;' + trickname;
    return;
}

function PhotosBigClose() {
    document.getElementById('BigImg').src = '';
    document.getElementById('BigImg').style.display = 'none';
    if (BigImageLoadInterval != null) {
        clearInterval(BigImageLoadInterval);
    }
}

function CenterPositionElement(elementId, width, height) {
    var element = document.getElementById(elementId);
    var Wwidth = $(window).width();
    var scrollTop = $(window).scrollTop();
    var Wheight = $(window).height();

    if (Wwidth < width) {
        width = Wwidth;
    }

    if (Wheight < height) {
        height = Wheight;
    }
    var PosX = (Wwidth - width) / 2;
    var PosY = (Wheight - height) / 2;
    element.style.width = width + 'px';
    element.style.height = height + 'px';
    element.style.left = PosX + 'px';
    element.style.top = scrollTop + PosY + 'px';
}

function LoadUserIframe(source, width, height) {
    var IframeElem = document.getElementById('UserIframe');
    var UserOverlay = document.getElementById('UserOverlay');
    IframeElem.style.width = width + 'px';
    IframeElem.style.height = height + 'px';
    CenterPositionElement('UserOverlay', width, height);
    UserOverlay.style.display = 'block';
    IframeElem.src = source;
    var ApiOverlay = $("#UserOverlay").expose({ color: '#676767', onBeforeClose: function() { unLoadUserIframe(); } });
}
function unLoadUserIframe() {
    var IframeElem = document.getElementById('UserIframe');
    var UserOverlay = document.getElementById('UserOverlay');
    UserOverlay.style.width = '0px';
    UserOverlay.style.height = '0px';
    IframeElem.style.width = '0px';
    IframeElem.style.height = '0px';
    UserOverlay.style.left = '0px';
    UserOverlay.style.top = '0px';
    UserOverlay.style.display = 'none';
    IframeElem.src = '';
}


function ChangeResults() {
    
    __doPostBack(SearchRefreshButton, '');
}

function CloseResultsDiv() {
    document.getElementById('SearchTitlesDiv').style.display = 'none';
}

function ElementDisplay(ElementId, mode) {
    document.getElementById(ElementId).style.display = mode;
}

function SwitchPageStyle(StyleName) {
    createCookie('StylePreference', StyleName, 365);
    setTimeout("ElementDisplay('ctl00_htmlbody', 'none')", 50);
    setTimeout("ReplacePageCssFile('page', '/css/pageC" + StyleName + ".css', 'css')", 60)
    setTimeout("ElementDisplay('ctl00_htmlbody', 'block')", 1500);
}

function getRadioCheckedValue(radio_name) {
    var oRadio = document.forms[0].elements[radio_name];
    for (var i = 0; i < oRadio.length; i++) {
        if (oRadio[i].checked) {
            return oRadio[i].value;
        }
    }
    return '';
}

function getSelectedValue(Element_Id) {
    var selected_index = Element_Id.selectedIndex;
    if (selected_index > 0) {
        return Element_Id.options[selected_index].value;
    }
    else { return ''; }
}

function OpenFeratelFrame() {
    //var AccT = getRadioCheckedValue('AccType');
    var AccT = FeratelAccTypeList.options[FeratelAccTypeList.selectedIndex].value;
    var Loc = FeratelSrchOrte.options[FeratelSrchOrte.selectedIndex].value;
    var dateString = FeratelDatumPrihoda.value.split('/');
    var FromMonth = dateString[1];
    var FromDay = dateString[0];
    var FromYear = dateString[2];
    if (FromMonth.length == 1) {
        FromMonth = '0' + FromMonth;
    }
    if (FromDay.length == 1) {
        FromDay = '0' + FromDay;
    }
    var OnlyOnline = '0';
    if (document.getElementById('SrchBookOnly').checked) {
        OnlyOnline = '1';
    }
    link = "http://web.deskline.net/maribor/" + FeratelLangCode + "/qfind_accommodation?qfdAccommodationType=" + AccT + "&qfdArrivalDate=" + FromYear + FromMonth + FromDay + "&qfdLocation=" + Loc + "&SrchFromDay=" + dateString[0] + "&SrchFromMonth=" + dateString[1] + "&SrchFromYear=" + FromYear + "&qfdNights=" + FeratelNoci.value + "&qfdNumberOfUnits=" + FeratelSob.value + "&qfdAdults=" + FeratelOseb.value + "&qfdOnlyBookable=" + OnlyOnline + "&qfdShowOnMap=checked";
    var FeratelDiv = document.getElementById('feratel_div');
    var VsebinskiDiv = document.getElementById('contentCell');
    var FeratelFrame = document.getElementById('feratel_frame');
    FeratelDiv.style.display = 'block';
    VsebinskiDiv.style.display = 'none';
    FeratelFrame.src = link;
    //alert(link);
    //    FeratelExposeLoad.close();
}




//GMap


function ExposeLargeMap() {
    var GmapHolderWidth = getSize("width") - 20;
    var GmapHolderHeight = getSize("Height");
    var GmapWidth = GmapHolderWidth - 145;
    var GmapHeight = GmapHolderHeight;
    var currWindowPosTop = ($(window).scrollTop());
    var currWindowPosLeft = ($(window).scrollLeft());
    GmapHolder.style.left = currWindowPosLeft + 'px';
    GmapHolder.style.top = currWindowPosTop + 'px';
    GmapHolder.style.backgroundColor = 'White';
    GmapHolder.style.width = GmapHolderWidth + 'px';
    GmapHolder.style.height = GmapHolderHeight + 'px';
    Gmap.style.width = GmapWidth + 'px';
    Gmap.style.height = GmapHeight + 'px';
    EnLargeMapButton.onclick = CloseLargeMap;
//    EnLargeMapButton.style.top = '100px';
//    EnLargeMapButton.style.right = '5px';
//    GmapLogoImg.style.top = '20px';
//    GmapLogoImg.style.right = '5px';
    GmapLogoImg.style.display = 'block';
    map.checkResize();
    map.addControl(new google.maps.LocalSearch());
}
function CloseLargeMap() {
//    EnLargeMapButton.style.top = '10px';
//    EnLargeMapButton.style.right = '10px';
    GmapHolder.style.removeProperty("left");
    GmapHolder.style.removeProperty("top");
    GmapHolder.style.removeProperty("left");
    GmapHolder.style.backgroundColor = '#EEEEEE';
    GmapHolder.style.width = '360px';
    GmapHolder.style.height = '126px';
    Gmap.style.width = '220px';
    Gmap.style.height = '126px';
    GmapLogoImg.style.display = 'none';
    map.checkResize();
    EnLargeMapButton.onclick = ExposeLargeMap;
}

//QuirksMode cookies management

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 var 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 eraseCookie(name) {
    createCookie(name, "", -1);
}

function createjscssfile(filename, filetype) {
    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    return fileref
}

function ReplacePageCssFile(oldfilename, newfilename, filetype) {
    var targetelement = (filetype == "js") ? "script" : (filetype == "css") ? "link" : "none" //determine element type to create nodelist using
    var targetattr = (filetype == "js") ? "src" : (filetype == "css") ? "href" : "none" //determine corresponding attribute to test for
    var allsuspects = document.getElementsByTagName(targetelement)
    for (var i = allsuspects.length; i >= 0; i--) { //search backwards within nodelist for matching elements to remove
        if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].getAttribute(targetattr).indexOf(oldfilename) != -1) {
            var newelement = createjscssfile(newfilename, filetype)
            allsuspects[i].parentNode.replaceChild(newelement, allsuspects[i])
        }
    }
}

function reloadStylesheets() {
    var stylesheets = $('link[rel="stylesheet"]');
    var reloadQueryString = '?reload=' + new Date().getTime();
    stylesheets.each(function() {
        this.href = this.href.replace(/\?.*|$/, reloadQueryString);
    });
}

// Kainoto actions end


//LazyLoad

/*
 * Lazy Load - jQuery plugin for lazy loading images
 *
 * Copyright (c) 2007-2009 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   http://www.appelsiini.net/projects/lazyload
 *
 * Version:  1.4.0
 *
 */
(function($) {

    $.fn.lazyload = function(options) {
        var settings = {
            threshold    : 0,
            failurelimit : 0,
            event        : "scroll",
            effect       : "show",
            container    : window
        };
                
        if(options) {
            $.extend(settings, options);
        }

        /* Fire one scroll event per scroll. Not one scroll event per image. */
        var elements = this;
        if ("scroll" == settings.event) {
            $(settings.container).bind("scroll", function(event) {
                
                var counter = 0;
                elements.each(function() {
                    if ($.abovethetop(this, settings) ||
                        $.leftofbegin(this, settings)) {
                            /* Nothing. */
                    } else if (!$.belowthefold(this, settings) &&
                        !$.rightoffold(this, settings)) {
                            $(this).trigger("appear");
                    } else {
                        if (counter++ > settings.failurelimit) {
                            return false;
                        }
                    }
                });
                /* Remove image from array so it is not looped next time. */
                var temp = $.grep(elements, function(element) {
                    return !element.loaded;
                });
                elements = $(temp);
            });
        }
        
        return this.each(function() {
            var self = this;
            $(self).data("original", $(self).attr("src"));

            if ("scroll" != settings.event || (
                         $.abovethetop(self, settings) ||
                         $.leftofbegin(self, settings) || 
                         $.belowthefold(self, settings) || 
                         $.rightoffold(self, settings) )) {
                if (settings.placeholder) {
                    $(self).attr("src", settings.placeholder);      
                } else {
                    $(self).removeAttr("src");
                }
                self.loaded = false;
            } else {
                self.loaded = true;
            }
            
            /* When appear is triggered load original image. */
            $(self).one("appear", function() {
                if (!this.loaded) {
                    $("<img />")
                        .bind("load", function() {
                            $(self)
                                .hide()
                                .attr("src", $(self).data("original"))
                                [settings.effect](settings.effectspeed);
                            self.loaded = true;
                        })
                        .attr("src", $(self).data("original"));
                };
            });

            /* When wanted event is triggered load original image */
            /* by triggering appear.                              */
            if ("scroll" != settings.event) {
                $(self).bind(settings.event, function(event) {
                    if (!self.loaded) {
                        $(self).trigger("appear");
                    }
                });
            }
        });

    };

    /* Convenience methods in jQuery namespace.           */
    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */

    $.belowthefold = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).height() + $(window).scrollTop();
        } else {
            var fold = $(settings.container).offset().top + $(settings.container).height();
        }
        return fold <= $(element).offset().top - settings.threshold;
    };
    
    $.rightoffold = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).width() + $(window).scrollLeft();
        } else {
            var fold = $(settings.container).offset().left + $(settings.container).width();
        }
        return fold <= $(element).offset().left - settings.threshold;
    };
        
    $.abovethetop = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).scrollTop();
        } else {
            var fold = $(settings.container).offset().top;
        }
        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
    };
    
    $.leftofbegin = function(element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).scrollLeft();
        } else {
            var fold = $(settings.container).offset().left;
        }
        return fold >= $(element).offset().left + settings.threshold + $(element).width();
    };
    /* Custom selectors for your convenience.   */
    /* Use as $("img:below-the-fold").something() */

    $.extend($.expr[':'], {
        "below-the-fold" : "$.belowthefold(a, {threshold : 0, container: window})",
        "above-the-fold" : "!$.belowthefold(a, {threshold : 0, container: window})",
        "right-of-fold"  : "$.rightoffold(a, {threshold : 0, container: window})",
        "left-of-fold"   : "!$.rightoffold(a, {threshold : 0, container: window})"
    });
    
})(jQuery);

//CurveyCorners

/****************************************************************
*                                                              *
*  CurvyCorners                                                *
*  ------------                                                *
*                                                              *
*  This script generates rounded corners for your boxes.       *
*                                                              *
*  Version 2.0.4                                               *
*  Copyright (c) 2009 Cameron Cooke                            *
*  Contributors: Tim Hutchison, CPK Smithies, Terry Rigel      *
*                                                              *
*  Website: http://www.curvycorners.net                        *
*  SVN:     http://curvycorners.googlecode.com/                *
*  Email:   cameron@curvycorners.net                           *
*  Discuss: http://groups.google.com/group/curvycorners        *
*                                                              *
*  Please consult the SVN for a list of changes since the last *
*  revision.                                                   *
*                                                              *
*  This library is free software; you can redistribute         *
*  it and/or modify it under the terms of the GNU              *
*  Lesser General Public License as published by the           *
*  Free Software Foundation; either version 2.1 of the         *
*  License, or (at your option) any later version.             *
*                                                              *
*  This library is distributed in the hope that it will        *
*  be useful, but WITHOUT ANY WARRANTY; without even the       *
*  implied warranty of MERCHANTABILITY or FITNESS FOR A        *
*  PARTICULAR PURPOSE. See the GNU Lesser General Public       *
*  License for more details.                                   *
*                                                              *
*  You should have received a copy of the GNU Lesser           *
*  General Public License along with this library;             *
*  Inc., 59 Temple Place, Suite 330, Boston,                   *
*  MA 02111-1307 USA                                           *
*                                                              *
****************************************************************/

/*
Version 2.x now autoMagically applies borders via CSS rules.
Safari, Chrome and Mozilla support rounded borders via

-webkit-border-radius, -moz-border-radius

We let these browsers render their borders natively.
Firefox for Windows renders non-antialiased
borders so they look a bit ugly. Google's Chrome will render its "ugly"
borders as well. So if we let FireFox, Safari, and Chrome render their
borders natively, then we only have to support IE and Opera
for rounded borders. Fortunately IE reads CSS properties
that it doesn't understand (Opera, Firefox and Safari discard them);
so for IE and Opera we find and apply -webkit-border-radius and friends.

So to make curvycorners work with any major browser simply add the following
CSS declarations and it should be good to go...

.round {
-webkit-border-radius: 3ex;
-moz-border-radius: 3ex;
}

NB at present you must (for Opera's sake) include these styles in
the page itself.
*/

function browserdetect() {
    var agent = navigator.userAgent.toLowerCase();
    this.isIE = agent.indexOf("msie") > -1;
    this.ieVer = this.isIE ? /msie\s(\d\.\d)/.exec(agent)[1] : 0;
    this.isMoz = agent.indexOf('firefox') != -1;
    this.isSafari = agent.indexOf('safari') != -1;
    this.quirksMode = this.isIE && (!document.compatMode || document.compatMode.indexOf("BackCompat") > -1);
    this.isOp = 'opera' in window;
    this.isWebKit = agent.indexOf('webkit') != -1;
    if (this.isIE) {
        this.get_style = function(obj, prop) {
            if (!(prop in obj.currentStyle)) return "";
            var matches = /^([\d.]+)(\w*)/.exec(obj.currentStyle[prop]);
            if (!matches) return obj.currentStyle[prop];
            if (matches[1] == 0) return '0';
            // now convert to pixels if necessary
            if (matches[2] && matches[2] !== 'px') {
                var style = obj.style.left;
                var rtStyle = obj.runtimeStyle.left;
                obj.runtimeStyle.left = obj.currentStyle.left;
                obj.style.left = matches[1] + matches[2];
                matches[0] = obj.style.pixelLeft;
                obj.style.left = style;
                obj.runtimeStyle.left = rtStyle;
            }
            return matches[0];
        };
    }
    else {
        this.get_style = function(obj, prop) {
            prop = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
            return document.defaultView.getComputedStyle(obj, '').getPropertyValue(prop);
        };
    }
}
var curvyBrowser = new browserdetect;

/* Force caching of bg images in IE6 */
if (curvyBrowser.isIE) {
    try {
        document.execCommand("BackgroundImageCache", false, true);
    }
    catch (e) { };
}

// object that parses border-radius properties for a box

function curvyCnrSpec(selText) {
    this.selectorText = selText;
    this.tlR = this.trR = this.blR = this.brR = 0;
    this.tlu = this.tru = this.blu = this.bru = "";
    this.antiAlias = true; // default true
}
curvyCnrSpec.prototype.setcorner = function(tb, lr, radius, unit) {
    if (!tb) { // no corner specified
        this.tlR = this.trR = this.blR = this.brR = parseInt(radius);
        this.tlu = this.tru = this.blu = this.bru = unit;
    }
    else { // corner specified
        propname = tb.charAt(0) + lr.charAt(0);
        this[propname + 'R'] = parseInt(radius);
        this[propname + 'u'] = unit;
    }
}
/*
get(propstring)
where propstring is:
- 'tR' or 'bR' : returns top or bottom radius.
- 'tlR', 'trR', 'blR' or 'brR' : returns top/bottom left/right radius.
- 'tlu', 'tru', 'blr' or 'bru' : returns t/b l/r unit (px, em...)
- 'tRu' or 'bRu' : returns top/bottom radius+unit
- 'tlRu', 'trRu', 'blRu', 'brRu' : returns t/b l/r radius+unit
*/
curvyCnrSpec.prototype.get = function(prop) {
    if (/^(t|b)(l|r)(R|u)$/.test(prop)) return this[prop];
    if (/^(t|b)(l|r)Ru$/.test(prop)) {
        var pname = prop.charAt(0) + prop.charAt(1);
        return this[pname + 'R'] + this[pname + 'u'];
    }
    if (/^(t|b)Ru?$/.test(prop)) {
        var tb = prop.charAt(0);
        tb += this[tb + 'lR'] > this[tb + 'rR'] ? 'l' : 'r';
        var retval = this[tb + 'R'];
        if (prop.length === 3 && prop.charAt(2) === 'u')
            retval += this[tb = 'u'];
        return retval;
    }
    throw new Error('Don\'t recognize property ' + prop);
}
curvyCnrSpec.prototype.radiusdiff = function(tb) {
    if (tb !== 't' && tb !== 'b') throw new Error("Param must be 't' or 'b'");
    return Math.abs(this[tb + 'lR'] - this[tb + 'rR']);
}
curvyCnrSpec.prototype.setfrom = function(obj) {
    this.tlu = this.tru = this.blu = this.bru = 'px'; // default to px
    if ('tl' in obj) this.tlR = obj.tl.radius;
    if ('tr' in obj) this.trR = obj.tr.radius;
    if ('bl' in obj) this.blR = obj.bl.radius;
    if ('br' in obj) this.brR = obj.br.radius;
    if ('antiAlias' in obj) this.antiAlias = obj.antiAlias;
};
curvyCnrSpec.prototype.cloneOn = function(box) { // not needed by IE
    var props = ['tl', 'tr', 'bl', 'br'];
    var converted = 0;
    var i, propu;

    for (i in props) if (!isNaN(i)) {
        propu = this[props[i] + 'u'];
        if (propu !== '' && propu !== 'px') {
            converted = new curvyCnrSpec;
            break;
        }
    }
    if (!converted)
        converted = this; // no need to clone
    else {
        var propi, propR, save = curvyBrowser.get_style(box, 'left');
        for (i in props) if (!isNaN(i)) {
            propi = props[i];
            propu = this[propi + 'u'];
            propR = this[propi + 'R'];
            if (propu !== 'px') {
                var save = box.style.left;
                box.style.left = propR + propu;
                propR = box.style.pixelLeft;
                box.style.left = save;
            }
            converted[propi + 'R'] = propR;
            converted[propi + 'u'] = 'px';
        }
        box.style.left = save;
    }
    return converted;
}
curvyCnrSpec.prototype.radiusSum = function(tb) {
    if (tb !== 't' && tb !== 'b') throw new Error("Param must be 't' or 'b'");
    return this[tb + 'lR'] + this[tb + 'rR'];
}
curvyCnrSpec.prototype.radiusCount = function(tb) {
    var count = 0;
    if (this[tb + 'lR']) ++count;
    if (this[tb + 'rR']) ++count;
    return count;
}
curvyCnrSpec.prototype.cornerNames = function() {
    var ret = [];
    if (this.tlR) ret.push('tl');
    if (this.trR) ret.push('tr');
    if (this.blR) ret.push('bl');
    if (this.brR) ret.push('br');
    return ret;
}

/*
Object that parses Opera CSS
*/
function operasheet(sheetnumber) {
    var txt = document.styleSheets.item(sheetnumber).ownerNode.text;
    txt = txt.replace(/\/\*(\n|\r|.)*?\*\//g, ''); // strip comments
    // this pattern extracts all border-radius-containing rulesets
    // matches will be:
    // [0] = the whole lot
    // [1] = the selector text
    // [2] = all the rule text between braces
    // [3] = top/bottom and left/right parts if present (only if webkit/CSS3)
    // [4] = top|bottom
    // [5] = left|right
    // .. but 3..5 are useless as they're only the first match.
    var pat = new RegExp("^\s*([\\w.#][-\\w.#, ]+)[\\n\\s]*\\{([^}]+border-((top|bottom)-(left|right)-)?radius[^}]*)\\}", "mg");
    var matches;
    this.rules = [];
    while ((matches = pat.exec(txt)) !== null) {
        var pat2 = new RegExp("(..)border-((top|bottom)-(left|right)-)?radius:\\s*([\\d.]+)(in|em|px|ex|pt)", "g");
        var submatches, cornerspec = new curvyCnrSpec(matches[1]);
        while ((submatches = pat2.exec(matches[2])) !== null)
            if (submatches[1] !== "z-")
            cornerspec.setcorner(submatches[3], submatches[4], submatches[5], submatches[6]);
        this.rules.push(cornerspec);
    }
}
// static class function to determine if the sheet is worth parsing
operasheet.contains_border_radius = function(sheetnumber) {
    return /border-((top|bottom)-(left|right)-)?radius/.test(document.styleSheets.item(sheetnumber).ownerNode.text);
}

/*
Usage:

curvyCorners(settingsObj, "selectorStr");
curvyCorners(settingsObj, domObj1[, domObj2[, domObj3[, . . . [, domObjN]]]]);
selectorStr::= "<complexSelector>[, <complexSelector>]..."
complexSelector::= <selector>[ <selector]
selector::= "[<elementname>].classname" | "#id"
*/

function curvyCorners() {
    var i, j, boxCol, settings, startIndex;
    // Check parameters
    if (typeof arguments[0] !== "object") throw curvyCorners.newError("First parameter of curvyCorners() must be an object.");
    if (arguments[0] instanceof curvyCnrSpec) {
        settings = arguments[0];
        if (!settings.selectorText && typeof arguments[1] === 'string')
            settings.selectorText = arguments[1];
    }
    else {
        if (typeof arguments[1] !== "object" && typeof arguments[1] !== "string") throw curvyCorners.newError("Second parameter of curvyCorners() must be an object or a class name.");
        j = arguments[1];
        if (typeof j !== 'string') j = '';
        if (j !== '' && j.charAt(0) !== '.' && 'autoPad' in arguments[0]) j = '.' + j; // for compatibility, prefix with dot
        settings = new curvyCnrSpec(j);
        settings.setfrom(arguments[0]);
    }

    // Get object(s)
    if (settings.selectorText) {
        startIndex = 0;
        var args = settings.selectorText.replace(/\s+$/, '').split(/,\s*/); // handle comma-separated selector list
        boxCol = new Array;

        // converts div#mybox to #mybox
        function idof(str) {
            var ret = str.split('#');
            return (ret.length === 2 ? "#" : "") + ret.pop();
        }

        for (i = 0; i < args.length; ++i) {
            var arg = idof(args[i]);
            var argbits = arg.split(' ');
            switch (arg.charAt(0)) {
                case '#': // id
                    j = argbits.length === 1 ? arg : argbits[0];
                    j = document.getElementById(j.substr(1));
                    if (j === null)
                        curvyCorners.alert("No object with ID " + arg + " exists yet.\nCall curvyCorners(settings, obj) when it is created.");
                    else if (argbits.length === 1)
                        boxCol.push(j);
                    else
                        boxCol = boxCol.concat(curvyCorners.getElementsByClass(argbits[1], j));
                    break;
                default:
                    if (argbits.length === 1)
                        boxCol = boxCol.concat(curvyCorners.getElementsByClass(arg));
                    else {
                        var encloser = curvyCorners.getElementsByClass(argbits[0]);
                        for (j = 0; j < encloser.length; ++j) {
                            boxCol = boxCol.concat(curvyCorners.getElementsByClass(argbits[1], encloser));
                        }
                    }
                    //break;
            }
        }
    }
    else {
        // Get objects
        startIndex = 1;
        boxCol = arguments;
    }

    // Loop through each argument
    for (i = startIndex, j = boxCol.length; i < j; ++i) {
        if (boxCol[i] && (!('IEborderRadius' in boxCol[i].style) || boxCol[i].style.IEborderRadius != 'set')) {
            if (boxCol[i].className && boxCol[i].className.indexOf('curvyRedraw') !== -1) {
                if (typeof curvyCorners.redrawList === 'undefined') curvyCorners.redrawList = new Array;
                curvyCorners.redrawList.push({
                    node: boxCol[i],
                    spec: settings,
                    copy: boxCol[i].cloneNode(false)
                });
            }
            boxCol[i].style.IEborderRadius = 'set';
            var obj = new curvyObject(settings, boxCol[i]);
            obj.applyCorners();
        }
    }
}
curvyCorners.prototype.applyCornersToAll = function() { // now redundant
    curvyCorners.alert('This function is now redundant. Just call curvyCorners(). See documentation.');
};

curvyCorners.redraw = function() {
    if (!curvyBrowser.isOp && !curvyBrowser.isIE) return;
    if (!curvyCorners.redrawList) throw curvyCorners.newError('curvyCorners.redraw() has nothing to redraw.');
    var old_block_value = curvyCorners.bock_redraw;
    curvyCorners.block_redraw = true;
    for (var i in curvyCorners.redrawList) {
        if (isNaN(i)) continue; // in case of added prototype methods
        var o = curvyCorners.redrawList[i];
        if (!o.node.clientWidth) continue; // don't resize hidden boxes
        var newchild = o.copy.cloneNode(false);
        for (var contents = o.node.firstChild; contents != null; contents = contents.nextSibling)
            if (contents.className === 'autoPadDiv') break;
        if (!contents) {
            curvyCorners.alert('Couldn\'t find autoPad DIV');
            break;
        }
        o.node.parentNode.replaceChild(newchild, o.node);
        while (contents.firstChild) newchild.appendChild(contents.removeChild(contents.firstChild));
        o = new curvyObject(o.spec, o.node = newchild);
        o.applyCorners();
    }
    curvyCorners.block_redraw = old_block_value;
}
curvyCorners.adjust = function(obj, prop, newval) {
    if (curvyBrowser.isOp || curvyBrowser.isIE) {
        if (!curvyCorners.redrawList) throw curvyCorners.newError('curvyCorners.adjust() has nothing to adjust.');
        var i, j = curvyCorners.redrawList.length;
        for (i = 0; i < j; ++i) if (curvyCorners.redrawList[i].node === obj) break;
        if (i === j) throw curvyCorners.newError('Object not redrawable');
        obj = curvyCorners.redrawList[i].copy;
    }
    if (prop.indexOf('.') === -1)
        obj[prop] = newval;
    else eval('obj.' + prop + "='" + newval + "'");
}
curvyCorners.handleWinResize = function() {
    if (!curvyCorners.block_redraw) curvyCorners.redraw();
}
curvyCorners.setWinResize = function(onoff) {
    curvyCorners.block_redraw = !onoff;
}
curvyCorners.newError = function(errorMessage) {
    return new Error("curvyCorners Error:\n" + errorMessage)
}
curvyCorners.alert = function(errorMessage) {
    if (typeof curvyCornersVerbose === 'undefined' || curvyCornersVerbose) alert(errorMessage);
}

// curvyCorners object (can be called directly)

function curvyObject() {
    var boxDisp;
    this.box = arguments[1];
    this.settings = arguments[0];
    this.topContainer = this.bottomContainer = this.shell = boxDisp = null;
    var boxWidth = this.box.clientWidth; // browser-independent IE-emulation (NB includes padding)

    // if no client width, maybe the box or a parent has 'display:none'.

    if (!boxWidth && curvyBrowser.isIE) {
        this.box.style.zoom = 1; // can force IE to calculate width
        boxWidth = this.box.clientWidth;
    }
    if (!boxWidth) {
        if (!this.box.parentNode) throw this.newError("box has no parent!"); // unlikely...
        for (boxDisp = this.box; ; boxDisp = boxDisp.parentNode) {
            if (!boxDisp || boxDisp.tagName === 'BODY') { // we've hit the buffers
                this.applyCorners = function() { } // make the error benign
                curvyCorners.alert(this.errmsg("zero-width box with no accountable parent", "warning"));
                return;
            }
            if (boxDisp.style.display === 'none') break;
        }
        // here, we've found the box whose display is set to 'none'.
        boxDisp.style.display = 'block'; // display in order to get browser to calculate clientWidth
        boxWidth = this.box.clientWidth;
    }
    if (arguments[0] instanceof curvyCnrSpec)
        this.spec = arguments[0].cloneOn(this.box); // convert non-pixel units
    else {
        this.spec = new curvyCnrSpec('');
        this.spec.setfrom(this.settings); // no need for unit conversion, use settings param. directly
    }

    // Get box formatting details
    var borderWidth = curvyBrowser.get_style(this.box, "borderTopWidth");
    var borderWidthB = curvyBrowser.get_style(this.box, "borderBottomWidth");
    var borderWidthL = curvyBrowser.get_style(this.box, "borderLeftWidth");
    var borderWidthR = curvyBrowser.get_style(this.box, "borderRightWidth");
    var borderColour = curvyBrowser.get_style(this.box, "borderTopColor");
    var borderColourB = curvyBrowser.get_style(this.box, "borderBottomColor");
    var borderColourL = curvyBrowser.get_style(this.box, "borderLeftColor");
    var boxColour = curvyBrowser.get_style(this.box, "backgroundColor");
    var backgroundImage = curvyBrowser.get_style(this.box, "backgroundImage");
    var backgroundRepeat = curvyBrowser.get_style(this.box, "backgroundRepeat");
    if (this.box.currentStyle && this.box.currentStyle.backgroundPositionX) {
        var backgroundPosX = curvyBrowser.get_style(this.box, "backgroundPositionX");
        var backgroundPosY = curvyBrowser.get_style(this.box, "backgroundPositionY");
    }
    else {
        var backgroundPosX = curvyBrowser.get_style(this.box, 'backgroundPosition');
        backgroundPosX = backgroundPosX.split(' ');
        var backgroundPosY = backgroundPosX[1];
        backgroundPosX = backgroundPosX[0];
    }
    var boxPosition = curvyBrowser.get_style(this.box, "position");
    var topPadding = curvyBrowser.get_style(this.box, "paddingTop");
    var bottomPadding = curvyBrowser.get_style(this.box, "paddingBottom");
    var leftPadding = curvyBrowser.get_style(this.box, "paddingLeft");
    var rightPadding = curvyBrowser.get_style(this.box, "paddingRight");
    var border = curvyBrowser.get_style(this.box, "border");
    filter = curvyBrowser.ieVer > 7 ? curvyBrowser.get_style(this.box, 'filter') : null; // IE8 bug fix

    var topMaxRadius = this.spec.get('tR');
    var botMaxRadius = this.spec.get('bR');
    var styleToNPx = function(val) {
        if (typeof val === 'number') return val;
        if (typeof val !== 'string') throw new Error('unexpected styleToNPx type ' + typeof val);
        var matches = /^[-\d.]([a-z]+)$/.exec(val);
        if (matches && matches[1] != 'px') throw new Error('Unexpected unit ' + matches[1]);
        if (isNaN(val = parseInt(val))) val = 0;
        return val;
    }
    var min0Px = function(val) {
        return val <= 0 ? "0" : val + "px";
    }

    // Set formatting properties
    try {
        this.borderWidth = styleToNPx(borderWidth);
        this.borderWidthB = styleToNPx(borderWidthB);
        this.borderWidthL = styleToNPx(borderWidthL);
        this.borderWidthR = styleToNPx(borderWidthR);
        this.boxColour = curvyObject.format_colour(boxColour);
        this.topPadding = styleToNPx(topPadding);
        this.bottomPadding = styleToNPx(bottomPadding);
        this.leftPadding = styleToNPx(leftPadding);
        this.rightPadding = styleToNPx(rightPadding);
        this.boxWidth = boxWidth;
        this.boxHeight = this.box.clientHeight;
        this.borderColour = curvyObject.format_colour(borderColour);
        this.borderColourB = curvyObject.format_colour(borderColourB);
        this.borderColourL = curvyObject.format_colour(borderColourL);
        this.borderString = this.borderWidth + "px" + " solid " + this.borderColour;
        this.borderStringB = this.borderWidthB + "px" + " solid " + this.borderColourB;
        this.backgroundImage = ((backgroundImage != "none") ? backgroundImage : "");
        this.backgroundRepeat = backgroundRepeat;
    }
    catch (e) {
        throw this.newError('getMessage' in e ? e.getMessage() : e.message);
    }
    var clientHeight = this.boxHeight;
    var clientWidth = boxWidth; // save it as it gets trampled on later
    if (curvyBrowser.isOp) {
        backgroundPosX = styleToNPx(backgroundPosX);
        backgroundPosY = styleToNPx(backgroundPosY);
        if (backgroundPosX) {
            var t = clientWidth + this.borderWidthL + this.borderWidthR;
            if (backgroundPosX > t) backgroundPosX = t;
            backgroundPosX = (t / backgroundPosX * 100) + '%'; // convert to percentage
        }
        if (backgroundPosY) {
            var t = clientHeight + this.borderWidth + this.borderWidthB;
            if (backgroundPosY > t) backgroundPosY = t;
            backgroundPosY = (t / backgroundPosY * 100) + '%'; // convert to percentage
        }
    }
    if (curvyBrowser.quirksMode) {
    }
    else {
        this.boxWidth -= this.leftPadding + this.rightPadding;
        this.boxHeight -= this.topPadding + this.bottomPadding;
    }

    // Create content container
    this.contentContainer = document.createElement("div");
    if (filter) this.contentContainer.style.filter = filter; // IE8 bug fix
    while (this.box.firstChild) this.contentContainer.appendChild(this.box.removeChild(this.box.firstChild));

    if (boxPosition != "absolute") this.box.style.position = "relative";
    this.box.style.padding = '0';
    this.box.style.border = this.box.style.backgroundImage = 'none';
    this.box.style.backgroundColor = 'transparent';

    this.box.style.width = (clientWidth + this.borderWidthL + this.borderWidthR) + 'px';
    this.box.style.height = (clientHeight + this.borderWidth + this.borderWidthB) + 'px';

    // Ok we add an inner div to actually put things into this will allow us to keep the height

    var newMainContainer = document.createElement("div");
    newMainContainer.style.position = "absolute";
    if (filter) newMainContainer.style.filter = filter; // IE8 bug fix
    if (curvyBrowser.quirksMode) {
        newMainContainer.style.width = (clientWidth + this.borderWidthL + this.borderWidthR) + 'px';
    } else {
        newMainContainer.style.width = clientWidth + 'px';
    }
    newMainContainer.style.height = min0Px(clientHeight + this.borderWidth + this.borderWidthB - topMaxRadius - botMaxRadius);
    newMainContainer.style.padding = "0";
    newMainContainer.style.top = topMaxRadius + "px";
    newMainContainer.style.left = "0";
    if (this.borderWidthL)
        newMainContainer.style.borderLeft = this.borderWidthL + "px solid " + this.borderColourL;
    if (this.borderWidth && !topMaxRadius)
        newMainContainer.style.borderTop = this.borderWidth + "px solid " + this.borderColour;
    if (this.borderWidthR)
        newMainContainer.style.borderRight = this.borderWidthR + "px solid " + this.borderColourL;
    if (this.borderWidthB && !botMaxRadius)
        newMainContainer.style.borderBottom = this.borderWidthB + "px solid " + this.borderColourB;
    newMainContainer.style.backgroundColor = boxColour;
    newMainContainer.style.backgroundImage = this.backgroundImage;
    newMainContainer.style.backgroundRepeat = this.backgroundRepeat;
    this.shell = this.box.appendChild(newMainContainer);

    boxWidth = curvyBrowser.get_style(this.shell, "width");
    if (boxWidth === "" || boxWidth === "auto" || boxWidth.indexOf("%") !== -1) throw this.newError('Shell width is ' + boxWidth);
    this.boxWidth = (boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1) ? parseInt(boxWidth) : this.shell.clientWidth;

    /*
    This method creates the corners and
    applies them to the div element.
    */
    this.applyCorners = function() {
        /*
        Set up background offsets. This may need to be delayed until
        the background image is loaded.
        */
        if (this.backgroundObject) {
            var bgOffset = function(style, imglen, boxlen) {
                if (style === 0) return 0;
                var retval;
                if (style === 'right' || style === 'bottom') return boxlen - imglen;
                if (style === 'center') return (boxlen - imglen) / 2;
                if (style.indexOf('%') > 0) return (boxlen - imglen) * 100 / parseInt(style);
                return styleToNPx(style);
            }
            this.backgroundPosX = bgOffset(backgroundPosX, this.backgroundObject.width, clientWidth);
            this.backgroundPosY = bgOffset(backgroundPosY, this.backgroundObject.height, clientHeight);
        }
        else if (this.backgroundImage) {
            this.backgroundPosX = styleToNPx(backgroundPosX);
            this.backgroundPosY = styleToNPx(backgroundPosY);
        }
        /*
        Create top and bottom containers.
        These will be used as a parent for the corners and bars.
        */
        // Build top bar only if a top corner is to be drawn
        if (topMaxRadius) {
            newMainContainer = document.createElement("div");
            newMainContainer.style.width = this.boxWidth + "px";
            newMainContainer.style.fontSize = "1px";
            newMainContainer.style.overflow = "hidden";
            newMainContainer.style.position = "absolute";
            newMainContainer.style.paddingLeft = this.borderWidth + "px";
            newMainContainer.style.paddingRight = this.borderWidth + "px";
            newMainContainer.style.height = topMaxRadius + "px";
            newMainContainer.style.top = -topMaxRadius + "px";
            newMainContainer.style.left = -this.borderWidthL + "px";
            this.topContainer = this.shell.appendChild(newMainContainer);
        }
        // Build bottom bar only if a bottom corner is to be drawn
        if (botMaxRadius) {
            var newMainContainer = document.createElement("div");
            newMainContainer.style.width = this.boxWidth + "px";
            newMainContainer.style.fontSize = "1px";
            newMainContainer.style.overflow = "hidden";
            newMainContainer.style.position = "absolute";
            newMainContainer.style.paddingLeft = this.borderWidthB + "px";
            newMainContainer.style.paddingRight = this.borderWidthB + "px";
            newMainContainer.style.height = botMaxRadius + "px";
            newMainContainer.style.bottom = -botMaxRadius + "px";
            newMainContainer.style.left = -this.borderWidthL + "px";
            this.bottomContainer = this.shell.appendChild(newMainContainer);
        }

        var corners = this.spec.cornerNames();  // array of available corners

        /*
        Loop for each corner
        */
        for (var i in corners) if (!isNaN(i)) {
            // Get current corner type from array
            var cc = corners[i];
            var specRadius = this.spec[cc + 'R'];
            // Has the user requested the currentCorner be round?
            // Code to apply correct color to top or bottom
            var bwidth, bcolor, borderRadius, borderWidthTB;
            if (cc == "tr" || cc == "tl") {
                bwidth = this.borderWidth;
                bcolor = this.borderColour;
                borderWidthTB = this.borderWidth;
            } else {
                bwidth = this.borderWidthB;
                bcolor = this.borderColourB;
                borderWidthTB = this.borderWidthB;
            }
            borderRadius = specRadius - borderWidthTB;
            var newCorner = document.createElement("div");
            newCorner.style.height = this.spec.get(cc + 'Ru');
            newCorner.style.width = this.spec.get(cc + 'Ru');
            newCorner.style.position = "absolute";
            newCorner.style.fontSize = "1px";
            newCorner.style.overflow = "hidden";
            // THE FOLLOWING BLOCK OF CODE CREATES A ROUNDED CORNER
            // ---------------------------------------------------- TOP
            var intx, inty, outsideColour;
            var trans = filter ? parseInt(/alpha\(opacity.(\d+)\)/.exec(filter)[1]) : 100; // IE8 bug fix
            // Cycle the x-axis
            for (intx = 0; intx < specRadius; ++intx) {
                // Calculate the value of y1 which identifies the pixels inside the border
                var y1 = (intx + 1 >= borderRadius) ? -1 : Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow(intx + 1, 2))) - 1;
                // Calculate y2 and y3 only if there is a border defined
                if (borderRadius != specRadius) {
                    var y2 = (intx >= borderRadius) ? -1 : Math.ceil(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow(intx, 2)));
                    var y3 = (intx + 1 >= specRadius) ? -1 : Math.floor(Math.sqrt(Math.pow(specRadius, 2) - Math.pow((intx + 1), 2))) - 1;
                }
                // Calculate y4
                var y4 = (intx >= specRadius) ? -1 : Math.ceil(Math.sqrt(Math.pow(specRadius, 2) - Math.pow(intx, 2)));
                // Draw bar on inside of the border with foreground colour
                if (y1 > -1) this.drawPixel(intx, 0, this.boxColour, trans, (y1 + 1), newCorner, true, specRadius);
                // Draw border/foreground antialiased pixels and border only if there is a border defined
                if (borderRadius != specRadius) {
                    // Cycle the y-axis
                    if (this.spec.antiAlias) {
                        for (inty = y1 + 1; inty < y2; ++inty) {
                            // For each of the pixels that need anti aliasing between the foreground and border colour draw single pixel divs
                            if (this.backgroundImage != "") {
                                var borderFract = curvyObject.pixelFraction(intx, inty, borderRadius) * 100;
                                this.drawPixel(intx, inty, bcolor, trans, 1, newCorner, borderFract >= 30, specRadius);
                            }
                            else if (this.boxColour !== 'transparent') {
                                var pixelcolour = curvyObject.BlendColour(this.boxColour, bcolor, curvyObject.pixelFraction(intx, inty, borderRadius));
                                this.drawPixel(intx, inty, pixelcolour, trans, 1, newCorner, false, specRadius);
                            }
                            else this.drawPixel(intx, inty, bcolor, trans >> 1, 1, newCorner, false, specRadius);
                        }
                        // Draw bar for the border
                        if (y3 >= y2) {
                            if (y2 == -1) y2 = 0;
                            this.drawPixel(intx, y2, bcolor, trans, (y3 - y2 + 1), newCorner, false, 0);
                        }
                        outsideColour = bcolor;  // Set the colour for the outside AA curve
                        inty = y3;               // start_pos - 1 for y-axis AA pixels
                    }
                    else { // no antiAlias
                        if (y3 > y1) { // NB condition was >=, changed to avoid zero-height divs
                            this.drawPixel(intx, (y1 + 1), bcolor, trans, (y3 - y1), newCorner, false, 0);
                        }
                    }
                }
                else {
                    outsideColour = this.boxColour;  // Set the colour for the outside curve
                    inty = y1;               // start_pos - 1 for y-axis AA pixels
                }
                // Draw aa pixels?
                if (this.spec.antiAlias) {
                    // Cycle the y-axis and draw the anti aliased pixels on the outside of the curve
                    while (++inty < y4) {
                        // For each of the pixels that need anti aliasing between the foreground/border colour & background draw single pixel divs
                        this.drawPixel(intx, inty, outsideColour, (curvyObject.pixelFraction(intx, inty, specRadius) * trans), 1, newCorner, borderWidthTB <= 0, specRadius);
                    }
                }
            }
            // END OF CORNER CREATION
            // ---------------------------------------------------- END

            /*
            Now we have a new corner we need to reposition all the pixels unless
            the current corner is the bottom right.
            */
            // Loop through all children (pixel bars)
            for (var t = 0, k = newCorner.childNodes.length; t < k; ++t) {
                // Get current pixel bar
                var pixelBar = newCorner.childNodes[t];
                // Get current top and left properties
                var pixelBarTop = parseInt(pixelBar.style.top);
                var pixelBarLeft = parseInt(pixelBar.style.left);
                var pixelBarHeight = parseInt(pixelBar.style.height);
                // Reposition pixels
                if (cc == "tl" || cc == "bl") {
                    pixelBar.style.left = (specRadius - pixelBarLeft - 1) + "px"; // Left
                }
                if (cc == "tr" || cc == "tl") {
                    pixelBar.style.top = (specRadius - pixelBarHeight - pixelBarTop) + "px"; // Top
                }
                pixelBar.style.backgroundRepeat = this.backgroundRepeat;

                if (this.backgroundImage) switch (cc) {
                    case "tr":
                        pixelBar.style.backgroundPosition = (this.backgroundPosX - this.borderWidthL + specRadius - clientWidth - pixelBarLeft) + "px " + (this.backgroundPosY + pixelBarHeight + pixelBarTop + this.borderWidth - specRadius) + "px";
                        break;
                    case "tl":
                        pixelBar.style.backgroundPosition = (this.backgroundPosX - specRadius + pixelBarLeft + this.borderWidthL) + "px " + (this.backgroundPosY - specRadius + pixelBarHeight + pixelBarTop + this.borderWidth) + "px";
                        break;
                    case "bl":
                        pixelBar.style.backgroundPosition = (this.backgroundPosX - specRadius + pixelBarLeft + 1 + this.borderWidthL) + "px " + (this.backgroundPosY - clientHeight - this.borderWidth + (curvyBrowser.quirksMode ? pixelBarTop : -pixelBarTop) + specRadius) + "px";
                        break;
                    case "br":
                        if (curvyBrowser.quirksMode) {
                            pixelBar.style.backgroundPosition = (this.backgroundPosX + this.borderWidthL - clientWidth + specRadius - pixelBarLeft) + "px " + (this.backgroundPosY - clientHeight - this.borderWidth + pixelBarTop + specRadius) + "px";
                        } else {
                            pixelBar.style.backgroundPosition = (this.backgroundPosX - this.borderWidthL - clientWidth + specRadius - pixelBarLeft) + "px " + (this.backgroundPosY - clientHeight - this.borderWidth + specRadius - pixelBarTop) + "px";
                        }
                        //break;
                }
            }

            // Position the container
            switch (cc) {
                case "tl":
                    newCorner.style.top = newCorner.style.left = "0";
                    this.topContainer.appendChild(newCorner);
                    break;
                case "tr":
                    newCorner.style.top = newCorner.style.right = "0";
                    this.topContainer.appendChild(newCorner);
                    break;
                case "bl":
                    newCorner.style.bottom = newCorner.style.left = "0";
                    this.bottomContainer.appendChild(newCorner);
                    break;
                case "br":
                    newCorner.style.bottom = newCorner.style.right = "0";
                    this.bottomContainer.appendChild(newCorner);
                    //break;
            }
        }

        /*
        The last thing to do is draw the rest of the filler DIVs.
        */

        // Find out which corner has the bigger radius and get the difference amount
        var radiusDiff = {
            t: this.spec.radiusdiff('t'),
            b: this.spec.radiusdiff('b')
        };

        for (z in radiusDiff) {
            if (typeof z === 'function') continue; // for prototype, mootools frameworks
            if (!this.spec.get(z + 'R')) continue; // no need if no corners
            if (radiusDiff[z]) {
                // check unsupported feature and warn if necessary
                if (this.backgroundImage && this.spec.radiusSum(z) !== radiusDiff[z])
                    curvyCorners.alert(this.errmsg('Not supported: unequal non-zero top/bottom radii with background image'));
                // Get the type of corner that is the smaller one
                var smallerCornerType = (this.spec[z + "lR"] < this.spec[z + "rR"]) ? z + "l" : z + "r";

                // First we need to create a DIV for the space under the smaller corner
                var newFiller = document.createElement("div");
                newFiller.style.height = radiusDiff[z] + "px";
                newFiller.style.width = this.spec.get(smallerCornerType + 'Ru');
                newFiller.style.position = "absolute";
                newFiller.style.fontSize = "1px";
                newFiller.style.overflow = "hidden";
                newFiller.style.backgroundColor = this.boxColour;

                // Position filler
                switch (smallerCornerType) {
                    case "tl":
                        newFiller.style.bottom =
            newFiller.style.left = "0";
                        newFiller.style.borderLeft = this.borderString;
                        this.topContainer.appendChild(newFiller);
                        break;
                    case "tr":
                        newFiller.style.bottom =
            newFiller.style.right = "0";
                        newFiller.style.borderRight = this.borderString;
                        this.topContainer.appendChild(newFiller);
                        break;
                    case "bl":
                        newFiller.style.top =
            newFiller.style.left = "0";
                        newFiller.style.borderLeft = this.borderStringB;
                        this.bottomContainer.appendChild(newFiller);
                        break;
                    case "br":
                        newFiller.style.top =
            newFiller.style.right = "0";
                        newFiller.style.borderRight = this.borderStringB;
                        this.bottomContainer.appendChild(newFiller);
                        //break;
                }
            }

            // Create the bar to fill the gap between each corner horizontally
            var newFillerBar = document.createElement("div");
            if (filter) newFillerBar.style.filter = filter; // IE8 bug fix
            newFillerBar.style.position = "relative";
            newFillerBar.style.fontSize = "1px";
            newFillerBar.style.overflow = "hidden";
            newFillerBar.style.width = this.fillerWidth(z);
            newFillerBar.style.backgroundColor = this.boxColour;
            newFillerBar.style.backgroundImage = this.backgroundImage;
            newFillerBar.style.backgroundRepeat = this.backgroundRepeat;

            switch (z) {
                case "t":
                    // Top Bar
                    if (this.topContainer) {
                        if (curvyBrowser.quirksMode) {
                            newFillerBar.style.height = 100 + topMaxRadius + "px";
                        } else {
                            newFillerBar.style.height = 100 + topMaxRadius - this.borderWidth + "px";
                        }
                        newFillerBar.style.marginLeft = this.spec.tlR ? (this.spec.tlR - this.borderWidthL) + "px" : "0";
                        newFillerBar.style.borderTop = this.borderString;
                        if (this.backgroundImage) {
                            var x_offset = this.spec.tlR ?
                (this.backgroundPosX - (topMaxRadius - this.borderWidthL)) + "px " : "0 ";
                            newFillerBar.style.backgroundPosition = x_offset + this.backgroundPosY + "px";
                            // Reposition the box's background image
                            this.shell.style.backgroundPosition = this.backgroundPosX + "px " + (this.backgroundPosY - topMaxRadius + this.borderWidthL) + "px";
                        }
                        this.topContainer.appendChild(newFillerBar);
                    }
                    break;
                case "b":
                    if (this.bottomContainer) {
                        // Bottom Bar
                        if (curvyBrowser.quirksMode) {
                            newFillerBar.style.height = botMaxRadius + "px";
                        } else {
                            newFillerBar.style.height = botMaxRadius - this.borderWidthB + "px";
                        }
                        newFillerBar.style.marginLeft = this.spec.blR ? (this.spec.blR - this.borderWidthL) + "px" : "0";
                        newFillerBar.style.borderBottom = this.borderStringB;
                        if (this.backgroundImage) {
                            var x_offset = this.spec.blR ?
                (this.backgroundPosX + this.borderWidthL - botMaxRadius) + "px " : this.backgroundPosX + "px ";
                            newFillerBar.style.backgroundPosition = x_offset + (this.backgroundPosY - clientHeight - this.borderWidth + botMaxRadius) + "px";
                        }
                        this.bottomContainer.appendChild(newFillerBar);
                    }
                    //break;
            }
        }

        // style content container
        this.contentContainer.style.position = "absolute";
        // contentContainer.style.border = "1px dotted #000"; // DEBUG, comment for production
        this.contentContainer.className = "autoPadDiv";
        this.contentContainer.style.left = this.borderWidthL + "px";
        // Get padding amounts
        // Apply top padding
        this.contentContainer.style.paddingTop = this.topPadding + "px";
        this.contentContainer.style.top = this.borderWidth + "px";
        // skip bottom padding - it doesn't show!
        // Apply left and right padding
        this.contentContainer.style.paddingLeft = this.leftPadding + "px";
        this.contentContainer.style.paddingRight = this.rightPadding + "px";
        z = clientWidth;
        if (!curvyBrowser.quirksMode) z -= this.leftPadding + this.rightPadding;
        this.contentContainer.style.width = z + "px";
        this.contentContainer.style.textAlign = curvyBrowser.get_style(this.box, 'textAlign');
        this.box.style.textAlign = 'left'; // important otherwise layout goes wild

        this.box.appendChild(this.contentContainer);
        if (boxDisp) boxDisp.style.display = 'none';
    }
    if (this.backgroundImage) {
        backgroundPosX = this.backgroundCheck(backgroundPosX);
        backgroundPosY = this.backgroundCheck(backgroundPosY);
        if (this.backgroundObject) {
            this.backgroundObject.holdingElement = this;
            this.dispatch = this.applyCorners;
            this.applyCorners = function() {
                if (this.backgroundObject.complete)
                    this.dispatch();
                else this.backgroundObject.onload = new Function('curvyObject.dispatch(this.holdingElement);');
            }
        }
    }
}

curvyObject.prototype.backgroundCheck = function(style) {
    if (style === 'top' || style === 'left' || parseInt(style) === 0) return 0;
    if (!(/^[-\d.]+px$/.test(style)) && !this.backgroundObject) {
        this.backgroundObject = new Image;
        var imgName = function(str) {
            var matches = /url\("?([^'"]+)"?\)/.exec(str);
            return (matches ? matches[1] : str);
        }
        this.backgroundObject.src = imgName(this.backgroundImage);
    }
    return style;
}

curvyObject.dispatch = function(obj) {
    if ('dispatch' in obj)
        obj.dispatch();
    else throw obj.newError('No dispatch function');
}

// append a pixel DIV to newCorner

curvyObject.prototype.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) {
    var pixel = document.createElement("div");
    pixel.style.height = height + "px";
    pixel.style.width = "1px";
    pixel.style.position = "absolute";
    pixel.style.fontSize = "1px";
    pixel.style.overflow = "hidden";
    var topMaxRadius = this.spec.get('tR');
    pixel.style.backgroundColor = colour;
    // Don't apply background image to border pixels
    if (image && this.backgroundImage != "") {
        pixel.style.backgroundImage = this.backgroundImage;
        pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) - this.borderWidth) + "px";
    }
    // Set opacity if the transparency is anything other than 100
    if (transAmount != 100) curvyObject.setOpacity(pixel, transAmount);
    // Set position
    pixel.style.top = inty + "px";
    pixel.style.left = intx + "px";
    //pixel.nodeValue = ' ';
    newCorner.appendChild(pixel);
}

curvyObject.prototype.fillerWidth = function(tb) {
    var bWidth = curvyBrowser.quirksMode ? 0 : this.spec.radiusCount(tb) * this.borderWidthL;
    return (this.boxWidth - this.spec.radiusSum(tb) + bWidth) + 'px';
}

curvyObject.prototype.errmsg = function(msg, gravity) {
    var extradata = "\ntag: " + this.box.tagName;
    if (this.box.id) extradata += "\nid: " + this.box.id;
    if (this.box.className) extradata += "\nclass: " + this.box.className;
    var parent;
    if ((parent = this.box.parentNode) === null)
        extradata += "\n(box has no parent)";
    else {
        extradata += "\nParent tag: " + parent.tagName;
        if (parent.id) extradata += "\nParent ID: " + parent.id;
        if (parent.className) extradata += "\nParent class: " + parent.className;
    }
    if (gravity === undefined) gravity = 'warning';
    return 'curvyObject ' + gravity + ":\n" + msg + extradata;
}

curvyObject.prototype.newError = function(msg) {
    return new Error(this.errmsg(msg, 'exception'));
}

// ------------- UTILITY FUNCTIONS

//  Convert a number 0..255 to hex


curvyObject.IntToHex = function(strNum) {
    var hexdig = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];

    return hexdig[strNum >>> 4] + '' + hexdig[strNum & 15];
}

/*
Blends the two colours by the fraction
returns the resulting colour as a string in the format "#FFFFFF"
*/

curvyObject.BlendColour = function(Col1, Col2, Col1Fraction) {
    if (Col1 === 'transparent' || Col2 === 'transparent') throw this.newError('Cannot blend with transparent');
    if (Col1.charAt(0) !== '#') {
        //curvyCorners.alert('Found colour1 ' + Col1 + ': please let us know you saw this report.');
        Col1 = curvyObject.format_colour(Col1);
    }
    if (Col2.charAt(0) !== '#') {
        //curvyCorners.alert('Found colour2 ' + Col2 + ': please let us know you saw this report.');
        Col2 = curvyObject.format_colour(Col2);
    }
    var red1 = parseInt(Col1.substr(1, 2), 16);
    var green1 = parseInt(Col1.substr(3, 2), 16);
    var blue1 = parseInt(Col1.substr(5, 2), 16);
    var red2 = parseInt(Col2.substr(1, 2), 16);
    var green2 = parseInt(Col2.substr(3, 2), 16);
    var blue2 = parseInt(Col2.substr(5, 2), 16);

    if (Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1;

    var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction)));
    if (endRed > 255) endRed = 255;
    if (endRed < 0) endRed = 0;

    var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction)));
    if (endGreen > 255) endGreen = 255;
    if (endGreen < 0) endGreen = 0;

    var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction)));
    if (endBlue > 255) endBlue = 255;
    if (endBlue < 0) endBlue = 0;

    return "#" + curvyObject.IntToHex(endRed) + curvyObject.IntToHex(endGreen) + curvyObject.IntToHex(endBlue);
}

/*
For a pixel cut by the line determines the fraction of the pixel on the 'inside' of the
line.  Returns a number between 0 and 1
*/

curvyObject.pixelFraction = function(x, y, r) {
    var fraction;
    var rsquared = r * r;

    /*
    determine the co-ordinates of the two points on the perimeter of the pixel that the
    circle crosses
    */
    var xvalues = new Array(2);
    var yvalues = new Array(2);
    var point = 0;
    var whatsides = "";

    // x + 0 = Left
    var intersect = Math.sqrt(rsquared - Math.pow(x, 2));

    if (intersect >= y && intersect < (y + 1)) {
        whatsides = "Left";
        xvalues[point] = 0;
        yvalues[point] = intersect - y;
        ++point;
    }
    // y + 1 = Top
    intersect = Math.sqrt(rsquared - Math.pow(y + 1, 2));

    if (intersect >= x && intersect < (x + 1)) {
        whatsides += "Top";
        xvalues[point] = intersect - x;
        yvalues[point] = 1;
        ++point;
    }
    // x + 1 = Right
    intersect = Math.sqrt(rsquared - Math.pow(x + 1, 2));

    if (intersect >= y && intersect < (y + 1)) {
        whatsides += "Right";
        xvalues[point] = 1;
        yvalues[point] = intersect - y;
        ++point;
    }
    // y + 0 = Bottom
    intersect = Math.sqrt(rsquared - Math.pow(y, 2));

    if (intersect >= x && intersect < (x + 1)) {
        whatsides += "Bottom";
        xvalues[point] = intersect - x;
        yvalues[point] = 0;
    }

    /*
    depending on which sides of the perimeter of the pixel the circle crosses calculate the
    fraction of the pixel inside the circle
    */
    switch (whatsides) {
        case "LeftRight":
            fraction = Math.min(yvalues[0], yvalues[1]) + ((Math.max(yvalues[0], yvalues[1]) - Math.min(yvalues[0], yvalues[1])) / 2);
            break;

        case "TopRight":
            fraction = 1 - (((1 - xvalues[0]) * (1 - yvalues[1])) / 2);
            break;

        case "TopBottom":
            fraction = Math.min(xvalues[0], xvalues[1]) + ((Math.max(xvalues[0], xvalues[1]) - Math.min(xvalues[0], xvalues[1])) / 2);
            break;

        case "LeftBottom":
            fraction = yvalues[0] * xvalues[1] / 2;
            break;

        default:
            fraction = 1;
    }

    return fraction;
}

// Returns an array of rgb values

curvyObject.rgb2Array = function(rgbColour) {
    // Remove rgb()
    var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")"));

    // Split RGB into array
    return rgbValues.split(", ");
}

// This function converts CSS rgb(x, x, x) to hexadecimal

curvyObject.rgb2Hex = function(rgbColour) {
    try {
        // Get array of RGB values
        var rgbArray = curvyObject.rgb2Array(rgbColour);

        // Get RGB values
        var red = parseInt(rgbArray[0]);
        var green = parseInt(rgbArray[1]);
        var blue = parseInt(rgbArray[2]);

        // Build hex colour code
        var hexColour = "#" + curvyObject.IntToHex(red) + curvyObject.IntToHex(green) + curvyObject.IntToHex(blue);
    }
    catch (e) {
        var msg = 'getMessage' in e ? e.getMessage() : e.message;
        throw new Error("Error (" + msg + ") converting RGB value to Hex in rgb2Hex");
    }

    return hexColour;
}

/*
Function by Simon Willison from sitepoint.com
Modified by Cameron Cooke adding Safari's rgba support
*/

curvyObject.setOpacity = function(obj, opacity) {
    opacity = (opacity == 100) ? 99.999 : opacity;

    if (curvyBrowser.isSafari && obj.tagName != "IFRAME") {
        // Get array of RGB values
        var rgbArray = curvyObject.rgb2Array(obj.style.backgroundColor);

        // Get RGB values
        var red = parseInt(rgbArray[0]);
        var green = parseInt(rgbArray[1]);
        var blue = parseInt(rgbArray[2]);

        // Safari using RGBA support
        obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity / 100 + ")";
    }
    else if (typeof obj.style.opacity !== "undefined") { // W3C
        obj.style.opacity = opacity / 100;
    }
    else if (typeof obj.style.MozOpacity !== "undefined") { // Older Mozilla
        obj.style.MozOpacity = opacity / 100;
    }
    else if (typeof obj.style.filter != "undefined") { // IE
        obj.style.filter = "alpha(opacity=" + opacity + ")";
    }
    else if (typeof obj.style.KHTMLOpacity != "undefined") { // Older KHTML Based curvyBrowsers
        obj.style.KHTMLOpacity = opacity / 100;
    }
}


// Cross browser add event wrapper

function addEvent(elm, evType, fn, useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
    }
    if (elm.attachEvent) return elm.attachEvent('on' + evType, fn);
    elm['on' + evType] = fn;
    return false;
}

// Gets the computed colour.
curvyObject.getComputedColour = function(colour) {
    var d = document.createElement('DIV');
    d.style.backgroundColor = colour;
    document.body.appendChild(d);

    if (window.getComputedStyle) { // Mozilla, Opera, Chrome, Safari
        var rtn = document.defaultView.getComputedStyle(d, null).getPropertyValue('background-color');
        d.parentNode.removeChild(d);
        if (rtn.substr(0, 3) === "rgb") rtn = curvyObject.rgb2Hex(rtn);
        return rtn;
    }
    else { // IE
        var rng = document.body.createTextRange();
        rng.moveToElementText(d);
        rng.execCommand('ForeColor', false, colour);
        var iClr = rng.queryCommandValue('ForeColor');
        var rgb = "rgb(" + (iClr & 0xFF) + ", " + ((iClr & 0xFF00) >> 8) + ", " + ((iClr & 0xFF0000) >> 16) + ")";
        d.parentNode.removeChild(d);
        rng = null;
        return curvyObject.rgb2Hex(rgb);
    }
}

// convert colour name, rgb() and #RGB to #RRGGBB
curvyObject.format_colour = function(colour) {
    // Make sure colour is set and not transparent
    if (colour != "" && colour != "transparent") {
        // RGB Value?
        if (colour.substr(0, 3) === "rgb") {
            // Get HEX aquiv.
            colour = curvyObject.rgb2Hex(colour);
        }
        else if (colour.charAt(0) !== '#') {
            // Convert colour name to hex value
            colour = curvyObject.getComputedColour(colour);
        }
        else if (colour.length === 4) {
            // 3 chr colour code add remainder
            colour = "#" + colour.charAt(1) + colour.charAt(1) + colour.charAt(2) + colour.charAt(2) + colour.charAt(3) + colour.charAt(3);
        }
    }
    return colour;
}

// Get elements by class by Dustin Diaz / CPKS
// NB if searchClass is a class name, it MUST be preceded by '.'

curvyCorners.getElementsByClass = function(searchClass, node) {
    var classElements = new Array;
    if (node === undefined) node = document;
    searchClass = searchClass.split('.'); // see if there's a tag in there
    var tag = '*'; // prepare for no tag
    if (searchClass.length === 1) {
        tag = searchClass[0];
        searchClass = false;
    }
    else {
        if (searchClass[0]) tag = searchClass[0];
        searchClass = searchClass[1];
    }
    var i, els, elsLen;
    if (tag.charAt(0) === '#') {
        els = document.getElementById(tag.substr(1));
        if (els) classElements.push(els);
    }
    else {
        els = node.getElementsByTagName(tag);
        elsLen = els.length;
        if (searchClass) {
            var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
            for (i = 0; i < elsLen; ++i) {
                if (pattern.test(els[i].className)) classElements.push(els[i]);
            }
        }
        else for (i = 0; i < elsLen; ++i) classElements.push(els[i]);
    }
    return classElements;
}

if (curvyBrowser.isMoz || curvyBrowser.isWebKit)
    var curvyCornersNoAutoScan = true; // it won't do anything anyway.
else {

    // autoscan code

    curvyCorners.scanStyles = function() {
        function units(num) {
            var matches = /^[\d.]+(\w+)$/.exec(num);
            return matches[1];
        }
        var t, i, j;

        if (curvyBrowser.isIE) {
            function procIEStyles(rule) {
                var style = rule.style;

                if (curvyBrowser.ieVer > 6.0) {
                    var allR = style['-webkit-border-radius'] || 0;
                    var tR = style['-webkit-border-top-right-radius'] || 0;
                    var tL = style['-webkit-border-top-left-radius'] || 0;
                    var bR = style['-webkit-border-bottom-right-radius'] || 0;
                    var bL = style['-webkit-border-bottom-left-radius'] || 0;
                }
                else {
                    var allR = style['webkit-border-radius'] || 0;
                    var tR = style['webkit-border-top-right-radius'] || 0;
                    var tL = style['webkit-border-top-left-radius'] || 0;
                    var bR = style['webkit-border-bottom-right-radius'] || 0;
                    var bL = style['webkit-border-bottom-left-radius'] || 0;
                }
                if (allR || tL || tR || bR || bL) {
                    var settings = new curvyCnrSpec(rule.selectorText);
                    if (allR)
                        settings.setcorner(null, null, parseInt(allR), units(allR));
                    else {
                        if (tR) settings.setcorner('t', 'r', parseInt(tR), units(tR));
                        if (tL) settings.setcorner('t', 'l', parseInt(tL), units(tL));
                        if (bL) settings.setcorner('b', 'l', parseInt(bL), units(bL));
                        if (bR) settings.setcorner('b', 'r', parseInt(bR), units(bR));
                    }
                    curvyCorners(settings);
                }
            }
            for (t = 0; t < document.styleSheets.length; ++t) {
                if (document.styleSheets[t].imports) {
                    for (i = 0; i < document.styleSheets[t].imports.length; ++i)
                        for (j = 0; j < document.styleSheets[t].imports[i].rules.length; ++j)
                        procIEStyles(document.styleSheets[t].imports[i].rules[j]);
                }
                for (i = 0; i < document.styleSheets[t].rules.length; ++i)
                    procIEStyles(document.styleSheets[t].rules[i]);
            }
        }
        else if (curvyBrowser.isOp) {
            for (t = 0; t < document.styleSheets.length; ++t) {
                if (operasheet.contains_border_radius(t)) {
                    j = new operasheet(t);
                    for (i in j.rules) if (!isNaN(i))
                        curvyCorners(j.rules[i]);
                }
            }
        }
        else curvyCorners.alert('Scanstyles does nothing in Webkit/Firefox');
    };

    // Dean Edwards/Matthias Miller/John Resig

    curvyCorners.init = function() {
        // quit if this function has already been called
        if (arguments.callee.done) return;

        // flag this function so we don't do the same thing twice
        arguments.callee.done = true;

        // kill the timer
        if (curvyBrowser.isWebKit && curvyCorners.init.timer) {
            clearInterval(curvyCorners.init.timer);
            curvyCorners.init.timer = null;
        }

        // do stuff
        curvyCorners.scanStyles();
    };
}

if (typeof curvyCornersNoAutoScan === 'undefined' || curvyCornersNoAutoScan === false) {
    if (curvyBrowser.isOp)
        document.addEventListener("DOMContentLoaded", curvyCorners.init, false);
    else addEvent(window, 'load', curvyCorners.init, false);
}

/*
VERSION: Drop Shadow jQuery Plugin 1.6  12-13-2007

REQUIRES: jquery.js (verified for 1.3.2)

SYNTAX: $(selector).dropShadow(options);  // Creates new drop shadows
$(selector).redrawShadow();       // Redraws shadows on elements
$(selector).removeShadow();       // Removes shadows from elements
$(selector).shadowId();           // Returns an existing shadow's ID

OPTIONS:

left    : integer (default = 4)
top     : integer (default = 4)
blur    : integer (default = 2)
opacity : decimal (default = 0.5)
color   : string (default = "black")
swap    : boolean (default = false)

The left and top parameters specify the distance and direction, in  pixels, to
offset the shadow. Zero values position the shadow directly behind the element.
Positive values shift the shadow to the right and down, while negative values 
shift the shadow to the left and up.
  
The blur parameter specifies the spread, or dispersion, of the shadow. Zero 
produces a sharp shadow, one or two produces a normal shadow, and three or four
produces a softer shadow. Higher values increase the processing load.
  
The opacity parameter should be a decimal value, usually less than one. You can
use a value higher than one in special situations, e.g. with extreme blurring. 
  
Color is specified in the usual manner, with a color name or hex value. The
color parameter does not apply with transparent images.
  
The swap parameter reverses the stacking order of the original and the shadow.
This can be used for special effects, like an embossed or engraved look.

EXPLANATION:
  
This jQuery plug-in adds soft drop shadows behind page elements. It is only
intended for adding a few drop shadows to mostly stationary objects, like a
page heading, a photo, or content containers.

The shadows it creates are not bound to the original elements, so they won't
move or change size automatically if the original elements change. A window
resize event listener is assigned, which should re-align the shadows in many
cases, but if the elements otherwise move or resize you will have to handle
those events manually. Shadows can be redrawn with the redrawShadow() method
or removed with the removeShadow() method. The redrawShadow() method uses the
same options used to create the original shadow. If you want to change the
options, you should remove the shadow first and then create a new shadow.
  
The dropShadow method returns a jQuery collection of the new shadow(s). If
further manipulation is required, you can store it in a variable like this:

var myShadow = $("#myElement").dropShadow();

You can also read the ID of the shadow from the original element at a later
time. To get a shadow's ID, either read the shadowId attribute of the
original element or call the shadowId() method. For example:

var myShadowId = $("#myElement").attr("shadowId");  or
var myShadowId = $("#myElement").shadowId();

If the original element does not already have an ID assigned, a random ID will
be generated for the shadow. However, if the original does have an ID, the 
shadow's ID will be the original ID and "_dropShadow". For example, if the
element's ID is "myElement", the shadow's ID would be "myElement_dropShadow".

If you have a long piece of text and the user resizes the window so that the
text wraps or unwraps, the shape of the text changes and the words are no
longer in the same positions. In that case, you can either preset the height
and width, so that it becomes a fixed box, or you can shadow each word
separately, like this:

<h1><span>Your</span> <span>Page</span> <span>Title</span></h1>

$("h1 span").dropShadow();

The dropShadow method attempts to determine whether the selected elements have
transparent backgrounds. If you want to shadow the content inside an element,
like text or a transparent image, it must not have a background-color or
background-image style. If the element has a solid background it will create a
rectangular shadow around the outside box.

The shadow elements are positioned absolutely one layer below the original 
element, which is positioned relatively (unless it's already absolute).

*** All shadows have the "dropShadow" class, for selecting with CSS or jQuery.

ISSUES:
  
1)  Limited styling of shadowed elements by ID. Because IDs must be unique,
and the shadows have their own ID, styles applied by ID won't transfer
to the shadows. Instead, style elements by class or use inline styles.
2)  Sometimes shadows don't align properly. Elements may need to be wrapped
in container elements, margins or floats changed, etc. or you may just 
have to tweak the left and top offsets to get them to align. For example,
with draggable objects, you have to wrap them inside two divs. Make the 
outer div draggable and set the inner div's position to relative. Then 
you can create a shadow on the element inside the inner div.
3)  If the user changes font sizes it will throw the shadows off. Browsers 
do not expose an event for font size changes. The only known way to 
detect a user font size change is to embed an invisible text element and
then continuously poll for changes in size.
4)  Safari support is shaky, and may require even more tweaks/wrappers, etc.
    
The bottom line is that this is a gimick effect, not PFM, and if you push it
too hard or expect it to work in every possible situation on every browser,
you will be disappointed. Use it sparingly, and don't use it for anything 
critical. Otherwise, have fun with it!
        
AUTHOR: Larry Stevens.  This work is in the public domain,
and is not supported in any way. Use it at your own risk.
*/


(function($) {

    var dropShadowZindex = 1;  //z-index counter

    $.fn.dropShadow = function(options) {
        // Default options
        var opt = $.extend({
            left: 4,
            top: 4,
            blur: 2,
            opacity: .5,
            color: "black",
            swap: false
        }, options);
        var jShadows = $([]);  //empty jQuery collection

        // Loop through original elements
        this.not(".dropShadow").each(function() {
            var jthis = $(this);
            var shadows = [];
            var blur = (opt.blur <= 0) ? 0 : opt.blur;
            var opacity = (blur == 0) ? opt.opacity : opt.opacity / (blur * 8);
            var zOriginal = (opt.swap) ? dropShadowZindex : dropShadowZindex + 1;
            var zShadow = (opt.swap) ? dropShadowZindex + 1 : dropShadowZindex;

            // Create ID for shadow
            var shadowId;
            if (this.id) {
                shadowId = this.id + "_dropShadow";
            }
            else {
                shadowId = "ds" + (1 + Math.floor(9999 * Math.random()));
            }

            // Modify original element
            $.data(this, "shadowId", shadowId); //store id in expando
            $.data(this, "shadowOptions", options); //store options in expando
            jthis
        .attr("shadowId", shadowId)
        .css("zIndex", zOriginal);
            if (jthis.css("position") != "absolute") {
                jthis.css({
                    position: "relative",
                    zoom: 1 //for IE layout
                });
            }

            // Create first shadow layer
            bgColor = jthis.css("backgroundColor");
            if (bgColor == "rgba(0, 0, 0, 0)") bgColor = "transparent";  //Safari
            if (bgColor != "transparent" || jthis.css("backgroundImage") != "none"
          || this.nodeName == "SELECT"
          || this.nodeName == "INPUT"
          || this.nodeName == "TEXTAREA") {
                shadows[0] = $("<div></div>")
          .css("background", opt.color);
            }
            else {
                shadows[0] = jthis
          .clone()
          .removeAttr("id")
          .removeAttr("name")
          .removeAttr("shadowId")
          .css("color", opt.color);
            }
            shadows[0]
        .addClass("dropShadow")
        .css({
            height: jthis.outerHeight(),
            left: blur,
            opacity: opacity,
            position: "absolute",
            top: blur,
            width: jthis.outerWidth(),
            zIndex: zShadow
        });

            // Create other shadow layers
            var layers = (8 * blur) + 1;
            for (i = 1; i < layers; i++) {
                shadows[i] = shadows[0].clone();
            }

            // Position layers
            var i = 1;
            var j = blur;
            while (j > 0) {
                shadows[i].css({ left: j * 2, top: 0 });           //top
                shadows[i + 1].css({ left: j * 4, top: j * 2 });   //right
                shadows[i + 2].css({ left: j * 2, top: j * 4 });   //bottom
                shadows[i + 3].css({ left: 0, top: j * 2 });       //left
                shadows[i + 4].css({ left: j * 3, top: j });       //top-right
                shadows[i + 5].css({ left: j * 3, top: j * 3 });   //bottom-right
                shadows[i + 6].css({ left: j, top: j * 3 });       //bottom-left
                shadows[i + 7].css({ left: j, top: j });           //top-left
                i += 8;
                j--;
            }

            // Create container
            var divShadow = $("<div></div>")
        .attr("id", shadowId)
        .addClass("dropShadow")
        .css({
            left: jthis.position().left + opt.left - blur,
            marginTop: jthis.css("marginTop"),
            marginRight: jthis.css("marginRight"),
            marginBottom: jthis.css("marginBottom"),
            marginLeft: jthis.css("marginLeft"),
            position: "absolute",
            top: jthis.position().top + opt.top - blur,
            zIndex: zShadow
        });

            // Add layers to container  
            for (i = 0; i < layers; i++) {
                divShadow.append(shadows[i]);
            }

            // Add container to DOM
            jthis.after(divShadow);

            // Add shadow to return set
            jShadows = jShadows.add(divShadow);

            // Re-align shadow on window resize
            $(window).resize(function() {
                try {
                    divShadow.css({
                        left: jthis.position().left + opt.left - blur,
                        top: jthis.position().top + opt.top - blur
                    });
                }
                catch (e) { }
            });

            // Increment z-index counter
            dropShadowZindex += 2;

        });  //end each

        return this.pushStack(jShadows);
    };


    $.fn.redrawShadow = function() {
        // Remove existing shadows
        this.removeShadow();

        // Draw new shadows
        return this.each(function() {
            var shadowOptions = $.data(this, "shadowOptions");
            $(this).dropShadow(shadowOptions);
        });
    };


    $.fn.removeShadow = function() {
        return this.each(function() {
            var shadowId = $(this).shadowId();
            $("div#" + shadowId).remove();
        });
    };


    $.fn.shadowId = function() {
        return $.data(this[0], "shadowId");
    };


    $(function() {
        // Suppress printing of shadows
        var noPrint = "<style type='text/css' media='print'>";
        noPrint += ".dropShadow{visibility:hidden;}</style>";
        $("head").append(noPrint);
    });

})(jQuery);

// ScrollBar

/* Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* 
* See http://kelvinluck.com/assets/jquery/jScrollPane/
* $Id: jScrollPane.js 90 2010-01-25 03:52:10Z kelvin.luck $
*/

/**
* Replace the vertical scroll bars on any matched elements with a fancy
* styleable (via CSS) version. With JS disabled the elements will
* gracefully degrade to the browsers own implementation of overflow:auto.
* If the mousewheel plugin has been included on the page then the scrollable areas will also
* respond to the mouse wheel.
*
* @example jQuery(".scroll-pane").jScrollPane();
*
* @name jScrollPane
* @type jQuery
* @param Object	settings	hash with options, described below.
*								scrollbarWidth	-	The width of the generated scrollbar in pixels
*								scrollbarMargin	-	The amount of space to leave on the side of the scrollbar in pixels
*								wheelSpeed		-	The speed the pane will scroll in response to the mouse wheel in pixels
*								showArrows		-	Whether to display arrows for the user to scroll with
*								arrowSize		-	The height of the arrow buttons if showArrows=true
*								animateTo		-	Whether to animate when calling scrollTo and scrollBy
*								dragMinHeight	-	The minimum height to allow the drag bar to be
*								dragMaxHeight	-	The maximum height to allow the drag bar to be
*								animateInterval	-	The interval in milliseconds to update an animating scrollPane (default 100)
*								animateStep		-	The amount to divide the remaining scroll distance by when animating (default 3)
*								maintainPosition-	Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
*								tabIndex		-	The tabindex for this jScrollPane to control when it is tabbed to when navigating via keyboard (default 0)
*								enableKeyboardNavigation - Whether to allow keyboard scrolling of this jScrollPane when it is focused (default true)
*								animateToInternalLinks - Whether the move to an internal link (e.g. when it's focused by tabbing or by a hash change in the URL) should be animated or instant (default false)
*								scrollbarOnLeft	-	Display the scrollbar on the left side?  (needs stylesheet changes, see examples.html)
*								reinitialiseOnImageLoad - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (default false)
*								topCapHeight	-	The height of the "cap" area between the top of the jScrollPane and the top of the track/ buttons
*								bottomCapHeight	-	The height of the "cap" area between the bottom of the jScrollPane and the bottom of the track/ buttons
*								observeHash		-	Whether jScrollPane should attempt to automagically scroll to the correct place when an anchor inside the scrollpane is linked to (default true)
* @return jQuery
* @cat Plugins/jScrollPane
* @author Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
*/

(function($) {

    $.jScrollPane = {
        active: []
    };
    $.fn.jScrollPane = function(settings) {
        settings = $.extend({}, $.fn.jScrollPane.defaults, settings);

        var rf = function() { return false; };

        return this.each(
		function() {
		    var $this = $(this);
		    var paneEle = this;
		    var currentScrollPosition = 0;
		    var paneWidth;
		    var paneHeight;
		    var trackHeight;
		    var trackOffset = settings.topCapHeight;
		    var $container;

		    if ($(this).parent().is('.jScrollPaneContainer')) {
		        $container = $(this).parent();
		        currentScrollPosition = settings.maintainPosition ? $this.position().top : 0;
		        var $c = $(this).parent();
		        paneWidth = $c.innerWidth();
		        paneHeight = $c.outerHeight();
		        $('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap', $c).remove();
		        $this.css({ 'top': 0 });
		    } else {
		        $this.data('originalStyleTag', $this.attr('style'));
		        // Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
		        $this.css('overflow', 'hidden');
		        this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
		        this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
		        paneWidth = $this.innerWidth();
		        paneHeight = $this.innerHeight();
		        $container = $('<div></div>')
					.attr({ 'className': 'jScrollPaneContainer' })
					.css(
						{
						    'height': paneHeight + 'px',
						    'width': paneWidth + 'px'
						}
					);
		        if (settings.enableKeyboardNavigation) {
		            $container.attr(
						'tabindex',
						settings.tabIndex
					);
		        }
		        $this.wrap($container);
		        $container = $this.parent();
		        // deal with text size changes (if the jquery.em plugin is included)
		        // and re-initialise the scrollPane so the track maintains the
		        // correct size
		        $(document).bind(
					'emchange',
					function(e, cur, prev) {
					    $this.jScrollPane(settings);
					}
				);

		    }
		    trackHeight = paneHeight;

		    if (settings.reinitialiseOnImageLoad) {
		        // code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
		        // except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
		        // TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
		        var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this);
		        var loadedImages = [];

		        if ($imagesToLoad.length) {
		            $imagesToLoad.each(function(i, val) {
		                $(this).bind('load readystatechange', function() {
		                    if ($.inArray(i, loadedImages) == -1) { //don't double count images
		                        loadedImages.push(val); //keep a record of images we've seen
		                        $imagesToLoad = $.grep($imagesToLoad, function(n, i) {
		                            return n != val;
		                        });
		                        $.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad);
		                        var s2 = $.extend(settings, { reinitialiseOnImageLoad: false });
		                        $this.jScrollPane(s2); // re-initialise
		                    }
		                }).each(function(i, val) {
		                    if (this.complete || this.complete === undefined) {
		                        //needed for potential cached images
		                        this.src = this.src;
		                    }
		                });
		            });
		        };
		    }

		    var p = this.originalSidePaddingTotal;
		    var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;

		    var cssToApply = {
		        'height': 'auto',
		        'width': realPaneWidth + 'px'
		    }

		    if (settings.scrollbarOnLeft) {
		        cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
		    } else {
		        cssToApply.paddingRight = settings.scrollbarMargin + 'px';
		    }

		    $this.css(cssToApply);

		    var contentHeight = $this.outerHeight();
		    var percentInView = paneHeight / contentHeight;

		    var isScrollable = percentInView < .99;
		    $container[isScrollable ? 'addClass' : 'removeClass']('jScrollPaneScrollable');

		    if (isScrollable) {
		        $container.append(
					$('<div></div>').addClass('jScrollCap jScrollCapTop').css({ height: settings.topCapHeight }),
					$('<div></div>').attr({ 'className': 'jScrollPaneTrack' }).css({ 'width': settings.scrollbarWidth + 'px' }).append(
						$('<div></div>').attr({ 'className': 'jScrollPaneDrag' }).css({ 'width': settings.scrollbarWidth + 'px' }).append(
							$('<div></div>').attr({ 'className': 'jScrollPaneDragTop' }).css({ 'width': settings.scrollbarWidth + 'px' }),
							$('<div></div>').attr({ 'className': 'jScrollPaneDragBottom' }).css({ 'width': settings.scrollbarWidth + 'px' })
						)
					),
					$('<div></div>').addClass('jScrollCap jScrollCapBottom').css({ height: settings.bottomCapHeight })
				);

		        var $track = $('>.jScrollPaneTrack', $container);
		        var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);


		        var currentArrowDirection;
		        var currentArrowTimerArr = []; // Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug.
		        var currentArrowInc;
		        var whileArrowButtonDown = function() {
		            if (currentArrowInc > 4 || currentArrowInc % 4 == 0) {
		                positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
		            }
		            currentArrowInc++;
		        };

		        if (settings.enableKeyboardNavigation) {
		            $container.bind(
						'keydown.jscrollpane',
						function(e) {
						    switch (e.keyCode) {
						        case 38: //up
						            currentArrowDirection = -1;
						            currentArrowInc = 0;
						            whileArrowButtonDown();
						            currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
						            return false;
						        case 40: //down
						            currentArrowDirection = 1;
						            currentArrowInc = 0;
						            whileArrowButtonDown();
						            currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
						            return false;
						        case 33: // page up
						        case 34: // page down
						            // TODO
						            return false;
						        default:
						    }
						}
					).bind(
						'keyup.jscrollpane',
						function(e) {
						    if (e.keyCode == 38 || e.keyCode == 40) {
						        for (var i = 0; i < currentArrowTimerArr.length; i++) {
						            clearInterval(currentArrowTimerArr[i]);
						        }
						        return false;
						    }
						}
					);
		        }

		        if (settings.showArrows) {

		            var currentArrowButton;
		            var currentArrowInterval;

		            var onArrowMouseUp = function(event) {
		                $('html').unbind('mouseup', onArrowMouseUp);
		                currentArrowButton.removeClass('jScrollActiveArrowButton');
		                clearInterval(currentArrowInterval);
		            };
		            var onArrowMouseDown = function() {
		                $('html').bind('mouseup', onArrowMouseUp);
		                currentArrowButton.addClass('jScrollActiveArrowButton');
		                currentArrowInc = 0;
		                whileArrowButtonDown();
		                currentArrowInterval = setInterval(whileArrowButtonDown, 100);
		            };
		            $container
						.append(
							$('<a></a>')
								.attr(
									{
									    'href': 'javascript:;',
									    'className': 'jScrollArrowUp',
									    'tabindex': -1
									}
								)
								.css(
									{
									    'width': settings.scrollbarWidth + 'px',
									    'top': settings.topCapHeight + 'px'
									}
								)
								.html('Scroll up')
								.bind('mousedown', function() {
								    currentArrowButton = $(this);
								    currentArrowDirection = -1;
								    onArrowMouseDown();
								    this.blur();
								    return false;
								})
								.bind('click', rf),
							$('<a></a>')
								.attr(
									{
									    'href': 'javascript:;',
									    'className': 'jScrollArrowDown',
									    'tabindex': -1
									}
								)
								.css(
									{
									    'width': settings.scrollbarWidth + 'px',
									    'bottom': settings.bottomCapHeight + 'px'
									}
								)
								.html('Scroll down')
								.bind('mousedown', function() {
								    currentArrowButton = $(this);
								    currentArrowDirection = 1;
								    onArrowMouseDown();
								    this.blur();
								    return false;
								})
								.bind('click', rf)
						);
		            var $upArrow = $('>.jScrollArrowUp', $container);
		            var $downArrow = $('>.jScrollArrowDown', $container);
		        }

		        if (settings.arrowSize) {
		            trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
		            trackOffset += settings.arrowSize;
		        } else if ($upArrow) {
		            var topArrowHeight = $upArrow.height();
		            settings.arrowSize = topArrowHeight;
		            trackHeight = paneHeight - topArrowHeight - $downArrow.height();
		            trackOffset += topArrowHeight;
		        }
		        trackHeight -= settings.topCapHeight + settings.bottomCapHeight;
		        $track.css({ 'height': trackHeight + 'px', top: trackOffset + 'px' })

		        var $pane = $(this).css({ 'position': 'absolute', 'overflow': 'visible' });

		        var currentOffset;
		        var maxY;
		        var mouseWheelMultiplier;
		        // store this in a seperate variable so we can keep track more accurately than just updating the css property..
		        var dragPosition = 0;
		        var dragMiddle = percentInView * paneHeight / 2;

		        // pos function borrowed from tooltip plugin and adapted...
		        var getPos = function(event, c) {
		            var p = c == 'X' ? 'Left' : 'Top';
		            return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
		        };

		        var ignoreNativeDrag = function() { return false; };

		        var initDrag = function() {
		            ceaseAnimation();
		            currentOffset = $drag.offset(false);
		            currentOffset.top -= dragPosition;
		            maxY = trackHeight - $drag[0].offsetHeight;
		            mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
		        };

		        var onStartDrag = function(event) {
		            initDrag();
		            dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
		            $('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
		            if ($.browser.msie) {
		                $('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
		            }
		            return false;
		        };
		        var onStopDrag = function() {
		            $('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
		            dragMiddle = percentInView * paneHeight / 2;
		            if ($.browser.msie) {
		                $('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
		            }
		        };
		        var positionDrag = function(destY) {
		            $container.scrollTop(0);
		            destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
		            dragPosition = destY;
		            $drag.css({ 'top': destY + 'px' });
		            var p = destY / maxY;
		            $this.data('jScrollPanePosition', (paneHeight - contentHeight) * -p);
		            $pane.css({ 'top': ((paneHeight - contentHeight) * p) + 'px' });
		            $this.trigger('scroll');
		            if (settings.showArrows) {
		                $upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
		                $downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
		            }
		        };
		        var updateScroll = function(e) {
		            positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
		        };

		        var dragH = Math.max(Math.min(percentInView * (paneHeight - settings.arrowSize * 2), settings.dragMaxHeight), settings.dragMinHeight);

		        $drag.css(
					{ 'height': dragH + 'px' }
				).bind('mousedown', onStartDrag);

		        var trackScrollInterval;
		        var trackScrollInc;
		        var trackScrollMousePos;
		        var doTrackScroll = function() {
		            if (trackScrollInc > 8 || trackScrollInc % 4 == 0) {
		                positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
		            }
		            trackScrollInc++;
		        };
		        var onStopTrackClick = function() {
		            clearInterval(trackScrollInterval);
		            $('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
		        };
		        var onTrackMouseMove = function(event) {
		            trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
		        };
		        var onTrackClick = function(event) {
		            initDrag();
		            onTrackMouseMove(event);
		            trackScrollInc = 0;
		            $('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
		            trackScrollInterval = setInterval(doTrackScroll, 100);
		            doTrackScroll();
		            return false;
		        };

		        $track.bind('mousedown', onTrackClick);

		        $container.bind(
					'mousewheel',
					function(event, delta) {
					    delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ?
-event.detail / 3 : 0);
					    initDrag();
					    ceaseAnimation();
					    var d = dragPosition;
					    positionDrag(dragPosition - delta * mouseWheelMultiplier);
					    var dragOccured = d != dragPosition;
					    return !dragOccured;
					}
				);

		        var _animateToPosition;
		        var _animateToInterval;
		        function animateToPosition() {
		            var diff = (_animateToPosition - dragPosition) / settings.animateStep;
		            if (diff > 1 || diff < -1) {
		                positionDrag(dragPosition + diff);
		            } else {
		                positionDrag(_animateToPosition);
		                ceaseAnimation();
		            }
		        }
		        var ceaseAnimation = function() {
		            if (_animateToInterval) {
		                clearInterval(_animateToInterval);
		                delete _animateToPosition;
		            }
		        };
		        var scrollTo = function(pos, preventAni) {
		            if (typeof pos == "string") {
		                // Legal hash values aren't necessarily legal jQuery selectors so we need to catch any
		                // errors from the lookup...
		                try {
		                    $e = $(pos, $this);
		                } catch (err) {
		                    return;
		                }
		                if (!$e.length) return;
		                pos = $e.offset().top - $this.offset().top;
		            }
		            ceaseAnimation();
		            var maxScroll = contentHeight - paneHeight;
		            pos = pos > maxScroll ? maxScroll : pos;
		            $this.data('jScrollPaneMaxScroll', maxScroll);
		            var destDragPosition = pos / maxScroll * maxY;
		            if (preventAni || !settings.animateTo) {
		                positionDrag(destDragPosition);
		            } else {
		                $container.scrollTop(0);
		                _animateToPosition = destDragPosition;
		                _animateToInterval = setInterval(animateToPosition, settings.animateInterval);
		            }
		        };
		        $this[0].scrollTo = scrollTo;

		        $this[0].scrollBy = function(delta) {
		            var currentPos = -parseInt($pane.css('top')) || 0;
		            scrollTo(currentPos + delta);
		        };

		        initDrag();

		        scrollTo(-currentScrollPosition, true);

		        // Deal with it when the user tabs to a link or form element within this scrollpane
		        $('*', this).bind(
					'focus',
					function(event) {
					    var $e = $(this);

					    // loop through parents adding the offset top of any elements that are relatively positioned between
					    // the focused element and the jScrollPaneContainer so we can get the true distance from the top
					    // of the focused element to the top of the scrollpane...
					    var eleTop = 0;

					    while ($e[0] != $this[0]) {
					        eleTop += $e.position().top;
					        $e = $e.offsetParent();
					    }

					    var viewportTop = -parseInt($pane.css('top')) || 0;
					    var maxVisibleEleTop = viewportTop + paneHeight;
					    var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
					    if (!eleInView) {
					        var destPos = eleTop - settings.scrollbarMargin;
					        if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom.
					            destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight;
					        }
					        scrollTo(destPos);
					    }
					}
				)


		        if (settings.observeHash) {
		            if (location.hash && location.hash.length > 1) {
		                setTimeout(function() {
		                    scrollTo(location.hash);
		                }, $.browser.safari ? 100 : 0);
		            }

		            // use event delegation to listen for all clicks on links and hijack them if they are links to
		            // anchors within our content...
		            $(document).bind('click', function(e) {
		                $target = $(e.target);
		                if ($target.is('a')) {
		                    var h = $target.attr('href');
		                    if (h && h.substr(0, 1) == '#' && h.length > 1) {
		                        setTimeout(function() {
		                            scrollTo(h, !settings.animateToInternalLinks);
		                        }, $.browser.safari ? 100 : 0);
		                    }
		                }
		            });
		        }

		        // Deal with dragging and selecting text to make the scrollpane scroll...
		        function onSelectScrollMouseDown(e) {
		            $(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove);
		            $(document).bind('mouseup.jScrollPaneDragging', onSelectScrollMouseUp);

		        }

		        var textDragDistanceAway;
		        var textSelectionInterval;

		        function onTextSelectionInterval() {
		            direction = textDragDistanceAway < 0 ? -1 : 1;
		            $this[0].scrollBy(textDragDistanceAway / 2);
		        }

		        function clearTextSelectionInterval() {
		            if (textSelectionInterval) {
		                clearInterval(textSelectionInterval);
		                textSelectionInterval = undefined;
		            }
		        }

		        function onTextSelectionScrollMouseMove(e) {
		            var offset = $this.parent().offset().top;
		            var maxOffset = offset + paneHeight;
		            var mouseOffset = getPos(e, 'Y');
		            textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
		            if (textDragDistanceAway == 0) {
		                clearTextSelectionInterval();
		            } else {
		                if (!textSelectionInterval) {
		                    textSelectionInterval = setInterval(onTextSelectionInterval, 100);
		                }
		            }
		        }

		        function onSelectScrollMouseUp(e) {
		            $(document)
					  .unbind('mousemove.jScrollPaneDragging')
					  .unbind('mouseup.jScrollPaneDragging');
		            clearTextSelectionInterval();
		        }

		        $container.bind('mousedown.jScrollPane', onSelectScrollMouseDown);


		        $.jScrollPane.active.push($this[0]);

		    } else {
		        $this.css(
					{
					    'height': paneHeight + 'px',
					    'width': paneWidth - this.originalSidePaddingTotal + 'px',
					    'padding': this.originalPadding
					}
				);
		        $this[0].scrollTo = $this[0].scrollBy = function() { };
		        // clean up listeners
		        $this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane');
		    }

		}
	)
    };

    $.fn.jScrollPaneRemove = function() {
        $(this).each(function() {
            $this = $(this);
            var $c = $this.parent();
            if ($c.is('.jScrollPaneContainer')) {
                $this.css(
				{
				    'top': '',
				    'height': '',
				    'width': '',
				    'padding': '',
				    'overflow': '',
				    'position': ''
				}
			);
                $this.attr('style', $this.data('originalStyleTag'));
                $c.after($this).remove();
            }
        });
    }

    $.fn.jScrollPane.defaults = {
        scrollbarWidth: 10,
        scrollbarMargin: 5,
        wheelSpeed: 18,
        showArrows: false,
        arrowSize: 0,
        animateTo: false,
        dragMinHeight: 1,
        dragMaxHeight: 99999,
        animateInterval: 100,
        animateStep: 3,
        maintainPosition: true,
        scrollbarOnLeft: false,
        reinitialiseOnImageLoad: false,
        tabIndex: 0,
        enableKeyboardNavigation: true,
        animateToInternalLinks: false,
        topCapHeight: 0,
        bottomCapHeight: 0,
        observeHash: true
    };

    // clean up the scrollTo expandos
    $(window)
	.bind('unload', function() {
	    var els = $.jScrollPane.active;
	    for (var i = 0; i < els.length; i++) {
	        els[i].scrollTo = els[i].scrollBy = null;
	    }
	}
);

})(jQuery);


curvyCornersVerbose = false; 


/* Jquery gradient */

/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Color functions from Steve's Cross Browser Gradient Backgrounds v1.0 (steve@slayeroffice.com && http://slayeroffice.com/code/gradient/)
*
* $LastChangedDate: 2007-06-26 19:52:18 -0500 (Tue, 26 Jun 2007) $
* $Rev: 2163 $
*
* Version 1.0
*/
(function($) {

    /**
    * Adds a gradient to the background of an element.
    *
    * @example $('div').gradient({ from: '000000', to: 'CCCCCC' });
    *
    * @param Map options Settings/options to configure the gradient.
    * @option String from The hex color code to start the gradient with.
    * 		By default the value is "000000".
    * @option String to The hex color code to end the gradient with.
    * 		By default the value is "FFFFFF".
    * @option String direction This tells the gradient to be horizontal
    *      or vertical. By default the value is "horizontal".
    * @option Number length This is used to constrain the gradient to a
    *      particular width or height (depending on the direction). By default
    *      the length is set to null, which will use the width or height
    *      (depending on the direction) of the element.
    * @option String position This tells the gradient to be positioned
    *      at the top, bottom, left and/or right within the element. The
    *      value is just a string that specifices top or bottom and left or right.
    *      By default the value is 'top left'.
    *
    * @name gradient
    * @type jQuery
    * @cat Plugins/gradient
    * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
    */
    $.fn.gradient = function(options) {
        options = $.extend({ from: '000000', to: 'ffffff', direction: 'horizontal', position: 'top', length: null }, options || {});
        var createColorPath = function(startColor, endColor, distance) {
            var colorPath = [],
		    colorPercent = 1.0,
			distance = (distance < 100) ? distance : 100;
            do {
                colorPath[colorPath.length] = setColorHue(longHexToDec(startColor), colorPercent, longHexToDec(endColor));
                colorPercent -= ((100 / distance) * 0.01);
            } while (colorPercent > 0);
            return colorPath;
        },
	setColorHue = function(originColor, opacityPercent, maskRGB) {
	    var returnColor = [];
	    for (var i = 0; i < originColor.length; i++)
	        returnColor[i] = Math.round(originColor[i] * opacityPercent) + Math.round(maskRGB[i] * (1.0 - opacityPercent));
	    return returnColor;
	},
	longHexToDec = function(longHex) {
	    return new Array(toDec(longHex.substring(0, 2)), toDec(longHex.substring(2, 4)), toDec(longHex.substring(4, 6)));
	},
	toDec = function(hex) {
	    return parseInt(hex, 16);
	};
        return this.each(function() {
            var $this = $(this), width = $this.innerWidth(), height = $this.innerHeight(), x = 0, y = 0, w = 1, h = 1, html = [],
		    length = options.length || (options.direction == 'vertical' ? width : height),
		    position = (options.position == 'bottom' ? 'bottom:0;' : 'top:0;') + (options.position == 'right' ? 'right:0;' : 'left:0;'),
		    colorArray = createColorPath(options.from, options.to, length);

            if (options.direction == 'horizontal') {
                h = Math.round(length / colorArray.length) || 1;
                w = width;
            } else {
                w = Math.round(length / colorArray.length) || 1;
                h = height;
            }

            html.push('<div class="gradient" style="position: absolute; ' + position + ' width: ' + (options.direction == 'vertical' ? length + "px" : "100%") + '; height: ' + (options.direction == 'vertical' ? "100%" : length + "px") + '; overflow: hidden; z-index: 0; background-color: #' + (options.position.indexOf('bottom') != -1 ? options.from : options.to) + '">');
            for (var i = 0; i < colorArray.length; i++) {
                html.push('<div style="position:absolute;z-index:1;top:' + y + 'px;left:' + x + 'px;height:' + (options.direction == 'vertical' ? "100%" : h + "px") + ';width:' + (options.direction == 'vertical' ? w + "px" : "100%") + ';background-color:rgb(' + colorArray[i][0] + ',' + colorArray[i][1] + ',' + colorArray[i][2] + ');"></div>');
                options.direction == 'vertical' ? x += w : y += h;

                if (y >= height || x >= width) break;
            }
            html.push('</div>');

            if ($this.css('position') == 'static')
                $this.css('position', 'relative');

            $this
			.html('<div style="display:' + $this.css("display") + '; position: relative; z-index: 2;">' + this.innerHTML + '</div>')
			.prepend(html.join(''));
        });
    };

})(jQuery);



/*
* jQuery Tools 1.2.3 - The missing UI library for the Web
* 
* [scrollable, scrollable.autoscroll, scrollable.navigator, overlay, toolbox.expose]
* 
* NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
* 
* http://flowplayer.org/tools/
* 
* File generated: Mon Jun 14 08:23:17 GMT 2010
*/
(function(e) {
    function n(f, c) { var a = e(c); return a.length < 2 ? a : f.parent().find(c) } function t(f, c) {
        var a = this, l = f.add(a), g = f.children(), k = 0, m = c.vertical; j || (j = a); if (g.length > 1) g = e(c.items, f); e.extend(a, { getConf: function() { return c }, getIndex: function() { return k }, getSize: function() { return a.getItems().size() }, getNaviButtons: function() { return o.add(p) }, getRoot: function() { return f }, getItemWrap: function() { return g }, getItems: function() { return g.children(c.item).not("." + c.clonedClass) }, move: function(b, d) {
            return a.seekTo(k +
b, d)
        }, next: function(b) { return a.move(1, b) }, prev: function(b) { return a.move(-1, b) }, begin: function(b) { return a.seekTo(0, b) }, end: function(b) { return a.seekTo(a.getSize() - 1, b) }, focus: function() { return j = a }, addItem: function(b) { b = e(b); if (c.circular) { e(".cloned:last").before(b); e(".cloned:first").replaceWith(b.clone().addClass(c.clonedClass)) } else g.append(b); l.trigger("onAddItem", [b]); return a }, seekTo: function(b, d, h) {
            if (c.circular && b === 0 && k == -1 && d !== 0) return a; if (!c.circular && b < 0 || b > a.getSize() || b < -1) return a;
            var i = b; if (b.jquery) b = a.getItems().index(b); else i = a.getItems().eq(b); var q = e.Event("onBeforeSeek"); if (!h) { l.trigger(q, [b, d]); if (q.isDefaultPrevented() || !i.length) return a } i = m ? { top: -i.position().top} : { left: -i.position().left }; k = b; j = a; if (d === undefined) d = c.speed; g.animate(i, d, c.easing, h || function() { l.trigger("onSeek", [b]) }); return a
        } 
        }); e.each(["onBeforeSeek", "onSeek", "onAddItem"], function(b, d) { e.isFunction(c[d]) && e(a).bind(d, c[d]); a[d] = function(h) { e(a).bind(d, h); return a } }); if (c.circular) {
            var r = a.getItems().slice(-1).clone().prependTo(g),
s = a.getItems().eq(1).clone().appendTo(g); r.add(s).addClass(c.clonedClass); a.onBeforeSeek(function(b, d, h) { if (!b.isDefaultPrevented()) if (d == -1) { a.seekTo(r, h, function() { a.end(0) }); return b.preventDefault() } else d == a.getSize() && a.seekTo(s, h, function() { a.begin(0) }) }); a.seekTo(0, 0)
        } var o = n(f, c.prev).click(function() { a.prev() }), p = n(f, c.next).click(function() { a.next() }); !c.circular && a.getSize() > 1 && a.onBeforeSeek(function(b, d) {
            setTimeout(function() {
                if (!b.isDefaultPrevented()) {
                    o.toggleClass(c.disabledClass,
d <= 0); p.toggleClass(c.disabledClass, d >= a.getSize() - 1)
                } 
            }, 1)
        }); c.mousewheel && e.fn.mousewheel && f.mousewheel(function(b, d) { if (c.mousewheel) { a.move(d < 0 ? 1 : -1, c.wheelSpeed || 50); return false } }); c.keyboard && e(document).bind("keydown.scrollable", function(b) { if (!(!c.keyboard || b.altKey || b.ctrlKey || e(b.target).is(":input"))) if (!(c.keyboard != "static" && j != a)) { var d = b.keyCode; if (m && (d == 38 || d == 40)) { a.move(d == 38 ? -1 : 1); return b.preventDefault() } if (!m && (d == 37 || d == 39)) { a.move(d == 37 ? -1 : 1); return b.preventDefault() } } });
        e(a).trigger("onBeforeSeek", [c.initialIndex])
    } e.tools = e.tools || { version: "1.2.3" }; e.tools.scrollable = { conf: { activeClass: "active", circular: false, clonedClass: "cloned", disabledClass: "disabled", easing: "swing", initialIndex: 0, item: null, items: ".items", keyboard: true, mousewheel: false, next: ".next", prev: ".prev", speed: 400, vertical: false, wheelSpeed: 0} }; var j; e.fn.scrollable = function(f) {
        var c = this.data("scrollable"); if (c) return c; f = e.extend({}, e.tools.scrollable.conf, f); this.each(function() {
            c = new t(e(this), f); e(this).data("scrollable",
c)
        }); return f.api ? c : this
    } 
})(jQuery);
(function(c) {
    var g = c.tools.scrollable; g.autoscroll = { conf: { autoplay: true, interval: 3E3, autopause: true} }; c.fn.autoscroll = function(d) {
        if (typeof d == "number") d = { interval: d }; var b = c.extend({}, g.autoscroll.conf, d), h; this.each(function() {
            var a = c(this).data("scrollable"); if (a) h = a; var e, i, f = true; a.play = function() { if (!e) { f = false; e = setInterval(function() { a.next() }, b.interval); a.next() } }; a.pause = function() { e = clearInterval(e) }; a.stop = function() { a.pause(); f = true }; b.autopause && a.getRoot().add(a.getNaviButtons()).hover(function() {
                a.pause();
                clearInterval(i)
            }, function() { f || (i = setTimeout(a.play, b.interval)) }); b.autoplay && setTimeout(a.play, b.interval)
        }); return b.api ? h : this
    } 
})(jQuery);
(function(d) {
    function p(c, g) { var h = d(g); return h.length < 2 ? h : c.parent().find(g) } var m = d.tools.scrollable; m.navigator = { conf: { navi: ".navi", naviItem: null, activeClass: "active", indexed: false, idPrefix: null, history: false} }; d.fn.navigator = function(c) {
        if (typeof c == "string") c = { navi: c }; c = d.extend({}, m.navigator.conf, c); var g; this.each(function() {
            function h(a, b, i) { e.seekTo(b); if (j) { if (location.hash) location.hash = a.attr("href").replace("#", "") } else return i.preventDefault() } function f() {
                return k.find(c.naviItem ||
"> *")
            } function n(a) { var b = d("<" + (c.naviItem || "a") + "/>").click(function(i) { h(d(this), a, i) }).attr("href", "#" + a); a === 0 && b.addClass(l); c.indexed && b.text(a + 1); c.idPrefix && b.attr("id", c.idPrefix + a); return b.appendTo(k) } function o(a, b) { a = f().eq(b.replace("#", "")); a.length || (a = f().filter("[href=" + b + "]")); a.click() } var e = d(this).data("scrollable"), k = p(e.getRoot(), c.navi), q = e.getNaviButtons(), l = c.activeClass, j = c.history && d.fn.history; if (e) g = e; e.getNaviButtons = function() { return q.add(k) }; f().length ? f().each(function(a) {
                d(this).click(function(b) {
                    h(d(this),
a, b)
                })
            }) : d.each(e.getItems(), function(a) { n(a) }); e.onBeforeSeek(function(a, b) { setTimeout(function() { if (!a.isDefaultPrevented()) { var i = f().eq(b); !a.isDefaultPrevented() && i.length && f().removeClass(l).eq(b).addClass(l) } }, 1) }); e.onAddItem(function(a, b) { b = n(e.getItems().index(b)); j && b.history(o) }); j && f().history(o)
        }); return c.api ? g : this
    } 
})(jQuery);
(function(a) {
    function t(d, b) {
        var c = this, i = d.add(c), o = a(window), k, f, m, g = a.tools.expose && (b.mask || b.expose), n = Math.random().toString().slice(10); if (g) { if (typeof g == "string") g = { color: g }; g.closeOnClick = g.closeOnEsc = false } var p = b.target || d.attr("rel"); f = p ? a(p) : d; if (!f.length) throw "Could not find Overlay: " + p; d && d.index(f) == -1 && d.click(function(e) { c.load(e); return e.preventDefault() }); a.extend(c, { load: function(e) {
            if (c.isOpened()) return c; var h = q[b.effect]; if (!h) throw 'Overlay: cannot find effect : "' + b.effect +
'"'; b.oneInstance && a.each(s, function() { this.close(e) }); e = e || a.Event(); e.type = "onBeforeLoad"; i.trigger(e); if (e.isDefaultPrevented()) return c; m = true; g && a(f).expose(g); var j = b.top, r = b.left, u = f.outerWidth({ margin: true }), v = f.outerHeight({ margin: true }); if (typeof j == "string") j = j == "center" ? Math.max((o.height() - v) / 2, 0) : parseInt(j, 10) / 100 * o.height(); if (r == "center") r = Math.max((o.width() - u) / 2, 0); h[0].call(c, { top: j, left: r }, function() { if (m) { e.type = "onLoad"; i.trigger(e) } }); g && b.closeOnClick && a.mask.getMask().one("click",
c.close); b.closeOnClick && a(document).bind("click." + n, function(l) { a(l.target).parents(f).length || c.close(l) }); b.closeOnEsc && a(document).bind("keydown." + n, function(l) { l.keyCode == 27 && c.close(l) }); return c
        }, close: function(e) { if (!c.isOpened()) return c; e = e || a.Event(); e.type = "onBeforeClose"; i.trigger(e); if (!e.isDefaultPrevented()) { m = false; q[b.effect][1].call(c, function() { e.type = "onClose"; i.trigger(e) }); a(document).unbind("click." + n).unbind("keydown." + n); g && a.mask.close(); return c } }, getOverlay: function() { return f },
            getTrigger: function() { return d }, getClosers: function() { return k }, isOpened: function() { return m }, getConf: function() { return b } 
        }); a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(e, h) { a.isFunction(b[h]) && a(c).bind(h, b[h]); c[h] = function(j) { a(c).bind(h, j); return c } }); k = f.find(b.close || ".close"); if (!k.length && !b.close) { k = a('<a class="close"></a>'); f.prepend(k) } k.click(function(e) { c.close(e) }); b.load && c.load()
    } a.tools = a.tools || { version: "1.2.3" }; a.tools.overlay = { addEffect: function(d,
b, c) { q[d] = [b, c] }, conf: { close: null, closeOnClick: true, closeOnEsc: true, closeSpeed: "fast", effect: "default", fixed: !a.browser.msie || a.browser.version > 6, left: "center", load: false, mask: null, oneInstance: true, speed: "normal", target: null, top: "10%"}
    }; var s = [], q = {}; a.tools.overlay.addEffect("default", function(d, b) { var c = this.getConf(), i = a(window); if (!c.fixed) { d.top += i.scrollTop(); d.left += i.scrollLeft() } d.position = c.fixed ? "fixed" : "absolute"; this.getOverlay().css(d).fadeIn(c.speed, b) }, function(d) {
        this.getOverlay().fadeOut(this.getConf().closeSpeed,
d)
    }); a.fn.overlay = function(d) { var b = this.data("overlay"); if (b) return b; if (a.isFunction(d)) d = { onBeforeLoad: d }; d = a.extend(true, {}, a.tools.overlay.conf, d); this.each(function() { b = new t(a(this), d); s.push(b); a(this).data("overlay", b) }); return d.api ? b : this } 
})(jQuery);
(function(b) {
    function k() { if (b.browser.msie) { var a = b(document).height(), d = b(window).height(); return [window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, a - d < 20 ? d : a] } return [b(document).width(), b(document).height()] } function h(a) { if (a) return a.call(b.mask) } b.tools = b.tools || { version: "1.2.3" }; var l; l = b.tools.expose = { conf: { maskId: "exposeMask", loadSpeed: "slow", closeSpeed: "fast", closeOnClick: true, closeOnEsc: true, zIndex: 9998, opacity: 0.8, startOpacity: 0, color: "#fff", onLoad: null,
        onClose: null}
    }; var c, i, f, g, j; b.mask = { load: function(a, d) {
        if (f) return this; if (typeof a == "string") a = { color: a }; a = a || g; g = a = b.extend(b.extend({}, l.conf), a); c = b("#" + a.maskId); if (!c.length) { c = b("<div/>").attr("id", a.maskId); b("body").append(c) } var m = k(); c.css({ position: "absolute", top: 0, left: 0, width: m[0], height: m[1], display: "none", opacity: a.startOpacity, zIndex: a.zIndex }); a.color && c.css("backgroundColor", a.color); if (h(a.onBeforeLoad) === false) return this; a.closeOnEsc && b(document).bind("keydown.mask", function(e) {
            e.keyCode ==
27 && b.mask.close(e)
        }); a.closeOnClick && c.bind("click.mask", function(e) { b.mask.close(e) }); b(window).bind("resize.mask", function() { b.mask.fit() }); if (d && d.length) { j = d.eq(0).css("zIndex"); b.each(d, function() { var e = b(this); /relative|absolute|fixed/i.test(e.css("position")) || e.css("position", "relative") }); i = d.css({ zIndex: Math.max(a.zIndex + 1, j == "auto" ? 0 : j) }) } c.css({ display: "block" }).fadeTo(a.loadSpeed, a.opacity, function() { b.mask.fit(); h(a.onLoad) }); f = true; return this
    }, close: function() {
        if (f) {
            if (h(g.onBeforeClose) ===
false) return this; c.fadeOut(g.closeSpeed, function() { h(g.onClose); i && i.css({ zIndex: j }) }); b(document).unbind("keydown.mask"); c.unbind("click.mask"); b(window).unbind("resize.mask"); f = false
        } return this
    }, fit: function() { if (f) { var a = k(); c.css({ width: a[0], height: a[1] }) } }, getMask: function() { return c }, isLoaded: function() { return f }, getConf: function() { return g }, getExposed: function() { return i } 
    }; b.fn.mask = function(a) { b.mask.load(a); return this }; b.fn.expose = function(a) { b.mask.load(a, this); return this }
})(jQuery);



/*	sIFR v2.0.7
Copyright 2004 - 2008 Mark Wubben and Mike Davidson. Prior contributions by Shaun Inman and Tomas Jogin.
	
This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

var hasFlash = function() { var a = 6; if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1) { document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + a + '))) \n</script\> \n'); if (window.hasFlash != null) return window.hasFlash } if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) { var b = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description; return parseInt(b.substr(b.indexOf(".") - 2, 2), 10) >= a } return false } (); String.prototype.normalize = function() { return this.replace(/\s+/g, " ") }; if (Array.prototype.push == null) { Array.prototype.push = function() { var i = 0, a = this.length, b = arguments.length; while (i < b) { this[a++] = arguments[i++] } return this.length } } if (!Function.prototype.apply) { Function.prototype.apply = function(a, b) { var c = []; var d, e; if (!a) a = window; if (!b) b = []; for (var i = 0; i < b.length; i++) { c[i] = "b[" + i + "]" } e = "a.__applyTemp__(" + c.join(",") + ");"; a.__applyTemp__ = this; d = eval(e); a.__applyTemp__ = null; return d } } function named(a) { return new named.Arguments(a) } named.Arguments = function(a) { this.oArgs = a }; named.Arguments.prototype.constructor = named.Arguments; named.extract = function(a, b) { var c, d; var i = a.length; while (i--) { d = a[i]; if (d != null && d.constructor != null && d.constructor == named.Arguments) { c = a[i].oArgs; break } } if (c == null) return; for (e in c) if (b[e] != null) b[e](c[e]); return }; var parseSelector = function() { var a = /^([^#.>`]*)(#|\.|\>|\`)(.+)$/; function r(s, t) { var u = s.split(/\s*\,\s*/); var v = []; for (var i = 0; i < u.length; i++) v = v.concat(b(u[i], t)); return v } function b(c, d, e) { c = c.normalize().replace(" ", "`"); var f = c.match(a); var g, h, i, j, k, n; var l = []; if (f == null) f = [c, c]; if (f[1] == "") f[1] = "*"; if (e == null) e = "`"; if (d == null) d = document; switch (f[2]) { case "#": k = f[3].match(a); if (k == null) k = [null, f[3]]; g = document.getElementById(k[1]); if (g == null || (f[1] != "*" && !o(g, f[1]))) return l; if (k.length == 2) { l.push(g); return l } return b(k[3], g, k[2]); case ".": if (e != ">") h = m(d, f[1]); else h = d.childNodes; for (i = 0, n = h.length; i < n; i++) { g = h[i]; if (g.nodeType != 1) continue; k = f[3].match(a); if (k != null) { if (g.className == null || g.className.match("(\\s|^)" + k[1] + "(\\s|$)") == null) continue; j = b(k[3], g, k[2]); l = l.concat(j) } else if (g.className != null && g.className.match("(\\s|^)" + f[3] + "(\\s|$)") != null) l.push(g) } return l; case ">": if (e != ">") h = m(d, f[1]); else h = d.childNodes; for (i = 0, n = h.length; i < n; i++) { g = h[i]; if (g.nodeType != 1) continue; if (!o(g, f[1])) continue; j = b(f[3], g, ">"); l = l.concat(j) } return l; case "`": h = m(d, f[1]); for (i = 0, n = h.length; i < n; i++) { g = h[i]; j = b(f[3], g, "`"); l = l.concat(j) } return l; default: if (e != ">") h = m(d, f[1]); else h = d.childNodes; for (i = 0, n = h.length; i < n; i++) { g = h[i]; if (g.nodeType != 1) continue; if (!o(g, f[1])) continue; l.push(g) } return l } } function m(d, o) { if (o == "*" && d.all != null) return d.all; return d.getElementsByTagName(o) } function o(p, q) { return q == "*" ? true : p.nodeName.toLowerCase().replace("html:", "") == q.toLowerCase() } return r } (); var sIFR = function() { var a = "http://www.w3.org/1999/xhtml"; var b = false; var c = false; var d; var ah = []; var al = document; var ak = al.documentElement; var am = window; var au = al.addEventListener; var av = am.addEventListener; var f = function() { var g = navigator.userAgent.toLowerCase(); var f = { a: g.indexOf("applewebkit") > -1, b: g.indexOf("safari") > -1, c: navigator.product != null && navigator.product.toLowerCase().indexOf("konqueror") > -1, d: g.indexOf("opera") > -1, e: al.contentType != null && al.contentType.indexOf("xml") > -1, f: true, g: true, h: null, i: null, j: null, k: null }; f.l = f.a || f.c; f.m = !f.a && navigator.product != null && navigator.product.toLowerCase() == "gecko"; if (f.m && g.match(/.*gecko\/(\d{8}).*/)) f.j = new Number(g.match(/.*gecko\/(\d{8}).*/)[1]); f.n = g.indexOf("msie") > -1 && !f.d && !f.l && !f.m; f.o = f.n && g.match(/.*mac.*/) != null; if (f.d && g.match(/.*opera(\s|\/)(\d+\.\d+)/)) f.i = new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]); if (f.n || (f.d && f.i < 7.6)) f.g = false; if (f.a && g.match(/.*applewebkit\/(\d+).*/)) f.k = new Number(g.match(/.*applewebkit\/(\d+).*/)[1]); if (am.hasFlash && (!f.n || f.o)) { var aj = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description; f.h = parseInt(aj.substr(aj.indexOf(".") - 2, 2), 10) } if (g.match(/.*(windows|mac).*/) == null || f.o || f.c || (f.d && (g.match(/.*mac.*/) != null || f.i < 7.6)) || (f.b && f.h < 7) || (!f.b && f.a && f.k < 312) || (f.m && f.j < 20020523)) f.f = false; if (!f.o && !f.m && al.createElementNS) try { al.createElementNS(a, "i").innerHTML = "" } catch (e) { f.e = true } f.p = f.c || (f.a && f.k < 312); return f } (); function at() { return { bIsWebKit: f.a, bIsSafari: f.b, bIsKonq: f.c, bIsOpera: f.d, bIsXML: f.e, bHasTransparencySupport: f.f, bUseDOM: f.g, nFlashVersion: f.h, nOperaVersion: f.i, nGeckoBuildDate: f.j, nWebKitVersion: f.k, bIsKHTML: f.l, bIsGecko: f.m, bIsIE: f.n, bIsIEMac: f.o, bUseInnerHTMLHack: f.p} } if (am.hasFlash == false || !al.getElementsByTagName || !al.getElementById || (f.e && (f.p || f.n))) return { UA: at() }; function af(e) { if ((!k.bAutoInit && (am.event || e) != null) || !l(e)) return; b = true; for (var i = 0, h = ah.length; i < h; i++) j.apply(null, ah[i]); ah = [] } var k = af; function l(e) { if (c == false || k.bIsDisabled == true || ((f.e && f.m || f.l) && e == null && b == false) || al.getElementsByTagName("body").length == 0) return false; return true } function m(n) { if (f.n) return n.replace(new RegExp("%\d{0}", "g"), "%25"); return n.replace(new RegExp("%(?!\d)", "g"), "%25") } function as(p, q) { return q == "*" ? true : p.nodeName.toLowerCase().replace("html:", "") == q.toLowerCase() } function o(p, q, r, s, t) { var u = ""; var v = p.firstChild; var w, x, y, z; if (s == null) s = 0; if (t == null) t = ""; while (v) { if (v.nodeType == 3) { z = v.nodeValue.replace("<", "&lt;"); switch (r) { case "lower": u += z.toLowerCase(); break; case "upper": u += z.toUpperCase(); break; default: u += z } } else if (v.nodeType == 1) { if (as(v, "a") && !v.getAttribute("href") == false) { if (v.getAttribute("target")) t += "&sifr_url_" + s + "_target=" + v.getAttribute("target"); t += "&sifr_url_" + s + "=" + m(v.getAttribute("href")).replace(/&/g, "%26"); u += '<a href="asfunction:_root.launchURL,' + s + '">'; s++ } else if (as(v, "br")) u += "<br/>"; if (v.hasChildNodes()) { y = o(v, null, r, s, t); u += y.u; s = y.s; t = y.t } if (as(v, "a")) u += "</a>" } w = v; v = v.nextSibling; if (q != null) { x = w.parentNode.removeChild(w); q.appendChild(x) } } return { "u": u, "s": s, "t": t} } function A(B) { if (al.createElementNS && f.g) return al.createElementNS(a, B); return al.createElement(B) } function C(D, E, z) { var p = A("param"); p.setAttribute("name", E); p.setAttribute("value", z); D.appendChild(p) } function F(p, G) { var H = p.className; if (H == null) H = G; else H = H.normalize() + (H == "" ? "" : " ") + G; p.className = H } function aq(ar) { var a = ak; if (k.bHideBrowserText == false) a = al.getElementsByTagName("body")[0]; if ((k.bHideBrowserText == false || ar) && a) if (a.className == null || a.className.match(/\bsIFR\-hasFlash\b/) == null) F(a, "sIFR-hasFlash") } function j(I, J, K, L, M, N, O, P, Q, R, S, r, T) { if (!l()) return ah.push(arguments); aq(); named.extract(arguments, { sSelector: function(ap) { I = ap }, sFlashSrc: function(ap) { J = ap }, sColor: function(ap) { K = ap }, sLinkColor: function(ap) { L = ap }, sHoverColor: function(ap) { M = ap }, sBgColor: function(ap) { N = ap }, nPaddingTop: function(ap) { O = ap }, nPaddingRight: function(ap) { P = ap }, nPaddingBottom: function(ap) { Q = ap }, nPaddingLeft: function(ap) { R = ap }, sFlashVars: function(ap) { S = ap }, sCase: function(ap) { r = ap }, sWmode: function(ap) { T = ap } }); var U = parseSelector(I); if (U.length == 0) return false; if (S != null) S = "&" + S.normalize(); else S = ""; if (K != null) S += "&textcolor=" + K; if (M != null) S += "&hovercolor=" + M; if (M != null || L != null) S += "&linkcolor=" + (L || K); if (O == null) O = 0; if (P == null) P = 0; if (Q == null) Q = 0; if (R == null) R = 0; if (N == null) N = "#FFFFFF"; if (T == "transparent") if (!f.f) T = "opaque"; else N = "transparent"; if (T == null) T = ""; var p, V, W, X, Y, Z, aa, ab, ac; var ad = null; for (var i = 0, h = U.length; i < h; i++) { p = U[i]; if (p.className != null && p.className.match(/\bsIFR\-replaced\b/) != null) continue; V = p.offsetWidth - R - P; W = p.offsetHeight - O - Q; aa = A("span"); aa.className = "sIFR-alternate"; ac = o(p, aa, r); Z = "txt=" + m(ac.u).replace(/\+/g, "%2B").replace(/&/g, "%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t; F(p, "sIFR-replaced"); if (ad == null || !f.g) { if (!f.g) { if (!f.n) p.innerHTML = ['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="', J, '" quality="best" wmode="', T, '" bgcolor="', N, '" flashvars="', Z, '" width="', V, '" height="', W, '" sifr="true"></embed>'].join(""); else p.innerHTML = ['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" sifr="true" width="', V, '" height="', W, '" class="sIFR-flash"><param name="movie" value="', J, '"></param><param name="flashvars" value="', Z, '"></param><param name="quality" value="best"></param><param name="wmode" value="', T, '"></param><param name="bgcolor" value="', N, '"></param> </object>'].join('') } else { if (f.d) { ab = A("object"); ab.setAttribute("data", J); C(ab, "quality", "best"); C(ab, "wmode", T); C(ab, "bgcolor", N) } else { ab = A("embed"); ab.setAttribute("src", J); ab.setAttribute("quality", "best"); ab.setAttribute("flashvars", Z); ab.setAttribute("wmode", T); ab.setAttribute("bgcolor", N) } ab.setAttribute("sifr", "true"); ab.setAttribute("type", "application/x-shockwave-flash"); ab.className = "sIFR-flash"; if (!f.l || !f.e) ad = ab.cloneNode(true) } } else ab = ad.cloneNode(true); if (f.g) { if (f.d) C(ab, "flashvars", Z); else ab.setAttribute("flashvars", Z); ab.setAttribute("width", V); ab.setAttribute("height", W); ab.style.width = V + "px"; ab.style.height = W + "px"; p.appendChild(ab) } p.appendChild(aa); if (f.p) p.innerHTML += "" } if (f.n && k.bFixFragIdBug) setTimeout(function() { al.title = d }, 0) } function ai() { d = al.title } function ae() { if (k.bIsDisabled == true) return; c = true; if (k.bHideBrowserText) aq(true); if (am.attachEvent) am.attachEvent("onload", af); else if (!f.c && (al.addEventListener || am.addEventListener)) { if (f.a && f.k >= 132 && am.addEventListener) am.addEventListener("load", function() { setTimeout("sIFR({})", 1) }, false); else { if (al.addEventListener) al.addEventListener("load", af, false); if (am.addEventListener) am.addEventListener("load", af, false) } } else if (typeof am.onload == "function") { var ag = am.onload; am.onload = function() { ag(); af() } } else am.onload = af; if (!f.n || am.location.hash == "") k.bFixFragIdBug = false; else ai() } k.UA = at(); k.bAutoInit = true; k.bFixFragIdBug = true; k.replaceElement = j; k.updateDocumentTitle = ai; k.appendToClassName = F; k.setup = ae; k.debug = function() { aq(true) }; k.debug.replaceNow = function() { ae(); k() }; k.bIsDisabled = false; k.bHideBrowserText = true; return k } ();

if (typeof sIFR == "function" && !sIFR.UA.bIsIEMac && (!sIFR.UA.bIsWebKit || sIFR.UA.nWebKitVersion >= 100)) {
    sIFR.setup();
};

if (typeof sIFR == "function") (function() { var j = document; var h = j.documentElement; sIFR.removeDecoyClasses = function() { function a(b) { if (b && b.className != null) b.className = b.className.replace(/\bsIFR-hasFlash\b/, "") } return function() { a(h); a(j.getElementsByTagName("body")[0]) } } (); sIFR.preferenceManager = { storage: { sCookieId: "sifr", set: function(a) { var b = new Date(); b.setFullYear(b.getFullYear() + 3); j.cookie = [this.sCookieId, "=", a, ";expires=", b.toGMTString(), ";path=/"].join("") }, get: function() { var a = j.cookie.match(new RegExp(";?" + this.sCookieId + "=([^;]+);?")); if (a != null && a[1] == "false") return false; else return true }, reset: function() { var a = new Date(); a.setFullYear(a.getFullYear() - 1); j.cookie = [this.sCookieId, "=true;expires=", a.toGMTString(), ";path=/"].join("") } }, disable: function() { this.storage.set(false) }, enable: function() { this.storage.set(true) }, test: function() { return this.storage.get() } }; if (sIFR.preferenceManager.test() == false) { sIFR.bIsDisabled = true; sIFR.removeDecoyClasses() } sIFR.rollback = function() { function a(b) { var c, d, e, f, g, h; var l = parseSelector(b); var i = l.length - 1; var m = false; while (i >= 0) { c = l[i]; l.length--; d = c.parentNode; if (c.getAttribute("sifr") == "true") { h = 0; while (h < d.childNodes.length) { c = d.childNodes[h]; if (c.className == "sIFR-alternate") { e = c; h++; continue } d.removeChild(c) } if (e != null) { f = e.firstChild; while (f != null) { g = f.nextSibling; d.appendChild(e.removeChild(f)); f = g } d.removeChild(e) } if (!sIFR.UA.bIsXML && sIFR.UA.bUseInnerHTMLHack) d.innerHTML += ""; d.className = d.className.replace(/\bsIFR\-replaced\b/, "") }; m = true; i-- } return m } return function(k) { named.extract(arguments, { sSelector: function(a) { k = a } }); if (k == null) k = ""; else k += ">"; sIFR.removeDecoyClasses(); sIFR.bHideBrowserText = false; if (a(k + "embed") == false) a(k + "object") } } () })()


