<!-- Check Version -->
function sb_pluginVersion() {
	ajaxObj=sb_createXMLHttp()
	var component = document.getElementById('sb_element').value;
	var url=document.getElementById('mosConfig_live_site').value;
	url=url+"/index2.php?option="+component+"&no_html=1&task=ajax_pluginVersion"
	url=url+"&sid="+ new Date().getTime()
	ajaxObj.open("GET",url,true)
	ajaxObj.onreadystatechange=sb_processPluginVersion
	ajaxObj.send(null);
}
<!-- Check Version -->
<!-- Add Stream -->
function sb_addStream(streamForm) {
	ajaxObj=sb_createXMLHttp()
	var component = document.getElementById('sb_element').value;
	var url=document.getElementById('mosConfig_live_site').value;
	url=url+"/index2.php?option="+component+"&no_html=1&task=ajax_addStream"
	url=url+"&sid="+ new Date().getTime()
	ajaxObj.open("POST",url,true)
	ajaxObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajaxObj.onreadystatechange=sb_processStreamControls
	var sandboxFormBody = sb_getRequestBody(streamForm);
	ajaxObj.send(sandboxFormBody);
}
<!-- Add Stream -->
<!-- Delete Stream -->
function sb_deleteStream() {
	ajaxObj=sb_createXMLHttp()
	var component = document.getElementById('sb_element').value;
	var url=document.getElementById('mosConfig_live_site').value;
	url=url+"/index2.php?option="+component+"&no_html=1&task=ajax_deleteStream"
	url=url+"&sid="+ new Date().getTime()
	ajaxObj.open("POST",url,true)
	ajaxObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajaxObj.onreadystatechange=sb_processStreamControls
	var sandboxForm = document.forms['formStream'];
	var sandboxFormBody = sb_getRequestBody(sandboxForm);
	ajaxObj.send(sandboxFormBody);
}
<!-- Delete Stream -->
<!-- Edit Stream -->
function sb_editStream(vid) {
	var _sb_PROCESSING = document.getElementById('_sb_PROCESSING').value
	document.getElementById('stream_controls_table').onmousedown = new Function("alert ('" + _sb_PROCESSING + "'); return false;")
	ajaxObj=sb_createXMLHttp()
	var component = document.getElementById('sb_element').value;
	var url=document.getElementById('mosConfig_live_site').value;
	url=url+"/index2.php?option="+component+"&no_html=1&task=ajax_editStream&vid="+vid
	url=url+"&sid="+ new Date().getTime()
	ajaxObj.open("POST",url,true)
	ajaxObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajaxObj.onreadystatechange=sb_processStreamControls_edit
	var sandboxForm = document.forms['formStream'];
	var sandboxFormBody = sb_getRequestBody(sandboxForm);
	ajaxObj.send(sandboxFormBody);
}
<!-- Edit Stream -->
<!-- Save Edit Stream -->
function sb_saveEditStream(vid) {
	if (document.forms['formStream'].edit_vid_name.value == "") {
		document.forms['formStream'].edit_vid_name.style.backgroundColor = 'red';
		return false;
	}
	var _sb_PROCESSING = document.getElementById('_sb_PROCESSING').value
	document.getElementById('stream_controls_table').onmousedown = new Function("alert ('" + _sb_PROCESSING + "'); return false;")
	ajaxObj=sb_createXMLHttp()
	var component = document.getElementById('sb_element').value;
	var url=document.getElementById('mosConfig_live_site').value;
	url=url+"/index2.php?option="+component+"&no_html=1&task=ajax_saveEditStream&vid="+vid
	url=url+"&sid="+ new Date().getTime()
	ajaxObj.open("POST",url,true)
	ajaxObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajaxObj.onreadystatechange=sb_processStreamControls
	var sandboxForm = document.forms['formStream'];
	var sandboxFormBody = sb_getRequestBody(sandboxForm);
	ajaxObj.send(sandboxFormBody);
}
<!-- Save Edit Stream -->
<!-- Change Video Page -->
function sb_VidPagination(Page) {
	var _sb_PROCESSING = document.getElementById('_sb_PROCESSING').value
	document.getElementById('vidPagination').onmousedown = new Function("alert ('" + _sb_PROCESSING + "'); return false;")
	document.getElementById('viewPage').value = Page;
	sb_refreshVideos();
}
<!-- Change Video Page -->
<!-- Refresh the videos buffer -->
function sb_refreshVideos() {
	var _sb_PROCESSING = document.getElementById('_sb_PROCESSING').value
	var Page = document.getElementById('viewPage').value;
	if (document.getElementById('listView'))
		document.getElementById('listView').onclick = new Function("alert ('" + _sb_PROCESSING + "'); return false;")
	ajaxObj=sb_createXMLHttp()
	var component = document.getElementById('sb_element').value;
	var url=document.getElementById('mosConfig_live_site').value;
	url=url+"/index2.php?option="+component+"&no_html=1&task=ajax_refreshVideos&page="+Page
	url=url+"&sid="+ new Date().getTime()
	ajaxObj.open("GET",url,true)
	ajaxObj.onreadystatechange=sb_processStreams
	ajaxObj.send(null);
}
<!-- Refresh the videos buffer -->
<!-- Display fullsize video -->
function sb_fullSize(vid, module) {
	if (module === undefined) {
		module = "false";
	}
	var _sb_PROCESSING = document.getElementById('_sb_PROCESSING').value
	if (document.getElementById('MFU_div'))
		document.getElementById('MFU_div').onmousedown = new Function("alert ('" + _sb_PROCESSING + "'); return false;")
	else
		document.getElementById('mini_panel').onmousedown = new Function("alert ('" + _sb_PROCESSING + "'); return false;")
	ajaxObj=sb_createXMLHttp()
	var component = document.getElementById('sb_element').value;
	var url=document.getElementById('mosConfig_live_site').value;
	url=url+"/index2.php?option="+component+"&no_html=1&task=ajax_fullSize&vid="+vid+"&module="+module
	url=url+"&sid="+ new Date().getTime()
	ajaxObj.open("GET",url,true)
	if (module == "false")
		ajaxObj.onreadystatechange=sb_processStreams
	else
		ajaxObj.onreadystatechange=sb_processModStreams
	ajaxObj.send(null);
}
<!-- Display fullsize video -->

