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();
});

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; }

	//Select all links with lightbox class
	if ($().lightBox)
		$('a.lightbox').lightBox({ fixedNavigation: true });


	//set defaults for all datepicker instances
	initiateGallery();

    }

function datesEqual(a, b) {
	return (!(a>b||b>a))
}

	var imagearray = null;
	var currentvisibleindex = -1;

function initiateGallery() {
	var interval=4000;
	imagearray=$('#ulphotos li');
	var hasiframe=imagearray.find('iframe').length > 0;
	if (!hasiframe)
		setInterval("MoveRight();", interval);
}

function MoveRight() {
	var currentvisibleitem=null;
	var nextvisibleitem=null;
	if (currentvisibleindex<0) {
		currentvisibleitem=imagearray.filter(':visible');
		currentvisibleindex=imagearray.index(currentvisibleitem);
	}
	else
		currentvisibleitem=$(imagearray[currentvisibleindex]);

	//preparing next item
	if (currentvisibleindex+2>imagearray.length)
		currentvisibleindex=0;
	else
		currentvisibleindex+=1;
	nextvisibleitem=$(imagearray[currentvisibleindex]);

	//make transition
	var container=imagearray.parent().parent();
	var currentimgsrc=currentvisibleitem.find('img').attr('src');
	container.css('background-image', 'url(\''+currentimgsrc+'\')');
	currentvisibleitem.hide();
	nextvisibleitem.fadeIn(666);
}



jQuery.extend(jQuery.expr[':'], {
	focus: function (element) {
		return element==document.activeElement;
}
});

$.url = function (url) {
    return $('#baseHref').attr('href') + url.substr(1);
}
