

var browserName=navigator.appName; 
 if (browserName=="Microsoft Internet Explorer") {
	 document.write('<link rel="stylesheet" type="text/css" href="estilos_ie.css" media="screen" >');
 } else {//if (browserName=="Netscape")
 	document.write('<link rel="stylesheet" type="text/css" href="estilos.css" media="screen" >');
 	//window.onresize="document.location.href=document.location.href;";
}

var x,y;
	
function pintaImagen () {
//pathImage='imagenes/Cabecera_Grandee1.png';
pathImage='imagenes/pruebas/Cabecera_Grande.png';


if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}

image1_width = (x * 0.976);
image1_height = (y * 0.32);
var image1 = '<img alt="Criminon Espaņa" id ="imagenEncabezado" src="'+pathImage+'" width="' + image1_width
    + '"  height="' + image1_height + '" >';
document.write(image1);

}

/*
        cssQuery, version 2.0.2 (2005-08-19)
        Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
        License: http://creativecommons.org/licenses/LGPL/2.1/
*/

// the following functions allow querying of the DOM using CSS selectors
var cssQuery = function() {
var version = "2.0.2ruzee";

// -----------------------------------------------------------------------
// main query function
// -----------------------------------------------------------------------

var $COMMA = /\s*,\s*/;
var cssQuery = function($selector, $$from) {
// try {
        var $match = [];
        var $useCache = arguments.callee.caching && !$$from;
        var $base = ($$from) ? ($$from.constructor == Array) ? $$from : [$$from] : [document];
        // process comma separated selectors
        var $$selectors = parseSelector($selector).split($COMMA), i;
        for (i = 0; i < $$selectors.length; i++) {
                // convert the selector to a stream
                $selector = _toStream($$selectors[i]);
                // faster chop if it starts with id (MSIE only)
                if (isMSIE && $selector.slice(0, 3).join("") == " *#") {
                        $selector = $selector.slice(2);
                        $$from = _msie_selectById([], $base, $selector[1]);
                } else $$from = $base;
                // process the stream
                var j = 0, $token, $filter, $arguments, $cacheSelector = "";
                while (j < $selector.length) {
                        $token = $selector[j++];
                        $filter = $selector[j++];
                        $cacheSelector += $token + $filter;
                        // some pseudo-classes allow arguments to be passed
                        //  e.g. nth-child(even)
                        $arguments = "";
                        if ($selector[j] == "(") {
                                while ($selector[j++] != ")" && j < $selector.length) {
                                        $arguments += $selector[j];
                                }
                                $arguments = $arguments.slice(0, -1);
                                $cacheSelector += "(" + $arguments + ")";
                        }
                        // process a token/filter pair use cached results if possible
                        $$from = ($useCache && cache[$cacheSelector]) ?
                                cache[$cacheSelector] : select($$from, $token, $filter, $arguments);
                        if ($useCache) cache[$cacheSelector] = $$from;
                }
                $match = $match.concat($$from);
        }
        delete cssQuery.error;
        return $match;
/*} catch ($error) {
        for (p in $error){
          alert(p+':'+$error[p]);
        }
//         alert($error);
        cssQuery.error = $error;
        return [];
}*/
};

// -----------------------------------------------------------------------
// public interface
// -----------------------------------------------------------------------

cssQuery.toString = function() {
        return "function cssQuery() {\n  [version " + version + "]\n}";
};

// caching
var cache = {};
cssQuery.caching = false;
cssQuery.clearCache = function($selector) {
        if ($selector) {
                $selector = _toStream($selector).join("");
                delete cache[$selector];
        } else cache = {};
};

// allow extensions
var modules = {};
var loaded = false;
cssQuery.addModule = function($name, $script) {
        if (loaded) eval("$script=" + String($script));
        modules[$name] = new $script();;
};

// hackery
cssQuery.valueOf = function($code) {
        return $code ? eval($code) : this;
};

// -----------------------------------------------------------------------
// declarations
// -----------------------------------------------------------------------

var selectors = {};
var pseudoClasses = {};
// a safari bug means that these have to be declared here
var AttributeSelector = {match: /\[([\w-]+(\|[\w-]+)?)\s*(\W?=)?\s*([^\]]*)\]/};
var attributeSelectors = [];

// -----------------------------------------------------------------------
// selectors
// -----------------------------------------------------------------------

// descendant selector
selectors[" "] = function($results, $from, $tagName, $namespace) {
        // loop through current selection
        var $element, i, j;
        for (i = 0; i < $from.length; i++) {
                // get descendants
                var $subset = getElementsByTagName($from[i], $tagName, $namespace);
                // loop through descendants and add to results selection
                for (j = 0; ($element = $subset[j]); j++) {
                        if (thisElement($element) && compareNamespace($element, $namespace))
                                $results.push($element);
                }
        }
};

// ID selector
selectors["#"] = function($results, $from, $id) {
        // loop through current selection and check ID
        var $element, j;
        for (j = 0; ($element = $from[j]); j++) if ($element.id == $id) $results.push($element);
};

