﻿window.name='ds';

function PopWin(url,title,h,w) { 
	popupWin = window.open(url,title,'scrollbars=yes,resizable=yes,height=' + h + ',width=' + w+'');// ' + h + '
	popupWin.focus();
} 

function PopWinAdv(url,title,h,w,location,menu,scrollon,resize,toolbar,status) {
	popupWin = window.open(url, title, 'location='+location+',menubar='+menu+',toolbar='+toolbar+', scrollbars='+scrollon+', resizable='+resize+', height=' + h + ', width=' + w + ', top=140,left=190')// ' + h + '
//	if (popupWin.opener == null) popupWin.opener = self;
	popupWin.focus();
}

function Popup_open(urlStr) {
	this_win=window.open(urlStr,'Popup','scrollbars=yes,resizable=no,width=366,height=400,top=169,left=177');
        this_win.focus();
}

function logoprint(url,title,h,w,location,menu,scrollon,resize,toolbar,status,autnr){
    if (autnr != "no"){
     
       PopWinAdv(url,title,h,w,location,menu,scrollon,resize,toolbar,status);
    }
}

function showDescription(descLayer)
{
	if(document.getElementById)
	{	
		var style2 = document.getElementById(descLayer).style;
		style2.display = style2.display ? "" : "block";
	}
	else if (document.all)
	{
		var style2 = document.all[descLayer].style;
		style2.display = style2.display ? "" : "block";
	}
	else if (document.layers)
	{
		var style2 = document.layers[descLayer].style;
		style2.display = style2.display ? "" : "block";
	}
}

/* Whitespace trimming function, inspired by http://www.aspdev.org/articles/javascript-trim/ */
function trimWhitespace(str)
{
	while (str.substring(0,1) == ' ')
	{
		str = str.substring(1, str.length);
	}

	while (str.substring(str.length-1, str.length) == ' ')
	{
		str = str.substring(0,str.length-1);
	}
	
	return str;
}

function isSiteManagerTag(str)
{
	if (str.substr(0,4) == '<!--')
	{
		return true;
	}
}

/* 
Takes a commaseparated list of names and adress book ID numbers
and returns a string with names converted to adress book links
*/
function authorList(authors, IDs, lang)
{
	var names = authors.split(",");
	var numbers = IDs.split(",");
	var str = '';	

	for (i = 0; i < names.length; i++)
	{
		if (i < numbers.length)
		{
			if (isSiteManagerTag(numbers[i]))
			{
				str += trimWhitespace(names[i]);
			}
			else
			{
				if (lang == 'DAN')
				{
					str += '<a href="javascript:Popup_open(' + '\'http://www.danskeslagterier.dk/view.asp?ID=92&PERS_ID=' + trimWhitespace(numbers[i]) + '\'' + ');">' + trimWhitespace(names[i]) + '</a>';
				}
				else if (lang == 'ENG')
				{
					str += '<a href="javascript:Popup_open(' + '\'http://www.danskeslagterier.dk/view.asp?ID=10861&PERS_ID=' + trimWhitespace(numbers[i]) + '\'' + ');">' + trimWhitespace(names[i]) + '</a>';
				}
			}
		}
		else
		{
			str += trimWhitespace(names[i]);
		}

		if (names.length > 0 && i < (names.length-1))
		{
			if (i == (names.length-2))
			{
				if (lang == 'DAN')
				{
					str += ' og ';
				}
				else if (lang == 'ENG')
				{
					str += ' and ';
				}
			}
			else
			{
				str += ', ';
			}
		}
	}
	
	return str;
}

function checkform() { 
var error_message = ''; 
if (document.gb_form.gb_email.value=="") { error_message +='Email \n'; } 
if (document.gb_form.gb_firstname.value=="") { error_message +='Firstname \n'; ; } 
if (document.gb_form.gb_lastname.value=="") { error_message +='Lastname \n'; ; } 
if (document.gb_form.gb_address1.value=="") { error_message +='Address \n'; ; } 
if (document.gb_form.gb_custom1.value=="") { error_message +='Skole \n'; } 
if(error_message !=''){
error_message = 'Please fill in:\n' + error_message;
alert(error_message);
return false;
}
};

