jQuery.noConflict();

function doMailFormPostback() 
{
    document.location.href="desktopdefault.aspx/tabid-22/?co=10";
}

function appendBackButton(sPageUrl)
{
	var html='<div class="treeview">';
		html+='<a href="'+sPageUrl+'" title="Zur&uuml;ck"><img src="portaldata/1/Resources/_intern/but/but_zurueck.gif" alt="Zur&uuml;ck"/></a>';
		html+='</div>';
	jQuery('.breadcrumb').append(html);
}

function hideMenu(obj)
{
		jQuery('.area-submenu').hide();
		jQuery('.area-subsubmenu').hide();
}

function stopBubble(e)
{
	var e = e || window.event;
	e.cancelBubble = true;

	if (e.stopPropagation)
	{ 
    	e.stopPropagation();
	}
}

function hideIntroBox()
{
	jQuery('div.introbox').hide();
}



window.setTimeout('hideIntroBox()',15000);


//Font Size Cookie
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
jQuery(document).ready(function() {	
	  //Reset Font Size 
    var cookie = readCookie("txtsize");
    var standard = cookie ? cookie : "11,14";
	standard = standard.split(",");
	jQuery('#content *').each(
					function(i)
					{
						if( this.className!='breadcrumb' && this.parentNode.className!='breadcrumb' && this.parentNode.className!='noresize' && this.className!='noresize' )
						{
						    //add a: this.nodeName.indexOf('A')>-1 ||
						    if( this.nodeName.indexOf('A')>-1 || this.nodeName.indexOf('DIV')>-1 || this.nodeName.indexOf('P')>-1 || this.nodeName.indexOf('H2')>-1 || this.nodeName.indexOf('LI')>-1 || this.nodeName.indexOf('UL')>-1 || this.nodeName.indexOf('H3')>-1 || this.nodeName.indexOf('TD')>-1 || this.nodeName.indexOf('STRONG')>-1 || this.nodeName.indexOf('B')>-1  )
							{
								jQuery( this ).css({'fontSize':parseInt(standard[0]),'lineHeight':standard[1] +'px'});
							}
							if ( this.nodeName.indexOf('H1')>-1 )
							{
								jQuery( this ).css({'fontSize':parseInt(standard[0])+8,'lineHeight':(parseInt(standard[1])+4)+'px'});
							}
						}
	
	}

				
		);
	
	
	
		jQuery('div.introbox').css('opacity',0.95);
		jQuery('div[style=color: orange;]').hide();
		jQuery('#content').hover(
			function()
			{
				hideMenu( this );
				jQuery('#language_select').hide();
				jQuery( '.fk-submenue' ).hide();
			}
		);

	    jQuery('a.introclose').click(
			function()
			{
                jQuery('div.introbox').hide();
			}
		);

		jQuery('#area-main-menu .menu ul li a').hover(
			function(e)
			{
			  stopBubble(e);
				var SubMenu=jQuery('.area-submenu.' + jQuery(this).parent().attr('className').toString() );
				var pos=jQuery(this).offset();

				jQuery('.area-submenu .menu-items ul.items li a.hasChild_True').css({'background':'none','color':'#ffffff'});
				jQuery('.area-submenu').hide();
				jQuery('.area-subsubmenu').hide();
        jQuery('#language_select').hide();
        
				try {
					if( SubMenu.attr('className').match(/main-navi-19/)!=null )
					{
						SubMenu.css( {'top':pos.top+27,'left':pos.left-104} );
					}
					else
					{
						SubMenu.css( {'top':pos.top+27,'left':pos.left+3} );
					}
				}
				catch(e)
				{
					SubMenu.css( {'top':pos.top+27,'left':pos.left+3} );
				}
				
				SubMenu.show();
			}
		);

		jQuery('.area-submenu .menu-items ul.overview li a').hover(
			function(e)
			{
				stopBubble(e);
				jQuery('#language_select').hide();
				jQuery('.area-submenu .menu-items ul.items li a.hasChild_True').css({'background':'none','color':'#ffffff'});
				jQuery('.area-subsubmenu').hide();
			}
		);

		jQuery('.area-submenu .menu-items ul.items li a').hover(
			function(e)
			{
				stopBubble(e);
			    if( jQuery(this).attr('className').match(/hasChild_True/)!=null )
				{
				    
				    var MenuName=jQuery(this).attr('className').substring(14);
				    var SubMenu=jQuery('.area-subsubmenu.'+MenuName);
				    var pos=jQuery(this).offset();
          
          jQuery('#language_select').hide();
					jQuery('.area-subsubmenu').hide();
	
					jQuery('.area-submenu .menu-items ul.items li a.hasChild_True').css({'background':'none','color':'#ffffff'});
					jQuery(this).css( {'background':'url(../resources/_intern/bg/menu-hover-haschild.gif) 0 50% repeat-x #e6ecbe','color':'#004071'} );
	
					SubMenu.css( {'top':pos.top-4,'left':pos.left+212} );
					SubMenu.show();
				}
				else
				{
					jQuery('.area-submenu .menu-items ul.items li a.hasChild_True').css({'background':'none','color':'#ffffff'});
					jQuery('.area-subsubmenu').hide();
					jQuery('#language_select').hide();
				}

			}
		);

		jQuery('#content .content-products-overview .product-overview').hover(
			function()
			{
			    if( parseInt(jQuery(this).children('.icon').css('height'))>=113 )
				{
				    jQuery('#content .content-products-overview .product-overview .icon').css({'height':32,'opacity':0.5});
				    jQuery('#content .content-products-overview .product-overview .icon').removeClass('defaultImg');
				    jQuery('#content .content-products-overview .product-overview .item .text').hide();
				}
				else
				{
				    jQuery('#content .content-products-overview .product-overview .icon').css({'height':32,'opacity':0.5});
				    jQuery('#content .content-products-overview .product-overview .icon').removeClass('defaultImg');
				    jQuery('#content .content-products-overview .product-overview .item .text').hide();
					
					jQuery(this).children('.icon').addClass('defaultImg');
				    jQuery(this).children('.icon').css({'height':113,'opacity':1.0});
				    jQuery(this).children('.icon').parent().children('.products').children('.item').children('.text').show();
				}
			}
		);

		jQuery('#enlargeText').click(
			function()
			{
			    //enlarge Text
			    var Element=jQuery('#content');
			    var newSize=(parseInt(Element.css('fontSize'))+1);
			    newSize=20;
			    Element.css('fontSize', newSize );
			}
		);

		jQuery('.content-press-items .item').hover(
			function()
			{
			  //reset
			  jQuery('.content-press-items .item .press-preview').css({'opacity':0.5,'height':40});
				jQuery('.content-press-items .item .press-text .text p.preview').hide();

			  jQuery(this).children('.press-preview').css({'opacity':1.0,'height':113});
				var oContent=jQuery(this).children('.press-preview').parent().children('.press-text').children('.text').children('p.preview');
				oContent.show();

			  return false;
			}
		);

    jQuery('#area-main .header-left ul li.language a').hover(
      function() 
      {
        if( jQuery('#language_select').is('*') ) 
        {
          jQuery('#language_select').show();
        } 
        else 
        {
          var pos=jQuery(this).offset();
          var html='<div id="language_select" style="position: absolute; z-index: 101; width: 120px; background: none #ccecff; top:'+(pos.top+20)+'px;  left:'+(pos.left)+'px">';
              html+='<ul>';
              html+='<li><a href="/de/">Deutsch</a></li>';
              html+='<li><a href="/en/">English</a></li>';
              html+='</ul>';
              html+='</div>';
          hideMenu(null);
          jQuery('body').append(html);   
        }
        return false;
      }      
    );

	
		jQuery('#content div.treeview a.resize').click(
			function()
			{
				var FontSizeA=new Array(11,14);
				var FontSizeB=new Array(14,16);
				var FontSizeC=new Array(16,18);
				var newSize=FontSizeA;

				if( jQuery(this).hasClass('SizeA') )
				{
					newSize=FontSizeA;
				}
				else if ( jQuery(this).hasClass('SizeB') )
				{
					newSize=FontSizeB;
				}
				else if ( jQuery(this).hasClass('SizeC') )
				{
					newSize=FontSizeC;
				}
				
				jQuery('#content *').each(
					function(i)
					{
						if( this.className!='breadcrumb' && this.parentNode.className!='breadcrumb' && this.parentNode.className!='noresize' && this.className!='noresize' )
						{
						    //add a: this.nodeName.indexOf('A')>-1 ||
						    if( this.nodeName.indexOf('A')>-1 || this.nodeName.indexOf('DIV')>-1 || this.nodeName.indexOf('P')>-1 || this.nodeName.indexOf('H2')>-1 || this.nodeName.indexOf('LI')>-1 || this.nodeName.indexOf('UL')>-1 || this.nodeName.indexOf('H3')>-1 || this.nodeName.indexOf('TD')>-1 || this.nodeName.indexOf('STRONG')>-1 || this.nodeName.indexOf('B')>-1  )
							{
								jQuery( this ).css({'fontSize':newSize[0],'lineHeight':newSize[1]+'px'});
							}
							if ( this.nodeName.indexOf('H1')>-1 )
							{
								jQuery( this ).css({'fontSize':newSize[0]+8,'lineHeight':(newSize[1]+4)+'px'});
							}
						}
					}
					);
				createCookie('txtsize', newSize.join(","));
				return false;
			}
		);
		
		
		

		
/*		jQuery('.header-right .search input').click(
			function()
			{
				jQuery(this).val('');
			}
		);
*/

/*
		jQuery('.header-right .search input').blur(
			function()
			{
				jQuery(this).val('Suchbegriff eingeben');
			}
		);
*/		
        jQuery('.downloads-container .downloads div.clicker').click(
			function()
			{
				//open clicked container
				jQuery('.header').children('img').attr('src','portaldata/1/Resources/_intern/ico/indicator_inactive.jpg');
				jQuery('.content').hide();
				jQuery(this).children('.header').children('img').attr('src','portaldata/1/Resources/_intern/ico/indicator_active.jpg');
				jQuery(this).children('.content').show();
			}
		);
		
        jQuery('.fachkreise li').mouseover(
		    function()
		    {
		        jQuery('.fk-submenue').hide();
		        var pos=jQuery(this).offset();
		        if(jQuery(this).children('a').hasClass('hasChild_True'))
		        {
			        var iMenuNum=jQuery(this).children('a').attr('class').substr(14);
			        var fkSubMenu=jQuery( '.fk-submenue.'+iMenuNum );
			        fkSubMenu.css( {'top':pos.top-4,'left':pos.left+185} );
			        fkSubMenu.show();
		        }
		    }
		 );		

		
	}
);
