function GetPosts( keyword, page )
{
	sw = document.getElementById('searchedWord');
	compareValue = keyword+'|'+page;
	if(sw.value == compareValue)
		return false;
	
	sw.value = keyword+'|'+page;

	Loading("posts");
	GetAd();
	$.ajax({
			type: "GET",
			url: "/_ajax/get_posts.php",
			cache: false,
			data: "ch="+Math.random()+"&keyword="+keyword+"&page="+page,
			success: function(html){
			ShowContent( html, "posts");
	  }
	});
}

function GetAd(){
	return false;
}

function HotWord( word )
{
	objId = document.getElementById('searchBox');
	objId.value = word;
	EmptySearcher(objId);
	Searcher(objId);
	
}

function Page(num){
	theVal = document.getElementById('searchedWord').value;
	valArr = theVal.split('|');
	GetPosts( valArr[0], num );
}

function ShowContent( html, id )
{
	document.getElementById(id).innerHTML = html;
}

function Loading( id )
{
	ShowContent( "<center>Boooo! We're loading it. Yes, our server is slow, don't push it! Grrr...!<br /><br /><h2>Loading...</h2><br /><img src=\"../assets/images/ajax-loader.gif\" /></center>", id );
}

function LoadBlickr()
{
	Loading("blickrBox");
	GetAd();
	$.ajax({
			type: "GET",
			url: "/_ajax/get_blickr.php",
			cache: false,
			success: function(html){
			ShowContent( html, "blickrBox");
	  }
	});

	
}
function Searcher(id)
{
	
	if(id.value.length>2){
		for(a=0;a<=100000;a++);
		DoSearch();
	}
}
function CheckEnter(id, e){
	if(e.keyCode==13)
		Searcher(id);
}
function DoSearch()
{
	searchObj = document.getElementById('searchBox');
	GetPosts( searchObj.value, '1');
}

function EmptySearcher(id)
{
	ss = document.getElementById('searcherStatus');
	if(ss.value == '')
	{
		document.getElementById('searcherStatus').value = id.value;
		id.value = '';
	}
	else if(id.value == ''){
		id.value = document.getElementById('searcherStatus').value;
		document.getElementById('searcherStatus').value = '';
	}
}
