
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) );

promoimages=null;

(function(jQuery){
    jQuery.fn.extend({
        clearInputs: function(a){
            var d = a || jQuery(this).val();
            a && jQuery(this).val(a);
            return jQuery(this).focus(function(){
                var b = jQuery(this);
                b.val() == d && b.val("");
                jQuery(this).removeClass("error")
            }).blur(function(){
                var b = jQuery(this);
                if (b.val() == d || b.val() == "") 
                    b.val(d);
                jQuery(this).removeClass("error")
            })
        }
    });
	
	jQuery.fn.extend({
	    equalHeights: function(){
	        var tallest = jQuery(this).eq(0).height();
	        return jQuery(this).each(function(i){
	            var jQueryt = jQuery(this), h = jQueryt.height();
	            if(h > tallest) tallest = h;        
	        }).css('height',tallest);
	    }
	});
	
})(jQuery);

    
function kFlash(fileName, divId, flashWidth, flashHeight ) {
    var kFlashVars = {};
    var kFlashParams = {
        scale: "noScale",
        allowScriptAccess:"always", swLiveConnect:true, wmode: "transparent"
    };
    var kFlashAttributes = {  };
    swfobject.embedSWF("/iqsys-theme/swf/iqsys/"+fileName+"", divId, flashWidth, flashHeight, "9.0.0", "expressInstall.swf", kFlashVars, kFlashParams, kFlashAttributes);
}

function getFlashContent(){
    var result = jQuery("#flashContent").wrap("<div></div>").parent().html();
    var results = "";
    HTMLParser(result, {
        start: function(tag, attrs, unary){
            results += "<" + tag.toLowerCase();
            
            for (var i = 0; i < attrs.length; i++) 
                results += " " + attrs[i].name + '="' + attrs[i].escaped + '"';
            
            results += (unary ? "/" : "") + ">";
        },
        end: function(tag){
            results += "</" + tag.toLowerCase() + ">";
        },
        chars: function(text){
            results += text;
        }
    });
    
    var resultToString = HTMLtoXML(results);
    return resultToString;
}
    
jQuery(function(){
    jQuery('input.text').clearInputs('keresés...');
    jQuery('div.boxes').equalHeights();
	 
	 movenodes();
    kFlash("menu.swf", "flashContainer", "1003", "380" );
	 
	 if(isIE6)
	 DD_belatedPNG.fix('.dataform .field .inputwrapper .l, .dataform .field .inputwrapper .r, .dataform .field .tawrapper, .dataform .btn, #flashContainer ul.sidenav a');	 
	 
	 //if( jQuery('.dataform select').length>0 )
	 //jQuery('.dataform select').selectmenu({style:'dropdown'});

	initmenu();
	initloggedinmenu();
        promoimages=new initpromoimages();
	  fixblogedit();
	  unabsfoot();

	
	try{
	$j('.dataform select').selectmenu({style:'dropdown'});
		}
		catch(e){}
	 
}); //dom ready

