jQuery.noConflict();

jQuery(document).ready(function() {
	jQuery('.newsbilder table td:eq(1)').css('background-image', 'url()');
	
	jQuery("#headerarea #headertextbg").css({ opacity: 0.3 });
	jQuery("#headerarea #headertext .contenttable p").css({ opacity: 0.9 });
	
	jQuery('#leftmenuul:eq(0) li.li01:eq(0)').addClass('menu-home');
	jQuery('#leftmenuul:eq(0) li.li01:eq(1)').addClass('menu-kunden');
	jQuery('#leftmenuul:eq(0) li.li01:eq(2)').addClass('menu-zvme');
	jQuery('#leftmenuul:eq(0) li.li01:eq(3)').addClass('menu-otwa');
	
	jQuery('#otwabody-1 .tx-columna-pi1 .startseite .startseite_td:last > h1').css("background", "#113786");
	
	jQuery('#otwabody-1 #headerarea #headertext .contenttable tr:eq(1) td p').css("font-size", "12px");
	jQuery('#otwabody-1 #headerarea #headertext .contenttable tr:eq(1) th p').css("background-image", "url(/fileadmin/template/img/bg_info_kunden.gif)");
	
	if( jQuery.cookie('otwa_header') == null )
		jQuery.cookie('otwa_header',0,{expires:365,path:'/'});
	
	if((jQuery.cookie('otwa_header') == '1' && jQuery.cookie('otwa_header') != '0')) {
		jQuery('#headerarea').css('height', '135px');
		jQuery('#leftbar').css('margin-top', '-88px');
	}
	
	jQuery('#contentarea .contenttable').each(function() {
		jQuery(this).find('#content tr:even').css('background-color', '#f2f2f2');
	});
	
	var i_mode = 0;
	jQuery('#headertoggle').live('click', function() {
		if( jQuery.cookie('otwa_header') == '0' && jQuery.cookie('otwa_header') != '1' ) {
			jQuery('#headerarea').animate({height:'135px'});
			jQuery('#leftbar').animate({marginTop:'-88px'});
			i_mode = 1;
			jQuery.cookie('otwa_header',i_mode,{expires:365,path:'/'});
		} else {
			jQuery('#headerarea').animate({height:'312px'});
			jQuery('#leftbar').animate({marginTop:'-265px'});
			i_mode = 0;
			jQuery.cookie('otwa_header',i_mode,{expires:365,path:'/'});
		}
	});
	
	jQuery('.tx-columna-pi1 > table.startseite').each(function() {
		var anz_spalten = jQuery( this ).find('td.startseite_td').length;
		var breite_spalten = 0;
		if( anz_spalten == 1 )
			breite_spalten = 100;
		else if( anz_spalten == 2 )
			breite_spalten = 50;
		else if( anz_spalten == 3 )
			breite_spalten = 33;
		else if( anz_spalten == 4 )
			breite_spalten = 25;
		else if( anz_spalten == 5 )
			breite_spalten = 20;
		
		if( anz_spalten == 1 )
			jQuery( this ).find('td:eq(1)').remove();
		
		jQuery( this ).find('td.startseite_td').css('width', breite_spalten+'%');
	});
	
	jQuery('##contentarea table.contenttable tr').each(function() {
		jQuery( this ).find('td:last').css('border-right', '1px solid #cccccc');
	});
	
	var contentarea = jQuery('div#content div.innerpadding');
	var num_ee = contentarea.css('font-size');
	var num_e = parseFloat(num_ee, 10);
	jQuery("a.changer").click(function() {
		var currentSize = contentarea.css('font-size');
		var num = parseFloat(currentSize, 10);
		var unit = currentSize.slice(-2);
		if (this.id == 'linkLarge') {
			num = num * 1.2;
		} else if (this.id == 'linkSmall') {
			num = num / 1.2;
		} else if (this.id == 'linkDefault') {
			num = num_e;
		}
		
		contentarea.css('font-size', num + unit);
   		return false;
	});
});

function launchWin(winUrl, winName, winX, winY, winFeatures){
	var newWin;
	if (!newWin || newWin.closed) {
		winTop = (screen.height - winY) / 2;
		winLeft = (screen.width - winX) / 2;
		newWin = window.open(winUrl, winName, 'width=' + winX + ',height=' + winY + ',top=' + winTop + ',left=' + winLeft + ',' + winFeatures);
	}
	
	// window.setTimeout("newWin.focus()",500);
	
	newWin.focus();
}
