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

// Channel Comment Begin
function fxChannelComment(hidethisdiv,commentarea,userid,channelid)
{
	commentdetails=document.getElementById(commentarea).value;
	if(commentdetails=='')
	{
		showMe('addcommentError');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('addcommentError');
		hideMe('vcommentsnotmember');
		cp.call(baseurl+'/ajax/myajaxphp.php','channel_comments',channel_comment_response,commentdetails,userid,channelid);
	}	
}

function channel_comment_response(chancomresult)
{
	if(chancomresult.getElementsByTagName('chancommsg').item(0).firstChild.data==2)
	{
		showMe('vcommentsnotmember');
		showMe('addcommentdiv');
	}
	else if(chancomresult.getElementsByTagName('chancommsg').item(0).firstChild.data==0)
	{
		showMe('vcommentsfailure');
		showMe('addcommentdiv');
	}
	else
	{
		showMe('vcommentssuccess');
	}
}
// Channel 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

// Add Video To Channel Begin
function fxAddVideoToChannel(hidethisdiv,vaddtochanvideo,userid,videoid)
{
	vaddtochanvideo=document.getElementById(vaddtochanvideo).value;
	hideMe('vaddtochanexists');
	if(vaddtochanvideo=='')
	{
		showMe('vaddtochanvideoError');
	}
	else
	{
		hideMe(hidethisdiv);
		hideMe('vaddtochanvideoError');
		cp.call(baseurl+'/ajax/myajaxphp.php','add_video_to_channel',video_addtochan_response,vaddtochanvideo,userid,videoid);
	}	
}

function video_addtochan_response(vatchanresult)
{
	if(vatchanresult.getElementsByTagName('vatchanmsg').item(0).firstChild.data==2)
	{
		showMe('vaddtochanexists');
		showMe('addtochanneldiv');
	}
	else if(vatchanresult.getElementsByTagName('vatchanmsg').item(0).firstChild.data==0)
	{
		showMe('vaddtochanfailure');
		showMe('addtochanneldiv');
	}
	else
	{
		showMe('vaddtochansuccess');
	}
}
// Add Video To Channel End

// Share Video 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('sharevideodiv');
	}
	else if(vshareresult.getElementsByTagName('vshrmsg').item(0).firstChild.data==2)
	{
		showMe('vsharehalffailure');
		showMe('sharevideodiv');
	}
	else
	{
		showMe('vsharesuccess');
	}
}
// Share Video 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

// Subscribe To Series Begin
function fxSubscribeSeries(hidethisdiv,userid,seriesid)
{
	hideMe(hidethisdiv);	
	cp.call(baseurl+'/ajax/myajaxphp.php','member_subscribe_series',subscribe_response_series,userid,seriesid);		
}

function subscribe_response_series(subseriesresult)
{
	var subseriesresp=subseriesresult.getElementsByTagName('subseriesmessage').item(0).firstChild.data;
	if(subseriesresp=='0')
	{
		showMe('subscribeFailure');
	}
	else
	{
		showMe('subscribeSuccess');
	}
}
// Subscribe To Series End

// Subscribe To Channel Begin
function fxSubscribeChannel(hidethisdiv,userid,channelid)
{
	hideMe(hidethisdiv);	
	cp.call(baseurl+'/ajax/myajaxphp.php','member_subscribe_channel',subscribe_response_channel,userid,channelid);		
}

function subscribe_response_channel(jchanresult)
{
	var jchanresp=jchanresult.getElementsByTagName('jchanmessage').item(0).firstChild.data;
	if(jchanresp=='0')
	{
		showMe('subscribeFailure');
	}
	else
	{
		showMe('subscribeSuccess');
	}
}
// Subscribe To Channel 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 


// Series Rating Begin
function fxSeriesRater(rating,seriesid)
{
	cp.call(baseurl+'ajax/myajaxphp.php','rate_series',return_series_rating,rating,seriesid);
}

function return_series_rating(vsrrestults)
{
	var vsstatus = vsrrestults.getElementsByTagName('vsstatus').item(0).firstChild.data;				
	if(vsstatus=='0')
	{
		showMe('ratingExists');
	}
	else if(vsstatus=='1')
	{
		showMe('ratingSuccess');
	}
	else
	{
		showMe('ratingLogin');
	}
				
	return false;
}
// Series Rating End 

// Channel Rating Begin
function fxChannelsRater(rating,cid)
{
	cp.call(baseurl+'ajax/myajaxphp.php','rate_channel',return_channel_rating,rating,cid);
}

function return_channel_rating(chanrrestults)
{
	var chanstatus = chanrrestults.getElementsByTagName('chanstatus').item(0).firstChild.data;				
	if(chanstatus=='0')
	{
		showMe('ratingExists');
	}
	else if(chanstatus=='1')
	{
		showMe('ratingSuccess');
	}
	else
	{
		showMe('ratingLogin');
	}
				
	return false;
}
// Channel Rating End 

function showhidelists(a,b){
	showMe(a);
	hideMe(b);	
}

function playvideohide(hidethis){
	document.getElementById(hidethis).style.display="none";
}

function playvideoshow(showthis){
	if(document.getElementById('showShareVideo'))
	{
	document.getElementById('showShareVideo').style.display="none";
	}
	if(document.getElementById('showReportVideo'))
	{
	document.getElementById('showReportVideo').style.display="none";
	}
	if(document.getElementById('showAddToChannel'))
	{
	document.getElementById('showAddToChannel').style.display="none";
	}
	if(document.getElementById('showShareVideoNV'))
	{
	document.getElementById('showShareVideoNV').style.display="none";
	}
	if(document.getElementById('showReportVideoNV'))
	{
	document.getElementById('showReportVideoNV').style.display="none";
	}
	if(document.getElementById('showAddToChannelNV'))
	{
	document.getElementById('showAddToChannelNV').style.display="none";
	}
	if(document.getElementById('showAllThumbs'))
	{
	document.getElementById('showAllThumbs').style.display="none";
	}
	document.getElementById(showthis).style.display="block";
}