Form = function() {
	
	this.l_nState = 0; //1=art, 2=blog, 3=event
	this.l_sUploadedFile = '';

	this.l_nPhotoState = 0; //0=upload, 1=external file
	this.l_nEventPhotoState = 0; //0=upload, 1=external file

	this.l_nMaxFileBytes = 1048576;

	this.l_aBlogImagesTemp = new Array();
	this.l_aBlogImagesTempTimeout = new Array();
	this.l_aBlogImages = new Array();
	this.l_aBlogImageWidth = new Array();
	this.l_aBlogImageHeight = new Array();
	this.l_nBlogImageIndex = 0;
	this.l_nBlogImageLoadedCount = 0;
	this.l_nBlogValidImageCount = 0;
	
	this.l_nMinBlogImageWidth = 80;
	this.l_nMinBlogImageHeight = 80;

	this.l_sBlogUrl = '';
}



Form.prototype.chooseType = function(p_sType) {

	var thisForm = this;

	if (this.l_nState!=0) {
		$('.form_type').fadeOut(600);
	} else {
		$('#form_intro').fadeOut(600);
		$('#fancyBack').delay(700).fadeIn(700);
	}

	if (p_sType=='type_events') {
		
		if (this.l_nState!=3) {
			this.l_nState = 3;
			$('#form_events').delay(700).fadeIn(700);
			l_xController.getCoordsIP();
			
		}
	
	} else if (p_sType=='type_photos') {
		if (this.l_nState!=1) {
			this.l_nState = 1;
			$('#form_photos').delay(700).fadeIn(700);
			l_xController.getCoordsIP();
		}
	} else if (p_sType=='type_blogs') {
		if (this.l_nState!=2) {
			this.l_nState = 2;
			$('#form_blogs').delay(700).fadeIn(700);
			l_xController.getCoordsIP();
		}
	}
}


Form.prototype.reset = function(p_sType) {

	var thisForm = this;
	
	this.l_nState=0;
	this.l_sUploadedFile = '';
	this.l_nPhotoState = 0;
	this.l_nEventPhotoState = 0;
	$('#fancyBack').hide();
	$('.form_type').hide();
	$('#form_intro').show();
	$('#form .success').hide();
	$('#select_upload').addClass('active');
	$('#select_paste').removeClass('active');
	$('.upload_file').hide();
	$('#upload_file').show();
	$('.loader3').hide();
	
	$('.event_date .date').val('');
	$('#event_date2').hide();
	$('#addEndTime').show();
	
	$('.upload_date .date').val('');
	$('.upload_location .location').val('');
	$('.upload_title .title').val('');
	$('.event_title .title').val('');
	$('#event_image_url, #image_url').val('');
	$('.upload_desc #desc').val('');
	$('.event_desc #event_desc').val('');
	
	$('#fileToUpload, #fileToUpload2').val('');
	
	$('#blogs_wrapper input, #blogs_wrapper textarea').val('');
	$('#blog_image_wrapper').html('');
	$('#blog_form_images a').addClass('inactive');
	this.l_aBlogImages = new Array();
	this.l_aBlogImageWidth = new Array();
	this.l_aBlogImageHeight = new Array();
	this.l_nBlogImageIndex = 0;
	this.l_nBlogImageLoadedCount = 0;
	this.l_nBlogValidImageCount = 0;
}


///////////////////
//PHOTO FUNCTIONS//
///////////////////

Form.prototype.fileUpload = function() {
	
	var thisForm = this;
	
	$(".loader3")
	.ajaxStart(function(){
		$(this).show();
	})
	.ajaxComplete(function(){
		$(this).hide();
	});

	$.ajaxFileUpload
	(
		{
			url:'/lib/doajaxfileupload.php',
			secureuri:false,
			fileElementId:'fileToUpload',
			dataType: 'json',
			data:{name:'logan', id:'id'},
			success: function (data, status)
			{
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						alert(data.error);
					} else {
						var l_aData = data.msg.split('|');
						var l_nSize = l_aData[0];
						if (l_nSize > thisForm.l_nMaxFileBytes) {
							alert('File must be 1mb or less in size.');
						} else {
							var l_sFile = l_aData[1];
							thisForm.l_sUploadedFile = l_sFile;
							thisForm.validateItemPhoto();
						}
					}
				}
			},
			error: function (data, status, e)
			{
				alert(e);
			}
		}
	)
	
	return false;
}




