function subnavWide() {
	var options = document.getElementById("nav2").getElementsByTagName("ul");
	
	if(document.all) {
		for(i = 0; i < options.length; i++) {
			options[i].style.width = document.body.scrollWidth - 20;
		}
	}
}

function submitForm(form, action) {
	form.action = action;
	form.submit();
}

function submitFormThin(form) {
	form.submit();
}

function focuson(element) {
	document.getElementById(element).focus();
}

function isDefined(variable) {
	if(typeof(variable) !="undefined")
		return true;
	else
		return false;
}

function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 2;
	while(isDefined(theForm[z]) && theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
		if(theForm[z].type == 'checkbox') {
			theForm[z].checked = theElement.checked;
		}
		z++;
	}
}

function cancelForm(action) {
	window.location.href = action;
}

function toggleDiv(id) {
	element = document.getElementById(id);
	element.className = (element.className.toLowerCase() == 'show'?'hide':'show');
}

function showDiv(id) {
	document.getElementById(id).className = 'show';
}

function hideDiv(id) {
	document.getElementById(id).className = 'hide';
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function createQuickURL(primaryKeyID, typingField, quickURLField) {
	var regex1 = new RegExp(/[^A-Za-z0-9\-]/);
	var regex2 = new RegExp(/[^A-Za-z0-9\- ]/);
	
	if(document.getElementById(primaryKeyID).value == 0) {
		var typingString = document.getElementById(typingField).value;
		
		while(regex2.test(typingString)) {
			typingString = typingString.replace(regex2, '');
		}
		
		while(regex1.test(typingString)) {
			typingString = typingString.replace(regex1, '-');
		}
		
		document.getElementById(quickURLField).value = typingString.toLowerCase();
	}
	else {
		if(document.getElementById("itemTitleH2")) {
			document.getElementById("itemTitleH2").innerHTML = document.getElementById(typingField).value;
		}
	}
}

function typeInTitle(typingField, quickURLField) {
	if(document.getElementById(quickURLField)) {
		if(document.getElementById(quickURLField).innerHTML == '') {
			showDiv(quickURLField);
		}
		document.getElementById(quickURLField).innerHTML = document.getElementById(typingField).value;
		if(document.getElementById(typingField).value == '') {
			hideDiv(quickURLField);
		}
	}
}

function openWindow(url, windowName) {
	window.open(url, windowName, 'height=500,width=700,scrollbars=yes,menubar=no,toolbar=no,location=no,status=yes,resizable=yes');
}