// class selector
selectors["."] = function($results, $from, $className) {
        // create a RegExp version of the class
        $className = new RegExp("(^|\\s)" + $className + "(\\s|$)");
        // loop through current selection and check class
        var $element, i;
        for (i = 0; ($element = $from[i]); i++)
                if ($className.test($element.className)) $results.push($element);
};

// pseudo-class selector
selectors[":"] = function($results, $from, $pseudoClass, $arguments) {
        // retrieve the cssQuery pseudo-class function
        var $test = pseudoClasses[$pseudoClass], $element, i;
        // loop through current selection and apply pseudo-class filter
        if ($test) for (i = 0; ($element = $from[i]); i++)
                // if the cssQuery pseudo-class function returns "true" add the element
                if ($test($element, $arguments)) $results.push($element);
};

// -----------------------------------------------------------------------
// pseudo-classes
// -----------------------------------------------------------------------

pseudoClasses["link"] = function($element) {
        var $document = getDocument($element);
        if ($document.links) for (var i = 0; i < $document.links.length; i++) {
                if ($document.links[i] == $element) return true;
        }
};

pseudoClasses["visited"] = function($element) {
        // can't do this without jiggery-pokery
};

// -----------------------------------------------------------------------
// DOM traversal
// -----------------------------------------------------------------------

// IE5/6 includes comments (LOL) in it's elements collections.
// so we have to check for this. the test is tagName != "!". LOL (again).
var thisElement = function($element) {
        return ($element && $element.nodeType == 1 && $element.tagName != "!") ? $element : null;
};

// return the previous element to the supplied element
//  previousSibling is not good enough as it might return a text or comment node
var previousElementSibling = function($element) {
        while ($element && ($element = $element.previousSibling) && !thisElement($element)) continue;
        return $element;
};

// return the next element to the supplied element
var nextElementSibling = function($element) {
        while ($element && ($element = $element.nextSibling) && !thisElement($element)) continue;
        return $element;
};

// return the first child ELEMENT of an element
//  NOT the first child node (though they may be the same thing)
var firstElementChild = function($element) {
        return thisElement($element.firstChild) || nextElementSibling($element.firstChild);
};

var lastElementChild = function($element) {
        return thisElement($element.lastChild) || previousElementSibling($element.lastChild);
};

// return child elements of an element (not child nodes)
var childElements = function($element) {
        var $childElements = [];
        $element = firstElementChild($element);
        while ($element) {
                $childElements.push($element);
                $element = nextElementSibling($element);
        }
        return $childElements;
};

// -----------------------------------------------------------------------
// browser compatibility
// -----------------------------------------------------------------------

// all of the functions in this section can be overwritten. the default
//  configuration is for IE. The functions below reflect this. standard
//  methods are included in a separate module. It would probably be better
//  the other way round of course but this makes it easier to keep IE7 trim.

var isMSIE = true;

var isXML = function($element) {
        var $document = getDocument($element);
        return (typeof $document.mimeType == "unknown") ?
                /\.xml$/i.test($document.URL) :
                Boolean($document.mimeType == "XML Document");
};

// return the element's containing document
var getDocument = function($element) {
        return $element.ownerDocument || $element.document;
};

var getElementsByTagName = function($element, $tagName) {
        return ($tagName == "*" && $element.all) ? $element.all : $element.getElementsByTagName($tagName);
};

var compareTagName = function($element, $tagName, $namespace) {
        if ($tagName == "*") return thisElement($element);
        if (!compareNamespace($element, $namespace)) return false;
        if (!isXML($element)) $tagName = $tagName.toUpperCase();
        return $element.tagName == $tagName;
};

var compareNamespace = function($element, $namespace) {
        return !$namespace || ($namespace == "*") || ($element.scopeName == $namespace);
};

var getTextContent = function($element) {
        return $element.innerText;
};

function _msie_selectById($results, $from, id) {
        var $match, i, j;
        for (i = 0; i < $from.length; i++) {
                if ($match = $from[i].all.item(id)) {
                        if ($match.id == id) $results.push($match);
                        else if ($match.length != null) {
                                for (j = 0; j < $match.length; j++) {
                                        if ($match[j].id == id) $results.push($match[j]);
                                }
                        }
                }
        }
        return $results;
};

// for IE5.0
if (![].push) Array.prototype.push = function() {
        for (var i = 0; i < arguments.length; i++) {
                this[this.length] = arguments[i];
        }
        return this.length;
};

// -----------------------------------------------------------------------
// query support
// -----------------------------------------------------------------------

// select a set of matching elements.
// "from" is an array of elements.
// "token" is a character representing the type of filter
//  e.g. ">" means child selector
// "filter" represents the tag name, id or class name that is being selected
// the function returns an array of matching elements
var $NAMESPACE = /\|/;
function select($$from, $token, $filter, $arguments) {
        if ($NAMESPACE.test($filter)) {
                $filter = $filter.split($NAMESPACE);
                $arguments = $filter[0];
                $filter = $filter[1];
        }
        var $results = [];
        if (selectors[$token]) {
                selectors[$token]($results, $$from, $filter, $arguments);
        }
        return $results;
};

