// polling vote

function pollVote(id,vote,div)
{
	//alert(id + '::' + vote + '::' + div);return;
	var str = id + '::' + vote + '::' + div;
	DWREngine._execute(_cfscriptLocation, null, 'pollVote', str, showPollText);
}

function showPollText(result)
{
	//alert(result);return;
	splitstring = result.split("::");
	div = splitstring[0];
	text = splitstring[1];
	document.getElementById(div).innerHTML = "<font color=yellow><b>"+text+"</b></font>";
}


// vote fav band
function voteFav(vStr)
{
	DWREngine._execute(_cfscriptLocation, null, 'voteFav', vStr, showVoteText);
}

function showVoteText(result)
{
	splitstring = result.split("::");
	dText = splitstring[1];
	id = splitstring[0];
	document.getElementById("votediv"+id).innerHTML = dText;
}

function checkBandName(u)
{
	if (u != ''){
	DWREngine._execute(_cfscriptLocation, null, 'checkBandName', u, checkBandNameText);
	}
}

function checkBandNameText(result)
{
	if (result != 'ok'){
		alert('That band name is already in use!.  Please choose another name.');
		document.addBand.bname.value='';
		document.addBand.bname.focus();
	}else{
		var tstring = '';
		result=document.addBand.bname.value;
		result = '' + result;
		splitstring = result.split(" ");
		for(i = 0; i < splitstring.length; i++)
		tstring += splitstring[i];
		var tb='http://www.netvision.fm/'  + tstring ;
		document.getElementById("intband").innerHTML = tb;
	}
}



function checkUsername(u)
{
	
	if (u != ''){
	DWREngine._execute(_cfscriptLocation, null, 'checkUsername', u, checkUsernameText);
	}
}

function checkUsernameText(result)
{
	if (result != 'ok'){
		
		alert('That username is already in use!.  Please choose another username.');
		document.newuser.rusername.value='';
		document.newuser.rusername.focus();
	}
	//document.getElementById("addFav").innerHTML = result;
}



// Add to favorites
function addToFav(tID) //oID - adder userid, tID - target userID to be added
{
	//alert(tID);
	//DWRUtil.useLoadingMessage();
	//DWREngine._errorHandler =  errorHandler;
	//var state2 = "";//DWRUtil.getValue("state");
	DWREngine._execute(_cfscriptLocation, null, 'addToFavVideo', tID, showAddToFavText);
}

// save to favorite users
function addToFav2(uID)
{
	DWREngine._execute(_cfscriptLocation, null, 'addToFavUser', uID, showAddToFavText);
}
// save to favorite users
function addToFavUser(uID)
{
	DWREngine._execute(_cfscriptLocation, null, 'addToFavUser', uID, showAddToFavText);
}// save to favorite users
function addToFavBand(bID)
{
	DWREngine._execute(_cfscriptLocation, null, 'addToFavBand', bID, showAddToFavText);
}
function showAddToFavText(result)
{
	document.getElementById("addFav").innerHTML = result;
}

// subscribe to video/user
function subscribe(uID)
{
	//alert(uID);
	DWREngine._execute(_cfscriptLocation, null, 'subscribe', uID, showSubscribeText);
}

function showSubscribeText(result)
{
	document.getElementById("subscribe").innerHTML = result;
}



// block user
function blockUser(bID)
{
	DWREngine._execute(_cfscriptLocation, null, 'blockUser', bID, showBlockUserText );
}

function showBlockUserText(result)
{
	document.getElementById("block").innerHTML = result;
}

// rate band/profile
function rateProfile(vID)
{
	DWREngine._execute(_cfscriptLocation, null, 'rateProfile', vID, showRateText );
}

// rate video
function rateVideo(vID)
{
	DWREngine._execute(_cfscriptLocation, null, 'rateVideo', vID, showRateText );
}

function showRateText(result)
{
	document.getElementById("rate").innerHTML = result;
}

// add comment
function addComment(vID,cText,cType)
{
	var str = cText.length;
	if(str < 2) { alert("Comment is too short!");return false;}
	vID = vID + '::' + cText + '::' + cType;
	DWREngine._execute(_cfscriptLocation, null, 'addComment', vID, showCommentText);
}

function showCommentText(result)
{
	document.getElementById("commentdiv").innerHTML = result;
}

// set favorite profile view status
function setFavoriteProfileStatus(uID,sText)
{
	uID = uID + '::' + sText;
	DWREngine._execute(_cfscriptLocation, null, 'setFavoriteProfileStatus', uID, showFavoriteProfileStatus);
}

function showFavoriteProfileStatus(result)
{
	document.getElementById("profilestatus").innerHTML = result;
}

// check group name
function checkGroupName(name)
{
	if(name == "") {
		alert('Please type in a group name');
		return;
	}
	DWREngine._execute(_cfscriptLocation, null, 'checkGroupName', name, showGroupNameStatus);
}

function showGroupNameStatus(result)
{
	if(result == "ok") {
		alert('Group Name Valid');
	} else {
		document.createGroup.gname.value = "";
		document.createGroup.gname.focus();
		alert(result);
	}
	//document.getElementById("namecheckdiv").innerHTML = result;
}

