//------------------------rotator---------------------------------------
	function rotate(x) {   //musi być poza (document).ready bo inaczej nie bangla
		jQuery('#rotator div[id*=news]').fadeOut('slow');
		jQuery('#rotator div[id*=numb]').removeClass('current');
		jQuery('#news0'+x+', #news0'+x+'photo, #title_news0'+x).fadeIn('slow');
		jQuery('#numb0'+x).addClass('current');
		var nexti = x+1;
		nexti = (nexti==8)? 1 : nexti;
		timer = setTimeout("rotate("+nexti+")",10000);
	};
	
	function toSlide(x) {
		window.clearTimeout(timer);
		rotate(x);
	}
	
jQuery(document).ready(function () {

	rotate(1);
	
//------------------------end rotator-----------------------------------
var gfxPath = 'http://www.ardex.pl/assets/templates/ardex/gfx/';	
//------------------------mainmenu--------------------------------------
	jQuery('#mainmenu ul li a').mouseover(function(){
		if(jQuery(this).attr('headerindex')) {
		jQuery(this).css({'background':'#f0d764 url("'+gfxPath+'mainmenu_bg1.jpg") top right repeat-y','border-top':'1px solid #e1c153','border-bottom':'1px solid #e1c153'});
		}
	});

	jQuery('#mainmenu ul li a').mouseout(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var thisClass = jQuery(this).attr('class');
		arrayClass = thisClass.split(' ');
				if(disp=='none'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css({'background':'none','border-top':'1px solid transparent','border-bottom':'1px solid transparent'});
				}
		}
	});

	jQuery('#mainmenu ul li a').mousemove().mouseup(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var thisClass = jQuery(this).attr('class');
		var arrayClass = thisClass.split(' ');
			jQuery(this).click(function(){
				if(disp == 'block'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css({'background':'none','border-top':'1px solid transparent','border-bottom':'1px solid transparent'});
				}
				else {
					jQuery('#mainmenu ul li a').each(function(){
					var thisClass1 = jQuery(this).attr('class');
	  				var arrayClass1 = thisClass1.split(' ');
						if(jQuery(this).attr('headerindex')&&arrayClass1[2]!='active-submenuheader') {
						jQuery(this).css({'background':'none','border-top':'1px solid transparent','border-bottom':'1px solid transparent'});
						}
					});
				jQuery(this).css({'background':'#f0d764 url("'+gfxPath+'mainmenu_bg1.jpg") top right repeat-y','border-top':'1px solid #e1c153','border-bottom':'1px solid #e1c153'});
				}
			});			
		}
	});
//----------------------prodmenu--------------------
	jQuery('#menuitem12 a:first').css('background',"url('"+gfxPath+"menuitem12_bg.png') top left no-repeat");

	jQuery('#prodmenu ul li a').mouseover(function(){
		if(jQuery(this).attr('headerindex')) {
		var menuItemId = jQuery(this).parent().attr('id');
		jQuery(this).css('background',"url('"+gfxPath+""+menuItemId+"_bg.png') bottom left no-repeat");
		}
	});

	jQuery('#prodmenu ul li a').mouseout(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var menuItemId = jQuery(this).parent().attr('id');
		var thisClass = jQuery(this).attr('class');
		arrayClass = thisClass.split(' ');
		//jQuery('#kuku').text('-'+arrayClass[2]);
				if(disp=='none'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css('background',"url('"+gfxPath+""+menuItemId+"_bg.png') top left no-repeat");
				}
		}
	});

	jQuery('#prodmenu ul li a').mousemove().mouseup(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var menuItemId = jQuery(this).parent().attr('id');
		var thisClass = jQuery(this).attr('class');
		var arrayClass = thisClass.split(' ');
			jQuery(this).click(function(){
				if(disp == 'block'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css('background',"url('"+gfxPath+""+menuItemId+"_bg.png') top left no-repeat");
				}
				else {
					jQuery('#prodmenu ul li a').each(function(){
					var thisClass1 = jQuery(this).attr('class');
	  				var arrayClass1 = thisClass1.split(' ');
						if(jQuery(this).attr('headerindex')&&arrayClass1[2]!='active-submenuheader') {		//&&arrayClass1[2]!='active-submenuheader'
			//jQuery('#kuku').append('--'+disp+' - '+arrayClass1[2]);
						var menuItemId = jQuery(this).parent().attr('id');
						jQuery(this).css('background',"url('"+gfxPath+""+menuItemId+"_bg.png') top left no-repeat");
						}
					});
				jQuery(this).css('background',"url('"+gfxPath+""+menuItemId+"_bg.png') bottom left no-repeat");
				}
			});			
		}
	});
