Ext.onReady(function(){
	Ext.QuickTips.init();	
	if(Ext.get('BultenForm')){
		var BultenForm = new Ext.FormPanel({
			labelWidth: 60,
			frame:false,
			width: 150,
			height:110,
			defaults: {width: 85},
			defaultType: 'textfield',
			items: [{
					fieldLabel: 'Ad Soyad',
					name: 'AdSoyad',
					itemCls:'BultenLabel',				
					allowBlank:false,
					blankText:'Lütfen adınızı ve soyadınızı yazınız'
					},{
					fieldLabel: 'Email',
					name: 'Email',
					vtype:'email',
					itemCls:'BultenLabel',
					allowBlank:false,
					blankText: 'Lütfen email adresinizi yazınız.'
			}]
		});
		BultenForm.addButton('Gönder', function(){
			if (BultenForm.getForm().isValid()){
				BultenForm.getForm().submit({
					url:'includes/phpcodes.php',
					method:'POST',				
					params:{
						Action:'NewsLetter'
					}, 						
					waitMsg:'Kaydediliyor...',
					success:function(){
						Ext.MessageBox.alert('Teşekkürler', 'İlginizden dolayı teşekkür ederiz.');
						BultenForm.getForm().reset();
					}
				});	
			}else{
				Ext.MessageBox.alert('Hata', 'Lütfen eksikleri tamalayınız.');
			}
		}, BultenForm);	
		BultenForm.render('BultenForm');
	}
});
function ShowExperiences(ExpId){
	if(!ExpId){
		ExpId='';	
	}
	var GridWindow = new Ext.Window({
		title: '',
		width: 585,
		height:700,
		autoScroll:true,
		minWidth: 275,
		minHeight: 110,
		layout: 'fit',
		plain:true,
		bodyStyle:'padding:5px;',
		buttonAlign:'center',
		autoLoad: {url: 'mainwindow.php?Id='+ExpId, scripts: true},
		buttons: [{
					text: 'Geri',
					id:'GeriButton',
					disabled:true,
					handler: function() {
						PrevExp();
				  	}
				    },{
				  	text: 'İleri',
					id:'IleriButton',
					disabled:true,
				    handler: function(){
						NextExp();
				    }
				}]
	});		
	GridWindow.show();
}
function ShowPhotoAlbum(){
	var PhotoWindow = new Ext.Window({
		title: '',
		width: 525,
		height:'auto',
		autoHeight:true,
		minWidth: 275,
		minHeight: 110,
		layout: 'fit',
		plain:true,
		bodyStyle:'padding:5px;',
		buttonAlign:'center',
		autoLoad: {url: 'photowindow.php', scripts: true},
		buttons: [{
					text: 'Geri',
					id:'GeriButton',
					disabled:true,
					handler: function() {
						PrevExp();
				  	}
				    },{
				  	text: 'İleri',
					id:'IleriButton',
					disabled:true,
				    handler: function(){
						NextExp();
				    }
				}]
	});		
	PhotoWindow.show();
}
function ShowPaylas(){
	var PaylasWindow = new Ext.Window({
		title: 'Bizimle Paylaşın',
		width: 350,
		height:'auto',
		autoHeight:true,
		minWidth: 275,
		minHeight: 110,
		layout: 'fit',
		plain:true,
		bodyStyle:'padding:5px;',
		buttonAlign:'center',
		autoLoad: {url: 'paylaswindow.php', scripts: true},
		buttons: [{
        text: 'Kaydet',
        handler: function() {
            if (newForm.form.isValid()) {
                newForm.form.submit({
                    waitMsg:'Kaydediliyor',
                    failure: function(form, action) {
                        Ext.MessageBox.alert('Hata', 'Kaydederken hata oluştu. Lütfen tekrar deneyin');	
                    },
                    success: function(form, action) {
                        Ext.MessageBox.alert('Başarılı', 'Kayıt başarıyla eklendi');
                        PaylasWindow.close();
                    }
                });
            }
            else {
                Ext.MessageBox.alert('Dikkat', 'Lütfen eksikleri tamalayınız.');
            }
        }
        },{
        text: 'İptal',
            handler: function(){
            	newForm.getForm().reset();
            	PaylasWindow.close();
        	}
    	}]
	});		
	PaylasWindow.show();
}
function ShowTavsiye(){
	var TavsiyeWindow = new Ext.Window({
		title: 'Tavsiye Et',
		width: 400,
		height:'auto',
		autoHeight:true,
		minWidth: 275,
		minHeight: 110,
		layout: 'fit',
		plain:true,
		bodyStyle:'padding:5px;',
		buttonAlign:'center',
		autoLoad: {url: 'tavsiyewindow.php', scripts: true},
		buttons: [{
        text: 'Gönder',
        handler: function() {
            if (newForm.form.isValid()) {
                newForm.form.submit({
                    waitMsg:'Gönderiliyor',
                    failure: function(form, action) {
                        Ext.MessageBox.alert('Hata', 'Kaydederken hata oluştu. Lütfen tekrar deneyin');	
                    },
                    success: function(form, action) {
                        Ext.MessageBox.alert('Başarılı', 'Tavsiyeniz gönderildi. Gösterdiğiniz ilgiden dolayı çok teşekkür ederiz.');
                        TavsiyeWindow.close();
                    }
                });
            }
            else {
                Ext.MessageBox.alert('Dikkat', 'Lütfen eksikleri tamalayınız.');
            }
        }
        },{
        text: 'İptal',
            handler: function(){
            	newForm.getForm().reset();
            	TavsiyeWindow.close();
        	}
    	}]
	});		
	TavsiyeWindow.show();
}

