// =======================================================

$(document).ready(function(){
	PageInit();
});
  
// =======================================================

function PageInit() {
	$(".fancybox").fancybox({ 'hideOnContentClick': true,'imageScale': true, 'frameWidth': 640,  'frameHeight': 480}); 
	$(".fancybox-page").fancybox({ 'hideOnContentClick': false,'imageScale': true, 'frameWidth': 640,  'frameHeight': 480}); 
  ExternalLinks();
  $('a.email').nospam();		
}

// =======================================================

function ExternalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

// =======================================================

function ShowAndHide(showDivID,hideDivID) {
	
	// Get rid of the source div
	$('#' + hideDivID).fadeOut('slow');
	// Show nicely
	$('#' + showDivID).slideDown('slow');
	
	return false;
	
}

// =======================================================

function Remove(id) {
	$('#' + id).hide();
}

// =======================================================

function GetAjaxContent(pageName,targetDivID,removeDivID) {
		
	// Get rid of the source div
	$('#' + removeDivID).hide();
		
		$('#' + targetDivID).slideDown('slow');
		
		PageInit();
		
		
		/*
	$.ajax({
			    url: pageName,
			    type: 'GET',
			    dataType: 'html',
			    data: "",
			    timeout: 10000,
			    error: function(){
			    		// If no response from server, simply resolve the link!
			    		return true;
			    },
			    success: function(data){
			    		// Append the html content to the returned html (just a page load)
							//$('#' + targetDivID).html(data + $('#' + targetDivID).html());
							$('#' + targetDivID).html(data);
							// Make the div appear nicely
							$('#' + targetDivID).slideDown('slow');
							// And re-init the page (image popups, external links, email obfuscation...)
							PageInit();
							
							return false;
			    }
			});
			*/
			
	return false;
			
}

// =======================================================

function ConfirmSubmit(message) {
	var agree=confirm(message);
	if (agree)
		return true;
	else
		return false;
}
