function confirmthis (jsmsg) { 
	Check = confirm(jsmsg);
	if(Check == false) {
		return false;
	}
}

var openpopupWindow = null;
function openpopup (mypage,myname,w,h,pos,infocus,scrolling,resizable){
	if (openpopupWindow) {
		openpopupWindow.close();
	}
	if(pos=='random'){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=='center'){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	} else if((pos!='center' && pos!='random') || pos==null){
		LeftPosition=100;TopPosition=100;
	}
	settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=' + scrolling + ',resizable=' + resizable + ',dependent=no';
	openpopupWindow = window.open('',myname,settings);
	if(infocus=='front'){
		openpopupWindow.focus();
		openpopupWindow.location=mypage;
	}
	return false;
}

function external_init() {
	var a;
	var f;
	var node;

	if(!document.getElementsByTagName) return;
	
	a = document.getElementsByTagName("a");

	for(i = 0; i < a.length; i++) {
		if(!a[i].getAttribute("href") ||
		   a[i].getAttribute("rel") != "external") continue;
		a[i].target = "_blank";
	}

	f = document.getElementsByTagName("form");

	for(i = 0; i < f.length; i++) {
		if(f[i].className != "external") continue;
		f[i].target = "_blank";
	}
}

function resizeMyDocument() {
	if (screen.width < 1024) {
		document.getElementsByTagName('h1')[0].style.width = '770px';
		document.getElementById('desktop').style.width = '770px';
		document.getElementById('task').style.width = '145px';
		document.getElementById('main').style.width = '460px';
		document.getElementById('teaser').style.width = '145px';
	}
}

function init_all() {
	resizeMyDocument();
	external_init();
}

function textLimiter(myarea, myIndicator, maxlimit) {
	x = document.getElementById(myarea).value;
	if (x.length > maxlimit) {
		document.getElementById(myarea).value = x.substring(0, maxlimit);
	} else if (myIndicator) {
		document.getElementById(myIndicator).value = maxlimit - x.length;
	}
}



window.onload = init_all;