// JavaScript Document

function incHeight(elementid){
	myheight = parseInt(document.getElementById(elementid).style.height);
	if (myheight < 530){
		document.getElementById(elementid).style.height = (myheight + 100) + "px";
	}
}

function decHeight(elementid){
	myheight = parseInt(document.getElementById(elementid).style.height);
	if (myheight > 130){
		document.getElementById(elementid).style.height = (myheight - 100) + "px";
	}
}

function divToggle(id) {
	var e = document.getElementById(id);
	if(e.style.display == 'block') {
		e.style.display = 'none';
	} else {
		e.style.display = 'block';
	}
}

function divScrollToggle(id) {
	var e = document.getElementById(id);
	if(e.style.overflow == 'auto') {
		e.style.overflow = 'hidden';
	} else {
		e.style.overflow = 'auto';
	}
}

function pauseVideo(id) {
	var e = document.getElementById(id);
	e.Stop();
}

function divShow(id) {
	var e = document.getElementById(id);
	e.style.display = 'block';
}

function divHide(id) {
	var e = document.getElementById(id);
	e.style.display = 'none';
}

function btnShow(id) {
	var e = document.getElementById(id);
	e.style.display = 'inline';
}

function btnHide(id) {
	var e = document.getElementById(id);
	e.style.display = 'none';
}

function checkBox(id) {
	var e = document.getElementById(id);
	e.checked = 'true';
}

function confirmMsgBox(message) {
	var response = confirm(message);

	if(response) {
		return true;
	} else {
		return false;
	}
}

function confirmMsgBoxResult(tag1, tag2, score1, score2) {

	if (!isNaN(score1) && !isNaN(score2)) {
		if (score1 >= 0 && score2 >= 0) {
			var response = confirm(tag1 + ": " + score1 + ", " + tag2 +": " + score2 + ". Is this correct?");
		} else if (score1 < 0 && score2 < 0) {
			var response = confirm("Void match. Is this correct?");
		} else if (score1 < 0) {
			var response = confirm(tag2 + " default win. Is this correct?");
		} else if (score2 < 0) {
			var response = confirm(tag1 + " default win. Is this correct?");
		}
	} else {
		return true;
	}

	if(response) {
		return true;
	} else {
		return false;
	}
}

function addTag(tag, field_name) {
	 var txt = document.getElementById(field_name);
	 txt.value = (txt.value).substring(0, txt.selectionStart) + "["+tag+"]" + (txt.value).substring(txt.selectionStart, txt.selectionEnd) + "[/"+tag+"]" + (txt.value).substring(txt.selectionEnd, txt.textLength);
	 return;
}

function editInputValue(string, field_name) {
	 var txt = document.getElementById(field_name);
	 txt.value = string;
	 return;
}

function addAdvTag(tag, field_name, message, boxvalue) {
	var txt = document.getElementById(field_name);
	var address = prompt(message, boxvalue);

	if(address) {
		txt.value = (txt.value).substring(0, txt.selectionStart) + "["+tag+"="+address+"]" + (txt.value).substring(txt.selectionStart, txt.selectionEnd) + "[/"+tag+"]" + (txt.value).substring(txt.selectionEnd, txt.textLength);
		return true;
	} else {
		return false;
	}
}

function trToggle(id)
{
	var tr = document.getElementById(id);
	if (tr==null) {
		return;
	}
	var bExpand = tr.style.display == '';
	tr.style.display = (bExpand ? 'none' : '');
} 