/*	sIFR (Scalable Inman Flash Replacement) Version 2.0 Release Candidate 3
	Copyright 2004 Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben

	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"\> \n');
    document.write('on error resume next \n');
    document.write('hasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n');
    document.write('</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;
    var c=parseInt(b.charAt(b.indexOf(".")-1));
    return c>=a;
  };
  
  return false;
}();

String.prototype.normalize=function(){
  return this.replace(/\s+/g," ");
};

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

if(!Function.prototype.apply){
  Function.prototype.apply=function(d,e){
    var a=[];var b,c;if(!d)d=window;if(!e)e=[];
    for (var i=0;i<e.length;i++){
      a[i]="e["+i+"]";
    };
    c="d.__applyTemp__("+a.join(",")+");";
    d.__applyTemp__=this;
    b=eval(c);d.__applyTemp__=null;
    return b;
    };
  };

var parseSelector=function(){
  var a=/^([^#\.>\`]*)(#|\.|\>|\`)(.+)$/;
  
  function parseSelector(b,c,d){
  b=b.replace(" ","`");
  var e=b.match(a);
  var f,g,h,j;
  var k=[];
  if(e==null){e=[b,b]};
  if(e[1]==""){e[1]="*"};
  if(d==null){d="`"};
  if(c==null&&(e[2]==null||e[2]!=">")){c=document;};switch(e[2]){
    case "#":
      j=e[3].match(a);
      if(j==null){j=[null,e[3]]};
      f=document.getElementById(j[1]);
      if(f==null||(e[1]!="*"&&f.nodeName.toLowerCase()!=e[1].toLowerCase())){return k;};
      if(j.length==2){k.push(f);return k;};
      return parseSelector(j[3],f,"#");
    case ".":
      if(d=="`"){
        g=l(c,e[1]);
      } else {
        g=c.childNodes;
        };
      for(var i=0;i<g.length;i++){
        f=g[i];
        if(f.nodeType!=1){
          continue;
        };
        j=e[3].match(a);
        if(j!=null){
          if (f.className.match("\\b"+j[1]+"\\b")==null){
            continue;
          };
          h=parseSelector(j[3],f,j[2]);
          k=k.concat(h);
        } else if( f.className.match("\\b"+e[3]+"\\b")!=null){
          k.push(f);
        };
      };
      return k;
    case ">":
      if(d=="`"){
        g=l(c,e[1]);
      }else {
        g=c.childNodes;
      };
      for(var i=0;i<g.length;i++){
        f=g[i];
        if (f.nodeType!=1){
          continue;
        };
        if(f.nodeName.toLowerCase()!=e[1].toLowerCase()){
          continue;
          };
        h=parseSelector(e[3],f,">");
        k=k.concat(h);
      };
      return k;
    case "`":g=l(c,e[1]);for(var i=0;i<g.length;i++){f=g[i];h=parseSelector(e[3],f,"`");k=k.concat(h);};return k;default:g=l(c,e[0]);for(var i=0;i<g.length;i++){k.push(g[i]);};return k;
    };
  };
  function l(c,m){if(m=="*"&&c.all!=null){return c.all;};return c.getElementsByTagName(m);};
  return parseSelector;
}();

function named(oArgs){
  return new named.Arguments(oArgs);
};


named.Arguments=function named_Arguments(oArgs){
  this.oArgs=oArgs;
};

named.Arguments.prototype.constructor=named.Arguments;
named.extract=function named_extract(a,b){
  var c,d;
  for(var i=0;i<a.length;i++){
    d=a[i];
    if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){
      c=a[i].oArgs;
      break;
    };
  };
  if(c==null){
    return
    };
  for(var e in c){
    if(b[e]!=null){
      b[e](c[e]);
    };
  };
  return;
};

var sIFR=function(){
    if(window.hasFlash==false||!document.createElement||!document.getElementById){
      return false;
    };
    
  var a="http://www.w3.org/1999/xhtml";
  var b=false;
  var c=false;
  var d=[];
  var UA=function(){
    var sUA=navigator.userAgent.toLowerCase();
    var e={bIsWebKit:sUA.indexOf("applewebkit")>-1,bIsKHTML:sUA.indexOf("applewebkit")>-1||sUA.indexOf("konqueror")>-1,bIsOpera:sUA.indexOf("opera")>-1,bIsXML:document.contentType!=null&&document.contentType.indexOf("xml")>-1,bHasTransparentSupport:true};
    e.bIsIE=sUA.indexOf("msie")>-1&&!e.bIsOpera&&!e.bIsKHTML&&!e.bIsGecko;
    e.bIsGecko=!e.bIsKHTML&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";
    if(e.bIsOpera){
      e.nOperaVersion=new Number(sUA.match(/.*opera(\s|\/)(\d+\.\d+)/)[2])
    };
    if(e.bIsGecko){
      e.nGeckoBuildDate=new Number(sUA.match(/.*gecko\/(\d{8}).*/)[1])
    };
    if(e.bIsWebKit){
      e.nWebKitVersion=new Number(sUA.match(/.*applewebkit\/(\d+).*/)[1])
    };
    if(sUA.match(/.*(windows|mac).*/)==null||(e.bIsOpera==true&&e.nOperaVersion<7.6)||(e.bIsWebKit==true&&e.nWebKitVersion<124)||(e.bIsGecko==true&&e.nGeckoBuildDate<20020523)){
      e.bHasTransparentSupport=false;
    };
    return e;
  }();
  
  function sIFR(e){
    if((!self.bAutoInit&&(window.event||e)!=null)||!f(e)){
      return;
    };
    b=true;
    for(var i=0;i<d.length;i++){
      replaceElement.apply(null,d[i]);
    };
    d=[];
  };
  
  var self=sIFR;
  
  function f(e){
    if(c==false||((UA.bIsXML&&UA.bIsGecko||UA.bIsKHTML)&&e==null&&b==false)||document.getElementsByTagName("body").length==0){
      return false;
    };
    return true;
  };
  
  function g(h,j,k,l,m){
    var n="";
    var o=h.firstChild;
    var p,q,r;
    if(l==null){l=0};
    if(m==null){m=""};
    while(o){
      if(o.nodeType==3){
        switch(k){
          case "lower":
            n+=o.nodeValue.toLowerCase();
            break;
          case "upper":
            n+=o.nodeValue.toUpperCase();
            break;
          default:
            n+=o.nodeValue;};
      } else if (o.nodeType==1){
        if(o.nodeName.toLowerCase()=="a"&&!o.getAttribute("href")==false){
          if(o.getAttribute("target")){
            m+="&sifr_url_"+l+"_target="+o.getAttribute("target");
          };
          m+="&sifr_url_"+l+"="+o.getAttribute("href").replace(/&/g,"%26");n+='<a href="asfunction:_root.launchURL,'+l+'">';
          l++;
        }else if(o.nodeName.toLowerCase()=="br"){
          n+="<br/>";
        };
        if(o.hasChildNodes){
          r=g(o,null,k,l,m);
          n+=r.n;
          l=r.l;
          m=r.m;
        };
        if(o.nodeName.toLowerCase()=="a"){
          n+="</a>";
        };
      };
      p=o;
      o=o.nextSibling;
      if(j!=null){
        q=p.parentNode.removeChild(p);
        j.appendChild(q);
      };
    }; /* while */
    
    return{"n":n,"l":l,"m":m};
  };
  
  function s(t){
    if(document.createElementNS&&!UA.bIsOpera){
      return document.createElementNS(a,t);
    } else{
      return document.createElement(t);
    };
  };
  
  function u(v,w,x){
  var node=s("param");node.setAttribute("name",w);
  node.setAttribute("value",x);v.appendChild(node);
  };
  
  function replaceElement(y,z,aa,ab,ac,ad,ae,af,ag,ah,ai,k,aj){
    if(!f()){
      return d.push(arguments);
    };
    
    named.extract(
      arguments,{
        sSelector:function(value){y=value},
        sFlashSrc:function(value){z=value},
        sColor:function(value){aa=value},
        sLinkColor:function(value){ab=value},
        sHoverColor:function(value){ac=value},
        sBgColor:function(value){ad=value},
        nPaddingTop:function(value){ae=value},
        nPaddingRight:function(value){af=value},
        nPaddingBottom:function(value){ag=value},
        nPaddingLeft:function(value){ah=value},
        sFlashVars:function(value){ai=value},
        sCase:function(value){k=value},
        sWmode:function(value){aj=value}
      }
    );
    
    if(ai!=null){
      ai="&"+ai.normalize();
    }else{
      ai="";
    };
    
    if(ae==null){ae=0};
    if(af==null){af=0};
    if(ag==null){ag=0};
    if(ah==null){ah=0};
    if(aj=="transparent"){
      if(!UA.bHasTransparentSupport){
        aj="opaque";
      }else{
        ad="transparent";
      };
    };
    
    if(aj==null){aj=""};
    
    var ak,al,am,an,ao,ap,aq,ar;var as=parseSelector(y);
    if(as.length==0){return false};
    for(var i=0;i<as.length;i++){
      ak=as[i];
      if(ak.className.match(/\bsIFR\-replaced\b/)!=null){
        continue;
      };
      al=ak.offsetWidth-ah-af;
      am=ak.offsetHeight-ae-ag;
      ap=s("span");
      ap.className="sIFR-alternate";
      ar=g(ak,ap,k);
      an=ar.n;
      if(UA.bIsIE){
        an=an.replace(new RegExp("%\d{0}","g"),"%25");
      }else{
        an=an.replace(new RegExp("%(?!\d)","g"),"%25");
      };
      an=an.replace(/\+/g,"%2B");
      an=an.replace(/&/g,"%26");
      an=an.replace(/\"/g, "%22");
      an=an.normalize();
      ao="txt="+an+ai+"&w="+al+"&h="+am+ar.m;
      if(aa!=null){ao+="&textcolor="+aa};
      if(ab!=null){ao+="&linkcolor="+ab};
      if(ac!=null){ao+="&hovercolor="+ac};
      ak.className=ak.className.normalize()+(ak.className==""?"":" ")+"sIFR-replaced";
      if(UA.bIsOpera){
        if(UA.nOperaVersion<7.60){
          ak.innerHTML=['<object class="sIFR-flash" type="application/x-shockwave-flash" data="',z,'" quality="best" wmode="',aj,'" bgcolor="',ad,'" flashvars="',ao,'" width="',al,'" height="',am,'"></object>'].join("");
        }else{
          aq=s("object");
          aq.setAttribute("type","application/x-shockwave-flash");
          aq.setAttribute("data",z);
          u(aq,"quality","best");
          u(aq,"wmode",aj);
          u(aq,"bgcolor",ad);
          u(aq,"flashvars",ao);
        };
      }else{
        aq=s("embed");
        aq.setAttribute("src",z);
        aq.setAttribute("quality","best");
        aq.setAttribute("flashvars",ao);
        aq.setAttribute("type","application/x-shockwave-flash");
        aq.setAttribute("wmode",aj);
        aq.setAttribute("bgcolor",ad);
      };
      
      if(!UA.bIsOpera||UA.nOperaVersion>=7.60){
        aq.className="sIFR-flash";
        aq.setAttribute("width",al);
        aq.setAttribute("height",am);
        aq.style.width=al+"px";
        aq.style.height=am+"px";
        ak.appendChild(aq);
      };
      
      ak.appendChild(ap);
      
      if(UA.bIsKHTML||UA.bIsIE){
          ak.innerHTML+="";
        };
    };
  };
  
  function setup(){
    c=true;
    if(document.documentElement){
      document.documentElement.className=document.documentElement.className.normalize()+(document.documentElement.className==""?"":" ")+"sIFR-hasFlash";
    };
    if(window.attachEvent){
      window.attachEvent("onload",sIFR);
    }else if(document.addEventListener||window.addEventListener){
      if(document.addEventListener){
        document.addEventListener("load",sIFR,false);
      };
      if(window.addEventListener){
        window.addEventListener("load",sIFR,false);
      };
   
    } else{
      if(typeof window.onload=="function") {
        var fOld=window.onload;
        window.onload=function(){
          fOld();sIFR();
          };
      } else{ 
        window.onload=sIFR;
      };
    };
  };
  
  self.UA=UA;self.bAutoInit=true;
  self.replaceElement=replaceElement;
  self.setup=setup;
  return self;

}();

if(sIFR != false){
  sIFR.setup();
};
