function confirm_fetchRec(message,url,loadRecordID,progressID)
{
	if (confirm(message))
	{
		fetchRec(url,loadRecordID,progressID);
	}
	else
	{
		return false;
	}
}
function fetchRec(url,loadRecordID,progressID)
{
	var pars = '';
	this.progressID = progressID;
	this.loadRecordID = loadRecordID;
	if(this.progressID != '')
	{
		$(this.progressID).innerHTML = '<img src="images/loading.gif" align="center">';
	}
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'get',
		parameters: pars,
		onComplete: onCompleteProcess
	});
}
function onCompleteProcess(o)
{
	var responseTextTrim = trim(o.responseText);
	$(this.loadRecordID).innerHTML = responseTextTrim;
	
	if(this.progressID != '')
	{
		if($(this.progressID))
		{
			$(this.progressID).innerHTML = "";
		}
	}
}
function fetchFrm(url,frmID,loadRecordID,progressID,redirectUrl)
{
	this.frmID = frmID;
	this.redirectUrl = redirectUrl;
	this.progressID = progressID;
	this.loadRecordID = loadRecordID;
	var pars = Form.serialize(this.frmID);
	if(this.progressID != '')
	{
		$(this.progressID).innerHTML = '<img src="images/loading.gif">';
	}
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'get',
		parameters: pars,
		onComplete: onCompleteProcessFrm
	});
	return false;
}
function onCompleteProcessFrm(o)
{
	if(this.progressID != '')
	{
		if($(this.progressID))
		{
			$(this.progressID).innerHTML = "";
		}
	}
	
	var responseTextTrim = trim(o.responseText);
	var returnStatus = responseTextTrim.substr(0,1);
    var returnText = responseTextTrim.substr(1);
	if (returnStatus == 0)
	{
		$(this.loadRecordID).innerHTML = returnText;
	}
	else if(returnStatus == 2)
	{
		window.location.href = this.redirectUrl;
	}
	else
	{
		$(this.loadRecordID).innerHTML = "";
		$(this.frmID).innerHTML = returnText;
	}
}
function selectthis(selected_character_id)
{
	var url = 'join.php?IsProcess=Y&character_id='+selected_character_id;
	//$('waiting').innerHTML = '<img src="images/loading.gif" align="center">';
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'get',
		onComplete: onCompleteSelectCharacterProcess
	});
}

