var ajaxContent = 'content';

var IE = document.all?true:false;
var IE7 = false;
if (!IE) 
	document.captureEvents(Event.MOUSEMOVE)
var tempX = 0;
var tempY = 0;

var ajaxIndicator;
var ajaxIndicatorCounter = 0;

function getMouseXY(e) {
	//if (ajaxIndicatorCounter == 0)
	//	return true;
	if (IE7) {
		tempX = event.clientX + document.documentElement.scrollLeft;
		tempY = event.clientY + document.documentElement.scrollTop;
	}
	else if (IE) { // grab the x-y pos.s if browser is IE
		//alert('');
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	ajaxIndicator.style.left = (tempX+10) + 'px';
	ajaxIndicator.style.top = (tempY+16) + 'px';
	return true;
}

function doAjaxLink(from) {
	doAjax(from.href);
	return false;
}

function doAjax(param) {
	$.ajax({
		data: 'params=' + param +'&ajaxed=true'
	});
}

function vertButtonAnim() {
	$("#right_content").animate({
		width: 'toggle'
	}, 500);	
}

function slideShow(image) {
	var parent_id = image.parentNode.id;
	var slide1 = document.getElementById('slide1');
	var slide2 = document.getElementById('slide2');
	var to_slide = '';
	/*
	if ( (slide1.style.display=='none') && (slide2.style.display=='none') ) {
		$('#slide1').fadeIn(1000);
	}
	*/
	if (parent_id == 'slide1') {
		//alert(image.alt);
		$('#slide2').fadeOut(3000);
		to_slide = 'slide2';
		$('#slide1').fadeIn(2000, function() {
			$(this).animate({opacity: 1.0}, 5000, function() {
				$.get("slide_image.php", {last : image.alt},
				function(data) {
					//alert("Data Loaded: " + data);
					$('#'+to_slide).html(data);
				});
			});
		});
		
	} else {
		$('#slide1').fadeOut(3000);
		to_slide = 'slide1';
		$('#slide2').fadeIn(2000, function() {
			$(this).animate({opacity: 1.0}, 5000, function() {
				$.get("slide_image.php", {last : image.alt},
				function(data) {
					//alert("Data Loaded: " + data);
					$('#'+to_slide).html(data);
				});
			});
		});
		
	}
	

}

$(document).ready(function() {
/*
	ajaxIndicator = document.getElementById('ajax_indicator');	//$("#ajax_indicator");
	document.onmousemove = getMouseXY;
	if (IE && parseInt(jQuery.browser.version) >= 7) {
		IE7 = true;
	}
*/

	$.ajaxSetup({
		url: "index.php",
		async: true,
		type: "POST",
		success: function(data) {
			$('#'+ajaxContent).html(data);
			//alert(data);
		},
		error: function(data) {
			//alert(data);
		},
		timeout: function(data) {
			//alert(settings);
		},
		beforeSend: function(data) {
			//ajaxIndicator.style.display='block';
			ajaxIndicatorCounter++;
		},
		complete: function(data) {
			ajaxIndicatorCounter--;
			//alert(ajaxIndicatorCounter);
			//if (ajaxIndicatorCounter < 1)
			//	ajaxIndicator.style.display='none';
		}
	});
/*
	$('a[@rel=ajaxed]').click(function() {
		$.ajax({
			data: 'params=' + $(this).attr("href")+'&ajaxed=true'
		});
		$("#main_menu .submenu").slideUp("200");
		$("#main_menu li a").removeClass("selected");
		return false;
	});

/*
	$("#right_content").animate({
		width: 'hide'
	}, 250);
*/
/*
	$("#vert_button").click(function() {
		$("#right_content").animate({
			width: 'toggle'
		}, 500);	
	});
	*/
/*
	$("*:not(li)").click(function() {
		alert('a');
	});
*/

});

