//Develop:Yaron[NoCheck] Date:07/09/2009 15:39:24 Ticket:
var AdditionalCategories = {
    id : 'ctl00_ctl00_MasterPageTabs_dvAdditionalCategories',isOnLi : false,isOnMenu : false,
    Start: function() { AdditionalCategories.isOnLi = true; var pos = GetElementPos('ctl00_ctl00_MasterPageTabs_tabNewsCategories_TabsMenuOnMouseOver_liNoneActive'); $get(AdditionalCategories.id).style.left = pos[0] - 86 + "px"; $get(AdditionalCategories.id).style.top = Number(pos[1]) + Number(25) + "px"; show(AdditionalCategories.id); },
    Close : function(){var t = setTimeout("AdditionalCategories.Dispose();",500);},
    Dispose : function(){if ((AdditionalCategories.isOnMenu == false) && (AdditionalCategories.isOnLi == false))hide(AdditionalCategories.id);}
}
var AdditionalGiantCategories = {
    id: 'ctl00_BasicMasterPage_dvAdditionalCategories', isOnLi: false, isOnMenu: false,
    Start: function() { AdditionalGiantCategories.isOnLi = true; var pos = GetElementPos('ctl00_BasicMasterPage_tabHeaderTabs_TabsMenuOnMouseOver_liNoneActive'); $get(AdditionalGiantCategories.id).style.left = pos[0] - 140 + "px"; $get(AdditionalGiantCategories.id).style.top = Number(pos[1]) + Number(47) + "px"; show(AdditionalGiantCategories.id); },
    Close: function() { var t = setTimeout("AdditionalGiantCategories.Dispose();", 500); },
    Dispose: function() { if ((AdditionalGiantCategories.isOnMenu == false) && (AdditionalGiantCategories.isOnLi == false)) hide(AdditionalGiantCategories.id); }
}
function NewsFavoriteAuthorRemove(id){                                                         
    $.ajax('NewsFavoriteAuthorRemove', {postBody:"AuthorID=" + id, onSuccess : function(html, state){            
        if (state){
            $("ctl00_ctl00_BasicMasterPage_dvFavoriteAuthors").innerHTML = html.getHTML('NewsFavoriteAuthor');
        }
    }});
}
function NewsGiantFavoriteAuthorRemove(id,container) {
    $.ajax('NewsFavoriteAuthorRemove', { postBody: "AuthorID=" + id, onSuccess: function(html, state) {
        if (state) {
            $(container).hide();
        } 
    } 
    });
} 
function NewsFavoriteCategoryRemove(id){                                                                                            
    $.ajax('NewsFavoriteCategoryRemove', {postBody:"NewsTypeID=" + id, onSuccess : function(html, state){            
        if (state){
            $("ctl00_ctl00_BasicMasterPage_dvFavoriteCategories").innerHTML = html.getHTML('NewsFavoriteCategories');
        }
    }});
}
function NewsGiantFavoriteCategoryRemove(id,container) {
    $.ajax('NewsFavoriteCategoryRemove', { postBody: "NewsTypeID=" + id, onSuccess: function(html, state) {
        if (state) {
            $(container).hide();
        }
    }
    });
}  
function VoteForArticle(vote){                                                                
    $.ajax('ArticleVote', {postBody:"ArticleID=" + ArticleID + "&VoteFor=" + vote, onSuccess : function(html, state){            
        if (state){                                                                                                                                                                        
            var newValues = trim(html.split("\r\n")[1]);                        
            var VotesFor = newValues.split(",")[0];
            var VotesAgainst = newValues.split(",")[1];                                                                                                                                    
            VotesResults.VotesFor = VotesFor;
            VotesResults.VotesAgainst = VotesAgainst;                                                            
            $("spnVotesFor").innerHTML = VotesResults.VotesFor;
            $("spnVotesAgainst").innerHTML = VotesResults.VotesAgainst;                                                                                                                  
            $("ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_spnVotesAgainstNotVoted").hide();
            $("ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_spnVotesForNotVoted").hide();
            $("ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_spnVotesForVoted").show();
            $("ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_spnVotesAgainstVoted").show();
        }
    }});     
}    
function ArticleDeleteComment(id){                        
    var dvLoader = $('dvLoaderComment');
    setdvLoaderGenericHeight();
    $(dvLoader).show();    
    $.ajax('ArticleDeleteComment', { postBody:"CommentID=" + id + "&CurrentPage=" + PagingCurrentPageNewsViewArticle_Upper + "&BaseLink=" + encodeURIComponent(PagingBaseLinkOfNewsViewArticle_Upper), onSuccess : function(html, state){            
        if (state){
            $(dvLoader).hide();
            $("dvComment").innerHTML = html.getHTML('Comments');                                                              
            $("PagingBarTop").innerHTML = html.getHTML('Paging');
            $("PagingBarBottom").innerHTML = html.getHTML('Paging');
        }
    }});       
}              
function AddFavoriteCategory(id){                                                                                                                                                  
    var intH, intW;
    var element = $('ctl00_ctl00_BasicMasterPage_dvFavoriteCategories');
    if(element.offsetHeight) {
        intH = element.offsetHeight;
        intW = element.offsetWidth;
    }else{    
        intH = element.clientHeight;
        intW = element.clientWidth;   
    }
    var dvLoader = $('dvLoaderCatagorie');    
    dvLoader.style.left = ( Math.floor(intW /2)-8 ) + "px";
    dvLoader.style.top = (Math.floor(intH /2)-8 )+ "px";
    $(dvLoader).show();
    
        
    $.ajax('NewsFavoriteCategoryAdd', { postBody:"NewsTypeID=" + id, onSuccess : function(html, state){            
        $(dvLoader).hide();
        if (state){                                
            $get("ctl00_ctl00_BasicMasterPage_dvFavoriteCategories").innerHTML = html.getHTML('NewsFavoriteCategories');
            
            if (typeof AddFavoriteCategoryElement == 'string'){                            
                $(AddFavoriteCategoryElement).hide();
            }else{
                $("ctl00_ctl00_BasicMasterPage_hrfCategoryAddToFavorite").hide();
            }                                                                        
            ScrollToElement("ctl00_ctl00_BasicMasterPage_dvFavoriteCategories",100);
            new Effect.Highlight("ctl00_ctl00_BasicMasterPage_dvFavoriteCategories", {startcolor:'#FFFFD4',endcolor:'#ffffff',duration:1.0});            
        }
    }});               
}         


