function executeDB(sql){
		var processScriptUrl=baseurl+'ajax/myphpajax.php';
		cp.call(processScriptUrl,'executeDB',return_value,sql);
	
}
	
function return_value(result){
		dbreport=result.getElementsByTagName('dbreport').item(0).firstChild.data;
		if (dbreport=='1'){
			recordcount=result.getElementsByTagName('recordcount').item(0).firstChild.data;
			coloumcount=result.getElementsByTagName('coloumcount').item(0).firstChild.data;

				for( i=0;i<recordcount;i++){
					dbArray[i]=new Array(recordcount);
					for( ii=0;ii<coloumcount;ii++){
						dbArray[i][ii]=result.getElementsByTagName('dbvalue'+i+ii).item(0).firstChild.data;															
					}
				}	
		}


dbLoaded = false;
							
															
}
	function insertInToTable(tblId, varRow, varCell, varData){
		try{
			var x=document.getElementById(tblId).rows[varRow].cells;
			x[varCell].innerHTML=varData;
			return false;
		}
		catch(Err){
			return false;
		}
	}

	function txtBoxValidation(myId,defaultColor,errColor){
		try{	
			me=document.getElementById(myId);

			if(me.value==""){	
				me.style.background=errColor;
				me.setFocus;
				return false;
			}
			else{
				me.style.background=defaultColor;
				me.setFocus;
				return true;
			}
		}
		catch(Err){
			return 'Err';
		}
	}

function hideMe(myId){
	document.getElementById(myId).style.display="none";
	
}

function showMe(myId){
	document.getElementById(myId).style.display="block";
	
}

function directMyvalueto(myValue,thatId){
	document.getElementById(thatId).value=myValue;
}

// Video Comment Begin
function fxVideoComment(hidethisdiv,commentarea,userid,videoid)
{
	commentdetails=document.getElementById(commentarea).value;
	if(commentdetails=='')
	{
		showMe('addcommentError');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('addcommentError');
		cp.call(baseurl+'/ajax/myajaxphp.php','video_comments',video_comment_response,commentdetails,userid,videoid);
	}	
}

function video_comment_response(vcomresult)
{
	if(vcomresult.getElementsByTagName('vcommsg').item(0).firstChild.data==0)
	{
		showMe('vcommentsfailure');
		showMe('addcommentdiv');
	}
	else
	{
		showMe('vcommentssuccess');
	}
}
// Video Comment End

// Check Username Begin
function fxCheckUsername(hidethisdiv,checkusername)
{
	cusername=document.getElementById(checkusername).value;
	if(cusername=='')
	{
		hideMe('isavailable');
		hideMe('isnotavailable');
		showMe('usernameisempty');
	}
	else
	{
		hideMe('usernameisempty');
		hideMe(hidethisdiv);
		cp.call(baseurl+'/ajax/myajaxphp.php','check_username',check_username_response,cusername);
	}	
}

function check_username_response(cunameresult)
{
	if(cunameresult.getElementsByTagName('cunamemsg').item(0).firstChild.data==0)
	{
		hideMe('isavailable');
		showMe('isnotavailable');
		showMe('checkagain');
	}
	else if(cunameresult.getElementsByTagName('cunamemsg').item(0).firstChild.data==2)
	{
		hideMe('isavailable');
		hideMe('isnotavailable');
		showMe('usernameisempty');
		showMe('checkagain');
	}
	else
	{
		hideMe('isnotavailable');
		showMe('isavailable');
		showMe('checkagain');
	}
}
// Check Username End

// Profile Comment Begin
function fxProfileComment(hidethisdiv,commentarea,userid,profileid)
{
	commentdetails=document.getElementById(commentarea).value;
	if(commentdetails=='')
	{
		showMe('addcommentError');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('addcommentError');
		cp.call(baseurl+'/ajax/myajaxphp.php','profile_comments',profile_comment_response,commentdetails,userid,profileid);
	}	
}

function profile_comment_response(profcomresult)
{
	if(profcomresult.getElementsByTagName('pcommsg').item(0).firstChild.data==0)
	{
		showMe('vcommentsfailure');
		showMe('addcommentdiv');
	}
	else
	{
		showMe('vcommentssuccess');
	}
}
// Profile Comment End

// Report Video Begin
function fxReportVideo(hidethisdiv,vreportremarks,vreportreason,userid,videoid)
{
	videoreportremarks=document.getElementById(vreportremarks).value;
	videoreportreason=document.getElementById(vreportreason).value;
	if(videoreportreason=='')
	{
		showMe('vreportreasonError');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('vreportreasonError');
		cp.call(baseurl+'/ajax/myajaxphp.php','video_report',video_report_response,videoreportremarks,videoreportreason,userid,videoid);
	}	
}

function video_report_response(vreportresult)
{
	if(vreportresult.getElementsByTagName('vrepmsg').item(0).firstChild.data==0)
	{
		showMe('vreportfailure');
		showMe('reportvideodiv');
	}
	else
	{
		showMe('vreportsuccess');
	}
}
// Report Video End

