function AjaxRequest()
{
	this.mRequest = this.getHttpRequest();
	this.mHandlers = new Array();
	var self = this;
	
	this.mRequest.onreadystatechange = function()
	{
		if(	self.mHandlers[ self.mRequest.readyState ] != undefined )
		{
			for( i = 0 ; i < self.mHandlers[ self.mRequest.readyState ].length ; i++ )
			{
				self.mHandlers[ self.mRequest.readyState ][ i ]( self );				
			}
		}
	}
}

AjaxRequest.prototype.addEventListener = function( pEventType, pFunction )
{
	if(	this.mHandlers[ pEventType ] == undefined )
	{
		this.mHandlers[ pEventType ] = new Array();
	}
	
	this.mHandlers[ pEventType ].push( pFunction );
}

AjaxRequest.prototype.getHttpRequest = function()
{
	// List of Microsoft XMLHTTP versions - newest first

	var MSXML_XMLHTTP_PROGIDS = new Array
	(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
	);

	// Do we support the request natively (eg, Mozilla, Opera, Safari, Konqueror)

	if( window.XMLHttpRequest != null )
	{
		return new XMLHttpRequest();
	}
	else
	{
		// Look for a supported IE version

		for( i = 0 ; MSXML_XMLHTTP_PROGIDS.length > i ; i++ )
		{
			try
			{
				return new ActiveXObject( MSXML_XMLHTTP_PROGIDS[ i ] );
			}
			catch( e )
			{
			}
		}
	}
	
	return( null );
}
////////////////////////////////////
//// WRITTEN BY MARK FAIL /////////
///////////////////////////////////
function eMeetingDo( fileName, div )
{
	var Ajax = new AjaxRequest();

	if( Ajax.mRequest )
	{				
		Ajax.mFileName 	= fileName;		
		var obj = document.getElementById(div);				

		Ajax.mRequest.open( "GET", fileName);
		Ajax.mRequest.onreadystatechange = function() {
			if(Ajax.mRequest.readyState == 4 && Ajax.mRequest.status == 200){
				obj.innerHTML = Ajax.mRequest.responseText;
			}
		}		
	}
	Ajax.mRequest.send( null );
}

function ProfileTemplate(templateid){
	Timer_Icon('response_template');
	eMeetingDo('inc/ajax/_actions.php?action=ProfileTemplate&tid='+templateid,"response_template");
}
function Timer_Icon(divlayer){
	window.document.getElementById(divlayer).innerHTML='<img src="./images/DEFAULT/load_red.gif" width="16" height="16">';
}
function AddRating(rate, pid, fid){
Timer_Icon('responce_rating');
new Effect.Fade('FileRatingStars');
eMeetingDo('inc/ajax/_actions.php?action=profilerate&rating='+rate+'&pid='+pid+'&fid='+fid,"responce_rating");
}
function SearchSendWink(id, divid, username){
	Timer_Icon('response_search');
	new Effect.Pulsate(divid, { pulses : 9, duration : 5, from : 0 });
	eMeetingDo('inc/ajax/_actions.php?action=SendWink&id='+id+'&username='+username,"response_search");
}
function ProfileSendWink(id){
	Timer_Icon('profile_responce_span');
	eMeetingDo('inc/ajax/_actions.php?action=SendWink&id='+id,"profile_responce_span");
}
function ProfileAddNet(id, netid){
	Timer_Icon('profile_responce_span');
	eMeetingDo('inc/ajax/_actions.php?action=ProfileNetwork&nid='+netid+'&uid='+id,"profile_responce_span");
}
//////////////////////////////////////////////////

