// NOTE: Close script is contained in the modal tpl as it is loaded into the page and doesn't really exist in the DOM
// location: js/cssmodalclose.js

$(document).ready(function() {

	$('a.cssModal').click(function() {
		//remove the modalDiv so an animation can be used in modalClose
		if(document.getElementById('modalDiv')){
		$('#modalDiv').remove();}
		// Set href to path to modal
		var modalURL = $(this).attr("href");
		// displays semi transparent overlay 
		$('body').append('<div id="cssModalOverlay"></div>');
		// Shows modal containing divz
		$('body').append('<div id="modalDiv"></div>');
		

		$('#modalDiv').css({
			'position' : 'fixed', 
			'top': 100, 
			'margin' : 0, 
			'padding' : 0,
			'left' : $(window).width() / 2 - 300
			});
			
		$('#modalDiv').fadeIn('slow');
		$('#modalDiv').show();

		// Set URL of modal to import below
		$('#modalDiv').load(modalURL);
		
		return false;
	});
	
	$('area.cssModal').click(function() {
		//remove the modalDiv so an animation can be used in modalClose
		if(document.getElementById('modalDiv')){
		$('#modalDiv').remove();}
		// Set href to path to modal
		var modalURL = $(this).attr("href");
		// displays semi transparent overlay 
		$('body').append('<div id="cssModalOverlay"></div>');
		// Shows modal containing divz
		$('body').append('<div id="modalDiv"></div>');
		

		$('#modalDiv').css({
			'position' : 'fixed', 
			'top': 100, 
			'margin' : 0, 
			'padding' : 0,
			'left' : $(window).width() / 2 - 300
			});
			
		$('#modalDiv').fadeIn('slow');
		$('#modalDiv').show();

		// Set URL of modal to import below
		$('#modalDiv').load(modalURL);
		
		return false;
	});
	
});