﻿var basepath="/blogg/"

function loadhelp(URL) {
	window.open(URL, '_blank', 'toolbar=no,location=no,scrollbars=yes,menubar=no,status=no,resizable=yes,width=637,height=480,top=0,left=50') 
} 
		
function loadprofile(URL) {
	window.open(URL, '_blank', 'toolbar=no,location=no,scrollbars=yes,menubar=no,status=no,resizable=yes,width=637,height=480,top=0,left=50') 
} 


	
	var CurrentLayer="";
	
	function WriteComment(id)  {
	    CurrentLayer=document.getElementById("com_" + id);
      url=basepath + "addcomment.asp?ID=" + id
      GetContent(url);
      CurrentLayer.className="CommentSpace2";
	 }
	
	function ShowComments(id) {
	    CurrentLayer=document.getElementById("com_" + id);
	    if (CurrentLayer) {
	      url="getcomments.asp?ID=" + id
	      GetContent(url);
	      CurrentLayer.className="CommentSpace2";
	    }
	}
	
	
   function GetContent(url) { 
       /* if (window.XMLHttpRequest) { // Mozilla, Safari,... 
           http_request = new XMLHttpRequest(); 
       } else if (window.ActiveXObject) { // IE 
           http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
       } 
       http_request.onreadystatechange = alertContents; 
       http_request.open('GET', url, true); 
       http_request.send(null); */
       
       var bxmlhttp=new XMLHttpRequest();
       bxmlhttp.open('GET', url, true);
       
       bxmlhttp.onreadystatechange = function() {
				if (bxmlhttp.readyState==4) {
					if (bxmlhttp.status==200) {
						UpdateContent2(bxmlhttp.responseText);
					}
				}
			}
			bxmlhttp.send(null);

   } 
   
   
   function makePOSTRequest(url, parameters) {

      var bxmlhttp=new XMLHttpRequest();
      
      try {
      		bxmlhttp.overrideMimeType('text/html');
     	}
     	catch(x) {
     	}
     		
      bxmlhttp.open('POST', url, true);
     	bxmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      bxmlhttp.setRequestHeader("Content-length", parameters.length);
      bxmlhttp.setRequestHeader("Connection", "close");
      
      
      bxmlhttp.send(parameters);
      
      bxmlhttp.onreadystatechange = function() {
				if (bxmlhttp.readyState==4) {
					if (bxmlhttp.status==200) {
						UpdateComments();
					}
				}
			}
      
      
      //UpdateComments()
   }

   
   function UpdateContent2(x) {
   		//alert(x);
   		CurrentLayer.innerHTML=x;
   }

   
   
    function checkTextLength(x) {
        if (x.value.length > 1000) {
            alert(TooLongCommentMess);
            x.value=x.value.substring(0, 999);
         }
    }
    
    var CurrentID;
    
    function UpdateComments() {
        ShowComments(CurrentID);
    }
    
    
    
    function SaveComment(x, id) {
    		frm=document.getElementById(x);
    		CurrentID=id;
        makePOSTRequest(basepath + "addcomment.asp", "Save=1&ID=" + id + "&Comment=" + escape(frm.value));
       //setTimeout("UpdateComments()", 800);
    }
    
    
    
    function trim(sString) {
        while (sString.substring(0,1) == ' ') {
            sString = sString.substring(1, sString.length);
        }

        while (sString.substring(sString.length-1, sString.length) == ' ') {
            sString = sString.substring(0,sString.length-1);
        }
        
        return sString;
    }


   