//###################################### NEWS ###################################### 

var newsstore = new Ext.data.JsonStore({
		proxy: new Ext.data.HttpProxy({
			url: 'formJSON3.php',
			method: 'GET'
		}),
		storeId: 'NewsStore',
		pruneModifiedRecords: true,
		root: 'data',
		fields: [
			{
				name: 'ID',
				type: 'int'
			},
			{
				name: 'Datum'
			},
			{
				name: 'Ueberschrift'
			},
			{
				name: 'Text'
			}
		]
});

var newsstoremain = new Ext.data.JsonStore({
		proxy: new Ext.data.HttpProxy({
			url: 'formJSON3.php',
			method: 'GET'
		}),
		storeId: 'NewsStoreMain',
		pruneModifiedRecords: true,
		root: 'data',
		fields: [
			{
				name: 'ID',
				type: 'int'
			},
			{
				name: 'Datum'
			},
			{
				name: 'Ueberschrift'
			},
			{
				name: 'Bild'
			},
			{
				name: 'Bild_Txt'
			},
			{
				name: 'Text'
			}
		]
});

var NewsField = new Ext.form.DisplayField({
		id: 'NewsField',
		fieldLabel: 'Bitte beachten Sie',
		name: 'newsfield'
});

var UNews;
var DNews;
var News;
var INews;

var Newsbox_Datum; 
var Newsbox_Ueberschrift; 
var Newsbox_Bild;
var Newsbox_Bild_Title;  
var Newsbox_Bild_Txt;
var Newsbox_Txt;
var Newsbox_ID;

//###################################### Functions ######################################

//###################################### Panels ######################################

Ext.onReady(function () {

	newsstore.load({
		params: { news : 1 }
	});
	
	newsstoremain.load({
		params: { newsm : 1 }
	});
	
	newsstore.on("load", function(s,rs) {
		newsstore.each(function(record) {
			
			INews = record.data.ID;
			UNews = record.data.Ueberschrift;
			News = record.data.Text;
			DNews = record.data.Datum.slice(8,10)+'.'+record.data.Datum.slice(5,7)+'.'+record.data.Datum.slice(0,4);
			//DNews = record.data.Datum.getDate() + "." + (record.data.Datum.getMonth() + 1) + "." + record.data.Datum.getFullYear();
			
			var NewsBox2 = new Ext.Panel({
				//title: '<hr/><h2><a name="'+Newsbox_ID+'">('+Newsbox_Datum+') '+Newsbox_Ueberschrift+'</a></h2><hr/>',
				layout:'table',
				renderTo: 'ExtNews',
				defaults: {
					// applied to each contained panel
					//bodyStyle:'padding:15px'
				},
				layoutConfig: {
					// The total column count must be specified here
					columns: 1
					
				},
				items: [{
					html: '<div class="imp">(' + DNews + ') ' + UNews +' <a href="http://www.breitband-bautzen.de/index.htm#'+INews+'">[mehr]</a></div>',
					//rowspan: 2
					//width: '200',
					bodyStyle:'margin-bottom:5px;'
				}]
			});
			
			
		});
	});
	
	var zaehler = 0;
	
	newsstoremain.on("load", function(s,rs) {
		newsstoremain.each(function(record) {
			zaehler++;
			
			
			Newsbox_Datum = record.data.Datum.slice(8,10)+'.'+record.data.Datum.slice(5,7)+'.'+record.data.Datum.slice(0,4); 
			Newsbox_Ueberschrift = record.data.Ueberschrift; 
						
			if(record.data.Bild == null){
				Newsbox_Bild = './Bilder/logo_bautzen_schwarz.png';
				Newsbox_Bild_Txt = '';
				Newsbox_Bild_Title = 'Landkreis Bautzen';
			}
			else{
				Newsbox_Bild = record.data.Bild;
				Newsbox_Bild_Txt = record.data.Bild_Txt;
				Newsbox_Bild_Title = record.data.Bild_Txt;
			}
						
			Newsbox_Txt = record.data.Text;
			Newsbox_ID = record.data.ID;

			var NewsBox = new Ext.Panel({
				title: '<hr/><h2><a name="'+Newsbox_ID+'">('+Newsbox_Datum+') '+Newsbox_Ueberschrift+'</a></h2><hr/>',
				layout:'table',
				renderTo: 'ExtNewsMain',
				defaults: {
					// applied to each contained panel
					//bodyStyle:'padding:15px'
				},
				layoutConfig: {
					// The total column count must be specified here
					columns: 1 //2
					
				},/*
				items: [{
					html: '<img src="'+Newsbox_Bild+'" alt="'+Newsbox_Bild_Title+'" title="'+Newsbox_Bild_Title+'" width="200"></img><br><div class="imp_bild" >'+Newsbox_Bild_Txt+'</div>',
					//rowspan: 2
					width: '200',
					bodyStyle:'margin-top:0px;'
				},{
					html: '<div class="imp" >'+Newsbox_Txt+'</div>',
					bodyStyle:'padding-left:5px;margin-top:0px;'
				}]*/
				items: [{
					html: '<img src="'+Newsbox_Bild+'" alt="'+Newsbox_Bild_Title+'" title="'+Newsbox_Bild_Title+'" align="left" hspace="20" vspace="5" width="200"></img><div class="imp" >'+Newsbox_Txt+'</div>',
					//rowspan: 2
					//width: '400',
					bodyStyle:'margin-top:0px;'
				}]
			});
						
			
		});

		
	});

});





