/*




*/
function createRequestObject()
{
	var request_;
	var browser = navigator.appName;
	
	/*
	#	If the browser is MSIE, use active x to create
	#	the XMLHttpRequest object
	#
	#	Else use the standard method
	*/
	if(browser == "Microsoft Internet Explorer")
	{
		request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_ = new XMLHttpRequest();
	}
	
return request_;
}


var http = createRequestObject();

function ajax ( method, url, callback, async )
{
	/*
	#	IF aysnc isnt true, its false
	*/
	if ( async != true )
	{
		async = false;
	}

	/*
	#	Method is post, send extra header
	*/
	if ( method == 'post' )
	{
		http.open ( 'post', url, async );
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
	}
	else if ( method == 'get' )
	{
		/*
		#	Method is get, send normal request
		*/
		http.open ( 'get', url, async );
	}

	/*
	#	Set callback function, called on state change
	*/
	http.onreadystatechange = callback;

	http.send(null);

}

//setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')

function handleInfoo()
{
	if ( http.readyState == 4 )
	{
		var response = http.responseText;
		
		window.alert(response);
	}
}

/*
# The next functions deal with processing a rating
*/
function rateContent ( rating, category, id, user )
{
	d = new Date(); now = d.getTime();
	var url = '/backend/ajax/rate_process.php?rating=' + rating + '&cat=' + category + '&id=' + id + '&user=' + user;

	ajax ( 'get', url, handleRating, true );
}

function handleRating()
{
	if ( http.readyState == 4 )
	{
		var response = http.responseText;
		
		if ( response != '' )
		{
			alert ( response );
		}
	}
}

function confirmation( message, url)
{
	var answer = confirm ( message )
	if ( answer )
  {
		window.location = url;
	}
}

function showHide(id)
	{
		var elem = document.getElementById(id);
		var status = (elem.style.display == 'block')
						? 'none'
						: 'block';
		elem.style.display = status;
	}

function toggleCategory(mode)
{
	var shortList = document.getElementById('premtemps-catselect');
	var longList = document.getElementById('premtemps-full');

	if(mode == 1)
	{
		shortList.style.display = 'none';
		longList.style.display = 'block';
	}
	else if(mode == 0)
	{
		shortList.style.display = 'block';
		longList.style.display = 'none';
	}
	else
		return false;
}