// var b_isBadBrowser = /MSIE/.test(navigator.userAgent);
var b_isBadBrowser = typeof(window.XMLHttpRequest) == 'undefined';

var sw = screen.width;
var sh = screen.height;
var ww = window.outerWidth;
var iw = window.innerWidth;
var wh = window.outerHeight;
var ih = window.innerHeight;
var po = 0;
var wi = 0;
var i_offset = 0;
var i_mainImgWidth = 0;

var f_img_resize = function() {
		iw = window.innerWidth;
		if(typeof iw == 'undefined') {
			iw = document.body.clientWidth;
		}
		if(typeof iw == 'undefined') {
			iw = document.documentElement.clientWidth;
		}
		i_offset = Math.ceil(iw * 0.1614);

		if(iw > 1920) {
			i_mainImgWidth = 1610;
		} else if(iw >= 1024 && iw <= 1920) {
			i_mainImgWidth = iw - i_offset;
		} else if(iw < 1024) {
			i_mainImgWidth = 857;
		}

		$('#mainimg').css('width', i_mainImgWidth+'px');
		
		/** spruchband anpassen: */
		switch($('#topslogan').attr('class')) {
			// fuer den Augen/Mund Spruch:
			case 'ima_3':
				if(i_mainImgWidth >= 1398) {
					$('#topslogan').css('width', i_mainImgWidth+'px');
					$('#botslogan').hide();
				} else if(i_mainImgWidth < 1398 && i_mainImgWidth > 1329) {
					$('#topslogan').css('width', 1328+'px');
					$('#botslogan').show().css({'background-position':'-1328px top','width':1398-1328+'px'});
				} else if(i_mainImgWidth <= 1328 && i_mainImgWidth > 1274) {
					$('#topslogan').css('width', 1273+'px');
					$('#botslogan').show().css({'background-position':'-1273px top','width':1398-1273+'px'});
				} else if(i_mainImgWidth <= 1273 && i_mainImgWidth > 1243) {
					$('#topslogan').css('width', 1242+'px');
					$('#botslogan').show().css({'background-position':'-1242px top','width':1398-1242+'px'});
				} else if(i_mainImgWidth <= 1242 && i_mainImgWidth > 1188) {
					$('#topslogan').css('width', 1187+'px');
					$('#botslogan').show().css({'background-position':'-1187px top','width':1398-1187+'px'});
				} else if(i_mainImgWidth <= 1187 && i_mainImgWidth > 1132) {
					$('#topslogan').css('width', 	1131+'px');
					$('#botslogan').show().css({'background-position':'-1131px top','width':1398-1131+'px'});
				} else if(i_mainImgWidth <= 1131 && i_mainImgWidth > 1053) {
					$('#topslogan').css('width', 1052+'px');
					$('#botslogan').show().css({'background-position':'-1052px top','width':1398-1052+'px'});
				} else if(i_mainImgWidth <= 1052 && i_mainImgWidth > 1023) {
					$('#topslogan').css('width', 1022+'px');
					$('#botslogan').show().css({'background-position':'-1022px top','width':1398-1022+'px'});
				} else if(i_mainImgWidth <= 1022 && i_mainImgWidth > 979) {
					$('#topslogan').css('width', 978+'px');
					$('#botslogan').show().css({'background-position':'-978px top','width':1398-978+'px'});
				} else if(i_mainImgWidth <= 978 && i_mainImgWidth > 887) {
					$('#topslogan').css('width', 886+'px');
					$('#botslogan').show().css({'background-position':'-886px top','width':1398-886+'px'});
				} else {
					$('#topslogan').css('width', 825+'px');
					$('#botslogan').show().css({'background-position':'-825px top','width':1398-825+'px'});
				}
				break;
				
			case 'ima_2':
				if(i_mainImgWidth >= 875) {
					$('#topslogan').css('width', i_mainImgWidth+'px');
					$('#botslogan').hide();
				}	 else {
					$('#topslogan').css('width', 705+'px');
					$('#botslogan').show().css({'background-position':'-705px -2px','width':875-705+'px'});
				}			
				break;
				
			case 'ima_1':
				if(i_mainImgWidth >= 1101) {
					$('#topslogan').css('width', i_mainImgWidth+'px');
					$('#botslogan').hide();
				} else if(i_mainImgWidth < 1101 && i_mainImgWidth > 1008) {
					$('#topslogan').css('width', 1007+'px');
					$('#botslogan').show().css({'background-position':'-1007px top','width':1101-1007+'px'});
				}	 else if(i_mainImgWidth < 1007 && i_mainImgWidth > 957) {
					$('#topslogan').css('width', 956+'px');
					$('#botslogan').show().css({'background-position':'-956px top','width':1101-956+'px'});
				}	else if(i_mainImgWidth < 956 && i_mainImgWidth > 914) {
					$('#topslogan').css('width', 913+'px');
					$('#botslogan').show().css({'background-position':'-913px top','width':1101-913+'px'});
				} else if(i_mainImgWidth < 913 && i_mainImgWidth > 868) {
					$('#topslogan').css('width', 867+'px');
					$('#botslogan').show().css({'background-position':'-867px top','width':1101-867+'px'});
				} else {
					$('#topslogan').css('width', 821+'px');
					$('#botslogan').show().css({'background-position':'-821px top','width':1101-821+'px'});
				}	
				break;
			
			default: 
				$('#botslogan').hide();
				$('#topslogan').css('width', i_mainImgWidth+'px');
		}
}

$().ready(function() {
	f_img_resize();
	
	$(window).resize(function() {
		f_img_resize();	
	});
});