function onCompleteSelectCharacterProcess(o)
{
	var responseTextTrim = trim(o.responseText);
	//$('waiting').innerHTML = '';
	$('character').innerHTML = responseTextTrim;
}
function tostep3(formid,ajaxpagename)
{
	
	
	var url = ajaxpagename+'?IsProcess=Y';
	
	//$('waiting').innerHTML = '<img src="images/loading.gif" align="center">';
	var pars=Form.serialize(formid);
	
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'post',
		parameters: pars,
		onComplete: onCompleteStep3
	});
		
}
function onCompleteStep3(o)
{
	var responseTextTrim = trim(o.responseText);
	//$('waiting').innerHTML = '';
	if(responseTextTrim == '1')
	{
		window.location.href="join_step3.php";
	}
	else
	{
		$('err').innerHTML = "";
		$('err').innerHTML = '<div class=error>'+responseTextTrim+'</div>';
	}
}
function tostep4(formid,ajaxpagename)
{
	//alert(ajaxpagename);
	var url = ajaxpagename+'?IsProcess=Y';
	
	//$('waiting').innerHTML = '<img src="images/loading.gif" align="center">';
	var pars=Form.serialize(formid);
	
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'post',
		parameters: pars,
		onComplete: onCompleteStep4
	});
		
}
function onCompleteStep4(o)
{
	var responseTextTrim = trim(o.responseText);
	
	//$('waiting').innerHTML = '';
	if(responseTextTrim == '1')
	{
		window.location.href="join_step4.php";
	}
	else
	{
		$('err').innerHTML = "";
		$('err').innerHTML = '<div class=error>'+responseTextTrim+'</div>';
	}
}
function addtofavourite(gameid)
{
		//alert(ajaxpagename);
	var url = 'playgame.php?IsProcess=Y&game_id='+gameid;
	
	$('ajaxmsg').innerHTML = '<img src="images/loading.gif" align="center">';
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'get',
		onComplete: ProcessGeneralGet
	});
}
function ProcessGeneralGet(o)
{
	var responseTextTrim = trim(o.responseText);
	$('ajaxmsg').innerHTML = '';	
	
	$('ajaxmsg').addClassName('error');
	$('ajaxmsg').innerHTML = responseTextTrim;
	
}
function addtofavourite_video(video_id)
{
	var url = 'play-video.php?IsProcess=Y&video_id='+video_id;
	
	$('ajax_msg').innerHTML = '<img src="images/loading.gif" align="center">';
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'get',
		onComplete: ProcessGeneralGet_video
	});
}
function ProcessGeneralGet_video(o)
{
	var responseTextTrim = trim(o.responseText);
	$('ajax_msg').innerHTML = "";	
	
	$('ajax_msg').addClassName('error');
	$('ajax_msg').innerHTML = responseTextTrim;
}
function addto_favourite_video(video_id)
{
	var url = 'friend-play-video.php?IsProcess=Y&video_id='+video_id;
	
	$('ajax_msg').innerHTML = '<img src="images/loading.gif" align="center">';
	var myAjax = new Ajax.Request (
	url,
	{
		method: 'get',
		onComplete: Process_GeneralGet_video
	});
}
function Process_GeneralGet_video(o)
{
	var responseTextTrim = trim(o.responseText);
	$('ajax_msg').innerHTML = "";	
	
	$('ajax_msg').addClassName('error');
	$('ajax_msg').innerHTML = responseTextTrim;
}
function share(url, textareaid, formid)
{
	
	var pars=Form.serialize(formid);
	
   	$('ajaxmsg').innerHTML='<img src="images/loading.gif">';
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'post',
            parameters: pars,
            onComplete: ProcessGeneralPost
        });
}
function ProcessGeneralPost(o)
{
	var responseTextTrim = trim(o.responseText);
	
	$('ajaxmsg').innerHTML = '';	
	
	$('ajaxmsg').addClassName('error');
	$('ajaxmsg').innerHTML = responseTextTrim;
	
}


function wall(url, textareaid, formid)
{
	
	var pars=Form.serialize(formid);
   	$('msgs').innerHTML='<img src="images/loading.gif">';
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'post',
            parameters: pars,
            onComplete: ProcessGeneralPost_wall
        });
}
function ProcessGeneralPost_wall(o)
{
	var responseTextTrim = trim(o.responseText);
	$('msgs').innerHTML = '';	
	$('wall_text').value='';
	//$('ajaxmsg').addClassName('error');
	$('msgs').innerHTML = responseTextTrim;
	
}
function delete_walltext(wall_id)
{
	if(confirm("Do you want to delete this post ???"))	
	{
		var url = 'my-wall.php?IsProcess=Y&wall_id='+wall_id;
	
		$('ajaxmsg').innerHTML = '<img src="images/loading.gif" align="center">';
		var myAjax = new Ajax.Request (
		url,
		{
			method: 'get',
			onComplete: Processdelete_walltext
		});
	}
}
function delete_walltext(wall_id)
{
	if(confirm("Do you want to delete this post ???"))	
	{
		var url = 'friend-wall.php?IsProcess=Y&wall_id='+wall_id;
	
		$('ajaxmsg').innerHTML = '<img src="images/loading.gif" align="center">';
		var myAjax = new Ajax.Request (
		url,
		{
			method: 'get',
			onComplete: Processdelete_walltext
		});
	}
}
function Processdelete_walltext(o)
{
	var responseTextTrim = trim(o.responseText);
	$('ajaxmsg').innerHTML = '';	
	
	$('msgs').innerHTML = responseTextTrim;
	
}
function share_event(url, formid)
{
	
	var pars=Form.serialize(formid);
   	$('ajaxmsg').innerHTML='<img src="images/loading.gif">';
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'post',
            parameters: pars,
            onComplete: Processshare_event
        });
}
function Processshare_event(o)
{
	var responseTextTrim = trim(o.responseText);
	$('ajaxmsg').innerHTML = '';	
	
	$('ajaxmsg').addClassName('error');
	$('ajaxmsg').innerHTML = responseTextTrim;
	
}
