/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  JS Library.
  by DesignSlicer.com _ info@designslicer.com _
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
ieHover = function() {
  var ieEls = document.getElementById("page").getElementsByTagName("LI");
  for (var i=0; i<ieEls.length; i++) {
    ieEls[i].onmouseover=function() {
      this.className+=" hover";
    }
    ieEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp(" hover\\b"), "");
    }
  }
}
if (window.attachEvent) window.attachEvent("onload", ieHover);
try{document.execCommand("BackgroundImageCache",false,true);}catch(err){}
jQuery(document).ready(function() {
  jQuery('input[value]').each(function(){
    if(this.type == 'text') {
      jQuery(this).focus(function(){
        if (this.value == this.defaultValue) {
          this.value = '';
        }
      }).blur(function(){
        if (!this.value.length) {
          this.value = this.defaultValue;
        }
      });
    }
  });
  jQuery('#community textarea').each(function(){
    jQuery(this).focus(function(){
      jQuery(this).empty();
    }).blur(function(){
      jQuery(this).text('Description...');
    });
  });
  // jQuery('body').wrapInner('<div class="outer"></div>');
  // jQuery('#page').wrapInner('<div class="outer"><div class="outer"><div class="outer"><div class="outer"></div></div></div></div>');
  jQuery('#theThemes').wrapInner('<div class="inner"><div class="inner"></div></div>');
  jQuery('#commentBox .reply').click(function(event){
    event.preventDefault();
    var string = '<a class="replyTo" href="#' + jQuery(this).parents('li').attr('id') + '">@' + jQuery(this).parents('li').find('.author').text() + ':</a>';
    var currentValue = jQuery('#comment').val();
    jQuery('#comment').val(currentValue + string + '\n').focus();
  });
  var exp = /^@/;
  var exphref = /^#comment-/;
  jQuery('#commentBox .content p a').each(function(){
      if (jQuery(this).text().match(exp) && jQuery(this).attr('href').match(exphref)) {
        jQuery(this).addClass('replyTo');
      }
  });
  var offset = jQuery('#commentBox').offset();
  jQuery('.replyTo').hover(
    function(){
      jQuery(jQuery(this).attr('href')).clone().hide().attr('id','').insertAfter(jQuery(this).parents('li')).addClass('commentTip').fadeIn('medium');
    },
    function(){
      jQuery('.commentTip').fadeOut('fast',function(){
        jQuery(this).remove();
      });
    }
  ).mousemove(function(e){
    jQuery('.commentTip').css({'left' : (e.pageX - offset.left + 10) , 'top' : (e.pageY - offset.top + 5)});
  });
  jQuery('.tabControl').tabs({ fx: { height: 'toggle' } });
  jQuery('#newsletter .close').click(function(){
    jQuery('#newsletter').animate({ height: "0" }).css({ border: "none" });
    createCookie('close1', '#newsletter', 365);
  });
  jQuery('#subscribe .close').click(function(){
    jQuery('#subscribe').animate({ top: "-276px" });
    createCookie('close2', '#subscribe', 365);
  });
  var c1 = readCookie('close1'); if (c1) closeIt(c1);
  var c2 = readCookie('close2'); if (c2) closeIt(c2);
});
function closeIt(boxID){
  jQuery(boxID).css({ display: "none" });
}
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);
}