// JavaScript Document
//var domain = new URI
/*	SIFR */
//domain = ((domain.get('scheme')+'/'+domain.get('host')));

    function colorMenu(){
	var color;
	var color_default = '#666';
	$$('#menu .k1').addEvent('mouseenter', function(){
		color = this.getElement('a').get('rel');
		this.setStyle('background-color',color);									  
	});
	
	$$('#menu .k1').addEvent('mouseleave', function(){
		if(!this.hasClass('act')){
			this.setStyle('background-color',color_default);
		}
	});
	}

window.addEvent('domready', function() {
    /* SMOOTHBOX */
	//$$('.smoothbox').set('rel','lightbox');
    /* /end of SMOOTHBOX */
    
    // zastępuje target=_blank	
    $$('.targetBlank').addEvent('click', function(e){
        e.stop();
		targetBlank(this);
	});
    
    $$('.k1 a').each(function(v,i){
        if((v.getNext('.podmenu'))!=null){													  
            v.addClass('toggler');
        }
    });
 /*   
    var myAccordion = new Accordion($$('.toggler'), $$('.podmenu'), {
        display:-1,
        opacity:0,
        initialDisplayFx :true,
        alwaysHide: false
    });
*/	
    $$('.toggler').getParent('li').setStyle('margin-bottom',0);
    if(Browser.Engine.presto){
        $$('.podmenu').setStyle('padding-bottom',15);
	}
    
    var gallery = new Array;
	$$('#gallery img').each(function(v,i){
	   gallery[i] = new Fx.Tween(v,{duration:200, wait:false});
       v.addEvent('mouseenter', function(){
        gallery[i].start('opacity',0.7);											   
       });
       
       v.addEvent('mouseleave', function(){
        gallery[i].start('opacity',1);														   
       });
    });
    
    if ($$('.news_button')) {
        $$('.news_button').addEvent('click', function(event) {  
            event.stop();
            
            (this).blur();
			var req = new Request.HTML({  
				method: 'post',
				url: 'pl/ajax/news',
				data: {
					'pass': $('news_password').value,
                    'page': $('page_id').value
				},
                evalScripts: false,
				onRequest: function() {
				    $('ajax_news_load').innerHTML = '<div style="text-align: center;"><img src="public/design/frontend/images/ajax-loader.gif"></div>';
					$('ajax_news_password').style.display = 'none';
				},
				onComplete: function(responseTree, responseElements, response, responseJavaScript) {
				    $('ajax_news_password').style.display = 'none';
					$('ajax_news_content').innerHTML = response;
					$('news_password').value = '';
                    $('ajax_news_load').innerHTML = '';
                    
                    var myAccordion = new Accordion($$('.toggle'), $$('.section'), {
				        display: 0,
                        alwaysHide: false
                    });
                    
                    if (response == 'error') {
                        $('ajax_news_content').innerHTML = '<span style="color: red;">Podałeś błędne hasło</span>';
                        setTimeout(function() {
                            $('ajax_news_password').style.display = 'block';
                            $('ajax_news_content').style.display = 'none';
                        },5000);
                    }
				}
			}).send();  
		}); 
	}
    
    
	var transparent2 = new Array;
    $$('.transparent2').each(function(v,i){
        transparent2[i] = new Fx.Tween(v,{duration:200, wait:false});
        v.getParent('div').addEvent('mouseenter', function(e){
            transparent2[i].start('bottom',230);		
            e.stop();
        });
        
        v.getParent('div').addEvent('mouseleave', function(e){
            setTimeout(function() {
                transparent2[i].start('bottom',0);
                e.stop();
            },10);
        });
    });
    
    var transparent1 = new Array;
    $$('.transparent1').each(function(v,i){
        transparent1[i] = new Fx.Tween(v,{duration:50, wait:false});
        v.getParent('div').addEvent('mouseenter', function(){
            transparent1[i].start('bottom','-100%');											   
        });
        
        v.getParent('div').addEvent('mouseleave', function(){
            setTimeout(function() {
                transparent1[i].start('bottom',0);
            },10);
        });
	});
});