function hrfAddAuthorToFavorite(id){                                               
    var intH, intW;
    var element = $get('ctl00_ctl00_BasicMasterPage_dvFavoriteAuthors');
    if(element.offsetHeight) {
        intH = element.offsetHeight;
        intW = element.offsetWidth;
    }else{    
        intH = element.clientHeight;
        intW = element.clientWidth;   
    }
    var dvLoader = $('dvLoaderAuthor');
    dvLoader.style.left = ( Math.floor(intW /2)-8 ) + "px";        
    dvLoader.style.top = ( Math.floor(intH /2)-8 ) + "px";
    $show(dvLoader);      
    $.ajax('NewsFavoriteAuthorAdd', { postBody:"AuthorID=" + id, onSuccess : function(html, state){            
        $(dvLoader).hide();
        if (state){                                
            $("ctl00_ctl00_BasicMasterPage_dvFavoriteAuthors").innerHTML = html.getHTML('NewsFavoriteAuthor');
            if (typeof hrfAddAuthorToFavoriteElement == 'string'){
                hide(hrfAddAuthorToFavoriteElement);
                hide(spnAddAuthorToFavoriteElement);
            }else{
                $("ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_hrfAddAuthorToFavorite").hide();
                $("ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_spnAddAuthorToFavorite").hide();
            }
            ScrollToElement("ctl00_ctl00_BasicMasterPage_dvFavoriteAuthors", 100);
            new Effect.Highlight("ctl00_ctl00_BasicMasterPage_dvFavoriteAuthors", {startcolor:'#FFFFD4',endcolor:'#ffffff',duration:1.0});         
        }
    }});         
}                
    
function AddComment(){            
    if (!IsLogin){            
        NotLogin();
        return false;                                  
    }        
    var val = $("txtCommentAdd").value;
    if (val == "") return;
    var PostBody = ["ArticleID=" + ArticleID,"Content=" + encodeURIComponent(val),"BaseLink=" + encodeURIComponent(PagingBaseLinkOfNewsViewArticle_Upper)];                                            
    setdvLoaderGenericHeight();
    $("dvLoaderComment").show();                
    $.ajax('ArticleAddComment', {postBody:PostBody, onSuccess : function(html, state){                    
        $("dvLoaderComment").hide();
        $("txtCommentAdd").value = "";                
        $("PagingBarTop").innerHTML = html.getHTML('Paging');
        $("PagingBarBottom").innerHTML = html.getHTML('Paging');
        $("dvComment").innerHTML = html.getHTML('Comments');                                            
    }});          
}


var  VotesResults = { VotesFor : null , VotesAgainst : null }                                                                                                     
var hrfAddAuthorToFavoriteElement = "ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_hrfAddAuthorToFavorite";
var spnAddAuthorToFavoriteElement = "ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_spnAddAuthorToFavorite";
var AddFavoriteCategoryElement = "ctl00_ctl00_BasicMasterPage_cphNewsMasterPage_hylAddCategoryFavorites";

function EditArticle(id){
    var url = DomainURL + "News/EditArticle.aspx?ArticleID=" + id;
    MoveToPage(url);
    return false;
}
                                  
function NotLogin(){               
    $('dvNotLoggedIn').show();
    ScrollToElement('dvNotLoggedIn');
    return false;
}               
function MoveToPageLogin(url){            
    if (!IsLogin){            
        NotLogin();
        return false;                                  
    }
    window.location.href = url;
    try{$('taSendReply').focus();}catch(e){}
    return true;         
}

