$(document).ready(function() {
    
    var options = {target:'#reportartform',beforeSubmit:art_showRequest,success:art_showResponse}; 
    $('#reportartform').ajaxForm(options); 
    
    var options = {target:'#suggestnewsform',beforeSubmit:sug_showRequest,success:sug_showResponse}; 
    $('#suggestnewsform').ajaxForm(options); 
    
  /*  $('#ST_Face').html('<table style="background: url(/images/news/facebook_share.png) no-repeat;" border="0" cellpadding="0" cellspacing="0"><tr><td style="height:61px;" valign="bottom"><a name="fb_share" type="box_count" share_url="'+ISF_ShareURL+'" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></td></tr></table>');
    $('#ST_Twit').html('<iframe width="50" scrolling="no" height="61" frameborder="0" src="http://api.tweetmeme.com/button.js?url='+ISF_ShareURL_Enc+'&amp;style=normal&amp;source=SpaceFellowship&amp;service=bit.ly"></frame>');
    */
    
    setTimeout("InsertShare()", 500); 
    
    $(".ellipsis").each(function(i){
                         
        var content = $(this).html();
        $(this).attr("title", content);
        
        var iNewWidth = $(this).width();
        var iParentWidth = $(this.parentNode).width();

        var MinChars = content.length;
        var Diff = 4;
        
        if(isIE6) 
        {
            var Padding = $(this.parentNode).css("padding-left");
            var PadDif = Padding.substring(0,Padding.length-2);
            $(this.parentNode).css("width", "auto");
            Diff -= parseInt(PadDif);
        }
        
        while((iParentWidth-Diff) < iNewWidth)
        {
            $(this).html(content.substring(0,MinChars) + "&hellip;");
           
            iNewWidth = $(this).width();
            MinChars--;
            if(MinChars < 0) break;
        }
    });
    
    $(".makeblock").each(function(i){
           $(this).css("display", "block");
    });
    
    
    $('#ArticleContent a:has(img)').click(function(){
        
        pviewer_show($(this).attr("href"));
        
        return false;
    });
 
});

function InsertShare()
{
    $('#ShareMore').prepend('<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>');
    
}


function ReportArt()
{
    SuggestNews_Close();
    if(true == isIE6)
    {
        $('#reportart').toggle();
    }else
    {
        $('#reportart').animate({height: 'toggle'}, 300);
    }
}

function ReportArt_Close()
{
    if(true == isIE6)
    {
        $('#reportart').hide();
    }else
    {
        $('#reportart').animate({height: 'hide'}, 300);
    }
}

function art_showRequest(formData, jqForm, options){ 
    ReportArt_Close();
    return true; 
} 

function art_showResponse(responseText, statusText){ 

    $('#reportartform').css({"margin-top":"10px"});
    setTimeout("ReportArt_Close()",6500);

    if(true == isIE6)
    {
        $('#reportart').show();
    }else
    {
        $('#reportart').animate({height: 'show'}, 300);
    }
}

function SuggestNews()
{   
    ReportArt_Close();
    
    if(true == isIE6)
    {
        $('#suggestnews').toggle();
    }else
    {
        $('#suggestnews').animate({height: 'toggle'}, 300);
    }    
}

function SuggestNews_Close()
{
    if(true == isIE6)
    {
        $('#suggestnews').hide();
    }else
    {
        $('#suggestnews').animate({height: 'hide'}, 300);
    }       
}

function sug_showRequest(formData, jqForm, options){ 
    SuggestNews_Close()
    return true; 
} 

function sug_showResponse(responseText, statusText){ 

    $('#suggestnewsform').css({"margin-top":"10px"});
    setTimeout("SuggestNews_Close()",6500);

    if(true == isIE6)
    {
        $('#suggestnews').show();
    }else
    {
        $('#suggestnews').animate({height: 'show'}, 300);
    }
}


CurrentReplyPosition = 0;

function ReplyComment(CommentID)
{
    if(0 != CurrentReplyPosition)
    {
        $("#RCom" + CurrentReplyPosition).css("display", "none");
    }
    
    $("#CancelReply").css("display", "block");
    $("#DefaultReplyField").appendTo("#RCom" + CommentID);
    $("#RCom" + CommentID).css("display", "block");
    
    $("#comment_parent").val(CommentID);
    
    CurrentReplyPosition = CommentID;
}


function ReplyCancel()
{   
    if(0 == CurrentReplyPosition) return;
    $("#RCom" + CurrentReplyPosition).css("display", "none");
    $("#DefaultReplyField").appendTo("#DefaultReplyFieldBox");
    $("#CancelReply").css("display", "none");
     $("#comment_parent").val(0);
    
    CurrentReplyPosition = 0;
}

