function o(a){return document.getElementById(a);};
function clearInputValue(id)
{
        my_input = getById(id);
        
        my_input.value = '';
}

function getById(id)
{
        var elem = document.getElementById(id);
        
        return elem;
}


function tooggler(id)
{
	visibility_mode = document.getElementById(id).style.display;
	
	if(visibility_mode == 'none')
	{
		document.getElementById(id).style.display = 'block';
	}
	
	else
	{
		document.getElementById(id).style.display = 'none';
	}
}


function chk_fields(sform)
{
    sform.frtoken.value = 'Arch120';
}

function show_adv()
{
        visib = document.getElementById('AdvOpts');
        
        if(visib.style.display == 'none')
        {   
          document.getElementById('AdvOpts').style.display = 'block';
          document.getElementById('AdvLink').innerHTML = '<span>&laquo;</span> zwiń';
        }
        
        else
        {
         document.getElementById('AdvOpts').style.display = 'none';
         document.getElementById('AdvLink').innerHTML = 'wyszukiwanie szczegółowe <span>&raquo;</span>';
        }
}

function select_url(s)
{
	var gourl = s.options[s.selectedIndex].value;	window.top.location.href = gourl;
}



function top_five(mode)
{
   
   if(mode == 'projects')
   {
     document.getElementById('BoxTopInvestitions').style.display = 'none';
     document.getElementById('BoxTopProjects').style.display = 'block';
     document.getElementById('InvLink').className = 'top_noactive';
     document.getElementById('PojectLink').className = 'top_active';
   }
   
   if(mode == 'invs')
   {
     document.getElementById('BoxTopInvestitions').style.display = 'block';
     document.getElementById('BoxTopProjects').style.display = 'none';
     document.getElementById('InvLink').className = 'top_active';
     document.getElementById('PojectLink').className = 'top_noactive';
   }
}




var timer,over=0;
function submenu_list(show)
{

		
		clearTimeout(timer)
		if(!over){timer=setTimeout("over=1;submenu_list('"+show+"')",500);return;}
		
		
		
       submenus = new Array('aktualnosci', 'artykuly', 'inwestycje','wydarzenia','praca','konkursy','strefa_architekta');
        
        for(i=0;i<submenus.length;i++)
          {
			if(document.getElementById(submenus[i]))
            document.getElementById(submenus[i]).style.display = 'none';
          }
        
        if(show != 'main')
        {
          //document.getElementById('link'+show).className = 'active';
          document.getElementById(show).style.display = 'block';
        }
       over=0;
}
function target(e) {
      var targ;
      if (!e) var e = window.event;
      if (e.target) targ = e.target;
      else if (e.srcElement) targ = e.srcElement;
      if (targ.nodeType == 3)targ = targ.parentNode;
      return targ;	
    }
	
	

function show(a){o(a).style.display='block'}
function hide(a){o(a).style.display='none'}
	
function initMenu(){
/*
	o('MainMenu').getElementsByTagName('ul')[0].onmouseover=function(e){
		var t=target(e),v;
		
		if(t.nodeName=='A'&&(v=(t.parentNode.onmouseover+"").match(/\"(.+)\"/gi))){
			console.log(v);
			timer=setTimeout('show('+v+')',500);
			cur=v;
		}
	}
	o('MainMenu').onmouseout=function(){
		
		setTimeout("hide("+cur+")",500)
	}
*/		
}
//onload=initMenu
var news_gal={
	margin:8,
	i:0,
	len:0,
	pre:function pre(){
		
		this.i--;
		this.sel();
		return false;
	},
	nxt:function nxt(){
		this.i++;
		
		this.sel();
		return false;
	},
	sel:function(){
		if(this.i==this.len-1)this.i=0;
		if(this.i<0)this.i=this.len-2;
		var list = $('.news_half_column .item').not('.item0');
		for(var i =0;i<list.length;i++){
			$(list[i]).removeClass('min').attr('style','');
			if(i >= this.i && i<=this.i+1){
				
				$(list[i]).addClass('min');
				if(i==this.i){
					$(list[i]).css('margin-right',this.margin);
					$(list[i]).css('margin-left',0);
				}
			}	
		}
		
	
	}

}


$(document).ready(function(){
	
	if($('.news_half_column .item').length>2) 
	$('.news_half_column').children('.item:eq(1),.item:eq(2)').addClass('min').filter('.item1').attr('style','')

	$('.news_half_column .item a').one('click',function(e){
	
		$(this).parents('.item').addClass('sel')
		
		e.preventDefault();
		if($(this).parents('.big_half_column').length)return;
		$(this).parents('.news_half_column').addClass('big_half_column').prepend('<img id="bigone" src="'+$(this).attr('href')+'"/><p id="bigone_descr">'+$('+p',this).text()+'</p>');
		
		$('.news_half_column .pre,.news_half_column .nxt').remove();
		
		var f = $('.news_half_column .item').addClass('min').attr('style','').children('a').click(function(e){
			e.preventDefault();
			//console.log(this)
			
			$(this).parents('.news_half_column').children('.sel').removeClass('sel')
			$(this).parents('.item').addClass('sel')
			$('#bigone').attr('src',this.href)
			$('#bigone_descr').text( $('+p',this).text() );
			//$('.news_half_column .item0 img').attr('src',$(this).children('img').attr('src').replace('hc_thumb',''))
		})[0];
		
		if(!$('#bigone').attr('src')){
		$('#bigone').attr('src',f.href);
		$('#bigone_descr').text( $('+p',f).text() );
		}
		
	});
	if($('.news_half_column .item').length>2) {
		news_gal.len = $('.news_half_column .item').not('.item0').length;
		news_gal.sel();
		if(news_gal.len>2)
			$('.news_half_column').append('<a href="#" class="pre" onClick="return news_gal.pre()">&#9668;</a><a href="#" class="nxt" onClick="return news_gal.nxt()">&#9658;</a>')
	}
	
	
});