function changeClass(obj, new_class)
{
    obj.className = new_class;
}

function changeBgColor(obj, new_color)
{
	obj.style.backgroundColor=new_color;
}

function changePic(name, pic)
{
	name.src = pic;
}

function popup (url, name, width, height)
{
	left_pos = (screen.width / 2) - (width / 2);
	top_pos = (screen.height / 2) - (height / 2);

	window.open(url, name, 'resizable=1, width=' + width + ',height=' + height + ',left=' + left_pos + ',top=' + top_pos);	
}

function externalLinks()
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}
window.onload = externalLinks;

function emptyfield (field, defaultval, blur)
{
	
	if ( blur == true ) {
	
		if (field.value == '') {
			field.value = defaultval;
		}
	
	} else {
	
		if (field.value == defaultval) {
			field.value = '';
		}
	
	}
		
	return true;
}


function saveCursor (formElement)
{
    if (document.getElementById(formElement).createTextRange) {
        document.getElementById(formElement).cursorPosition = document.selection.createRange().duplicate();
	}  
}
function addTag (tag, formElement)
{
	if (document.getElementById(formElement).createTextRange && document.getElementById(formElement).cursorPosition) {
        document.getElementById(formElement).cursorPosition.text = document.getElementById(formElement).cursorPosition.text.charAt(document.getElementById(formElement).cursorPosition.text.length - 1) == ' ' ? tag + ' ' : tag;
    } else {
        document.getElementById(formElement).value += tag;
    }
    document.getElementById(formElement).focus();
}