//------------------------------------------------------------------------------------------------------------------------

//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp13 = false;
//Check if we are using IE.
try {
//If the Javascript version is greater than 5.
xmlhttp13 = new ActiveXObject("Msxml2.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer.");
} catch (e) {
//If not, then use the older active x object.
try {
//If we are using Internet Explorer.
xmlhttp13 = new ActiveXObject("Microsoft.XMLHTTP");
//alert ("You are using Microsoft Internet Explorer");
} catch (E) {
//Else we must be using a non-IE browser.
xmlhttp13 = false;
}
}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp13 && typeof XMLHttpRequest != 'undefined') {
xmlhttp13 = new XMLHttpRequest();
//alert ("You are not using Microsoft Internet Explorer");
}	
	
function makeShowLatestNewsSidebarRequest(serverPage, objID, homePageUrl) 
	{
		
		var obj = document.getElementById(objID); 
		
		if (homePageUrl != '')
			obj.innerHTML = '<div style="color: #dbdbdb; margin-left: 10px; margin-top: 5px; margin-bottom: 6px;">se incarca...</div>';
		
		xmlhttp13.open("GET", serverPage);
		xmlhttp13.onreadystatechange = function() 
			{
				if (xmlhttp13.readyState == 4 && xmlhttp13.status == 200) 
					{
						obj.innerHTML = xmlhttp13.responseText;	
						fadeIn(objID);
					}//end if
			}
		xmlhttp13.send(null);
	}//end makeShowLatestNewsSidebarRequest()
//---------------------------------------------------------------------------------------------------------------------	


function onFocusTexareaComment(id,idTextareaCommentButtons,idTextareaCommentCounter,focusedClass,normalClass)
	{
		change(id,focusedClass); 
		showDiv(idTextareaCommentButtons);
		showDiv(idTextareaCommentCounter);
	}//end function nFocusTexareaComment()
	
function onBlurTexareaComment(idTextarea,idTextareaCommentButtons,idTextareaCommentCounter,focusedClass,normalClass)
	{
		//doar daca nu am scris nimic in textbox, inchid, altfel le las asa deschise toate
		if (document.getElementById(idTextarea).value.length <= 0)
			{
				change(idTextarea,normalClass); 
				hideDiv(idTextareaCommentButtons);
				hideDiv(idTextareaCommentCounter);
			}//end if
			else
				{
				
				}//end else
	}//end function onBlurTexareaComment()
	
	
function showTexareaCommentCharCounter(idTextarea,idCounter)
	{
		document.getElementById(idCounter).value=(1000-document.getElementById(idTextarea).value.length);
	}//end showTexareaCommentCharCounter()
	
	
function submitMiniblogComment(serverPage, objID, homePageUrl, postId, idTextarea,idTextareaCommentButtons,idTextareaCommentCounter,focusedClass,normalClass)
	{
		var obj = document.getElementById(objID);
		
		//inlocuieste ENTER-urile cu <br />
		serverPage=nl2br(serverPage);
		
		if (homePageUrl != '')
			obj.innerHTML = '<img id="imageLoader" src="'+homePageUrl+'app/img/icons/ajax-loader.gif" width="16" height="16" style="margin: 0px; padding: 0px; vertical-align: middle;" />';
					
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() 
			{
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
					{
						obj.innerHTML = xmlhttp.responseText;
						tmp=obj.innerHTML;
						/*Update v1.0 beta - pentru a nu aparea iconita de loading la apelare, in alte div-uri*/
						obj='';
						
						//Daca reuseste, atunci dau refres si la div-ul cu lista comentariilor, de jos
						if (tmp.indexOf("s-a adaugat") != -1)
							{
								//fac refresh la lista cu comentariile
								makerequest(homePageUrl+'app/plugins/miniblog/refresh-show-post-comments.php?id='+postId, 'show-post-comments', homePageUrl, 'fadeIn');
								
								//inchid formularul textarea si ce mai am pe langa el
								//change(idTextarea,normalClass); 
								//hideDiv(idTextareaCommentButtons);
								//hideDiv(idTextareaCommentCounter);
								
								
								//setTimeout('change(\''+idTextarea+'\',\''+normalClass+'\')', 500);
								//setTimeout('hideDiv(\''+idTextareaCommentButtons+'\')', 500);
								//setTimeout('hideDiv(\''+idTextareaCommentCounter+'\')', 500);
								
								//golesc continutul textarea-ului
								//document.getElementById(idTextarea).value='';

								
							}//end if
							else
								{
									//nimic
								}//end else
						
					}//end if
			}//end
		
		xmlhttp.send(null);
		
		//document.getElementById(idCounter).value="ok";
	}//end submitMiniblogComment()
	
	
