
ua = navigator.userAgent.toLowerCase(); 
isIE = ((ua.indexOf("msie") != -1) );
isIE6 = ((ua.indexOf("msie 6.0") != -1) );
isIE7 = ((ua.indexOf("msie 7.0") != -1) );
isOPERA = ((ua.indexOf("opera") != -1) );
isFF = ((ua.indexOf("firefox") != -1) );
isSafari = ((ua.indexOf("safari") != -1) );

$(document).ready(function(){

if(isIE6)
  {
  DD_belatedPNG.fix('img, #textbox1 h2.eletmentoallomas, .infoboxes .item .bg, #textbox2 h2.eszkozok');        
  }
  
  
$('ul.imgmenu li .img img').vAlign(); 

inputclickhandler('searchform');

});

//-----------------------------------------------
function debug(txt)
{
try {
	console.debug(txt);
	}
catch(e){}
}
//-----------------------------------------------
(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
		
	$(this).css('margin-top', mh);
	});
};
})(jQuery);
//-----------------------------------------------
function inputclickhandler(formid)
{
var mainform=('#'+formid);

if( $(mainform).length == 0 ) return;

$(mainform).find('input[type=text][title]').bind('focus', function(event)
  {    
  var title=$(this).attr('title');  
  if( $(this).val() == title ) $(this).val('');
  });
  
$(mainform).find('input[type=text][title]').bind('blur', function(event)
  {    
  var title=$(this).attr('title');  
  if( $(this).val() == '' ) $(this).val(title) ;
  });  
  
}
//-----------------------------------------------
function initgallery(id)
{
var mainelement=$('#'+id);

if( isIE6 || isIE7 )
	{
	$(mainelement).find('.controller ul li img').vAlign();  
	} 	

$(mainelement).find('.galcontent .item:eq(0)').css('display', 'block');
var current=0;

$(mainelement).find('.controller a').click( function(event)
	{
	event.preventDefault();
	
	$(mainelement).find('.controller a').removeClass('active');	
	$(this).addClass('active');
	
	refresh(500);	
	});

refresh(0);

function refresh(duration)
	{
	var index= $(mainelement).find('.controller a').index( $(mainelement).find('.controller a.active') );
	
	if(current==index) return;
	
	current=index;		
	
	$(mainelement).find('.galcontent .item').animate({ opacity : 'hide' }, duration);	
	$(mainelement).find('.galcontent .item').eq(index).animate({ opacity : 'show' }, duration);
	}

}

function initgalleryVideoRefresh(id, current)
{
var mainelement=$('#'+id);

refresh(0);

function refresh(duration)
	{
	var index= $(mainelement).find('.controller a').index( $(mainelement).find('.controller a.active') );
	
	if(current==index) return;
	
	current=index;		
	
	$(mainelement).find('.galcontent .item').animate({ opacity : 'hide' }, duration);	
	$(mainelement).find('.galcontent .item').eq(index).animate({ opacity : 'show' }, duration);
	}

}
//-----------------------------------------------
function initaccordion(id)
{
var mainelement=$('#'+id);
var self=this;	

$(mainelement).find('h1 a').click( function(event)
	{
	event.preventDefault();

	var itemobj=$(this).parents('.item');
	var contentobj=$(itemobj).find('.content');

	$(itemobj).toggleClass('open');
		
	$(contentobj).animate(
		{
		opacity : 'toggle',
		height : 'toggle'	
		}, 500);

	});

//END;
}