// -----------------------------------------------------------------------
// parsing
// -----------------------------------------------------------------------

// convert css selectors to a stream of tokens and filters
//  it's not a real stream. it's just an array of strings.
var $STANDARD_SELECT = /^[^\s>+~]/;
var $$STREAM = /[\s#.:>+~()@]|[^\s#.:>+~()@]+/g;
function _toStream($selector) {
        if ($STANDARD_SELECT.test($selector)) $selector = " " + $selector;
        return $selector.match($$STREAM) || [];
};

var $WHITESPACE = /\s*([\s>+~(),]|^|$)\s*/g;
var $IMPLIED_ALL = /([\s>+~,]|[^(]\+|^)([#.:@])/g;
var parseSelector = function($selector) {
        return $selector
        // trim whitespace
        .replace($WHITESPACE, "$1")
        // e.g. ".class1" --> "*.class1"
        .replace($IMPLIED_ALL, "$1*$2");
};

var Quote = {
        toString: function() {return "'"},
        match: /^('[^']*')|("[^"]*")$/,
        test: function($string) {
                return this.match.test($string);
        },
        add: function($string) {
                return this.test($string) ? $string : this + $string + this;
        },
        remove: function($string) {
                return this.test($string) ? $string.slice(1, -1) : $string;
        }
};

var getText = function($text) {
        return Quote.remove($text);
};

var $ESCAPE = /([\/()[\]?{}|*+-])/g;
function regEscape($string) {
        return $string.replace($ESCAPE, "\\$1");
};

// -----------------------------------------------------------------------
// modules
// -----------------------------------------------------------------------

// -------- >>      insert modules here for packaging       << -------- \\


// -------- >>      level2 added by ruzee                   << -------- \\

// -----------------------------------------------------------------------
// selectors
// -----------------------------------------------------------------------

// child selector
selectors[">"] = function($results, $from, $tagName, $namespace) {
        var $element, i, j;
        for (i = 0; i < $from.length; i++) {
                var $subset = childElements($from[i]);
                for (j = 0; ($element = $subset[j]); j++)
                        if (compareTagName($element, $tagName, $namespace))
                                $results.push($element);
        }
};

// sibling selector
selectors["+"] = function($results, $from, $tagName, $namespace) {
        for (var i = 0; i < $from.length; i++) {
                var $element = nextElementSibling($from[i]);
                if ($element && compareTagName($element, $tagName, $namespace))
                        $results.push($element);
        }
};

// attribute selector
selectors["@"] = function($results, $from, $attributeSelectorID) {
        var $test = attributeSelectors[$attributeSelectorID].test;
        var $element, i;
        for (i = 0; ($element = $from[i]); i++)
                if ($test($element)) $results.push($element);
};

// -----------------------------------------------------------------------
// pseudo-classes
// -----------------------------------------------------------------------

pseudoClasses["first-child"] = function($element) {
        return !previousElementSibling($element);
};

pseudoClasses["lang"] = function($element, $code) {
        $code = new RegExp("^" + $code, "i");
        while ($element && !$element.getAttribute("lang")) $element = $element.parentNode;
        return $element && $code.test($element.getAttribute("lang"));
};

// -----------------------------------------------------------------------
//  attribute selectors
// -----------------------------------------------------------------------

// constants
AttributeSelector.NS_IE = /\\:/g;
AttributeSelector.PREFIX = "@";
// properties
AttributeSelector.tests = {};
// methods
AttributeSelector.replace = function($match, $attribute, $namespace, $compare, $value) {
        var $key = this.PREFIX + $match;
        if (!attributeSelectors[$key]) {
                $attribute = this.create($attribute, $compare || "", $value || "");
                // store the selector
                attributeSelectors[$key] = $attribute;
                attributeSelectors.push($attribute);
        }
        return attributeSelectors[$key].id;
};
AttributeSelector.parse = function($selector) {
        $selector = $selector.replace(this.NS_IE, "|");
        var $match;
        while ($match = $selector.match(this.match)) {
                var $replace = this.replace($match[0], $match[1], $match[2], $match[3], $match[4]);
                $selector = $selector.replace(this.match, $replace);
        }
        return $selector;
};
AttributeSelector.create = function($propertyName, $test, $value) {
        var $attributeSelector = {};
        $attributeSelector.id = this.PREFIX + attributeSelectors.length;
        $attributeSelector.name = $propertyName;
        $test = this.tests[$test];
        $test = $test ? $test(this.getAttribute($propertyName), getText($value)) : false;
        $attributeSelector.test = new Function("e", "return " + $test);
        return $attributeSelector;
};
AttributeSelector.getAttribute = function($name) {
        switch ($name.toLowerCase()) {
                case "id":
                        return "e.id";
                case "class":
                        return "e.className";
                case "for":
                        return "e.htmlFor";
                case "href":
                        if (isMSIE) {
                                // IE always returns the full path not the fragment in the href attribute
                                //  so we RegExp it out of outerHTML. Opera does the same thing but there
                                //  is no way to get the original attribute.
                                return "String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')";
                        }
        }
        return "e.getAttribute('" + $name.replace($NAMESPACE, ":") + "')";
};

// -----------------------------------------------------------------------
//  attribute selector tests
// -----------------------------------------------------------------------

AttributeSelector.tests[""] = function($attribute) {
        return $attribute;
};

AttributeSelector.tests["="] = function($attribute, $value) {
        return $attribute + "==" + Quote.add($value);
};

AttributeSelector.tests["~="] = function($attribute, $value) {
        return "/(^| )" + regEscape($value) + "( |$)/.test(" + $attribute + ")";
};

AttributeSelector.tests["|="] = function($attribute, $value) {
        return "/^" + regEscape($value) + "(-|$)/.test(" + $attribute + ")";
};

// -----------------------------------------------------------------------
//  parsing
// -----------------------------------------------------------------------

// override parseSelector to parse out attribute selectors
var _parseSelector = parseSelector;
parseSelector = function($selector) {
        return _parseSelector(AttributeSelector.parse($selector));
};


// -------- >>      standard added by ruzee                 << -------- \\

// -----------------------------------------------------------------------
// browser compatibility
// -----------------------------------------------------------------------

// sniff for Win32 Explorer
isMSIE = eval("false;/*@cc_on@if(@\x5fwin32)isMSIE=true@end@*/");

if (!isMSIE) {
        getElementsByTagName = function($element, $tagName, $namespace) {
                return $namespace ? $element.getElementsByTagNameNS("*", $tagName) :
                        $element.getElementsByTagName($tagName);
        };

        compareNamespace = function($element, $namespace) {
                return !$namespace || ($namespace == "*") || ($element.prefix == $namespace);
        };

        isXML = document.contentType ? function($element) {
                return /xml/i.test(getDocument($element).contentType);
        } : function($element) {
                return getDocument($element).documentElement.tagName != "HTML";
        };

        getTextContent = function($element) {
                // mozilla || opera || other
                return $element.textContent || $element.innerText || _getTextContent($element);
        };

        function _getTextContent($element) {
                var $textContent = "", $node, i;
                for (i = 0; ($node = $element.childNodes[i]); i++) {
                        switch ($node.nodeType) {
                                case 11: // document fragment
                                case 1: $textContent += _getTextContent($node); break;
                                case 3: $textContent += $node.nodeValue; break;
                        }
                }
                return $textContent;
        };
}

loaded = true;

// -----------------------------------------------------------------------
// return the query function
// -----------------------------------------------------------------------

return cssQuery;

}(); // cssQuery


/**
 * RUZEE.Borders 0.16.1
 * (c) 2006 Steffen Rusitschka <steffen@rusitschka.de>
 *
 * RUZEE.Borders is freely distributable under the terms of an MIT-style license.
 * For details, see http://www.ruzee.com/
 */

var RUZEE=window.RUZEE||{};
RUZEE.userAgent=navigator.userAgent.toLowerCase();
RUZEE.isIE=typeof window.RUZEE.isIE != 'undefined'
  ?window.RUZEE.isIE
  :RUZEE.userAgent.indexOf('msie')>=0
    && RUZEE.userAgent.indexOf('opera')==-1;

RUZEE.Borders={

  /**
   * Set to false to not draw the borders automatically on
   * domload when RUZEE.Events are available.
   */
  autoRender:true,

  /** Add mapping rules to be executed on render(). */
  add:function(mappings){
    for(rule in mappings){
      var rules=rule.split(',');
      for(var i=0; i<rules.length; ++i){
        var r=rules[i].replace(/^\s+|\s+$/,'');
        var ms=RUZEE.Borders.mappings[r]||{};
        for (m in mappings[rule]) ms[m]=mappings[rule][m];
        RUZEE.Borders.mappings[r]=ms;
      }
    }
  },

  /**
   * Render all added mapping rules into the DOM
   * If RUZEE.Events is not available, this method MUST be called in the
   * window.onload method (or with a similar technique)!
   * Note: Since v0.12, this method is asynchronous! If you need to do
   * stuff AFTER the rendering finished, do it inside the function you passed
   * in via the onfinished parameter.
   */
  render:function(onfinished){
    if(onfinished) RUZEE.Borders.onfinished=onfinished;
    var start=new Date().getTime();
    for(rule in RUZEE.Borders.mappings){
      var e=RUZEE.Borders.cssQuery(rule);
      var b=new RUZEE.Borders.Border(RUZEE.Borders.mappings[rule]);
      delete RUZEE.Borders.mappings[rule];
      b.calc(e);
      // if we are rendering for more than 3 seconds, give Firefox some time to get
      // rid of the "unresponsive script" message.
      if(new Date().getTime()-start>3000){
        setTimeout('RUZEE.Borders.render()',0);
        return;
      }
    }
    RUZEE.Borders.renderCalcs();
    if(RUZEE.Borders.onfinished) RUZEE.Borders.onfinished();
  },

  // ---- internal fields and methods ----

  /** the mappings: 'CSS rule' -> Border */
  mappings:{},

  /** The corner cache */
  cache:{},

  /** The completed calulations to render */
  calcs:[],

  /** if Dean Edward's cssQuery is available, use it */
  cssQuery:function(s){
    var c=s.charAt(0);
    if(c=='#'&&!(/\s/.test(s))) return [ document.getElementById(s.substr(1)) ];
    if(window.cssQuery) return window.cssQuery(s);

    alert("Don't know what to do with '"+s+"' Did you forget to include cssquery?");
    return [];
  },

  /** Add a completed calculation */
  addCalc:function(calc){
    RUZEE.Borders.calcs.push(calc);
  },

  renderCalcs:function(){
    for(var i=0; i<RUZEE.Borders.calcs.length; ++i){
      RUZEE.Borders.calcs[i]();
    }
    RUZEE.Borders.calcs=[];
  }
};

/** The Border class */
RUZEE.Borders.Border=function(d){
  var t=this;

  var _cornerRadius,_shadowRadius,_shadowPadding,_shadowShift,_coShadowS,
      _coBgIn,_coBorder,_coBgOut,
      _imgBgInURL,_imgBgInRepeat,_isL,_isR,_isT,_isB,_imgBgInURL,
      _cacheID,_psT,_psB,_wBorder,_height;

  /** Set the background image for element e to position x,y */
  var setBgImg=function(e,x,y){
    if(!_imgBgInURL) return;
    e.style.backgroundImage=_imgBgInURL;
    x=-x;y=-y;
    e.style.backgroundPosition=x+'px '+y+'px';
    if(_imgBgInRepeat) e.style.backgroundRepeat=_imgBgInRepeat;
  };

  /** Create a DIV with width w, height h, background color bg, overflow o */
  var crDiv=function(w,h,bg,o){
    var d=RUZEE.isXHTML
      ?document.createElementNS('http://www.w3.org/1999/xhtml','div')
      :document.createElement('div');
    d.style.padding=d.style.margin='0px';
    d.style.border='none';
    d.style.width=w?w:'auto';
    if(h) { d.style.height=h; d.style.fontSize="0"; d.style.lineHeight="0px"; }
    if(!bg) bg='transparent';
    d.style.background=bg;
    if(o) d.style.overflow=o;
    return d;
  };

  /** Create wrapper DIV around element c */
  var addLR=function(c,co,w,h,bgx,bgy){
    var e=crDiv(null,h,co);
    if(typeof bgx!='undefined') setBgImg(e,bgx,bgy);
    if(!w) w='1px';
    c.style.margin='0px '+(_isR?w:'0px')+' 0px '+(_isL?w:'0px');
    e.appendChild(c);
    return e;
  };

  /** Create the top (top==true) or bottom (top==false) of the border */
  var crTB=function(top){
    var ca=RUZEE.Borders.cache[_cacheID+'.'+top];
    if(ca){
      if(top){
        _psT=ca.ps;
      }else{
        _psB=ca.ps;
      }
      return ca.el.cloneNode(true);
    }
    var sh=top?-_shadowShift:_shadowShift;
    var cxc=_shadowPadding-_cornerRadius-1;
    var cxb=cxc;
    var cxe=cxc+_cornerRadius;
    var exb=0;
    var exe=cxc-1;
    var syc=_cornerRadius-_shadowPadding+sh+1;
    var yb,ye;
    var cwb=_wBorder;
    if(cwb==0) cwb=1;

    if(top){
      if(!_isT){
        _psT=1;
        return crDiv(null,'1px');
      }
      yb=syc+_shadowRadius-1;
      ye=cwb>_shadowRadius?syc+_shadowRadius-cwb-1:syc-1;
      yi=-1;
      _psT=yb-ye;
    }else{
      if(!_isB) {
        _psB=1;
        return crDiv(null,'1px');;
      }
      yb=cwb>_shadowRadius?syc+_shadowRadius-cwb:syc;
      yb=yb<0?yb:0;
      ye=syc+_shadowRadius;
      yi=1;
      _psB=ye-yb;
    }

    var e=crDiv(null, Math.abs(yb-ye)+'px',null,'hidden');
    for(var y=yb; y!=ye; y+=yi){
      var co;
      if(y<=_cornerRadius-cwb){
        co=_coBgIn;
      }else if(y<=_cornerRadius){
        co=_coBorder;
      }else if(y-syc<0){
        co=_coShadow;
      }else{
        co=rzBlend(_coShadow,_coBgOut,(y-syc)/_shadowRadius);
      }
      var line=crDiv(null,'1px',rzC2S(co),'hidden');
      var fstLine=line;
      var xbg=null;
      for(var x=0; x<_shadowRadius; ++x){
        var isIn=false, doBgImg=false;
        var sd, out=0;
        if(y<syc){
          sd=x;
        }else{
          sd=Math.sqrt(Math.sqr(x)+Math.sqr(y-syc));
        }
        if(_shadowRadius>_cornerRadius && sd<=_shadowRadius){
          co=rzBlend(_coShadow, _coBgOut, sd/_shadowRadius);
        }else{
          co=_coBgOut;
          out++;
        }
        if(y<=_cornerRadius){
          if(x>=exb && x<=exe){
            if(y>_cornerRadius-cwb){
              co=_coBorder;
            }else{
              isIn=true;
            }
          }else if(x>=cxb && x<=cxe){
            var cd=Math.sqrt(Math.sqr(x-cxc)+Math.sqr(y))-_cornerRadius;
            if(y<0){
              if(x-cxc>_cornerRadius-_wBorder){
                co=_coBorder;
              }else{ 
                isIn=true;
              }
            }else if(cd<-cwb){
              isIn=true;
            }else if(cd<-cwb+1){
              // first on border! do bgimg
/*              if(top&&_imgBgInURL){
                setBgImg=true;
              }else*/
                co=rzBlend(_coBgIn,_coBorder,cd+cwb);
            }else if(cd<0){
              co=_coBorder;
            }else if(cd<=1){
              co=rzBlend(_coBorder,co,cd);
            }else{
              out++;
            }
          }
        }else{
          out++;
        }
        if(!isIn&&line==fstLine&&y<=_cornerRadius-cwb&&top){
          setBgImg(fstLine,_shadowRadius-x,yb-y);
        }
        if(out>1){
          line=addLR(line,'transparent',(_shadowRadius-x)+'px');
          x=_shadowRadius; // done
        }else{
          if(!isIn){
            // fix a strange IE bug where the 12ths recursion seems to get lost...
            if(RUZEE.isIE&&x==_shadowRadius-12) line=addLR(line);
            line=addLR(line,rzC2S(co));
          }
          if(doBgImg) setBgImg(line,_shadowRadius-x,yb-y+1);
        }
      }
      e.appendChild(line);
    }
    var ce={ el:e, ps:top?_psT:_psB };
    RUZEE.Borders.cache[_cacheID+'.'+top]=ce;
    return e;
  };

  /** Create the left and right of the border */
  var crLR=function(e){
    var coBgInS=rzC2S(_coBgIn);
    var coBS=rzC2S(_coBorder);
    e.style.position='relative';
    if(_wBorder>0) e=addLR(e,coBS,_wBorder+'px');
    e.style.position='relative';
    for(var x=_shadowPadding; x<_shadowRadius; ++x){
      coS=rzC2S(rzBlend(_coShadow,_coBgOut,x/_shadowRadius));
      e=addLR(e,coS);
      e.style.position='relative';
    }
    return e;
  };

  var setEdges=function(ed){
    ed=ed?ed.toLowerCase():'lrtb';
    _isL=ed.indexOf('l')>=0;
    _isR=ed.indexOf('r')>=0;
    _isT=ed.indexOf('t')>=0;
    _isB=ed.indexOf('b')>=0;
  };

  /** Calculate the border around e */
  var calcP=function(e){
    RUZEE.isXHTML=typeof window.RUZEE.isXHTML != 'undefined'
      ?window.RUZEE.isXHTML
      :(/html\:/.test(document.getElementsByTagName('body')[0].nodeName));

    if(!e) return;
    if(e.constructor==Array){
      for(var i=0; i<e.length; ++i) calcP(e[i]);
      return;
    }

    // Get the bg image
    _imgBgInURL=rzGetStyle(e,'background-image');
    if(_imgBgInURL&&_imgBgInURL=='none') _imgBgInURL=null;
    if(_imgBgInURL){
      _imgBgInRepeat=rzGetStyle(e,'background-repeat');
    }
    _coBgIn=rzS2C(rzGetBg(e));
    _coBgOut=rzS2C(rzGetBg(e.parentNode));
    var borderCSS='border-'+(_isT?'top-':'bottom-');
    var bs=rzGetStyle(e,borderCSS+'style','none');
    if(bs && bs!='' && bs!='none' && bs!='hidden'){
      _coBorder=rzS2C(rzGetStyle(e,borderCSS+'color','black'));
      _wBorder=rzPX2I(rzGetStyle(e,borderCSS+'width','1px'));
    }else{
      _coBorder=_coBgIn;
      _wBorder=0;
    }
    _coShadow=_coShadowS=='.fade'?_coBorder:rzS2C(_coShadowS);

    _cacheID=
      rzC2S(_coBgIn)+'.'+rzC2S(_coBgOut)+'.'+
      rzC2S(_coBorder)+'.'+rzC2S(_coShadow)+'.'+
      _wBorder+'.'+_isL+_isR+_isT+_isB+'.'+
      _cornerRadius+'.'+_shadowRadius+'.'+
      _shadowPadding+'.'+this.shadowShift+'.'+
      _imgBgInURL+'.'+_imgBgInRepeat;

    var eb=crDiv(); // e border (2nd!)
    var elOb=crDiv(); // out border
    var elO=crDiv(); // out
    var elI=crDiv(); // in
    var elCw=crDiv(); // content wrapper
    var elCb=crDiv(); // content border
    var elC=crDiv(); // content

    eb.style.position=elC.style.position=elCw.style.position='relative';
    elC.style.zIndex=2; // Konq fix

    eb.appendChild(elOb);
    elOb.appendChild(crDiv(null,'1px')); // filler div (1)
    elOb.appendChild(elO);
    elOb.appendChild(crDiv(null,'1px')); // filler div (2)
    elI.appendChild(elCw);
    elCw.appendChild(elCb);
    elCb.appendChild(elC);

    elO.appendChild(crTB(true));
    var elTB=crLR(elI);
    elO.appendChild(elTB);
    elO.appendChild(crTB(false));
    var psLR=_shadowRadius-_shadowPadding+_wBorder;
    var psL=_isL?psLR:0;
    var psR=_isR?psLR:0;
    var isTB=_isT&&_isB;
    var psT=_psT;
    var psB=_psB;

    var bgImgY=_psT;
    setBgImg(elI,psL,bgImgY);
    elI.style.backgroundColor=rzC2S(_coBgIn);

    // work around for other browsers for sebs problem TODO:check it's working
    // add clearer DIVs
    var end=crDiv('1px','1px');
    elI.insertBefore(end,elCw);
    elI.appendChild(end.cloneNode(true));
    psT++; psB++;

    if(_height){
      elC.style.height=_height+'px';
    }
    var update=function(l,ps){
      var padL='padding-'+l; var padCC=rzCC(padL);
      var marL='margin-'+l; var marCC=rzCC(marL);
      var borL='border-'+l+'-width'; var borCC=rzCC(borL);

      var pad=rzGetStyle(e,padL);
      var borPx=rzPX2I(rzGetStyle(e,borL));
      var borPxNeg=(l=='top'||l=='bottom')?-borPx-1:-borPx; // -1 because of filler div (1) and (2)
      if(!_isB && l=='bottom') borPx-=2; // why???
      if(!_isT && l=='top') borPx-=2; // why???

      eb.style[marCC]=borPx+'px';
      elO.style[marCC]='-'+pad;
      elOb.style[marCC]=borPxNeg+'px';
      elCw.style[marCC]=(-ps)+'px';
      elC.style[marCC]=pad;
      elCb.style[marCC]=borPx+'px';

      return function(){
        // IE quirks... why oh why?
        if(RUZEE.isIE){
           if(l=='top') elOb.style[marCC]='-1px'; // remove top border
           if(l=='bottom') e.style[padCC]='1px'; // reduce bottom padding
        }
      };
    };

    var funcs=[update('top',psT),update('bottom',psB),
               update('left',psL),update('right',psR)];
    RUZEE.Borders.addCalc(function(){
      for(var i=0; i<funcs.length; ++i) funcs[i]();
      e.style.border='none';
      e.style.background='transparent';
      e.style.backgroundImage='none';
      if(RUZEE.isIE){
        e.style.height='1%';
      }
      e.style.position='relative';
      e.appendChild(eb);
      while (e.childNodes.length>1){
        elC.appendChild(e.removeChild(e.childNodes[0]));
      }
    });
  };

  var pub={
    init:function(d){
      var rad=d.cornerRadius||8;
      _height=d.height||0;
      _shadowShift=0;
      setEdges(d.edges||'lrtb');
      switch(d.borderType){
        case 'simple':
          _cornerRadius=_shadowRadius=_shadowPadding=rad;
          _coShadowS='000';
          break;
        case 'shadow':
          var sw=d.shadowWidth||8;
          _cornerRadius=rad;
          _shadowRadius=rad+sw*2;
          _shadowPadding=rad+sw;
          _shadowShift=Math.round(sw/2);
          _coShadowS=d.shadowColor||'000';
          break;
        case 'fade':
          _cornerRadius=_shadowPadding=1;
          _shadowRadius=rad;
          _coShadowS='.fade';
          break;
        case 'glow':
          _cornerRadius=_shadowPadding=rad;
          _shadowRadius=rad+(d.glowWidth||rad);
          _coShadowS=d.glowColor||'fff';
          break;
        default:
          alert('Unknown borderType: '+d.borderType);
      }
    },

    calc:calcP,

    /** Render the border around e */
    render:function(e){
      t.calc(e);
      RUZEE.Borders.renderCalcs();
    },

    // DEPRECATED STUFF - WILL BE REMOVED IN ONE OF THE NEXT RELEASES!
    draw:function(e,edges){
      setEdges(edges?edges.toLowerCase():'lrtb');
      if(typeof e=='string'){
        if(e.charAt(0)!='.') e='#'+e;
        e=RUZEE.Borders.cssQuery(e);
      }
      t.render(e);
    }
  };

  pub.init(d);
  delete pub.init;
  for(m in pub) t[m]=pub[m];
}; // of Border class

// add an event handler for render() if RUZEE.Events are available
if(RUZEE.Events){
  RUZEE.Events.add(window,'domload',function(){
    if(RUZEE.Borders.autoRender) RUZEE.Borders.render();
  });
}

// internal tools

Math.sqr=function(x){
  return x*x;
};

function rzCC(s){
  for(var exp=/-([a-z])/; exp.test(s); s=s.replace(exp,RegExp.$1.toUpperCase()));
  return s;
};

function rzGetStyle(e,a,d){
  if(e==null) return d;
  var v=null;
  if(document.defaultView && document.defaultView.getComputedStyle){
    var cs=document.defaultView.getComputedStyle(e,null);
    if(cs && cs.getPropertyValue) v=cs.getPropertyValue(a);
  }
  if(!v && e.currentStyle) v=e.currentStyle[rzCC(a)];
  return v?v:d?d:null;
};

function rzGetBg(e){
  var v=rzGetStyle(e,'background-color');
  // KHTML bug fix: transparent is #000000 - if you want black, use #010101 in your CSS.
  // Safari work around: transparent is 'rgba(0, 0, 0, 0)'
  while (!v || v=='transparent' || v=='#000000' || v=='rgba(0, 0, 0, 0)'){
    if(e==document.body) v='fff'; else {
      e=e.parentNode;
      v=rzGetStyle(e,'background-color');
    }
  }
  return v;
};

function rzPX2I(px){
  if(!px) return 0;
  var p=/\s*(\d\d*)px/.exec(px);
  if(p) return parseInt(p[1]);
  return 0;
};

function rzS2C(s,d){
    if (!s) return d?rzS2C(d):[0,0,0,0];
    if (s.charAt(0)=='#') s=s.substr(1,6);
    s=s.replace(/ /g,'').toLowerCase();
    // The CSS 2.1 colors
    var COLORS = {
         aqua:'00ffff', black:'000000', blue:'0000ff', fuchsia:'ff00ff',
         gray:'808080', green:'008000', lime:'00ff00', maroon:'800000',
         navy:'000080', olive:'808000', orange:'ffa500', purple:'800080',
         red:'ff0000', silver:'c0c0c0', teal:'008080', white:'ffffff',
         yellow:'ffff00'
    };
    for (var key in COLORS) if (s==key) s=COLORS[key];

    var p=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s);
    if(p) return [parseInt(p[1]),parseInt(p[2]),parseInt(p[3]),parseInt(p[4])];
    var p=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s);
    if(p) return [parseInt(p[1]),parseInt(p[2]),parseInt(p[3]),255];
    p=/^(\w{2})(\w{2})(\w{2})$/.exec(s);
    if(p) return [parseInt(p[1],16),parseInt(p[2],16),parseInt(p[3],16),255];
    p=/^(\w{1})(\w{1})(\w{1})$/.exec(s);
    if(p) return [parseInt(p[1]+p[1],16),parseInt(p[2]+p[2],16),parseInt(p[3]+p[3],16),255];
    return d?rzS2C(d):[0,0,0,0];
};

function rzC2S(c){
  if(typeof c=='string') return c;
  r='0'+c[0].toString(16);
  g='0'+c[1].toString(16);
  b='0'+c[2].toString(16);
  return '#'
    +r.substring(r.length-2)
    +g.substring(g.length-2)
    +b.substring(b.length-2);
};

function rzBlend(a,b,w){
  return Array(
    Math.round(a[0]+(b[0]-a[0])*w),
    Math.round(a[1]+(b[1]-a[1])*w),
    Math.round(a[2]+(b[2]-a[2])*w),
    Math.round(a[3]+(b[3]-a[3])*w));
};

// DEPRECATED STUFF - WILL BE REMOVED IN ONE OF THE NEXT RELEASES!
function rzCrSimpleBorder(rad){
  return new RUZEE.Borders.Border({ borderType:'simple', cornerRadius:rad });
};

function rzCrShadowBorder(rad,smar,coShadowS){
  return new RUZEE.Borders.Border({
    borderType:'shadow', cornerRadius:rad, shadowWidth:smar, shadowColor:coShadowS });
};

function rzCrFadeBorder(rad){
  return new RUZEE.Borders.Border({ borderType:'fade', cornerRadius:rad });
};

function rzCrGlowBorder(rad,gmar,coGlowS){
  return new RUZEE.Borders.Border({ borderType:'glow', cornerRadius:rad, glowWidth:gmar, glowColor:coGlowS });
};

		window.onload=RUZEE.Borders.render;



