var _doc = document;

function setSitemap(){
    $("#sitemap-nav, #sitemap-nav-2").click(function(){
        scroll_bottom();
          
        properties = {
            height: ['toggle', 'linear']

        };

        sitemap_visible =  $('#sitemap').is(':visible');
        
        duration = {
            duration: 1800,
            step: function(){
                if($('#mainContainer').height() >= $(_doc ).height()){
                    footer_info_position('fixed');    
                }
                else{
                    footer_info_position('static');   
                }
                
                if(sitemap_visible){
                    $('html, body').scrollTop($('html, body').scrollTop() - 1);
                } else {
                    scroll_bottom();    
                }
            },
            complete: function() {
                footer_info_position('static'); 
                $('#sitemap-nav, #sitemap-nav-2').toggleClass('hide');
                scroll_bottom();
            }
        };
        
        $('#sitemap').animate(properties, duration, "linear");
    })                     
       	
}

function footer_info_position(post){
    $('#footer .bar .bar-content').css({bottom:0, position:post});
}

function scroll_bottom(){
    $(_doc ).scrollTop($(_doc).height()); 
}

function setPanel(){
    $('#post_more').bind('click', function(){
        
        if($.browser.msie && $.browser.version == '6.0'){
            p_1 = {height: ['89.9%']};   
        } else if($.browser.version == '7.0') {
            p_1 = {height: ['90.9%']};
        } else {
            p_1 = {height: ['toggle', 'linear']};
        }
        
        
        $('#post-content-1').toggleClass('hide');
        $('#post-content-2').animate(p_1, {duration: 'fast'}, "linear");
        return false;    
    })        
            
    $('#close-panel').bind('click', function(){
        $('#post-content-2').animate({height: ['toggle', 'linear']}, {duration: 'fast', complete: function(){
            $('#post-content-1').toggleClass('hide');
        }}, "linear");
        return false;  
    })
}

function checkParam(){
    if($('#s-keyword').val() == '') { $('#s-keyword').val(' ') }
}

function galleryPreview(){
	
	previewShow($("div.aequivox-gallery a:first-child").attr('href'), $("div.aequivox-gallery a:first-child img").attr('title'));
	
	$('div.aequivox-gallery .ngg-gallery-thumbnail-box .ngg-gallery-thumbnail a').click(function(){
		previewShow($(this).attr('href'), $(this).children('img').attr('title'));
		return false;
	})
}


function previewShow(img, title){
	$('.aequivox-gallery .preview-panel .preview-box div').html('<table><tr><td class="box" valign="middle" align="center"><img src="'+img+'"> </td></tr></table> <h2>'+title+'</h2>');	
}

function breadcrumbForGallery(html){
	$('#breadcrumbs #sub-page').html(html);
}

function stripslashes (str) {
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ates Goral (http://magnetiq.com)
    // +      fixed by: Mick@el
    // +   improved by: marrtins    // +   bugfixed by: Onno Marsman
    // +   improved by: rezna
    // +   input by: Rick Waldron
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +   input by: Brant Messenger (http://www.brantmessenger.com/)    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: stripslashes('Kevin\'s code');
    // *     returns 1: "Kevin's code"
    // *     example 2: stripslashes('Kevin\\\'s code');
    // *     returns 2: "Kevin\'s code"    
    return (str+'').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
            case '\\':
                return '\\';
            case '0':                return '\u0000';
            case '':
                return '';
            default:
                return n1;        }
    });
}
	
function setTubepressPagination(){
    $('.tubepress_container .tubepress_thumbnail_area .pagination').find(":nth-child(1)").addClass('prev').text('◄');
    $('.tubepress_container .tubepress_thumbnail_area .pagination').find(":last-child").addClass('next').text('►');
}	