function comments(x)
{
	var xmlHttp;
	try
	  {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    try
	      {
	    	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	      }
	    catch (e)
	      {
	    	alert("Your browser does not support AJAX!");
	    	return false;
	      }
	    }
	  }
	 
	  xmlHttp.onreadystatechange=function()
	    { 
	    
		  if(xmlHttp.readyState==4)
	      {
			  document.getElementById("com_container_"+x).innerHTML= xmlHttp.responseText;	
		  }
		  
		  	  
		  
		  
	    
		}
		
		
	  

   	  var myDomain = document.domain;
	  
	  var url="http://"+myDomain+_site_path+"index.php/comments";
	  
	  url=url+"/?post_id="+x+"&rand="+Math.random()*9999999999999;
	  xmlHttp.open("GET",url,true);
	  xmlHttp.send(null);
	  
	  
	  
	  
}







function comments_nums(x)
{

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
 
  xmlHttp.onreadystatechange=function()
    {
    
	if(xmlHttp.readyState==4)
      {

      document.getElementById("comsnums_"+x).innerHTML=xmlHttp.responseText;
	  
      }
    }

 
  
  
  	  var myDomain = document.domain;
	  
	  var url="http://"+myDomain+_site_path+"index.php/commentsnums";
	  
	  url=url+"/?post_id="+x+"&rand="+Math.random()*9999999999999;
  
  
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);

}







var enableimg=function(objects)
{  


	objects.each
	(
			function(i,val)
			{	
			
			
				var i=$(this).find('span.post-picture');
				src=i.attr('source');
				
				
							o = {
									id : i.attr('id'),
									cl : i.attr('class'),
									w  : i.css('width'),
									h  : i.css('height'),
									ttl : i.attr('title'),
									src : i.attr('source')
								}
				
				var img='<img src="'+o.src+'" id="'+o.id+'" class="'+o.cl+'" alt="'+o.ttl+'" title="'+o.ttl+'" style="width:'+o.w+'; height:'+o.h+'" />';
				
				var destination=$(this);
				
				var container=$(this).parents('.w-pic');
				
				loadimg(img,destination,container);
			
			}
		
	);
	
}
 	






var loadimg=function(img,dest,cont)
{   
	
	$(cont).addClass('loading');
	$(cont).addClass('fade15');
	
	$(img).load
	(		
		function()
		{
			$(dest).append( $(this) );
			$(cont).removeClass('loading');
			$(cont).removeClass('fade15');
		}
	);	
}



var focus_on=function(obj,element)
{
	
	$(obj).scrollTo( $(element), 2000 );

}




// SHOW post
$(document).ready
(
 

 
 
 function(){ 
 
 	


	$('a.js-show-post').click( function(event) 
		{
			
			
			
			var node = $(this).parents('.x-post').children('.closed-post');
			var nodeview = $(this).parents('.post-head-im').children('.js-view');
			var nodehide = $(this).parents('.post-head-im').children('.js-hide');
			var imgs=$(this).parents('.x-post').find('.js-fixHover');
			var obj=$(this).parents('.x-post');
			var elm=$(this).parents('.x-post').children('.post-hhead-holder');
			$.scrollTo( obj.find('.post-hhead-holder'), 1000 );
			
			if(node.css('display') == 'none')
			{	
				node.animate({height:'show',opacity:'show'}, 'slow');
				nodeview.css("display","none");
				nodehide.css("display","block");
				//focus_on(obj,elm);
				enableimg(imgs);
				
			}
			else
			{
				node.animate({height:'hide',opacity:'hide'}, 'slow');
				nodeview.css("display","block");
				nodehide.css("display","none");
			}

			
			
			
		}
	);

  }
);
//



//INITIATE SHOW POST

$(document).ready
(
 function() 
 {

setTimeout( 
 function(){


			var count1=$('.x-post').length;
			var count2=$('.closed-post').length;
			var imgs=$('.x-post').find('.js-fixHover');

			
			var node=$('.closed-post');
			var nodeview=$('.js-view');
			var nodehide=$('.js-hide');

			if(count1<2 && count2>0)
			{

				node.animate({height:'show',opacity:'show'}, 'slow');
				nodeview.css("display","none");
				nodehide.css("display","block");
				enableimg(imgs);
			}
			

  }
  ,300);
 }
);
//




$(document).ready
(
 function() 
 {

$('.vote-box span a').click(function() {
		$(this).addClass('inactive-vote'); 
		var votes=$(this).parents('.vote-box').find('span em');
		var count=Math.floor(votes.html());
		
		$(votes).html(count+1);
		
	});
	//
 }
);
//










