/**
 * SimpleModal Test
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2008 Eric Martin - http://ericmmartin.com
 *
 * Revision: $Id: simplemodal.js 179 2008-12-15 23:02:07Z emartin24 $
 *
 */

$(document).ready(function() {  
						   
		/* contact us accordion */
	
		$("#button-sales").click(function(event) {
			$('#modalContentInstSales').modal({
				onClose: modalClose, 
				onOpen: modalOpen,
				containerCss: {
					height: 420,
					width: 342
				}
			});
		});
		
		$("#button-consult").click(function(event) {
			$('#modalContentConsult').modal({
				onClose: modalClose, 
				onOpen: modalOpen,
				containerCss: {
					height: 370,
					width: 342
				}
			});
		});
		
		$("#button-inquiries").click(function(event) {
			$('#modalContentGeneralInquiries').modal({
				onClose: modalClose, 
				onOpen: modalOpen,
				containerCss: {
					height: 150,
					width: 342
				}
			});
		});
		
		/* bios */
		
		$("#button-uebelein").click(function(event) {
			$('#modalContentBioUebelein').modal({
				onClose: modalClose, 
				onOpen: modalOpen,
				containerCss: {
					height: 485,
					width: 619
				}
			});
		});
		
		$("#button-chin").click(function(event) {
			$('#modalContentBioChin').modal({
				onClose: modalClose, 
				onOpen: modalOpen,
				containerCss: {
					height: 530,
					width: 619
				}
			});
		});
		
		$("#button-barnett").click(function(event) {
			$('#modalContentBioBarnett').modal({
				onClose: modalClose, 
				onOpen: modalOpen,
				containerCss: {
					height: 515,
					width: 619
				}
			});
		});
		
		$("#button-carroll").click(function(event) {
			$('#modalContentBioCarroll').modal({
				onClose: modalClose, 
				onOpen: modalOpen,
				containerCss: {
					height: 485,
					width: 619
				}
			});
		});
			
});

/**
 * When the open event is called, this function will be used to 'open'
 * the overlay, container and data portions of the modal dialog.
 *
 * onOpen callbacks need to handle 'opening' the overlay, container
 * and data.
 */
function modalOpen (dialog) {
	dialog.overlay.fadeIn('fast', function () {
		dialog.container.fadeIn('slow', function () {});
		dialog.data.fadeIn('slow');
		
		$("#flash-wrapper").removeClass('showme');
		$("#flash-wrapper").addClass('hideme');
		
		$("#panel-map").removeClass('showme');
		$("#panel-map").addClass('hideme');
		
		var a = [
				self.pageXOffset ||
				document.documentElement.scrollLeft ||
				document.body.scrollLeft
				,
				self.pageYOffset ||
				document.documentElement.scrollTop ||
				document.body.scrollTop
				];
		$(window).bind('scroll',{pos: a},scrollLock);
				
	});
}


function scrollLock(e) {
    var a=e.data.pos;
    window.scrollTo(a[0],a[1]);
    return false;
}



/**
 * When the close event is called, this function will be used to 'close'
 * the overlay, container and data portions of the modal dialog.
 *
 * The SimpleModal close function will still perform some actions that
 * don't need to be handled here.
 *
 * onClose callbacks need to handle 'closing' the overlay, container
 * data and iframe.
 */
function modalClose (dialog) {
	
	dialog.data.fadeOut('fast', function () {});
	dialog.container.fadeOut('slow', function () {
		dialog.overlay.fadeOut('slow', function () {
			$.modal.close();
			
			$("#flash-wrapper").removeClass('hideme');
			$("#flash-wrapper").addClass('showme');
			
			$("#panel-map").removeClass('hideme');
			$("#panel-map").addClass('showme');
			
			$(window).unbind('scroll',scrollLock); // unbinds lock

		});									   
	});
	
}

/**
 * After the dialog is show, this callback will bind some effects
 * to the data when the 'button' button is clicked.
 *
 * This callback is completely user based; SimpleModal does not have
 * a matching function.
 */
 
function modalShow (dialog) {
	dialog.data.find('input.animate').one('click', function () {
		dialog.data.slideUp('slow', function () {
			dialog.data.slideDown('slow');
		});
	});
}


