// JavaScript Document
/*
	author      : GEN3
	email, msn  : info@gen3.com.tr

*/

	
function maillist(){	
	var email = $("#email").val();
	if(checkEmail(email)){	
		var str = $("#BulletinAddForm").serialize() + '&G2='+$("#G2").val();	
		$.ajax({type:'POST',url:$("#baseurl").val()+'ajax.php',data:'IS=1&'+str,cache:false,timeout:5000,success:function(d){alert(d);window.location.reload();}});	
	}else{ alert("Hatalı mail adresi!"); }	
}

function checkEmail(email){ var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/; return pattern.test(email); }

function anket(x){	
		var str = $("#PollForm"+x).serialize() + '&G2='+$("#G2").val();	
		$.ajax({type:'POST',url:$("#baseurl").val()+'ajax.php',data:'IS=2&'+str,cache:false,timeout:5000,success:function(d){alert(d);window.location.reload();}});	
}

function iletisim_Form(){	
		
	var hata = 0 ; var ad = $("#ad").val(); var tel = $("#tel").val(); var eposta = $("#eposta").val(); var mesaj = $("#mesaj").val(); var GK = $("#GK").val(); var G2 = $("#G2").val();		
	if( eposta == "" || !checkEmail(eposta) ){  $("#eposta").addClass('ihata');	hata = 1; }else{ $("#eposta").removeClass('ihata'); }	
	if( GK == "" || GK != G2 ){  $("#GK").addClass('ihata');	hata = 1; }else{ $("#GK").removeClass('ihata'); }
	var str = "IS=3&ad="+ad+"&tel="+tel+"&eposta="+eposta+"&mesaj="+mesaj+"&G2="+GK;
	if(hata == 0){ $.ajax({type:'POST',url:$("#baseurl").val()+'ajax.php',data:str,cache:false,timeout:5000,success:function(d){alert(d);window.location.reload();}}); }
}

function kariyer_Form(){
	var hata = 0 ; var GK = $("#GK").val(); var G2 = $("#G2").val(); var eposta = $("#eposta").val();		
	if( GK == "" || GK != G2 ){  $("#GK").addClass('ihata');	hata = 1; }else{ $("#GK").removeClass('ihata'); }
	if( eposta == "" ){  $("#eposta").addClass('ihata'); hata = 1; }else{ $("#eposta").removeClass('ihata'); }
	var str = "IS=4&" + $("#kariyerForm").serialize() + "&G2=" + GK;
	if(hata == 0){ $.ajax({type:'POST',url:$("#baseurl").val()+'ajax.php',data:str,cache:false,timeout:5000,success:function(d){alert(d);window.location.reload();}}); }
}

function randevu_Form(){
	var hata = 0 ; var GK = $("#GK").val(); var G2 = $("#G2").val(); var tel = $("#tel").val(); var eposta = $("#eposta").val(); var sehir = $("#sehir").val();		
	if( GK == "" || GK != G2 ){  $("#GK").addClass('ihata'); hata = 1; }else{ $("#GK").removeClass('ihata'); }
	if( tel == "" ){  $("#tel").addClass('ihata'); hata = 1; }else{ $("#tel").removeClass('ihata'); }
	if( eposta == "" ){  $("#eposta").addClass('ihata'); hata = 1; }else{ $("#eposta").removeClass('ihata'); }
	if( sehir == "" ){  $("#sehir").addClass('ihata'); hata = 1; }else{ $("#sehir").removeClass('ihata'); }
	var str = "IS=7&" + $("#randevuForm").serialize() + "&G2=" + GK;
	if(hata == 0){ $.ajax({type:'POST',url:$("#baseurl").val()+'ajax.php',data:str,cache:false,timeout:5000,success:function(d){alert(d);window.location.reload();}}); }
}

function basvuru_Form(){
	var hata = 0 ; var GK = $("#GK").val(); var G2 = $("#G2").val(); var eposta = $("#eposta").val();		
	if( GK == "" || GK != G2 ){  $("#GK").addClass('ihata');	hata = 1; }else{ $("#GK").removeClass('ihata'); }
	if( eposta == "" ){  $("#eposta").addClass('ihata'); hata = 1; }else{ $("#eposta").removeClass('ihata'); }
	var str = "IS=8&" + $("#basvuruForm").serialize() + "&G2=" + GK;
	if(hata == 0){ $.ajax({type:'POST',url:$("#baseurl").val()+'ajax.php',data:str,cache:false,timeout:5000,success:function(d){alert(d);window.location.reload();}}); }
}


$(document).ready(function(){
	
	
$("#dosyaekle").each(function(){
		
	new AjaxUpload(this, { 
		action    : $("#baseurl").val()+'ajax.php?IS=5&G2='+$("#G2").val() ,
		name      : 'uploadfile',
		onSubmit  : function(file, ext){ 
						if (! (ext && /^(jpg|png|gif|doc|docx)$/.test(ext))){ 
						alert('Sadece jpg|png|gif|doc|docx formatında dosya yükleyiniz!'); 
						return false;} 
							
						$(this).attr('disabled','disabled');
						$("#gonder").attr('disabled','disabled');
						
						},
		onComplete: function(file, response){ 
				 
				if(response != "hata"){
						$("#dosyaekle").attr('disabled','');
						$("#dosyaekle").hide();
			
						$("#dosyaad").show();	
						
						var str = response.split('|');							
							
						$("#dosyaad span").html(str[0]);				 
						
						$("#dosya1").val(str[0]);
						$("#dosya2").val(str[1]);
					}else{ alert("Teknik bir hata oluştu!");}
					
					$("#gonder").attr('disabled','');
							 
			}});
			
			});


	$("#dosyasil").click(function(){
		
	var str = "IS=6&dosya=" + $("#dosya2").val() + '&G2='+$("#G2").val() ;
	$.ajax({type:'POST',url:$("#baseurl").val()+'ajax.php',data:str,cache:false,timeout:5000,success:function(d){ 
		
		$("#dosyaekle").attr('disabled','');
		$("#dosyaekle").show(); 
		$("#dosyaad").hide(); 
		$("#dosya1").val('');
		$("#dosya2").val('');	
			
			}});

	
	
	});	
	
	});
