﻿//pikey declaration to stop nasty client side msgs (good idea thou tbh)
//var undefined;

function ConfirmDeletion() {
	return confirm("Are you sure you wish to delete this record?");
}

function right(e) {
	var msg = "Sorry, you don't have permission to right-click.";
	if (navigator.appName == 'Netscape' && e.which == 3) {
		alert(msg);
		return false;
	}
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button == 2) {
		alert(msg);
		return false;
	}
	else
		return true;
}

function trap() {
	if (document.images) {
		for (i = 0; i < document.images.length; i++) {
			if ((document.images[i].alt.indexOf("(c)") > -1)
		        | (document.images[i].title.indexOf("(c)") > -1)) {
				document.images[i].onmousedown = right;
				document.images[i].onmouseup = right;
			}
		}
	}
}

function closeChildren() {
	if (!childWindows) {
		return;
	}
	for (var i = 0, len = childWindows.length; i < len; i++) {
		childWindows[i].close();
	}
}

var newwindow;
function oPhoto(DatastoreID, FW, wWidth, wHeight) {
	if (newwindow) newwindow.close();
	newwindow = window.open('photo.aspx?ID=' + DatastoreID + '&FW=' + FW, 'photo', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,screenX=101,screenY=101,width=' + wWidth + ',height=' + wHeight);
	if (window.focus) { newwindow.focus() }
}

function oWin(url, name) {
	window.open(url, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,screenX=100,screenY=100,width=360,height=230');
}

function oPuzzle(url, name) {
	window.open(url, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,screenX=100,screenY=100,width=806,height=685');
}

function setWindowStatus(text) {
	window.status = text;
}

function prevEmail(ID, emailserver, emailname, emailinner) {
	var span = document.getElementById(ID);
	if (span != null) {
		var str = "<a href='mailto:" + emailname + "@" + emailserver + "'>";
		if (emailinner == '') str += emailname + "@" + emailserver; else str += emailinner;
		str += "</a>";
		span.innerHTML = str;
	}
}

//called on page load (first 'full, non ajax' load);
$(document).ready(function() {
	main();
	trap();
});
function main() {
	//track click-throughs to 3rd party pages via Google Analytics...
	//$("a[rel*='nofollow']").click(function() {
	$("a[target*='_blank']").click(function() {
		if (pageTracker != null)
			pageTracker._trackPageview('/outgoing/' + $(this).attr('href'));
	});
}