//--------------------------------------------realizacje_obiekty_menu------------------------------------------

	jQuery('#realizacje_obiekty_menu ul li a').mouseover(function(){
		if(jQuery(this).attr('headerindex')) {
		jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') bottom left no-repeat");
		}
	});

	jQuery('#realizacje_obiekty_menu ul li a').mouseout(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var thisClass = jQuery(this).attr('class');
		arrayClass = thisClass.split(' ');
		//jQuery('#kuku').text('-'+arrayClass[2]);
				if(disp=='none'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') top left no-repeat");
				}
		}
	});

	jQuery('#realizacje_obiekty_menu ul li a').mousemove().mouseup(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var thisClass = jQuery(this).attr('class');
		var arrayClass = thisClass.split(' ');
			jQuery(this).click(function(){
				if(disp == 'block'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') top left no-repeat");
				}
				else {
					jQuery('#realizacje_obiekty_menu ul li a').each(function(){
					var thisClass1 = jQuery(this).attr('class');
	  				var arrayClass1 = thisClass1.split(' ');
						if(jQuery(this).attr('headerindex')&&arrayClass1[2]!='active-submenuheader') {		//&&arrayClass1[2]!='active-submenuheader'
			//jQuery('#kuku').append('--'+disp+' - '+arrayClass1[2]);
						var menuItemId = jQuery(this).parent().attr('id');
						jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') top left no-repeat");
						}
					});
				jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') bottom left no-repeat");
				}
			});			
		}
	});

//--------------------------------------------realizacje_produkty_menu------------------------------------------

	jQuery('#realizacje_produkty_menu ul li a').mouseover(function(){
		if(jQuery(this).attr('headerindex')) {
		jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') bottom left no-repeat");
		}
	});

	jQuery('#realizacje_produkty_menu ul li a').mouseout(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var thisClass = jQuery(this).attr('class');
		arrayClass = thisClass.split(' ');
		//jQuery('#kuku').text('-'+arrayClass[2]);
				if(disp=='none'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') top left no-repeat");
				}
		}
	});

	jQuery('#realizacje_produkty_menu ul li a').mousemove().mouseup(function(){
		if(jQuery(this).attr('headerindex')) {
		var disp = jQuery(this).parent().children('ul').css('display');
		var thisClass = jQuery(this).attr('class');
		var arrayClass = thisClass.split(' ');
			jQuery(this).click(function(){
				if(disp == 'block'&&arrayClass[2]!='active-submenuheader') {
				jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') top left no-repeat");
				}
				else {
					jQuery('#realizacje_produkty_menu ul li a').each(function(){
					var thisClass1 = jQuery(this).attr('class');
	  				var arrayClass1 = thisClass1.split(' ');
						if(jQuery(this).attr('headerindex')&&arrayClass1[2]!='active-submenuheader') {		//&&arrayClass1[2]!='active-submenuheader'
			//jQuery('#kuku').append('--'+disp+' - '+arrayClass1[2]);
						var menuItemId = jQuery(this).parent().attr('id');
						jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') top left no-repeat");
						}
					});
				jQuery(this).css('background',"url('"+gfxPath+"realizacje_menuitem_bg.png') bottom left no-repeat");
				}
			});			
		}
	});

//-------------------hide links if empty url---------------

		jQuery('#templt02_right_sidebar a').each(function() {
			if(jQuery(this).attr('href')=='') jQuery(this).hide();
		});
		
