$(function(){

  // Newsticker
  //$("#header ul").newsticker(6000);

  // Main Source Code
  if(jQuery.browser.msie) jQuery("#source span").html(" ");
  else {
    jQuery('<pre><code class="javascript"/></pre>').hide().appendTo("#source").hide();
    jQuery.ajax({url:"jquery.idTabs.js", dataType: "text", success:function(m){
      jQuery("#source pre code").html( m.replace(/</g,"&lt;").replace(/>/g,"&gt;")).chili();
    }});
    jQuery("#source span").toggle(
      function(){ jQuery("#source pre").slideDown(); },
      function(){ jQuery("#source pre").slideUp(); });
  }

  // Example Source Code
  jQuery(".example").each(function(){
    var str = jQuery(this).find(">div").html()
      .replace(/&/g,"&amp;")
      .replace(/</g,"&lt;")
      .replace(/>/g,"&gt;")
      .replace(/ opacity: 0\.9999;/ig,"")
      .replace(/ style="display: block;?"/ig,"")
      .replace(/ style="display: inline;?"/ig,"")
      .replace(/ style="display: none;?"/ig,"")
      .replace(/ class=""/ig,"")
      .replace(/ jQuery\d*="\d*"/ig,"")
      .replace(/ oldblock="\w*"/ig,"")
      .split("\n");
    while(str.length && /^\s*jQuery/.test(str[0])) str.shift(1);
    while(str.length && /^\s*jQuery/.test(str[str.length-1])) str.pop();
    if(!str.length) return;
    var n = str[0].match(/^\s*/)[0].length;
    for(var i=0; i<str.length; i++) str[i] = str[i].substr(n);
    str = str.join("\n");
    str = str.replace(/&lt;script\s*type="text\/javascript"\s*&gt;/g,'&lt;script type="text/javascript"&gt;</code><code class="javascript">');
    str = str.replace(/&lt;\/script&gt;/g,'</code><code class="html">&lt;\/script&gt;');
    str = '<code class="html">' + str + '</code>';
    jQuery(this).find(">pre").hide().html(str);
    jQuery("code",this).chili();
    jQuery(this).find(">span").toggle(
      function(){ jQuery(this.parentNode).find(">pre").slideDown(); },
      function(){ jQuery(this.parentNode).find(">pre").slideUp(); });
  });

  // Hack
  if(jQuery.browser.msie)
    jQuery("pre>code").each(function(){
      jQuery(this).html(jQuery(this).html().replace(/&lt;\/(\w*)&gt;/g,"&lt;/$1&gt;<br/>"));
    });

});