//-----------------------------------------------
function debug(txt)
{
try {
	console.debug(txt);
	}
catch(e){}
}
//-----------------------------------------------
function initloggedinmenu()
{
jQuery('ul.login li.logged_in > a').bind('mouseenter',function(event)
	{
	//event.preventDefault();	
	/*if( jQuery('ul.login li.logged_in').hasClass('open') ) jQuery('ul.login li.logged_in').removeClass('open');
	else*/ 
	
	jQuery('ul.login li.logged_in').addClass('open');	
	});
	
jQuery('ul.login li.logged_in').bind('mouseleave',function(event)
	{
	jQuery('ul.login li.logged_in').removeClass('open');
	});	
	
}
//-----------------------------------------------
function movenodes()
{
var moveto=jQuery('#flashContent .rightCont');

jQuery('div[id^=mnuContent_]').each( function()
	{
	jQuery(moveto).append(this);
	});	
	
	if(jQuery('.mainPromo').length>0)
	{
	jQuery('#flashContent').append(jQuery('.mainPromo'));
	}

jQuery('#flashContent .leftCont > h1').each( function(idx)
	{
	jQuery('#flashContainer .pagetitle').text(jQuery(this).text());	
	});
	
	
if(jQuery('.mainPromo').length>0)
	{
	jQuery('#flashContainer .primg').html(jQuery('.mainPromo').html());
	}
	
}
//-----------------------------------------------
function initpromoimages()
{
var mainelement=jQuery('#flashContainer .primg');

var cnt=jQuery(mainelement).find('img').length;

if(cnt==0) return;

var timer;
var current=0;

showimg(current);

function showimg(idx, duration)
	{
	if(duration==null) duration=0;
		
	if(idx>=cnt) idx=0;

	if(duration==0)
		{
		jQuery(mainelement).find('img').css('display', 'none');
		jQuery(mainelement).find('img').eq(idx).css('display', 'block');
		}
	else
		{
		jQuery(mainelement).find('img').animate({ opacity : 'hide' }, duration);
		jQuery(mainelement).find('img').eq(idx).animate({ opacity : 'show' }, duration);
		}
	
	var time=jQuery(mainelement).find('img').eq(idx).parent().attr('rev');
			
	current=idx;
	
	clearTimeout(timer);
	timer=setTimeout( function() { showimg(current+1, 500); }, time );			
	}
	
function stop()
{
clearTimeout(timer);
}	

this.stop=stop;
}
//-----------------------------------------------
function initmenu()
{
var mainelement=jQuery('#flashContainer ul.sidenav');
var dynamiccontent=jQuery('#flashContainer .dynamiccontent');

if( mainelement.length==0 ) return;

//Build menu html
//var positions=new Array(0,20,40,55,60,60,55,48,20,0);
//var positions=new Array(-7,15,36,49,56,57,55,47,20,0);
//var positions=new Array(-7,15,32,45,51,57,57,51,43,0);
// var positions=new Array(-7,11,26,39,48,53,54,53,44,43); Jax szerint nem jó a flash nélküliben,
var positions=new Array(2,21,34,44,51,55,53,48,38,28)

jQuery(mainelement).empty();

jQuery('#flashContent .leftCont ul li').each( function(idx)
	{
	var pos=0;
	if( positions[idx] ) pos=positions[idx];	
	var li=jQuery(this).clone().css('margin-left', pos+'px' );	
	jQuery(mainelement).append(li);	
	});
	
jQuery('.flashcont.w270').css('overflow', 'visible');

//---------------

//var current= jQuery(mainelement).find('li').index( jQuery(mainelement).find('li.selected') );
try
{
var current= getid( jQuery(mainelement).find('li.selected a').attr('id') );;

change(current);
}
catch(error){}
jQuery(mainelement).find('li a').hover( 
	//on
	function()
	{
	if(!jQuery(this).parent().hasClass('selected'))
		jQuery(this).filter(':not(:animated)').animate({paddingLeft: '44px'}, 300);
				
	//var index= jQuery(mainelement).find('li a').index(this);
	var index=getid( jQuery(this).attr('id') );;
	
	jQuery('#flashContainer .primg').css('display', 'none');
        try{
        promoimages.stop();
        }
        catch(e){}
	
	change(index);			
	},
	//off
	function()
	{
	if(!jQuery(this).parent().hasClass('selected'))
		jQuery(this).animate({paddingLeft: '36px'}, 300);
		
	//change(current);		
	});
	
//jQuery(mainelement).bind('mouseleave', function(){change(current)}); 	
	
	
function change(index)
{
if( jQuery(dynamiccontent).length>0 )
	{
	var buffer_container=jQuery('#flashContent .rightCont #mnuContent_'+index )
	
	jQuery(dynamiccontent).find('.innerbox h2').html( jQuery(buffer_container).find('h2').html() );
	jQuery(dynamiccontent).find('.innerbox h3').html( jQuery(buffer_container).find('h3').html() );
	jQuery(dynamiccontent).find('.innerbox p').html( jQuery(buffer_container).find('p').html() );		
	jQuery(dynamiccontent).find('.innerbox div.linkpanel').html( jQuery(buffer_container).find('div').html() );
	
	if( isIE6 )
		{
		jQuery(dynamiccontent).find('.imgcontainer').html( jQuery(buffer_container).find('img').clone().removeClass('pngImage') );	
		
		//if( isIE6 )
			DD_belatedPNG.fix('#flashContainer .dynamiccontent .imgcontainer img');
		}
	else
		{	
		jQuery(dynamiccontent).find('.imgcontainer').animate({opacity: 'hide'}, 100,null, function()
			{
			jQuery(dynamiccontent).find('.imgcontainer').html( jQuery(buffer_container).find('img').clone().removeClass('pngImage') );	
			jQuery(dynamiccontent).find('.imgcontainer').animate({opacity: 'show'}, 100);	
			});
		}

		
	}
}

function getid(idstring)
{
return idstring.replace('mnu_', '');
}

//END;
}

function unabsfoot(){
if (jQuery('.portlet-borderless-bar').length!=0 ){
try{
jQuery('.foot').each(function(i){
this.style.position='static';
});
}
catch(e)
{}
}
else{
try{
jQuery('.foot').each(function(i){
this.style.position='absolute';
});
}
catch(x)
{}
}
}    

function fixblogedit(){
if (jQuery('#_33_editor').length!=0 && jQuery('#right').length!=0){

jQuery('#pContainer').css('width','1550px');
jQuery('#left').css('width','750px');
}
if (isIE){
jQuery('.boxesCont').css({'padding-top':'75px', 'margin-top':'-90px'});
}

}
