var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));


Ext.onReady( function() {

	/*********
	*  Startseite Bildermanipulation
	*/

	var bereich1 = Ext.get('bereich1');
	if (bereich1){
		Ext.select('#bereich1 img').each( function( el ){

			var wb1 = bereich1.getWidth();
			var elw = el.getWidth();
			if (elw > wb1){
				var neww  = wb1 - 27;
				var faktor = neww / elw;
				var newh = el.getHeight () * faktor;
				el.setWidth( neww );
				el.setHeight( newh );
			}

		});
	}
	/**********************************/

	var box;
	var initlink = Ext.select('.extwndowlink');
	initlink.each( function(el) {
		var lnk = el.dom;
		var conf_title = 'Weitere Informationen';
		var conf_modal = true;
		var conf_width = 740;
		var conf_height = 420;
		var conf_display_header = false;
		lnk.onclick = function() {

			box = Ext.MessageBox.show( {
				title : conf_title,
				msg : '<img src=\"' + basepath + '_/scripts/ext/resources/images/default/grid/loading.gif\" alt=\"\" style=\"border:0; vertical-align:middle;\"> Loading...',
				animEl : lnk,
				modal : conf_modal,
				fn : function() {
					Ext.MessageBox.hide();
					box.getDialog().header.dom.style.display = 'block';
					Ext.MessageBox.getDialog().bwrap.removeClass('xdlgbodyxtra');
				}
			});
			//

			if (conf_display_header == false) {
				box.getDialog().header.dom.style.display = 'none';
			}
			var url = lnk.href;
			Ext.Ajax.request( {
				url : url,
				success : function(req) {
					var treg = /<!--\sINHALT\s-->(.+)<!--\sINHALT\s-->/gi;
					var bd = treg.exec(req.responseText.split(/\n/).join(''));
					if (bd && bd[1]) {
						var txt = bd[1];
						txt = '<div id="blubber" style="width:' + (conf_width - 40) + 'px; overflow-x:hidden;overflow-y:auto;">' + txt + '</div>';
						Ext.MessageBox.updateText(txt);
						Ext.MessageBox.getDialog().center();
						if (Ext.MessageBox.getDialog().size.height > 500) {
							Ext.get("blubber").dom.style.height = "470px";
							Ext.MessageBox.getDialog().resizeTo(conf_width, 500);
						} else {
							Ext.MessageBox.getDialog().resizeTo(conf_width, Ext.MessageBox.getDialog().size.height);
						}
						//Ext.MessageBox.getDialog().resizeTo(conf_width,conf_height);
					}
				}
			});
			Ext.MessageBox.getDialog().bwrap.addClass('xdlgbodyxtra');


			/*var toolbox  = Ext.get(Ext.MessageBox.getDialog().toolbox.dom.id);
			var box  = Ext.get('appendto');
			toolbox.appendTo(box);
			toolbox.dom.style.zIndex = "1000000";
			debugger;*/
			/*Ext.MessageBox.getDialog().center();
			Ext.MessageBox.getDialog().toolbox.setXY([-10,-10], true);*/


			return (false);
		}
	});
});


function showFullImage (url , lnk , mw , mh ){
	var conf_title = ""; 
	var conf_modal = true;
	var txt = '<img id="boxelem" src=\"' + url + '\" alt=\"\" style=\"border:0; vertical-align:middle;\">';
	var minwidth = parseInt(mw); 
	var minheight=parseInt(mh);  
	
	box = Ext.MessageBox.show( {
		title : conf_title,
		msg : 'Lade...',
		animEl : lnk,
		width : minwidth, 
		height: minheight,
		modal : conf_modal,
		fn : function() {
			
		}
	});
	Ext.MessageBox.updateText(txt);
	Ext.MessageBox.getDialog().center();
	
	var w = Ext.get('boxelem').getWidth(); 
	var h = Ext.get('boxelem').getHeight();
	if (w<minwidth) w = minwidth; 
	if (h<minheight) h = minheight; 
	
	Ext.MessageBox.getDialog().resizeTo(w+20, h+50); 
	
	
}
function showinBigBox(box, el , firstrun){

	var dur = .5;
	
	if (firstrun == true){
		var squares = Ext.select(".square");
		var buttons  = Ext.get("buttons");
		squares.each(function(el){
			el.appendTo(buttons);
			el.fadeIn({
				duration : dur,
				useDisplay: true
			});
			
			
			
		});
		
		
	}

	var elid = 'tm'+el; 
	var inh = Ext.get(elid);
	
	var squares = Ext.select(".square"); 
	squares.each(function(el){
		el.removeClass("activesquare"); 
	}); 
	
	if (inh){

		var boxel = Ext.get(box);
		if (boxel){
			var h = boxel.getHeight();
			var sollh = 231 - 50; // 20 = boxen zählboxen
			boxel.setHeight (sollh);

			Ext.get('square'+el).addClass('activesquare');

			boxel.fadeOut({
				duration : dur,
				useDisplay: true,
				callback : function(){
					boxel.dom.innerHTML = inh.dom.innerHTML;
					
					boxel.fadeIn({
						duration : dur,
						useDisplay: true
					});
				}
			});




			//boxel.setHeight (sollh);




		}

	}

}