/*!
 * HTML5 Placeholder jQuery Plugin v1.7
 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
 * @author Mathias Bynens <http://mathiasbynens.be/>
 */
(function(f,z){var e=z in document.createElement('input'),a=z in document.createElement('textarea');if(e&&a){f.fn.placeholder=function(){return this}}else{f.fn.placeholder=function(){return this.filter((e?'textarea':':input')+'['+z+']').bind('focus.'+z,b).bind('blur.'+z,d).trigger('blur.'+z).end()}}function c(h){var g={},i=/^jQuery\d+$/;f.each(h.attributes,function(k,j){if(j.specified&&!i.test(j.name)){g[j.name]=j.value}});return g}function b(){var g=f(this);if(g.val()===g.attr(z)&&g.hasClass(z)){if(g.data(z+'-password')){g.hide().next().show().focus()}else{g.val('').removeClass(z)}}}function d(g){var j,i=f(this);if(i.val()===''||i.val()===i.attr(z)){if(i.is(':password')){if(!i.data(z+'-textinput')){try{j=i.clone().attr({type:'text'})}catch(h){j=f('<input>').attr(f.extend(c(i[0]),{type:'text'}))}j.removeAttr('name').data(z+'-password',true).bind('focus.'+z,b);i.data(z+'-textinput',j).before(j)}i=i.hide().prev().show()}i.addClass(z).val(i.attr(z))}else{i.removeClass(z)}}f(function(){f('form').bind('submit.'+z,function(){var g=f('.'+z,this).each(b);setTimeout(function(){g.each(d)},10)})});f(window).bind('unload.'+z,function(){f('.'+z).val('')})})(jQuery,'placeholder');

function signLogIn() {
    jQuery("a.signLogIn").click(function(){
        jQuery(this).fadeOut(200);
        jQuery("#modalSignIn").delay(250).fadeIn(400);
        return false;
    });
    jQuery("#modalSignIn a.ttl_hdr").click(function(){
        jQuery(this).parent("#modalSignIn").fadeOut(400);
        jQuery("a.signLogIn").delay(450).fadeIn(200);
        return false;
    });
}

function headerSlideshow() {

    // Changes the slide to the next or first
    function change() {
    
        var container = jQuery("#headerSlideshow"),
            list = container.find("ul"),
            current = list.find(".current");

        if (current.hasClass("last")) {
            current.removeClass("current").fadeOut(200, function(){
                list.find(".first").addClass("current").fadeIn(200);
            });
        } else {
            current.removeClass("current").fadeOut(200, function(){
                current.next("li").addClass("current").fadeIn(200);
            });
        }

    }

    // Every 5 seconds, change the slide
    setInterval(function(){
        change();
    }, 5000);
    
}

function forumScrollToNewPost() {
    jQuery("a[href=#new-post]").click(function(){
        jQuery("html, body").animate({scrollTop: jQuery("#new-post").offset().top}, 1000);
        jQuery("#new-post").find("textarea").focus();
        return false;
    });
}

jQuery(function(){

    // Make the HTML5 Placeholder option work in older browsers
    jQuery('input, textarea').placeholder();
	
});

jQuery(window).bind("load",function(){
    
    // Toggle mini-modal sign-in box
    signLogIn();
    
    // Header slideshow
    headerSlideshow();
    
    // Forum slide down to new-post
    forumScrollToNewPost();

});
