//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 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;
	}
}

function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en' }, 'google_translate_element'); }

//called on page load (first 'full, non ajax' load);
$(document).ready(function () {
	main();
});

function main() {
	//disable right-click on entire document (copy-protect!)
	//$(document).bind("contextmenu", function (e) { return false; });

	//disable right-click on just img elements (copy-protect!)
	//$('img').bind("contextmenu", function (e) { return false; });

	//change css class on form input fields when activated
	var inputs=$('input[type=text], input[type=password], select, textarea');
	inputs.triggerHandler("focus");
	inputs.focus(function () { $(this).addClass('input_onfocus'); });
	inputs.blur(function () { $(this).removeClass('input_onfocus'); });

	//track click-throughs to 3rd party pages via Google Analytics...
	//$("a[rel*='nofollow']").click(function() {
	$("a[target*='_blank']").click(function () {
		if (typeof (pageTracker)!="undefined")
			pageTracker._trackPageview('/outgoing/'+$(this).attr('href'));
	});

	//breakout of frames
	if (parent!=window) { parent.location=location.href; }

	//googleTranslateElementInit();

	//Select all links with lightbox class
	//if ($().lightBox)
		//$('a.lightbox').lightBox({ fixedNavigation: true });

	if ($().flash) {
		//$('#test').flash({ swf: 'test.swf', height: 550, width: 512 });
	}

	trap();
}
