var isFlash = false;
var isFullFlash = false;

var FlashResizer = {
	height: 400,
    minHeight: 300,
	minWidth: 600,
	maxHeight: null,
	swfMovieRatio: 0.59,
	flashFile: '',
	altImage: '',
	altLink: '',
	altImageWidth: 0,
	altImageHeight: 0,
	altHTML: '',
	swfparams: '',
	wmodetransparent: 1,
	imgBasepath: '',
	imgFile: '',
	scaleFlash: 1,
	align: 'LT',
	headerType: 'headonly',
	

	init: function() {
	var so;
		if (this.flashFile != '') {
			isFlash = true;
			
			so = new SWFObject(this.flashFile, 'teaser', '100%', '100%', '8', '#FFFFFF');
		
			so.addParam('quality', 'high');
			so.addParam('align', this.align);
			so.addParam('allowScriptAccess', 'true');
			
			if(this.headerType != 'headonly') {
				isFullFlash = true;
			}
			
			for (var i in this.swfparams) {
				so.addVariable(this.swfparams[i]['name'], this.swfparams[i]['value']);
			}
		
			if(this.wmodetransparent == 1 || this.flashFile == '') {
				so.addParam('wmode', 'transparent');
			}
			
			so.addVariable('basepath', this.imgBasepath);
			so.addVariable('imgfile', this.imgFile);
			
			if(so.write('teaserflash')) {
				// ok, browser has flash
				$('#content>h2:first').css('display','none');
				$('h1.graphHeader1').remove();
				
				if(this.wmodetransparent == 0 && this.scaleFlash == 1) {
					$('#main').css('overflow', 'hidden');
				}
			} else {
				// nonflash variante.
				this.wmodetransparent = 1;
				
				if(this.headerType == 'headonly') {
					$('#flashHeader').css('display', 'none');
					$('#main_back_top').css('display','');
					$('#main').css('padding-top', '30px');
					$('#maincontent').css('padding-top', '0px');
				} else {
					var lang 	= '';
					var uid		= '';
					
					for(var i = 0; i < this.swfparams.length; i++) {
						if(this.swfparams[i]['name'] == 'lang') {
							lang = this.swfparams[i]['value'];
						}
						if(this.swfparams[i]['name'] == 'uid') {
							uid = this.swfparams[i]['value'];
						} 
					}
					
					$.post("/fileadmin/uhlsport/php/t3plugin_nonFlash.php", "action=getNonFlashPage&lang="+lang+"&uid="+uid, function(inhalt){
						$('#main').html(inhalt);
						
						$('#main').css('overflow','hidden');
						
						$('#noflashShort').html($('#noFlashTextShort').html());
						$('#noflashLong').html($('#noFlashTextLong').html());
						$('#noflashLink').html($('#noFlashLinkText').html());
						
						/*if ($.browser.name == 'msie' && $.browser.versionNumber == '6') {
							$('#text-teaser').css({
								'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src="/fileadmin/templates/img/shared/teaser_back_shadow.png"',
								'background': 'none'
							});
							$('.footerContainer').css({
								'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src="/fileadmin/templates/img/shared/nonFlash_back.png"',
								'background': 'none'
							});
							$('.top').css({
								'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src="/fileadmin/templates/img/shared/breadCrump_zu.png"',
								'background': 'none'
							});
						} else {
							$('#text-teaser').css('background', 'url(fileadmin/templates/img/shared/teaser_back_shadow.png)');
						}*/
						
						/*modifikation = 0;
						$('#text-teaser>.text-teaser_item').css('padding-top', '23px');
						$('div#text-teaser').height(65-modifikation);
						
						var range = 90;
	
						if($('#text-teaser').length <= 0) {
							range -= 40;
						}
						if($('#breadnav').length <= 0) {
							range -= 30;
							$('.top').css('top','-55px');
						} else {
							$('.top').hide();
							$('#main').css('padding-top','25px');
						}
						
						if($('#main').css('margin-top') != '') {
							range = eval(range + "+" + $('#main').css('margin-top').replace(/px/, ''));
						}
							
						$('#main').height($(window).height()-range);*/
					});
				}
			}
		}
	}
};

$(document).ready(function() { FlashResizer.init(); } );
