/**
 * 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 () {
	$('#demo_video1').click(function (e) {
		var imgurl = $('#showdemo').attr('src');
		var _id = parseInt(imgurl.substr(imgurl.lastIndexOf('/')+1,imgurl.lastIndexOf('.') - imgurl.lastIndexOf('/') - 1));
		if($('#flashiframe').attr("src") != 'democam.html') 
		$('#flashiframe').attr("src","demo.html?id="+_id);
		e.preventDefault();
		$('#demo_video_concent').modal({onOpen: modalOpen});
	});
	$('#demo_video2').click(function (e) {
		var imgurl = $('#showdemo').attr('src');
		var _id = parseInt(imgurl.substr(imgurl.lastIndexOf('/')+1,imgurl.lastIndexOf('.') - imgurl.lastIndexOf('/') - 1));
		if($('#flashiframe').attr("src") != 'democam.html') 
		$('#flashiframe').attr("src","demo.html?id="+_id);
		e.preventDefault();
		$('#demo_video_concent').modal({onOpen: modalOpen});
	});

});

/**
 * 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('slow', function () {
		dialog.container.fadeIn('slow', function () {
			dialog.data.slideDown('slow');
		});
	});
}

/**
 * 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('slow', function () {
		dialog.container.hide('slow', function () {
			dialog.overlay.slideUp('slow', function () {
				$.modal.close();
			});
		});
	});
}

/**
 * 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');
		});
	});
}