function setBlank(thetype) {
	var input = $F('doEmail');
	if (thetype == "empty" && input == "your email") {
		$('doEmail').clear();
//		alert(thetype.value);
	} else if (thetype == "fill" && input == "") {
		$('doEmail').value = 'your email';
	}
//alert(thetype);
}
function setEmail() {
	var email = $('doEmail').value;
	if (email != "" && email != "your email") {
		var divID = "response";
		var url = "php/js_setEmail.php";
		var pars = "email=" + email + "&r=" + Math.floor(Math.random());
		var doSetEmail = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	}
	return false;
}
function sendForm(form) {
	if ($F('name') == "") {
		alert("Please provide your name");
		$('name').focus();
		return false;
	} else if ($F('email') == "") {
		alert("Please provide your email");
		$('email').focus();
		return false;
	} else if ($F('message') == "") {
		alert("Please provide a message");
		$('message').focus();
		return false;
	}
	var divID = "response";
	var url = "php/js_sendMail.php";
	var pars = "name=" + escape($F('name')) + "&email=" + escape($F('email')) + "&message=" + escape($F('message')) + "&r=" + Math.floor(Math.random());
	var doSendMessage = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	return false;
}

/*function editStringValue(project_id, the_type, the_value, table, identify) {
	the_value = the_value.replace(/dddd/g, '&quot;');
	the_value = the_value.replace(/ssss/g, "'");
	$(the_type).update('<input type="text" name="' + the_type + '_edit" id="' + the_type + '_edit" value="' + the_value + '" onkeyup="return setStringValue(\'' + project_id + '\', \'' + the_type + '_edit\', \'' + the_type + '\', \'' + table + '\', \'' + identify + '\');" /><br /><input type="submit" value="DONE" style="width:auto" onclick="window.location.reload();" />');
	return false;
}
function editTextareaValue(project_id, the_type, the_value, table, identify) {
	the_value = the_value.replace(/dddd/g, '&quot;');
	the_value = the_value.replace(/ssss/g, "'");
	the_value = the_value.replace(/<br>/g, '\n');
	$(the_type).update('<textarea name="' + the_type + '_edit" id="' + the_type + '_edit" onkeyup="return setStringValue(\'' + project_id + '\', \'' + the_type + '_edit\', \'' + the_type + '\', \'' + table + '\', \'' + identify + '\');" style="text-align:left;"/>' + the_value + '</textarea><br /><input type="submit" value="DONE" style="width:auto" onclick="window.location.reload();">');
	return false;
}
function setStringValue(project_id, the_type, the_div, table, identify) {
	var div = the_type + "_edit";
	var value = escape($(the_type).value);
	var divID = "none";
	var url = "php/js_setStringValue.php";
	var pars = "project_id=" + project_id + "&div=" + the_div + "&value=" + value + "&table=" + table + "&identify=" + identify + "&r=" + Math.floor(Math.random());
	var doSetStringValue = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	return false;
}
function setSelectValue(table, column, the_value, identify, ident) {
	var divID = "none";
	var url = "php/js_setSelectValue.php";
	var get_value = $(the_value).value;
	var pars = "table=" + table + "&column=" + column + "&value=" + get_value + "&identify=" + identify + "&ident=" + ident + "&r=" + Math.floor(Math.random());
	var doSetReturnValue = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	return false;
}
function delItem(item_id, table, column) {
	var divID = "none";
	var url = "php/js_setInactive.php";
	var pars = "id=" + item_id + "&table=" + table + "&column=" + column + "&r=" + Math.floor(Math.random());
	var doSetInactive = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	window.location.reload()
}
function addUser(div, project_id) {
	if ($(div).value != "none") {
		var divID = "user_response";
		var url = "php/js_addUser.php";
		var pars = "project_id=" + project_id + "&user_id=" + $(div).value + "&r=" + Math.floor(Math.random());
		var doAddUser = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
		setTimeout("reloadPage();", 2000);
	}
}
function removeUser(user_id, project_id) {
	var answer = confirm ("Remove User from this project?")
	if (answer) {
//		alert(user_id);
//		alert(project_id);
		var divID = "response";
		var url = "php/js_removeUser.php";
		var pars = "user_id=" + user_id + "&project_id=" + project_id + "&r=" + Math.floor(Math.random());
		var doRemoveUser = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
		setTimeout("reloadPage();", 1000);
	}
}
function reloadPage() {
	window.location.reload();
//alert("5 seconds?");
}

function countChars(div, resp) {
	var count = $(div).value.length;
	var display = count + "/500";
	$(resp).update(display);
}
function submitComment(div, project, file, location, user, adt) {
	the_value = $(div).value;
	if (the_value == "") {
		alert("You must enter a comment to submit.");
	} else {
		the_value = the_value.replace(/dddd/g, '&quot;');
		the_value = the_value.replace(/ssss/g, "'");
		the_value = the_value.replace(/<br>/g, '\n');
		var divID = "comments";
		var url = "/php/js_submitComment.php";
		var pars = "project_id=" + project + "&file=" + file + "&location=" + location + "&adt=" + adt + "&user_id=" + user + "&comment=" + escape(the_value) + "&r=" + Math.floor(Math.random());
//	alert(pars);
		var doSubmit = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
		$('comments').update('');
		$('comm').update('<textarea name="com" id="com" onkeyup=\'return countChars("com", "resp");\'></textarea>');
	}
	return false;
}
function openiPhone(thelink) {
	if (thelink.value != 'none') {
		window.location.href=thelink.value;
	}
}
function startEncode(job_id, divID, root) {
	var answer = confirm ("Begin encoding this file?")
	if (answer) {
		var url = "https://" + root + "/php/js_startEncode.php";
		var pars = "job_id=" + job_id + "&r=" + Math.floor(Math.random());
		var doStartEncode = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
		return false;
	}
}
function setCut(project_id, thetype) {
	if (thetype == "cuts") {
		if ($('setCuts').value == "on") {
			var action = "on";
		} else {
			var action = "off";
		}
	} else if (thetype == "dailies") {
		if ($('setDailies').value == "on") {
			var action = "on";
		} else {
			var action = "off";
		}
	} else {
		if ($('setPromo').value == "on") {
			var action = "on";
		} else {
			var action = "off";
		}
	}
	var answer = confirm ("Change " + thetype + " status to " + action + "?")
	if (answer) {
		var divID = "response";
		var url = "php/js_setCut.php";
		var pars = "action=" + action + "&project_id=" + project_id + "&type=" + thetype + "&r=" + Math.floor(Math.random());
		var doSetCut = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
		setTimeout("reloadPage();", 2000);
	} else {
		setTimeout("reloadPage();", 100);	
	}
}
function setGroup(user_id, group_id, project_id){
	var check = $(group_id).value;
	var divID = "response";
	var url = "php/js_setBox.php";
	var pars = "user_id=" + user_id + "&group_id=" + group_id + "&project_id=" + project_id + "&action=" + check + "&r=" + Math.floor(Math.random());
	var doSetGroup = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	setTimeout("reloadPage();", 1000);	
}
function setAuth(user_id, auth, project_id){
	var divID = "response";
	var url = "php/js_setAuth.php";
	var pars = "user_id=" + user_id + "&auth=" + auth + "&project_id=" + project_id + "&r=" + Math.floor(Math.random());
	var doSetAuth = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	setTimeout("reloadPage();", 1000);	
}
function getCuts(project_id, user_id) {
	var divID = "shoot_days";
	var url = "/php/js_getCutNav.php";
	var pars = "project_id=" + project_id + "&user_id=" + user_id + "&r=" + Math.floor(Math.random());
	alert(pars);
	alert(url);
	var dogetCutNav = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	$('shoot_day_header').update('<a href=\'#nogo\' onclick=\'return getDays("$project_id", "user-id");\'>Shoot Days</a>');
	$('milestone_cuts_header').update('Milestone Cuts');
	return false;
}
function addEncode(form_id, divID, project_id, vers) {
	var thetype = $F(form_id + '_type');
	var bit = $F(form_id + '_bitrate');
	var res = $F(form_id + '_resolution');
	var url = "php/js_addEncode.php";
	var pars = "type=" + thetype + "&bitrate=" + bit + "&resolution=" + res + "&project_id=" + project_id + "&version=" + vers + "&r=" + Math.floor(Math.random());
	var doAddEncode = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	alert(pars);
	setTimeout("reloadPage();", 1500);	
	return false;
}
function editEncode(platform, theversion, thetype, project_id, thespec) {
	var spec = $(thespec).value;
	var url = "php/js_editEncode.php";
	var divID = "response";
	var pars = "platform=" + platform + "&version=" + theversion + "&type=" + thetype + "&project_id=" + project_id + "&spec=" + spec + "&r=" + Math.floor(Math.random());
	var doEditEncode = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
//	alert(pars);
	setTimeout("reloadPage();", 1500);	
	return false;
}
function deleteEncode(platform, theversion, project_id) {
	var answer = confirm ("Delete this encode?")
	if (answer) {
		var url = "php/js_deleteEncode.php";
		var divID = "response";
		var pars = "platform=" + platform + "&version=" + theversion + "&project_id=" + project_id + "&r=" + Math.floor(Math.random());
		var doDeleteEncode = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
//		alert(pars);
		setTimeout("reloadPage();", 1500);	
	}
	return false;	
}

function createFLVplayer(xfilename, xwidth, xheight, divID){
	var so = new SWFObject('mediaplayer.swf','mpl',xwidth,xheight,'8');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','false');
	so.addParam('wmode','window');
	so.addVariable('width',xwidth);
	so.addVariable('height',xheight);
	so.addVariable('file',xfilename);
	so.addVariable('showstop','true');
	so.addVariable('autostart','true');
	so.addVariable('streamscript','stream.php');
	so.addVariable('showdownload','false');
	so.addVariable('javascriptid','mpl');
	so.addVariable('enablejs','true');
//	so.addVariable('id','rollust_medium_206x165');
	so.write(divID);

	var prev_offset = getScrollXY() + 100;
	var interm = alertSize();
	var docHeight = Number(interm)+Number(prev_offset);

	var pwidth = xwidth-10;
	$('playcontrol').setStyle({
		width: pwidth + "px"
	});
	$('playcontrol').update('<p><a href="#nogo" onclick="return closePlayer()");">(-) close preview (-)</a></p>');
//	fromTop = 200 + (padding*200);
//	padding = (200+fromTop) + "px";
	$('player').setStyle({
		marginTop: prev_offset + "px",
		width: xwidth + "px"
	});
//	var dheight = document.height;
	$('preview').setStyle({
		height: docHeight + "px"
	});
	$('preview').show();
	return false;

	return false;
}
*/
