function rateVideo(video_id, rating)
{
		makeHttpRequest('/v2/ajax.videos.php?action=rateVideo&video_id=' + video_id + '&rating=' + rating, 'document.getElementById("ajaxMyRating").innerHTML=');
		makeHttpRequest('/v2/ajax.videos.php?action=getRating&video_id=' + video_id, 'document.getElementById("ajaxRating").innerHTML=');
}

function deleteVideoComment(div, comment_id) {
		if(confirm('Are you sure you want to delete this comment?'))
		{
				makeHttpRequest('/v2/ajax.videos.php?action=deleteComment&comment_id=' + comment_id, 'document.getElementById("' + div + '").innerHTML=');
		}
		
}


function sendVideo() {

	if(document.eaf.myname.value.length > 0)
	{
		if(document.eaf.myemail.value.length > 0 && checkEmail(document.eaf.myemail.value))
		{
			var string='';

			
			var FormName = 'eaf';
			var FieldName = 'user_ids[]';
			
			// gather user_ids into string
			
			if(document.forms[FormName].elements[FieldName])
			{

				var objCheckBoxes = document.forms[FormName].elements[FieldName];
				var countCheckBoxes = objCheckBoxes.length;
				if(!countCheckBoxes)
				{
					if(objCheckBoxes.checked)
					{
						string = objCheckBoxes.value;
					}
				}
				else
				{
					for(var i = 0; i < countCheckBoxes; i++)
						if(objCheckBoxes[i].checked)
							string = string + objCheckBoxes[i].value + ',';
				}
				
				// drop last comma
				string = string.substring(0, string.length - 1);
			}

			
			if (document.eaf.video_id) {
				video_id = document.eaf.video_id.value;
				photo_id = '';
			}else{
				photo_id = document.eaf.photo_id.value;
				video_id = '';
			}
				
				
			// submit over ajax
			if(document.eaf.url)
			{
				makeHttpPostRequest('/v2/ajax.videos.php', 'action=sendMedia&video_id=' + video_id + '&photo_id=' + photo_id + '&myname=' + document.eaf.myname.value + '&myemail=' + document.eaf.myemail.value + '&theirname=' + document.eaf.theirname.value + '&url=' + document.eaf.url.value + '&theiremail=' + document.eaf.theiremail.value + '&friends=' + string, 'document.getElementById(\'ajaxSendVideo\').innerHTML=');
			}
			else
			{
				makeHttpPostRequest('/v2/ajax.videos.php', 'action=sendMedia&video_id=' + video_id + '&photo_id=' + photo_id + '&myname=' + document.eaf.myname.value + '&myemail=' + document.eaf.myemail.value + '&theirname=' + document.eaf.theirname.value + '&theiremail=' + document.eaf.theiremail.value + '&friends=' + string, 'document.getElementById(\'ajaxSendVideo\').innerHTML=');
			}
			
			
			return false;
		}
		else
		{
			alert('Please supply a valid email address');
			document.eaf.myemail.focus();
			return false;
		}
	}
	else
	{
		alert('Please supply your name');
		document.eaf.myname.focus();
		return false;
	}	
}

function sendVideoToAFriend() {

	GetHeightDef();
	
	// divs are called
	// uploadingscreen and uploadingpanel
	var panelWidth = 550;
	var panelHeight = 300;
	
	document.getElementById('stafscreen').style.height = HeightDef + "px";
	document.getElementById('stafscreen').style.width = WidthDef + "px";

	
	// now position the panel
	document.getElementById('stafpanel').style.top = (HeightDef - (panelHeight+100))/2 + "px";
	document.getElementById('stafpanel').style.left = (WidthDef - panelWidth)/2 + "px";
	
	document.getElementById('stafscreen').style.display='';
	document.getElementById('stafpanel').style.display='';

}

function commentVideo() {
		
		
		if(!document.comment.comment.value)
		{
			alert('Please type in your comment....');
			document.comment.comment.focus();
			return false;
		}
		else
		{
			document.comment.button.disabled=true;
			document.comment.button.value='Adding comment......';
			makeHttpPostRequest('/v2/ajax.videos.php', 'action=postComment&video_id=' + document.comment.video_id.value + '&comment=' + document.comment.comment.value, 'document.getElementById(\'ajaxComments\').innerHTML=');
			return false;
		}

}