/*
 5 Posta Global JavaScript
*/
var global = {
	init : function() {
		$('#blog .post a[rel*=lightbox]').lightBox();
		$('#sidebar .gunun_gacisi a[rel*=lightbox]').lightBox();
	},
	add_subscriber : function() {
		$.post("/wp-content/themes/5posta/lib/ajax.php", {
			action: '4f893ee24950069dd823e083338a456d',
			email : $('#eposta').val()
		},
		function(data){
			alert(data);
			$('#email').val('');			
		});
	},
	contact_form : function() {
		var error = false;
		var arr = ['author', 'email', 'url', 'comment'];
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		jQuery.each(arr, function() {
			var el = $("#" + this);
			if (el.val() == '') {
				error = true;
				alert("Lütfen gerekli alanlari doldurunuz.");
				return false;
			}
			if (el.attr('id') == 'email') {
				if (reg.test($('#email').val()) == false) {
					error = true;
					alert("Lütfen dogru bir e-posta adresi giriniz.");
					return false;
				}
			}
		});
		if (!error) {
			$.post("/wp-content/themes/5posta/lib/ajax.php", {
				action: '5f4bd6addd5620480f7148fdda530391',
				name   : $('#author').val(),
				email  : $('#email').val(),
				subject: $('#url').val(),
				message: $('#comment').val()
			},
			function(data){
				if (data == 1) {
					alert("Tesekkür ederiz.\nEn kisa zamanda sizinle iletisime geçecegim.");
					document.location.href = "/iletisim/";
				} else {
					alert("Bir hata olustu.\nLütfen tekrar deneyiniz.");
					document.location.href = "/iletisim/";
				}
			});
		}
	}
};
$(document).ready(function(){global.init();});
