var NN4 = document.layers? true : false; //Netscape Navigator 4.x.
var IE4 = document.all? true : false; // IE version 4 and above.


var confirmMsg  = 'Delete?';

function confirmLink(theLink)
{
    if (confirmMsg == '') {
        return true;
    }
    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += '&confirmed=1';
    }
    return is_confirmed;
}

var popupCount = Math.round(Math.random() * 100);

function openPopup(fileID, width, height) {
	openPopup(fileID, width, height, '0');
}

function openPopup(fileID, width, height, scroll) {
	width += 15;
	height += 30;
 	popupCount ++;
	win = window.open(fileID , 'fly'+popupCount, "menubar=0,scrollbars=" + scroll + ",toolbar=0,location=0,directories=0,status=0,resizable=0,width=" + width + ",height=" + height + "left=10, top=10");
	win.resizeTo(width, height);
}

function toggle(elementId) {
	if (document.getElementById) {
		var theElement = document.getElementById(elementId);
	} else {
		if (document.all) {
			var theElement = document.all[elementId];
		} else {
			var theElement = new Object();
		}
	}
	if (!theElement) { return; }
	if (theElement.style) { theElement = theElement.style; }
	if (typeof(theElement.display) == 'undefined' && !( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ) { return; }
	if (theElement.display == 'none') {
		theElement.display = 'block';
	} else {
		theElement.display = 'none';
	}
}

function toggleAvail(e) {
	document.availlist.elements[e].click();
	var item = eval("list" + e);
	if (document.availlist.elements[e].checked == false) {
		item.bgColor = "#57DA00";
	} else {
		item.bgColor = "#3771D3";
	}
}

function checkCount(veld, aantal, volgende) {
	if(veld.value.length >= aantal) {
		volgende.focus(); }
}

function onlyNumbers(obj) {
	var checked = "", replace = false;
	for (i = 0; i < obj.value.length; i++)
	if (isNumber(obj.value.substr(i, 1))) checked += obj.value.substr(i, 1);
		else replace = true;
	if (replace) obj.value = checked;
}

function isNumber(c){
	if (c==0||c==1||c==2||c==3||c==4||c==5||c==6||c==7||c==8||c==9) return true;
		else return false;
}

function handler(n)	{
	var o = getElement("menu" + n);
	o.style.display = (o.style.display != "block") ? 'block' : 'none';
}

function getElement(id)	{
	// geen ns4 (zwak hoor jurriaan :P)
	var obj = null;
	if(document.getElementById)
		obj = document.getElementById(id);
	else if(document.all)
		obj = document.all[id];
	else
		obj = null;

	return obj;
}

function lightOn(o, c){
  if (document.getElementById || (document.all && !(document.getElementById))) {
    o.style.backgroundColor = c;
  }
}

function insertTags(tag, field) {
	if (document.all) {
		var range=document.selection.createRange();
		if (range.text != "") {
			rangeText="["+tag+"]"+range.text+"[/"+tag+"]";
			range.text=rangeText;
		}
	}
	field.focus();
}

function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function insertSmily(smily, field) {
	text = ' ' + smily + ' ';
	if (field.caretPos) {
		var caretPos = field.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	} else {
		field.value  += text;
	}
	field.focus();
}

var srcObj = new Object;

function startDrag(){
    srcObj = window.event.srcElement.id;
}

function overDrag() {
    window.event.returnValue = false;
}

function enterDrag() {
    window.event.returnValue = false;
}

function endDrag() {
    window.event.dataTransfer.clearData();
}

function resizeImage(ID) {
	resizeImage(ID, 660);
}

function resizeImage(ID, height) {
	var imgUrl = new Image();
	imgUrl.src = ID.src;

	var maxWidth = height;
	var width = imgUrl.width;
	var height = imgUrl.height;

	if (width > maxWidth) {
		height = (maxWidth / width) * height;
		width = maxWidth;
		ID.width = width;
		ID.height = height;
	}
}

function IL(page, label, param) {
	document.write(" <a href='http://www.clanbase.com/" + page + ".php?" + param + "'>" + label + "</a>");
}