$(document).ready(function () {
		$('.modalclick').click(function (dialog) {
			var item;
			var containerheight= document.documentElement.clientHeight-100;
			$.get("content/modalcontent.php?item="+this.id+"&height="+containerheight, function(data){
				$(data).modal({
					overlayId: 'simplemodal-overlay',
					containerId: 'simplemodal-container',
					onOpen: function (dialog) {
						dialog.overlay.fadeIn('250', function () {
							dialog.data.hide();
							dialog.container.fadeIn('333', function () {
								dialog.data.fadeIn('333');
							});
						});
					},
					onShow: function (dialog) {
						$('.submittercontactbutton').click(function (e) {
							e.preventDefault();
							var validationerror = validate();
							if(validationerror!=1)
							{
								dialog.data.fadeOut('200', function (){
									var formvals = $('#contactform').serialize();
									$('#modalcontent').html("Processing...");
									dialog.data.fadeIn('200', function () {
										var containerheight= document.documentElement.clientHeight-100;
										$.post(
											'content/modalcontent.php',
											formvals+'&item=submitform&height='+containerheight,
											function (data) {
												dialog.data.fadeOut('200', function (){
													$('#modalcontent').html(data);
														// select the div that was set in the custom modal
														// div.setinnerhtml
													dialog.data.fadeIn('200');
												});
											}
										);
									});
								});
	
							}
							//~ dialog.data.fadeOut('200', function (){
								//~ var formvals = $('#contactform').serialize();
								
								//~ $('#modalcontent').html("Processing...");
								//~ dialog.data.fadeIn('200', function () {
									//~ var containerheight= document.documentElement.clientHeight-100;
									
									//~ $.post(
										//~ // url: 'content/modalcontent.php',
										//~ // data: $('#contactform').serialize() + '&item=submitform&height='+containerheight+'&name2='+$('#formname').value,
										//~ // data: 'email='+email+'&item=submitform&height='+containerheight,
										//~ // type: 'post',
										//~ // cache: false,
										//~ // dataType: 'html',
										//~ 'content/modalcontent.php',
										//~ formvals+'&item=submitform&height='+containerheight,
										//~ function (data) {
											//~ dialog.data.fadeOut('200', function (){
												//~ $('#modalcontent').html(data);
													//~ // select the div that was set in the custom modal
													//~ // div.setinnerhtml
												//~ dialog.data.fadeIn('200');
											//~ });
										//~ }
									//~ );
								//~ });
							//~ });
						});
					},
					onClose: function (dialog) {
						dialog.data.fadeOut('333', function () {
							dialog.container.fadeOut('333', function () {
								dialog.overlay.fadeOut('250', function () {
									$.modal.close();
								});
							});
						});
					}, maxHeight:document.documentElement.clientHeight-100
				});
			});
		});
	});
	//~ function validate()
	//~ {
		//~ var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		//~ if(reg.test($(email).value) == false)
		//~ {
			//~ $(#formerror.html("email error"));
		//~ }
		
	//~ }
	
