
/* This file contains basic javascriptfunctions for use in the system */


/* Sure you want to delete that? */

function confirm_delete (url,message)
{
	var answer = confirm(message);
	if(answer){
		location.href=url;
	}
}



/* Create a popup window */

function popup_window(url,name,win_width,win_height)
{
	pos_horizon = ((screen.width/2)-(win_width/2));
	pos_vertical = ((screen.height/2)-(win_height/2));
	window.open(url,name,"width="+win_width+",height="+win_height+",top="+pos_vertical+",left="+pos_horizon);
}



/* Check for empty field */

function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value=="")
		{
			alert(alerttxt);return false
		}
		else {return true}
	}
}



/* Validte webpage */

function validate_webpage(thisform)
{
	with (thisform)
	{
		if (validate_required(link,"Der er ikke angivet noget link!")==false)
	  	{
			link.focus();return false
		}
	}
}


/* Validte newspost */

function validate_newspost(thisform)
{
	with (thisform)
	{
		if (validate_required(headline,"Der er ikke angivet nogen overskrift!")==false)
	  	{
			link.focus();return false
		}
	}
}