function submitMiniblogCommentReplay(serverPage, objID, homePageUrl, postId, idTextarea,idTextareaCommentButtons,idTextareaCommentCounter,focusedClass,normalClass)
	{
		var obj = document.getElementById(objID);
		
		//inlocuieste ENTER-urile cu <br />
		serverPage=nl2br(serverPage);
		
		if (homePageUrl != '')
			obj.innerHTML = '<img id="imageLoader" src="'+homePageUrl+'app/img/icons/ajax-loader.gif" width="16" height="16" style="margin: 0px; padding: 0px; vertical-align: middle;" />';
					
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() 
			{
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
					{
						obj.innerHTML = xmlhttp.responseText;
						tmp=obj.innerHTML;
						/*Update v1.0 beta - pentru a nu aparea iconita de loading la apelare, in alte div-uri*/
						obj='';
						
						//Daca reuseste, atunci dau refres si la div-ul cu lista comentariilor, de jos
						if (tmp.indexOf("s-a adaugat") != -1)
							{
								//fac refresh la lista cu comentariile
								makerequest(homePageUrl+'app/plugins/miniblog/refresh-show-post-comments.php?id='+postId, 'show-post-comments', homePageUrl, 'fadeIn');
								
								//inchid formularul textarea si ce mai am pe langa el
								change(idTextarea,normalClass); 
								hideDiv(idTextareaCommentButtons);
								hideDiv(idTextareaCommentCounter);
								
								//golesc continutul textarea-ului
								document.getElementById(idTextarea).value='';

								
							}//end if
							else
								{
									//nimic
								}//end else
						
					}//end if
			}//end
		
		xmlhttp.send(null);

	}//end submitMiniblogCommentReplay()
	
	
function deleteMiniblogComment(serverPage, objID, homePageUrl, commentPostId, fadeEffect)
	{
		var obj = document.getElementById(objID);
		
		if (homePageUrl != '')
			obj.innerHTML = '<img id="imageLoader" src="'+homePageUrl+'app/img/icons/ajax-loader.gif" width="16" height="16" />';
					
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() 
			{
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
					{
						obj.innerHTML = xmlhttp.responseText;
						tmp=obj.innerHTML;
						
						/*Update v1.0 beta - pentru a nu aparea iconita de loading la apelare, in alte div-uri*/
						obj='';
						
						//verific daca s-a returnat mesajul de confirmare, adica daca s-a sters comentariul
						if (tmp.indexOf("&nbsp;") != -1)
							{
								//inchid div-ul cu comentariul respectiv
								if (fadeEffect == "fadeIn")
									{
										fadeIn(commentPostId);
									}//end if
									else
										if (fadeEffect == "fadeOut")
											{
												fadeOut(commentPostId);
											}//end if
											else
												{
													//nu am setat efectul de fade, inchid simplu div-ul
													hideDiv(commentPostId);
												}//end else
							}//end if
							else
								{
									//nothing
								}//end else
					}//end if
			
			}//end 
		xmlhttp.send(null);
	}//end deleteMiniblogComment()