Form.prototype.saveExternalImage = function(p_sUrl) {
	
	var thisForm = this;
	
	$.post("/lib/formAjax.php?action=saveExternalImage", { url: p_sUrl },
		function(data){
			
			if (data.answer!=0) {
				thisForm.l_sUploadedFile = data.answer;
				thisForm.validateItemPhoto();
				
			} else {
				alert('File must be 1mb or less in size.');
			}
		}, "json");
}



Form.prototype.prepItemPhoto = function() {
	
	var thisForm = this;
	
	$('.loader3').show();
	
	if (!l_xController.l_sFBID) {
		alert('You must be connected with Facebook in order to share. Please login using the following popup.');
		triggerLogin(1);
		return false;
	}
	
	
	if (l_xController.l_nUserTerms==0) {
		this.showTerms(1);
		return false;
	}
	
	var thisForm = this;
	
	var l_sTitle = $('#form_photos .upload_title .title').val();
	
	if (!l_sTitle) {
		alert('Please enter a name for your image.');
		return false;
	}
	
	
	if (this.l_nPhotoState==0) {
		if (!$('#fileToUpload').val()) {
			alert('Please select a file!');
		} else {
			$('.loader3').show();
			l_xForm.fileUpload();
			
		}
	} else {
		var l_sUrl = $('#image_url').val();
		if (!l_sUrl) {
			alert('Please enter the url of an image first.');
		} else {
			$('.loader3').show();
			l_xForm.saveExternalImage(l_sUrl);
			
		}
	}
	
}

Form.prototype.validateItemPhoto = function() {
	
	var thisForm = this;
	
	this.createItemPhoto();
}


Form.prototype.createItemPhoto = function() {
	
	var thisForm = this;

	
	var l_sTitle = $('#form_photos .upload_title .title').val();
	
	
	if (!l_sTitle || !thisForm.l_sUploadedFile) {
		if (!l_sTitle && !thisForm.l_sUploadedFile) {
			alert('Please add a title and an image');
		} else if (!l_sTitle) {
			alert('Please choose a title for your image.');
		} else {
			alert('Please add an image first.');
		}
		return false;
	} else {
	
		var l_sRegion = l_xController.l_sRegion;
		var l_nLatitude = l_xController.l_nLatitude;
		var l_nLongitude = l_xController.l_nLongitude;
	
		var l_sDesc = $('#form_photos .upload_desc #desc').val();
	
		$.post("/lib/formAjax.php?action=createItemPhoto", { file: thisForm.l_sUploadedFile, title: l_sTitle, fbid: l_xController.l_sFBID, desc: l_sDesc, region: l_sRegion, latitude: l_nLatitude, longitude: l_nLongitude  },
			function(data){
			
				if (data.answer!=0) {
					$('#form_photos .success').fadeIn(500);
					$('.loader3').hide();
					setTimeout(function() {
						window.location.replace('/' + data.slug + '/');
						
					},2200);
					
			
				} else {
					alert('An error occurred. Please try again. [7]');
				}
			}, "json");
		}
}


//////////////////
//BLOG FUNCTIONS//
//////////////////

