
    function openSlideShow(gid,image)
    {
        var strHelpOptions = "location=no";
		strHelpOptions += ",toolbar=no";
		strHelpOptions += ",menubar=no";
		strHelpOptions += ",status=no";
		strHelpOptions += ",scrollbars=yes";
		strHelpOptions += ",resizable=no";
		strHelpOptions += ",top=300";
		strHelpOptions += ",left=300";
		strHelpOptions += ",width=850";
		strHelpOptions += ",height=700";

		window.open("../SlideShow/slideShow.aspx?tid=A&galleryID=" +gid + "&imageID=" + image, "4x4", strHelpOptions);
        
    }
    function openCloseComment(commentTrId,commentid)
    {
        var cId = document.getElementById(commentTrId);
        if(cId != null)
        {
            if(cId.className  == "commentBodyTrVisible")
            {   
                 cId.className = "commentBodyTrHidden";
                 updateHeadCss(commentid,"commentLine");
            }
            else
            {
                cId.className = "commentBodyTrVisible";
                updateHeadCss(commentid,"commentLineSelected");
                /*if(commentid != "" )
                {
                    updateCommentViewCount(commentid);
                }*/
            }
            
        }
    }
    
    function updateHeadCss(commentId,css)
    {
        var g = document.getElementById("tr"+commentId); 
        if ( g != null)
        {
            g.className = css;
        }
    }
    
    function closeComment(commentTrId)
    {
        var cId = document.getElementById(commentTrId);
        if(cId != null)
        {
            cId.className = "commentBodyTrHidden";
        }
    }
    function openAllComments(commentsNum)
    {
        for (i=1;i<=commentsNum;i++)
        {
            openCloseComment("ctr" + i );
        }
    }
    
    function showAddComment()
    {
        showElement('quickCommentTR');
        scrollDown();
    }
    
    /*COMMENTS AJAX*/
    function updateCommentViewCount(commentId)
    {
        var str = "comments.aspx";
	    str += "?articleId=";
	    str += "&subject=";
	    str += "&mesBody=";
        str += "&commentId=" + commentId;
	    doUpdateCount(str);
    }
    
    function doUpdateCount(url)
    {
     try 
        { 
            xmlHttp = GetXmlHttpObject(countCallbackMethod); 
            xmlHttp.onreadystatechange  =  countCallbackMethod;
            SendXmlHttpRequest(xmlHttp, url); 
        }
        catch(e){} 
    }
    
    function countCallbackMethod()
    {
         try
        {
            //readyState of 4 or 'complete' represents 
            //that data has been returned 
            if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
            {
                var response = xmlHttp.responseText; 
                if (response.length > 0)
                {
                    //update page
            	    if(response != "-1")
	        	    {
	        	        updateViewCount(response);
	        	    }
	            } 
            }
        }
        catch(e)
        {
            alert("an unexpected error has occured: " + e);
        }
    }
    
    function updateViewCount(id)
    {
        var g = document.getElementById("td"+ id);
        if(g != null)
        {
            try{
                g.innerHTML  =  parseInt(g.innerHTML,0) + 1;
            }catch(e){}
        }
    }
    
    function prepareComment(forumId,articleId)
    {
	    var g = document.getElementById("qrHeadTD");
        if(g != null){
            g.innerHTML = "הוסף תגובה ";
        }
	    if(document.aspnetForm.txtSubject.value == "" )
	    {
	        var g = document.getElementById("qrHeadTD");
            if(g != null){
	            g.innerHTML += "<font color=red><b>&nbsp;נא למלא נושא &nbsp;</b></font>";
            }
	        return;
	    }
	    var str = "comments.aspx";
	    str += "?articleId=" + articleId;
	    str += "&forumId=" + forumId;
	    str += "&threadId=" + document.aspnetForm.txtThreadId.value;
	    str += "&subject=" + document.aspnetForm.txtSubject.value;
	    str += "&mesBody=" +  replaceStupidly(document.aspnetForm.teQuickBody.value,"\n","|");
        str += "&commentId=";
//        if(document.aspnetForm.txtGuestName != null)
//        {
//            str += "&guest=" +  document.aspnetForm.txtGuestName.value;
//        }
//        else
//        {
//            str += "&guest=";
//        }
//alert(str);
        doComment(str);
	}
    
    
    function doComment(url)
    { 
        try 
        { 
            xmlHttp = GetXmlHttpObject(CallbackMethod); 
            xmlHttp.onreadystatechange  =  CallbackMethod;
            SendXmlHttpRequest(xmlHttp, url); 
        }
        catch(e){} 
    } 
    
    //CallbackMethod will fire when the state 
    //has changed, i.e. data is received back 
    function CallbackMethod() 
    { 
        
        try
        {
            //readyState of 4 or 'complete' represents 
            //that data has been returned 
            if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
            {
                var response = xmlHttp.responseText; 
                
                if (response.length > 0)
                {
                    //update page
            	    if(response == "OK")
	        	    {
	        	        window.location.reload();
	        	    }
	        	    else
	        	    {
	        	        var g = document.getElementById("qrHeadTD");
	        	        if(g != null)
	        	        {
	        	            if(response == "ERR_NC")
	        	            {
	        	                g.innerHTML += "<font color=red><b>&nbsp;נא להירשם לאתר לפני שליחת תגובה &nbsp;</b></font>";
	        	            }
	        	            else
	        	            {
	        	                g.innerHTML += "<font color=red><b>&nbsp;שליחת תגובה נכשלה &nbsp;</b></font>";
	        	            }
	        	        }
	        	    }
    	        	
                } 
            }
        }
        catch(e)
        {
            alert("an unexpected error has occured: " + e);
        }
    }