function sb_processPluginVersion() {
	if (ajaxObj.readyState==4 || ajaxObj.readyState=="complete") {
		document.getElementById('sb_pluginversion_output').innerHTML=ajaxObj.responseText;
		document.getElementById('ajax_loading').style.display="none";
	}
	else {
		document.getElementById('ajax_loading').style.display="inline";
	}
}

function sb_processStreamControls() {
	if (ajaxObj.readyState==4 || ajaxObj.readyState=="complete") {
		document.getElementById('stream_controls_div').innerHTML=ajaxObj.responseText;
		sb_refreshVideos();
	}
	else {
		document.getElementById('ajax_loading').style.display="inline";
	}
}
function sb_processStreamControls_edit() {
	if (ajaxObj.readyState==4 || ajaxObj.readyState=="complete") {
		document.getElementById('stream_controls_div').innerHTML=ajaxObj.responseText;
		document.getElementById('ajax_loading').style.display="none";
	}
	else {
		document.getElementById('ajax_loading').style.display="inline";
	}
}
function sb_processStreams() {
	if (ajaxObj.readyState==4 || ajaxObj.readyState=="complete") {
		document.getElementById('sandbox_output_streams').innerHTML=ajaxObj.responseText;
		document.getElementById('ajax_loading').style.display="none";
	}
	else {
		document.getElementById('ajax_loading').style.display="inline";
	}
}
function sb_processModStreams() {
	if (ajaxObj.readyState==4 || ajaxObj.readyState=="complete") {
		document.getElementById('mod_ajax_loading').style.display="none";
		document.getElementById('mod_sandbox_output_streams').innerHTML=ajaxObj.responseText;
	}
	else {
		document.getElementById('mod_ajax_loading').style.display="inline";
	}
}

function sb_createXMLHttp() {
	if (typeof XMLHttpRequest != 'undefined')
		return new XMLHttpRequest();
	else if (window.ActiveXObject) {
		var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp",
		"MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0",
		"MSXML2.XmlHttp.5.0"];
		for (var i = avers.length -1; i >= 0; i--) {
			try {
				httpObj = new ActiveXObject(avers[i]);
				return httpObj;
			} catch(e) {}
		}
	}
	throw new Error('XMLHttp (AJAX) not supported by your browser.');
}

function sb_getRequestBody(form_name) {
	var content_to_submit = '';
	var form_element;
	var last_element_name = '';

	for (i = 0; i < form_name.elements.length; i++) {
		form_element = form_name.elements[i];
		switch (form_element.type) {
			// Text fields, hidden form elements
			case 'text':
			case 'file':
			case 'hidden':
			case 'password':
			case 'textarea':
			case 'select-one':
				content_to_submit += form_element.name + '=' + escape(form_element.value) + '&'
			break;
			// Radio buttons
			case 'radio':
				if (form_element.checked) {
					content_to_submit += form_element.name + '=' + escape(form_element.value) + '&'
				}
			break;
			// Checkboxes
			case 'checkbox':
			if (form_element.checked) {
				// Continuing multiple, same-name checkboxes
				if (form_element.name == last_element_name) {
					// Strip of end ampersand if there is one
					if (content_to_submit.lastIndexOf('&') == content_to_submit.length - 1) {
						content_to_submit = content_to_submit.substr(0, content_to_submit.length - 1);
					}
					// Append value as pipe-delimited string
					content_to_submit += '|' + escape(form_element.value);
				}
				else {
					content_to_submit += form_element.name + '=' + escape(form_element.value);
				}
				content_to_submit += '&';
				last_element_name = form_element.name;
			}
			break;
		}
	}
	// Remove trailing separator
	content_to_submit = content_to_submit.substr(0, content_to_submit.length - 1);
	return content_to_submit;
}
