// set fancybox images
$(document).ready(function() {
	$(".main-text a.fancybox").fancybox();

	$("a#example2").fancybox({
		'overlayShow' : false,
		'transitionIn' : 'elastic',
		'transitionOut' : 'elastic'
	});

	$("a#example3").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none'
	});
});


// Global variables
var active_div_replace = false;

// Include the content of a given URL in a div
function replace_content(pURL, pNodeId) {
	if (!active_div_replace) {

		active_div_replace = true;
		var url = pURL;
		if (arguments.length >= 2) {
			rfNodeId = pNodeId;
		}

		// empty the div
		// document.getElementById(rfNodeId).innerHTML='';
		// alert(pURL);

		if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
			xmlhttp = new XMLHttpRequest();
			xmlhttp.onreadystatechange = replace_div_HTML;
			xmlhttp.open("GET", pURL, true); // leave true for Gecko
			xmlhttp.send(null);
		} else if (window.ActiveXObject) { // IE
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
			if (xmlhttp) {
				xmlhttp.onreadystatechange = replace_div_HTML;
				xmlhttp.open('GET', pURL, false);

				xmlhttp.send();
			}
		} else {
			alert('Your browser does not appear to support remote scripting.');
			xmlhttp = false;
			active_div_replace = false;
		}

		if ((typeof (xmlhttp)) != 'object') {
			document.write('You need to upgrade your browser to use this page.\r\nAs of March 2006 more than 98% of the web browsers in use support the remote scripting object. Either your browser does not support remote scripting or the support has been disabled.');
			active_div_replace = false;
		}

	} else {
		window.setTimeout("replace_content('" + pURL + "','" + pNodeId + "');", 1);
	}
}

function showDisable() {
	// disable all functions
	document.getElementById('div_disable').style.visibility = 'visible';
}

function hideDisable() {
	// enable all functions again
	document.getElementById('div_disable').style.visibility = 'hidden';
}

// function to replace the HTML of a div produced by the replace_content
// function
function replace_div_HTML() {
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			if (rfNodeId == '') {
				document.write(xmlhttp.responseText);
				active_div_replace = false;
			} else {
				document.getElementById(rfNodeId).innerHTML = xmlhttp.responseText;
				active_div_replace = false;
			}
		}
	}
}

function test() {
	alert('here');
}
/*
 * function pause(numberMillis) { var now = new Date(); var exitTime =
 * now.getTime() + numberMillis; while (true) { now = new Date(); if
 * (now.getTime() > exitTime) return; } }
 */
