// change url
function checkUrl(f)
{
	if (f != ""){
	DWREngine._execute(_cfscriptLocation, null, 'checkUrl', f, checkUrlText);
	}
}
function checkUrlText(result)
{
	if (result != 'ok'){
		alert('That url is already in use!.  Please choose another url.');
		document.changeurl.newurl1.value='';
		document.changeurl.newurl2.value='';
		document.changeurl.newurl1.focus();
	}
}


// invite a friend
function inviteAFriend(f)
{
	if (f != ""){
	DWREngine._execute(_cfscriptLocation, null, 'inviteAFriend', f, inviteAFriendText);
	}
}
function inviteAFriendText(result)
{
	document.getElementById("inviteAFriend").innerHTML = result;
}


// verify unique email during registration
function checkEmail(e)
{
	if (e != ""){
	DWREngine._execute(_cfscriptLocation, null, 'checkEmail', e, checkEmailText);
	}
}
function checkEmailText(result)
{
	if (result != 'ok'){
		alert('That email is already in use!.  Please choose another email.');
		document.newuser.remail.value='';
		document.newuser.remail.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);
}

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 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;}
	if(str > 2000) { alert("Comment is too long! Only 2000 characters allowed.");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;
}

// check group name
function displayPic(f)
{
	var uID = f.value;
	DWREngine._execute(_cfscriptLocation, null, 'displayPic', uID, showDisplayPic);
}
function showDisplayPic(result)
{
	//result: id:displayname:imagepath
	var d = result.split(':');
	//d[0],d[1],d[2],d[3]

	if(result == "invalid") {
		document.getElementById("profilepic").innerHTML = "Click Friend Name To View Image";
	} else {
		if(d[3] == 1)
			document.getElementById("profilepic").innerHTML = "<a class=user href=http://www.pluginroom.com/"+d[0]+">"+d[1]+"</a><br><img src=http://pluginroom.com/dir/"+d[0]+"/"+d[2]+" width=100 border=0>";
		else
			document.getElementById("profilepic").innerHTML = "<a class=user href=http://www.pluginroom.com/"+d[0]+">"+d[1]+"</a><br><img src=http://pluginroom.com/Images/noimage.gif width=100 border=0>";
	}
	//document.getElementById("namecheckdiv").innerHTML = result;

}

// subscribe to blog
function subscribeBlog(uID)
{
	//alert(uID);
	DWREngine._execute(_cfscriptLocation, null, 'subscribeBlog', uID, showSubscribeBlogText);
}

function showSubscribeBlogText(result)
{
	document.getElementById("subscribe").innerHTML = result;
}

// preview Blog/Customization
function previewBlog(uID)
{
	DWREngine._execute(_cfscriptLocation, null, 'previewBlog', uID, previewBlogText);
}

function previewBlogText(result)
{
	return false;
}