function showNewComment(){
    if($('new_comment')){
        $('new_comment').appear();
    }
    reply_links = $$('span.reply_slash');
    reply_links.each(function(item) {
            element_id = item.id;
            if((element_id.length) > 0){
                element_id = element_id.replace('reply_','');
                item.innerHTML = '';
            }
        }
    )
}

function replyTo(belongs){
    if($('comment_' + belongs)){
        if($('CommentBelongsId').value == 0){
            $('CommentBelongsId').value = belongs;
            $('reply_blank').innerHTML += '<div id="reply_blank_msg"><span>Replying to:</span><p class="replyTo">' + $('comment_' + belongs).innerHTML + '</p><a href="#" onclick="return cancelReply()">Cancel</a></div>';
            $('CommentComment').focus();
        }
    }
    return false;
}

function cancelReply(){
    $('CommentBelongsId').value = 0;
    $('reply_blank').innerHTML = '';
    return false;
}

function hideFlash(){
	if($('flashMessage')){
		$('flashMessage').fade();
	}
}

function setColumnHeights(){
    if($('left_hp_content') && $('right_hp_content') && $('store_hp_content')){
        tallest = $('left_hp_content').getHeight();
        if($('right_hp_content').getHeight() > tallest){ tallest = $('right_hp_content').getHeight(); }
        if($('store_hp_content').getHeight() > tallest){ tallest = $('store_hp_content').getHeight(); }

        $('left_hp_content').setStyle({ height: tallest + 'px' });
        $('right_hp_content').setStyle({ height: tallest + 'px' });
        $('store_hp_content').setStyle({ height: tallest + 'px' });

    } else if($('left_hp_content') && $('right_hp_wrapper')){
        tallest = $('left_hp_wrapper').getHeight();
        if($('right_hp_content').getHeight() > tallest){ tallest = $('right_hp_content').getHeight(); }

        $('left_hp_content').setStyle({ height: tallest + 'px' });
        $('right_hp_content').setStyle({ height: tallest + 'px' });
        
    }

    if($('left_content') && $('right_content')){
        tallest = $('left_content').getHeight();
        if($('right_content').getHeight() > tallest){ tallest = $('right_content').getHeight(); }
        $('left_content').setStyle({ height: tallest + 'px' });
        $('right_content').setStyle({ height: tallest + 'px' });
    }

    if($('last_project_link')){
        $('last_project_link').setStyle({ 'bottom':'0px', 'position':'absolute', 'bottom':'0px', 'right':'15px' });
        $('last_project_link').show();
    }

    if($('last_blog_link')){
        $('last_blog_link').setStyle({ 'bottom':'0px', 'position':'absolute', 'bottom':'0px', 'right':'15px' });
        $('last_blog_link').show();
    }
}

function initSearch(){
    if($('search_form')){
        Event.observe('search_form', 'submit',
            function(event) {
                if($('search_form_query').value.length < 4){
                    Event.stop(event);
                    alert('Search term must be at least 4 characters');
                }
            }
        );
    }
}

function show_large(the_file_name, project){
    if(project == null){
        project = 0;
    }
    window.open('/large_image.php?img='+the_file_name + '&project=' + project,'LargeImg','width=800,height=800,scrollbars=yes,menu=no,top=0,left=0,status=no');
    return false;
}

Event.observe(document, 'dom:loaded', initSearch);
Event.observe(window, 'load', function(){ setTimeout('hideFlash()',4500); });
Event.observe(window, 'load', setColumnHeights);