/********************
* Utility functions *
********************/

// write today's date
function todaysDate()
{
	var ndx;
	var text;
	var now = new Date();
	var ampm = new Array('morning', 'afternoon', 'evening');
	var days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
	var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
	var ampm = new Array('morning', 'afternoon', 'evening');
	var date = now.getDate();
	var hours = now.getHours();

	switch (date)
	{
		case 1:
		case 21:
		case 31:
			date = date + "st";
			break;

		case 2:
		case 22:
			date = date + "nd";
			break;

		case 3:
		case 23:
			date = date + "rd";
			break;

		default:
			date = date + "th";
	}

	if (hours <= 11)
		ndx = 0;
	else if (hours >=18)
		ndx = 2;
	else
		ndx = 1;

	text = "Good " + ampm[ndx] + " - today\'s date is " + days[now.getDay()] + ", " + date + " " + months[now.getMonth()] + " " + now.getYear() + ".";
	document.write(text);
}

// send error feedback
function sendFeedback(errNo)
{
	var email = "mailto";
	var at = "@";
	var mw = "eurobusinessenterprises.";
	var subject = "Website ";

	if (errNo > 0)
		subject += ("error " + errNo);
	else
		subject += ("feedback");

	parent.location.href = email + ":feedback" + at + mw + "com?subject=" + subject;
}


/*******************
* Window functions *
*******************/

var winMap			= null;
var winPrivacy	= null;
var winCookie		= null;
var winContact	= null;

function popupLocation(mappage)
{
	var w = 812;
	var h = 656;
	var x = ((screen.width - w) / 2);
	var y = ((screen.height - h) / 2);

	x = (x < 0) ? 0 : x;
	y = (y < 0) ? 0 : y;
	winMap = window.open(mappage, 'map', 'width='+w+',height='+h+',resizable=1,scrollbars=0,menubar=0,statusbar=0,screenX='+x+',left='+x+',screenY='+y+',top='+y);
	winMap.focus();
}

function popupPrivacy(privacypage)
{
	var w = 606;
	var h = 478;
	var x = (screen.width - w) / 2;
	var y = (screen.height - h) / 2;

	x = (x < 0) ? 0 : x;
	y = (y < 0) ? 0 : y;
	winPrivacy = window.open('privacy.htm', 'privacy', 'width='+w+',height='+h+',resizable=1,menubar=0,statusbar=0,screenX='+x+',left='+x+',screenY='+y+',top='+y);
	winPrivacy.focus();
}

function popupCookie(cookiepage)
{
	var w = 600;
	var h = 426;
	var x = (screen.width - w) / 2;
	var y = (screen.height - h) / 2;

	x = (x < 0) ? 0 : x;
	y = (y < 0) ? 0 : y;
	winCookie = window.open(cookiepage, 'cookie', 'width='+w+',height='+h+',resizable=1,menubar=0,statusbar=0,screenX='+x+',left='+x+',screenY='+y+',top='+y);
	winCookie.focus();
}

function popupContact(contactpage)
{
	var w = 450;
	var h = 314;
	var x = (screen.width - w) / 2;
	var y = (screen.height - h) / 2;

	x = (x < 0) ? 0 : x;
	y = (y < 0) ? 0 : y;
	winContact = window.open(contactpage, 'contactus', 'width='+w+',height='+h+',resizable=1,menubar=0,statusbar=0,screenX='+x+',left='+x+',screenY='+y+',top='+y);
	winContact.focus();
}

function closePopups()
{
	if (winMap)
		winMap.close();

	if (winPrivacy)
		winPrivacy.close();

	if (winCookie)
		winCookie.close();

	if (winContact)
		winContact.close();

	closeSubPopups();

	winMap = winPrivacy = winCookie = winContact = null;
}