Form.prototype.scrapeBlog = function() {
	
	
	var thisForm = this;


	$('#blog_title').val('');
	$('#blog_desc').val('');
	thisForm.l_aBlogImages = new Array();
	thisForm.l_aBlogImageWidth = new Array();
	thisForm.l_aBlogImageHeight = new Array();
	thisForm.l_nBlogImageIndex = 0;
	thisForm.l_nBlogImageLoadedCount = 0;
	thisForm.l_nBlogValidImageCount = 0;

	var l_sUrl = $('#blog_url').val();
	
	if (l_sUrl !='' && l_sUrl.substr(0,4) != 'http') {
		$('#blog_url').val('http://' + l_sUrl);
		l_sUrl = $('#blog_url').val();
	}
	
	var l_bUrlValid = thisForm.validateUrl(l_sUrl);
	
	if (!l_bUrlValid) {
		alert('Invalid Url');
		return false;
	} else {
		thisForm.l_sBlogUrl = l_sUrl;
		
		$('#blog_image_wrapper').html("<img id='blog_thumb_loader' src='/images/loader1.gif' alt='loading' />");
		$('#blog_thumb_loader').show();
		$('#blog_image_prev').addClass('inactive');
		$('#blog_image_next').addClass('inactive');
	
	}
	//alert('!');
	$.post("/lib/formAjax.php?action=scrapeBlog", { url: l_sUrl },
		function(data){
			
			
			if (data.answer!=0) {
				
				$('#blog_title').val(data.title);
				$('#blog_desc').val(data.desc);
				
				
				thisForm.l_aBlogImagesTemp = data.images;
				debugX(thisForm.l_aBlogImagesTemp);
				thisForm.filterImages();
				

			} else {
				alert('An error occurred. Please try again. [1]');
			}
		}, "json");
}

Form.prototype.filterImages = function() {
	var thisForm = this;
	
	if (thisForm.l_aBlogImagesTemp.length==0) {
		thisForm.noBlogImage();
		return false;
	}
	
	var img = new Image();
	img.src = thisForm.l_aBlogImagesTemp[thisForm.l_nBlogImageLoadedCount];
	
	
	
	var l_sSlashStart = img.src.indexOf('//',6);
	if (l_sSlashStart>0) {
		img.src = 'http://' + img.src.substr(l_sSlashStart);
	}
	
	//SETUP A TIMEOUT IN CASE IT HITS A BAD IMAGE
	thisForm.l_aBlogImagesTempTimeout[thisForm.l_nBlogImageLoadedCount] = 0;
	setTimeout(function() {
		if (thisForm.l_aBlogImagesTempTimeout[thisForm.l_nBlogImageLoadedCount]==0) {
			thisForm.l_aBlogImagesTempTimeout[thisForm.l_nBlogImageLoadedCount]=1;
			thisForm.l_nBlogImageLoadedCount++;
			
			//alert(thisForm.l_nBlogImageLoadedCount + ' - ' + thisForm.l_aBlogImagesTemp.length + ' - ' +  thisForm.l_aBlogImages.length)
			
			if (thisForm.l_nBlogImageLoadedCount==thisForm.l_aBlogImagesTemp.length && thisForm.l_aBlogImages.length==0) {
				thisForm.noBlogImage();
			} else if (thisForm.l_nBlogImageLoadedCount < thisForm.l_aBlogImagesTemp.length || thisForm.l_aBlogImages.length < 10) {
				thisForm.filterImages();
			}
		}
	},3000);
	
	//alert(img.src);
	img.onload = function() {
		
		if (thisForm.l_aBlogImagesTempTimeout[thisForm.l_nBlogImageLoadedCount]==0) {
			thisForm.l_aBlogImagesTempTimeout[thisForm.l_nBlogImageLoadedCount]=1;
		
			if (img.height >= thisForm.l_nMinBlogImageHeight && img.width >= thisForm.l_nMinBlogImageWidth) {
			
			
				thisForm.l_aBlogImages[thisForm.l_nBlogValidImageCount] = img.src;
				thisForm.l_aBlogImageWidth[thisForm.l_nBlogValidImageCount] = img.width;
				thisForm.l_aBlogImageHeight[thisForm.l_nBlogValidImageCount] = img.height;
	
				if (thisForm.l_nBlogValidImageCount==0) {
					$('#blog_image_wrapper').html('');
					thisForm.drawBlogImage(0);
				}
				thisForm.l_nBlogValidImageCount++;
				if (thisForm.l_nBlogValidImageCount==2) {
					$('#blog_image_next').removeClass('inactive');
				}
			}
			
			thisForm.l_nBlogImageLoadedCount++;
	
		
			if (thisForm.l_nBlogImageLoadedCount==thisForm.l_aBlogImagesTemp.length && thisForm.l_aBlogImages.length==0) {
				thisForm.noBlogImage();
			} else if (thisForm.l_nBlogImageLoadedCount < thisForm.l_aBlogImagesTemp.length || thisForm.l_aBlogImages.length < 10) {
				thisForm.filterImages();
			}
		}
		
	
		
	}
}