//-------------------hide link to calculator if empty data---------------

		jQuery('#calculatorForm input[name=stala]').each(function() {
			if(jQuery(this).attr('value')=='') jQuery('#kalkulatorTrigger').hide();
			//var login = (jQuery('#QE_Toolbar').css('display') == 'block')? 'tak' : 'nie';
			//alert(login);
			//if(jQuery(this).attr('value')=='' || login == 'nie') jQuery('#kalkulatorTrigger').hide();
		});
		
//-------------------change font size---------------------- 

		jQuery('.font_resizer_small').click(function() {
			jQuery('.content').css('font-size','11px');
			return false;
		});
		jQuery('.font_resizer_mid').click(function() {
			jQuery('.content').css('font-size','12px');
			return false;
		});
		jQuery('.font_resizer_big').click(function() {
			jQuery('.content').css('font-size','13px');
			return false;
		});
		
//-------------------------show color in products----------------

		var prodGroup = jQuery('#prodmenu .active-submenuheader:first').parent().attr('id');
		//alert (prodGroup);
		switch (prodGroup)
		{
		default: { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #EBBE48','border-top':'2px solid #ebbe48'});
			}
		case 'menuitem13': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2a.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #dedf00','border-top':'2px solid #dedf00'});
			break;
			}
		case 'menuitem14': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2b.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #f04e30','border-top':'2px solid #f04e30'});
			break;
			}
		case 'menuitem15': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2c.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #ee3d85','border-top':'2px solid #ee3d85'});
			break;
			}
		case 'menuitem16': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2d.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #00b7ec','border-top':'2px solid #00b7ec'});
			break;
			}
		case 'menuitem17': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2e.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #f4f4c6','border-top':'2px solid #f4f4c6'});
			break;
			}
		case 'menuitem18': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2f.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #f04e30','border-top':'2px solid #f04e30'});
			break;
			}
		case 'menuitem19': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2g.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #ee3d85','border-top':'2px solid #ee3d85'});
			break;
			}
		case 'menuitem20': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2h.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #00b7ec','border-top':'2px solid #00b7ec'});
			break;
			}
		case 'menuitem21': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2i.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #f4f4c6','border-top':'2px solid #f4f4c6'});
			break;
			}

		case 'menuitem256': { 
			jQuery('#templt02_cont_col .content h2').css('background',"url('"+gfxPath+"bul2j.png') top left no-repeat scroll");
			jQuery('#templt02_right_sidebar div.header').css({'border-left':'2px solid #dd9b00','border-top':'2px solid #dd9b00'});
			break;
			}

		}
	
//-------------------show light if doradcy and dystrybutorzy open---------------

	if(jQuery('#doradcymenu ul li a').css('display')=='block') {
		//alert('kuku');
		jQuery('#menuitem24 a').css({'border-bottom':'1px solid #E1C153','1px solid #E1C153':'2px solid blue','background':'#FFFFFF url('+gfxPath+'mainmenu_bg2.jpg) repeat-y scroll right top'});
	}

	if(jQuery('#dystrybutorzymenu ul li a').css('display')=='block') {
		//alert('kuku');
		jQuery('#menuitem25 a').css({'border-bottom':'1px solid #E1C153','1px solid #E1C153':'2px solid blue','background':'#FFFFFF url('+gfxPath+'mainmenu_bg2.jpg) repeat-y scroll right top'});
	}

//---------------------------calculator----------------------

    var optionsCalculator = { 
        target:        '#output'
        , success:	  showOutput
    };

		jQuery('#calculatorForm').submit(function() {
        jQuery(this).ajaxSubmit(optionsCalculator); 
        return false; 
		});
});
 
	function showOutput() {
	jQuery('#output').slideDown();
	}
//--------------------accordion-----------------------------
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "slow", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
   }
   
});
/*
jQuery(document).ready(function () {

	jQuery('#prodmenu ul li a').each(function(){
		var thisClass7 = jQuery(this).attr('class');
		var arrayClass7 = thisClass7.split(' ');
		if(jQuery(this).attr('headerindex')&&arrayClass7[2]=='active-submenuheader') {
			//jQuery('#kuku').append(' - '+arrayClass7[2]);
			//alert('kuku');
			jQuery(this).parent().children('ul').show();
		}
		else{
			jQuery(this).parent().children('ul').hide();
		}
	});

});*/ 