// Send Message Begin
function fxSendMessage(hidethisdiv,sendmessagesubject,sendmessagetext,userid,profileid)
{
	sendmessagesubjectz=document.getElementById(sendmessagesubject).value;
	sendmessagetextz=document.getElementById(sendmessagetext).value;
	if(userid=='')
	{
		showMe('sendmessagefailure');
	}
	else if(profileid=='')
	{
		showMe('sendmessagefailure');
	}
	else if(sendmessagesubjectz=='')
	{
		hideMe('mtextfailure');
		showMe('msubjectfailure');
	}
	else if(sendmessagetextz=='')
	{
		hideMe('msubjectfailure');
		showMe('mtextfailure');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('sendmessagefailure');
		hideMe('msubjectfailure');
		hideMe('mtextfailure');
		cp.call(baseurl+'/ajax/myajaxphp.php','send_message',send_message_response,sendmessagesubjectz,sendmessagetextz,userid,profileid);
	}	
}

function send_message_response(sendmessageresult)
{
	if(sendmessageresult.getElementsByTagName('sendmessagetomsg').item(0).firstChild.data==0)
	{
		hideMe('msubjectfailure');
		hideMe('mtextfailure');
		showMe('sendmessagefailure');
		showMe('sendmessagediv');
	}
	else
	{
		hideMe('msubjectfailure');
		hideMe('mtextfailure');
		hideMe('sendmessagefailure');
		showMe('sendmessagesuccess');
	}
}
// Send Message End

// Add To Friends Begin
function fxAddToFriends(hidethisdiv,addtofriendsmessage,userid,profileid)
{
	addtofriendzmessage=document.getElementById(addtofriendsmessage).value;
	if(userid=='')
	{
		showMe('addtofriendsfailure');
	}
	else if(profileid=='')
	{
		showMe('addtofriendsfailure');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('addtofriendsfailure');
		cp.call(baseurl+'/ajax/myajaxphp.php','add_to_friends',add_to_friends_response,addtofriendzmessage,userid,profileid);
	}	
}

function add_to_friends_response(add_to_friendsresult)
{
	if(add_to_friendsresult.getElementsByTagName('addtofriendsmsg').item(0).firstChild.data==0)
	{
		hideMe('addtofriendsexists');
		showMe('addtofriendsfailure');
		showMe('addtofriendsdiv');
	}
	else if(add_to_friendsresult.getElementsByTagName('addtofriendsmsg').item(0).firstChild.data==2)
	{
		hideMe('addtofriendsfailure');
		showMe('addtofriendsexists');
		showMe('addtofriendsdiv');
	}
	else
	{
		hideMe('addtofriendsfailure');
		hideMe('addtofriendsexists');
		showMe('addtofriendssuccess');
	}
}
// Add To Friends End

// Share Doc Begin
function fxShareVideo(hidethisdiv,vsharemessage,vshareto,userid,videoid)
{
	videosharemessage=document.getElementById(vsharemessage).value;
	videoshareto=document.getElementById(vshareto).value;
	if(videoshareto=='')
	{
		showMe('vshareemptyError');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('vshareemptyError');
		cp.call(baseurl+'/ajax/myajaxphp.php','video_share',video_share_response,videosharemessage,videoshareto,userid,videoid);
	}	
}

function video_share_response(vshareresult)
{
	if(vshareresult.getElementsByTagName('vshrmsg').item(0).firstChild.data==0)
	{
		showMe('vsharefailure');
		showMe('sharedocdiv');
	}
	else if(vshareresult.getElementsByTagName('vshrmsg').item(0).firstChild.data==2)
	{
		showMe('vsharehalffailure');
		showMe('sharedocdiv');
	}
	else
	{
		showMe('vsharesuccess');
	}
}
// Share Doc End

// Subscribe To Member Begin
function fxSubscribe(hidethisdiv,subscribee,subscriber)
{
	hideMe(hidethisdiv);	
	cp.call(baseurl+'/ajax/myajaxphp.php','member_subscribe',subscribe_response,subscribee,subscriber);		
}

function subscribe_response(subresult)
{
	var subresp=subresult.getElementsByTagName('submessage').item(0).firstChild.data;
	if(subresp=='0')
	{
		showMe('subscribeFailure');
	}
	else
	{
		showMe('subscribeSuccess');
	}
}
// Subscribe To Member End

// Favorite Video Begin
function fxFavVideo(hidethisdiv,fuserid,fvideoid)
{
	hideMe(hidethisdiv);	
	cp.call(baseurl+'/ajax/myajaxphp.php','fav_video',fav_video_response,fuserid,fvideoid);		
}

function fav_video_response(favvidresult)
{
	var favvidresp=favvidresult.getElementsByTagName('favvidmessage').item(0).firstChild.data;
	if(favvidresp=='0')
	{
		showMe('addtofavFailure');
	}
	else
	{
		showMe('addtofavSuccess');
	}
}
// Favorite Video End


// Video Rating Begin
function fxVideoRater(rating,videoid)
{
	cp.call(baseurl+'ajax/myajaxphp.php','rate_video',return_video_rating,rating,videoid);
}

function return_video_rating(vrrestults)
{
	var vstatus = vrrestults.getElementsByTagName('vstatus').item(0).firstChild.data;				
	if(vstatus=='0')
	{
		showMe('ratingExists');
	}
	else if(vstatus=='1')
	{
		showMe('ratingSuccess');
	}
	else
	{
		showMe('ratingLogin');
	}
				
	return false;
}
// Video Rating End 

function showhidelists(a,b){
	showMe(a);
	hideMe(b);	
}

function clearsearch(thisfield, defaulttext) {	
if (document.getElementById(thisfield).value == defaulttext) {
document.getElementById(thisfield).value = "";
}
}

function checksearch(thisfield, defaulttext) {
if (document.getElementById(thisfield).value == "") {
document.getElementById(thisfield).value = defaulttext;
}
}