Form.prototype.nextBlogImage = function() {
	var thisForm = this;
	
	thisForm.l_nBlogImageIndex++;
	if (thisForm.l_nBlogImageIndex >= thisForm.l_aBlogImages.length-1) {
		$('#blog_image_next').addClass('inactive');
	}
	if (thisForm.l_nBlogImageIndex == 1) {
		$('#blog_image_prev').removeClass('inactive');
	} 
	thisForm.drawBlogImage(thisForm.l_nBlogImageIndex);
	
}

Form.prototype.prevBlogImage = function() {
	var thisForm = this;
	
	thisForm.l_nBlogImageIndex--;
	if (thisForm.l_nBlogImageIndex == 0) {
		$('#blog_image_prev').addClass('inactive');
	}
	if (thisForm.l_nBlogImageIndex < thisForm.l_aBlogImages.length-1) {
		$('#blog_image_next').removeClass('inactive');
	}
	thisForm.drawBlogImage(thisForm.l_nBlogImageIndex);
	
}

Form.prototype.drawBlogImage = function(p_nIndex) {
	var thisForm = this;
	var l_sHtml;
	
	var l_sSrc = thisForm.l_aBlogImages[p_nIndex];
	var l_nHeight = thisForm.l_aBlogImageHeight[p_nIndex];
	var l_nWidth = thisForm.l_aBlogImageWidth[p_nIndex];
	
	
	if (l_nHeight >= l_nWidth) {
		
		l_nAdjust = (80 - (((l_nWidth/l_nHeight) * 80))) / 2; 
		
		l_sHtml = '<img class="blog_thumb tall" style="left:' + l_nAdjust + 'px;" src="' + l_sSrc + '" />';
		
	} else {
		l_nAdjust = (80 - (((l_nHeight/l_nWidth) * 80))) / 2;
		l_sHtml = '<img class="blog_thumb wide" style="top:' + l_nAdjust + 'px;" src="' + l_sSrc + '" />';
	}
	$('#blog_image_wrapper').html(l_sHtml);
}


	


Form.prototype.noBlogImage = function() {
	var thisForm = this;
	
	thisForm.l_nBlogImageIndex = -1;
	
	var l_sHtml = '<span>Sorry, no images found.</span>';
	
	$('#blog_image_wrapper').html(l_sHtml);
	
}


Form.prototype.prepBlog = function() {
	
	var thisForm = this;


	if (!l_xController.l_sFBID) {
		alert('You must be connected with Facebook in order to share. Please login using the following popup.');
		triggerLogin(2);
		return false;
	}
	
	if (l_xController.l_nUserTerms==0) {
		this.showTerms(2);
		return false;
	}
	
	
	
	
	var l_sUrl = $('#blog_url').val();
	if (l_sUrl!='' && l_sUrl.substr(0,4) != 'http') {
		$('#blog_url').val('http://' + l_sUrl);
		l_sUrl = $('#blog_url').val();
	}
	
	var l_sTitle = $('#blog_title').val();
	var l_sDesc = $('#blog_desc').val();
	var l_sImage;
	
	if (!l_sUrl || !l_sTitle || !l_sDesc) {
		alert('Please fill in the following: URL, Title, Decription');
		return false;
	}
	
	if (!thisForm.validateUrl(l_sUrl)) {
		if (!thisForm.l_sBlogUrl) {
			alert('Please enter a valid URL.');
			return false;
		} else {
			l_sUrl = thisForm.l_sBlogUrl;
		}
	}
	
	
	if (thisForm.l_nBlogImageIndex>=0) {
		l_sImage = thisForm.l_aBlogImages[thisForm.l_nBlogImageIndex];
		thisForm.saveExternalBlogThumbnail(l_sUrl,l_sTitle,l_sDesc,l_sImage);
		
	} else {
		l_sImage = '';
		thisForm.saveBlog(l_sUrl,l_sTitle,l_sDesc,'');
	}
	
}