//////////////////////////////////////////////////
function validateUsername(username){
	Timer_Icon('response_span');
	eMeetingDo('inc/ajax/_actions.php?action=validateUsername&username='+username,"response_span");
}
function validateEmail(email){
	Timer_Icon('response_span_email');
	eMeetingDo('inc/ajax/_actions.php?action=validateEmail&email='+email,"response_span_email");
}
function validatePassword(password){
	Timer_Icon('response_span_pass');
	eMeetingDo('inc/ajax/_actions.php?action=validatePassword&password='+password,"response_span_pass");
}
function CheckPassword(){
	window.document.getElementById('response_span_rpass').innerHTML="";
	if(document.getElementById('regPassword').value != document.getElementById('regRPassword').value){
		window.document.getElementById('response_span_rpass').innerHTML="Passwords do not match!";
	}
}
///////////////////////////////////////////////////////
function DeleteMessage(mailid,box,senderid){
	Timer_Icon('response_message');
	eMeetingDo('inc/ajax/_actions.php?action=DeleteMessage&box='+box+'&mailid='+mailid+'&senderid='+senderid,"response_message");
}
////////////////////////////////////////////////////////
function DeleteFile(fileid){
	Timer_Icon('response_gallery');
	eMeetingDo('inc/ajax/_actions.php?action=DeleteFile&fileid='+fileid,"response_gallery");
}
////////////////////////////////////////////////////////
function DeleteNetwork(userid){
	Timer_Icon('response_network');
	eMeetingDo('inc/ajax/_actions.php?action=DeleteNetwork&uid='+userid,"response_network");
}
function ApproveNetwork(userid){
	Timer_Icon('response_network');
	eMeetingDo('inc/ajax/_actions.php?action=ApproveNetwork&uid='+userid,"response_network");
}
function UpdateFeaDiv(divid, addid){
	new Effect.Fade(divid);
	Timer_Icon('response_search');
	eMeetingDo('inc/ajax/_actions.php?action=addFavs&id='+addid,"response_search");
}
function RemoveFeaDiv(divid, removeid){
	new Effect.Fade(divid);
	Timer_Icon('response_search');
	eMeetingDo('inc/ajax/_actions.php?action=removeFavs&id='+removeid,"response_search");
}
////////////////////////////////////////////////////////
function ProfileComments(uid, comments){
	new Effect.Fade('CommentsBox');
	Timer_Icon('response_comments');
	eMeetingDo('inc/ajax/_actions.php?action=profilecomment&id='+uid+'&comments='+comments,"response_comments");
}
function DeleteBlogPost(blogid){
	Timer_Icon('response_blog');
	eMeetingDo('inc/ajax/_actions.php?action=DeleteBlogPost&blogid='+blogid,"response_blog");
}
////////////////////////////////////////////////////////
function DeleteCommentsPost(id){
	Timer_Icon('response_comments');
	eMeetingDo('inc/ajax/_actions.php?action=deletecomment&id='+id,"response_comments");
}
function ApproveCommentsPost(id){
	Timer_Icon('response_comments');
	eMeetingDo('inc/ajax/_actions.php?action=approvecomment&id='+id,"response_comments");
}
function DeleteFileCommentsPost(id){
	Timer_Icon('response_comments');
	eMeetingDo('inc/ajax/_actions.php?action=DeleteFileComment&id='+id,"response_comments");
}
function ApproveFileCommentsPost(id){
	Timer_Icon('response_comments');
	eMeetingDo('inc/ajax/_actions.php?action=ApproveFileComment&id='+id,"response_comments");
}
//////////////////////////////////////////
function DeleteMatchTest(id){
	Timer_Icon('response_match');
	eMeetingDo('inc/ajax/_actions.php?action=deleteMatch&id='+id,"response_match");
}
function DeleteMatchTestResult(id){
	Timer_Icon('response_match');
	eMeetingDo('inc/ajax/_actions.php?action=deleteMatchTestResult&id='+id,"response_match");
}
/////////////
function MakeDefaultP(id){
	Timer_Icon('response_gallery');
	eMeetingDo('inc/ajax/_actions.php?action=MakeDefaultImage&id='+id,"response_gallery");
}
function DeleteAlbum(id){
	Timer_Icon('response_gallery');
	eMeetingDo('inc/ajax/_actions.php?action=deleteAlbum&id='+id,"response_gallery");
}
