function sb_Stream(sbform) {
 	var me = sbform.elements;
	var sbx = 0;
	var _sb_VIDEO_TAG_ERROR = document.getElementById('_sb_VIDEO_TAG_ERROR').value;
	
	sbform.vid_name.style.backgroundColor = '';
	sbform.vid_provider.style.backgroundColor = '';
	sbform.vid_tag.style.backgroundColor = '';
	if (sbform.vid_tag.value == "") {
		sbform.vid_tag.style.backgroundColor = 'red';
		sbx = 1;
	}
	else if (sbform.vid_tag.value.indexOf("www.") != -1 || sbform.vid_tag.value.indexOf("http:") != -1 || sbform.vid_tag.value.indexOf("<embed") != -1 || sbform.vid_tag.value.indexOf("<object") != -1) {
		sbform.vid_tag.style.backgroundColor = 'red';
		alert(_sb_VIDEO_TAG_ERROR);
		sbx = 1;
	}
	if (sbform.vid_name.value == '') {
		sbform.vid_name.style.backgroundColor = 'red';
		sbx = 1;
	}
	if (sbform.vid_provider.value == 'none') {
		sbform.vid_provider.style.backgroundColor = 'red';
		sbx = 1;
	}
	if (sbx == 1)
		return false;
	else {
		sbform.stream_button.disabled = true;
		sb_addStream(sbform);
	}
}

function sb_Delete(sbform) {
 	var me = sbform.elements;
	var videoNum = 0;
	var ctr = 0;
	var _sb_DELETE_ALERT = document.getElementById('_sb_DELETE_ALERT').value;
	var _sb_NO_VIDEOS_SELECTED = document.getElementById('_sb_NO_VIDEOS_SELECTED').value;
	var videoNum = sbform.stream_cid.length;
	if (videoNum > 1) {
		for (var idx = 0; idx < videoNum; idx++) {
			if (sbform.stream_cid[idx].checked == true) {
				sbform.stream_ids.value += '|' + escape(sbform.stream_cid[idx].value);
				ctr ++;
			}
		}
	}
	else {
		if (sbform.stream_cid.checked == true) {
			sbform.stream_ids.value += '|' + escape(sbform.stream_cid.value);
			ctr ++;
		}
	}
	if (ctr == 0) {
		alert(_sb_NO_VIDEOS_SELECTED);
	}
	else {
		var confirmDel = confirm(_sb_DELETE_ALERT);
		if (confirmDel) {
			sbform.deleteStream.disabled = true;
			sb_deleteStream();
		}
		else
			return false;
	}
}

var direction='block';
function sb_Expand() {
	document.getElementById('sb_direction').src="components/com_comprofiler/plugin/user/plug_ajaxsandbox2/images/"+direction+"-arrow.gif";
	document.getElementById('sb_Expand').style.display=direction;
	if(direction=='block') direction = 'none';
	else direction='block'
}

function hideCommentReplyForm(form_id) {
	var div_id = "div_" + form_id;
	var reply_id = "reply_" + form_id;
	toggleVisibility(reply_id, true);
	toggleVisibility(div_id, false);
	//setInnerHTML(div_id, "");
}

function toggleVisibility(whichForm, setVisible)
{
	var newstate="none"
	if(setVisible == true) 
		newstate = ""

	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichForm).style;
		style2.display = newstate;
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichForm].style;
		style2.display = newstate;
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichForm].style;
		style2.display = newstate;
	}
}