Form.prototype.saveExternalBlogThumbnail = function(l_sUrl,l_sTitle,l_sDesc,l_sImage) {
	
	var thisForm = this;
	
	$.post("/lib/formAjax.php?action=saveExternalBlogThumbnail", { image: l_sImage },
		function(data){
			
			if (data.answer!=0) {
				thisForm.saveBlog(l_sUrl,l_sTitle,l_sDesc,data.answer);
				 
			} else {
				alert('An error occurred. Please try again. [2]');
			}
		}, "json");
}

Form.prototype.saveBlog = function(l_sUrl,l_sTitle,l_sDesc,l_sImage) {
	
	var thisForm = this;
	
	$('.loader3').show();
	
	var l_sRegion = l_xController.l_sRegion;
	var l_nLatitude = l_xController.l_nLatitude;
	var l_nLongitude = l_xController.l_nLongitude;
	
	
	$.post("/lib/formAjax.php?action=saveBlog", { url: l_sUrl, title: l_sTitle, desc: l_sDesc, image: l_sImage, fbid: l_xController.l_sFBID, region: l_sRegion, latitude: l_nLatitude, longitude: l_nLongitude },
		function(data){
			
			if (data.slug!=0) {
				
				$('#form_blogs .success').fadeIn(500);
				$('.loader3').hide();
				setTimeout(function() {
					window.location.replace('/' + data.slug + '/');
					
				},2200);
				
			
			} else {
				alert('An error occurred. Please try again. [3]');
			}
		}, "json");
}

Form.prototype.validateUrl = function(p_sUrl) {
	
	if(/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(p_sUrl)) {
	  return 1;
	} else {
	  return 0;
	}
	
}


Form.prototype.showTerms = function(p_nCallbackType) {
	
	var thisForm = this;
	
	$('.form_type').fadeOut(700);
	$('#form_terms').delay(800).fadeIn(700);
	$('#agree').click(function(e) {
		e.preventDefault();
		$('.form_type').fadeOut(700);
		
		if (p_nCallbackType == 1) {
			$('#form_photos').delay(800).fadeIn(700);
		} else if (p_nCallbackType == 2) {
			$('#form_blogs').delay(800).fadeIn(700);
		} else if (p_nCallbackType == 3) {
			$('#form_events').delay(800).fadeIn(700);
		}
		setTimeout(function() {
			
			$.post("/lib/formAjax.php?action=userAgrees", { userid: l_xController.l_nUserId },
				function(data){

					if (data.answer!=0) {
						l_xController.l_nUserTerms = 1;
						l_xController.finishFormSubmission(p_nCallbackType);
					} else {
						alert('An error occurred. Please try again. [10]');
					}
				}, "json");
		
		},2000);
		

		return false;
	});
	
}



///////////////////
//EVENT FUNCTIONS//
///////////////////

Form.prototype.prepItemEvent = function() {
	
	var thisForm = this;
	
	$('.loader3').show();
	
	if (!l_xController.l_sFBID) {
		alert('You must be connected with Facebook in order to share. Please login using the following popup.');
		triggerLogin(3);
		return false;
	}
	if (l_xController.l_nUserTerms==0) {
		this.showTerms(3);
		return false;
	}
	
	
	var thisForm = this;
	
	var l_sTitle = $('#form_events .event_title .title').val();
	
	if (!l_sTitle) {
		alert('Please enter a name for your event.');
		return false;
	}
	
	
	if (this.l_nEventPhotoState==0) {
		if (!$('#fileToUpload2').val()) {
			thisForm.validateItemEvent();
		} else {
			$('.loader3').show();
			l_xForm.fileUploadEvent();
			
		}
	} else {
		var l_sUrl = $('#event_image_url').val();
		if (!l_sUrl) {
			thisForm.validateItemEvent();
		} else {
			$('.loader3').show();
			l_xForm.saveEventExternalImage(l_sUrl);
			
		}
	}
	
}


Form.prototype.fileUploadEvent = function() {
	
	
	var thisForm = this;
	
	$(".loader3")
	.ajaxStart(function(){
		$(this).show();
	})
	.ajaxComplete(function(){
		$(this).hide();
	});

	$.ajaxFileUpload
	(
		{
			url:'/lib/doajaxfileupload2.php',
			secureuri:false,
			fileElementId:'fileToUpload2',
			dataType: 'json',
			data:{name:'logan', id:'id'},
			success: function (data, status)
			{
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						alert(data.error);
					} else {
						var l_aData = data.msg.split('|');
						var l_nSize = l_aData[0];
						if (l_nSize > thisForm.l_nMaxFileBytes) {
							alert('File must be 1mb or less in size.');
						} else {
							var l_sFile = l_aData[1];
							thisForm.l_sUploadedFile = l_sFile;
							thisForm.validateItemEvent();
						}
					}
				}
			},
			error: function (data, status, e)
			{
				alert(e);
			}
		}
	)
	
	return false;
}


Form.prototype.saveEventExternalImage = function(p_sUrl) {
	
	var thisForm = this;
	
	$.post("/lib/formAjax.php?action=saveExternalImage", { url: p_sUrl },
		function(data){
			
			
			if (data.answer!=0) {
				thisForm.l_sUploadedFile = data.answer;
				thisForm.validateItemEvent();
				
			} else {
				alert('File must be 1mb or less in size.');
			}
		}, "json");
}

Form.prototype.validateItemEvent = function() {
	var thisForm = this;
	this.createItemEvent();
}

Form.prototype.createItemEvent = function() {
	
	
	
	var thisForm = this;

	
	var l_sTitle = $('#form_events .event_title .title').val();
	var l_sDate = $('#form_events #event_date .date').val();
	
	if (!l_sTitle) {
		alert('Please choose a title for your event.');
		return false;
	
	} else if (!l_sDate) {
		alert('Please choose a date for your event.');
		return false;
	} else {
		
		var l_sDate2 = $('#form_events #event_date2 .date').val();
		var l_sLocation = $('#form_events .event_location .location').val();
		var l_sDesc = $('#form_events .event_desc #event_desc').val();
		
		var l_sRegion = l_xController.l_sRegion;
		var l_nLatitude = l_xController.l_nLatitude;
		var l_nLongitude = l_xController.l_nLongitude;
		
		$.post("/lib/formAjax.php?action=createItemEvent", { file: thisForm.l_sUploadedFile, title: l_sTitle, fbid: l_xController.l_sFBID, desc: l_sDesc, region: l_sRegion, latitude: l_nLatitude, longitude: l_nLongitude, eventDate: l_sDate, eventDate2: l_sDate2, eventLocation: l_sLocation  },
			function(data){
			
				if (data.answer!=0) {
					$('#form_events .success').fadeIn(500);
					$('.loader3').hide();
					setTimeout(function() {
						window.location.replace('/' + data.slug + '/');
						
					},2200);
					
			
				} else {
					alert('An error occurred. Please try again. [8]');
				}
			}, "json");
		}
}

Form.prototype.showRegion = function(p_bShow) {
	
	var thisForm = this;
	
	l_xController.l_nRegionTimeStamp = 0;
	
	if (p_bShow) {
		$('.region_current span').html(l_xController.l_sRegion);
		$('.region_current2 span').html(l_xController.l_sRegion);
		$('#new_region').val(l_xController.l_sRegion);
		$('#new_region2').val(l_xController.l_sRegion);
	}
	$('.region_loading').hide();
	$('.region_loading2').hide();
	$('.region_loading3').hide();
	$('.prox_loading').hide();
	$('.region_current').show();
	$('.region_current2').show();
	$('.region_current3').show();
	
}

