/************** fülcsekés doboz *********************/
function readyInitSetActiveContentInTabbedBox()
{
    initSetActiveContentInTabbedBox();
    $('a.tabChLink').click(function() {
        var contextId = $(this).parents('.tabBoxWrap')[0].id;
        boxNum = parseInt(contextId.replace('tabBox',''));
        tabNum = parseInt($(this)[0].id.replace('tabLink_'+boxNum+'_',''));
        setTabInfo(boxNum,tabNum);

        $('#'+contextId+' .tabChLink').removeClass('tabAct');
        $('#'+contextId+' .tabChLink').addClass('tabInact');
        $(this).removeClass('tabInact');
        $(this).addClass('tabAct');
        setActiveContentInTabbedBox(contextId);
        return false;
    });
}
function initSetActiveContentInTabbedBox()
{
    $('.tabBoxWrap').each(function(index) {
        setActiveContentInTabbedBox($(this)[0].id);
    });
}
function setActiveContentInTabbedBox(contextId)
{
    $('#'+contextId+' .tabChLink').each(function(index) {
        var helpid = $(this)[0].id;
        if ($(this).hasClass('tabAct')) {
            boxNum = parseInt(contextId.replace('tabBox',''));
            var contentid = helpid.replace('tabLink_'+boxNum+'_','tabContent');
            $('#'+contextId+' .tabContent').hide();
            $('#'+contextId+' .'+contentid).show();
            $('#'+contextId+' #'+helpid+' img').each(function(index) {
                if ($(this).attr('src')=='/i/tabbox/inactbal.gif') $(this).attr('src','/i/tabbox/actbal.gif');
                else if ($(this).attr('src')=='/i/tabbox/inactjobb.gif') $(this).attr('src','/i/tabbox/actjobb.gif');
            });
        }
        else {
            $('#'+contextId+' #'+helpid+' img').each(function(index) {
                if ($(this).attr('src')=='/i/tabbox/actbal.gif') $(this).attr('src','/i/tabbox/inactbal.gif');
                else if ($(this).attr('src')=='/i/tabbox/actjobb.gif') $(this).attr('src','/i/tabbox/inactjobb.gif');
            });
        }
    });
}
/************** számocskás doboz *********************/
function readyInitSetActiveContentInNumTabbedBox()
{
    initSetActiveContentInNumTabbedBox();
    $('a.tabNumChLink').click(function() {
        var contextId = $(this).parents('.tabNumBoxWrap')[0].id;
        boxNum = parseInt(contextId.replace('tabNumBox',''));
        tabNum = parseInt($(this)[0].id.replace('tabNumLink_'+boxNum+'_',''));
        setTabInfo(boxNum,tabNum);

        $('#'+contextId+' .tabNumChLink').removeClass('tabNumAct');
        $('#'+contextId+' .tabNumChLink').addClass('tabNumInact');
        $(this).removeClass('tabNumInact');
        $(this).addClass('tabNumAct');
        setActiveContentInNumTabbedBox(contextId);
        return false;
    });
}
function initSetActiveContentInNumTabbedBox()
{
    $('.tabNumBoxWrap').each(function(index) {
        setActiveContentInNumTabbedBox($(this)[0].id);
    });
}
function setActiveContentInNumTabbedBox(contextId)
{
    $('#'+contextId+' .tabNumChLink').each(function(index) {
        var helpid = $(this)[0].id;
        if ($(this).hasClass('tabNumAct')) {
            boxNum = parseInt(contextId.replace('tabNumBox',''));
            var contentid = helpid.replace('tabNumLink_'+boxNum+'_','tabNumContent');
            $('#'+contextId+' .tabNumContent').hide();
            $('#'+contextId+' .'+contentid).show();
        }
        else {
        }
    });
}
/************** zászlós doboz *********************/
function readyInitSetActiveContentInZaszloBox()
{
    initSetActiveContentInZaszloBox();
    $('.tabZaszloChLink').click(function() {
        var contextId = $(this).parents('.tabZaszloBoxWrap')[0].id;
        boxNum = parseInt(contextId.replace('tabNumBox',''));
        tabNum = parseInt($(this)[0].id.replace('tabNumLink_'+boxNum+'_',''));
        setTabInfo(boxNum,tabNum);

        $('#'+contextId+' .tabZaszloChLink').removeClass('tabZaszloAct');
        $('#'+contextId+' .tabZaszloChLink').addClass('tabZaszloInact');
        $(this).removeClass('tabZaszloInact');
        $(this).addClass('tabZaszloAct');
        setActiveContentInZaszloBox(contextId);
        return false;
    });
}
function initSetActiveContentInZaszloBox()
{
    $('.tabZaszloBoxWrap').each(function(index) {
        setActiveContentInZaszloBox($(this)[0].id);
    });
}
function setActiveContentInZaszloBox(contextId)
{
    $('#'+contextId+' .tabZaszloChLink').each(function(index) {
        var helpid = $(this)[0].id;
        if ($(this).hasClass('tabZaszloAct')) {
            boxNum = parseInt(contextId.replace('tabNumBox',''));
            var contentid = helpid.replace('tabNumLink_'+boxNum+'_','tabNumContent');
            $('#'+contextId+' .tabNumContent').hide();
            $('#'+contextId+' .'+contentid).show();
        }
        else {
        }
    });
    $('img.tabZaszloInact').css('opacity','0.5');
    $('img.tabZaszloAct').css('opacity','1');
}
/************** scrollos doboz *********************/
var animLeft = new Array;
var animWidth=138;
function readyInitAdjustArrowImgInScrollerBox()
{
        //var animHiddenNum = new Array;
        //animHiddenNum[1]=2;
        //animHiddenNum[2]=1;
        initAdjustArrowImgInScrollerBox();
        $('.scrollerArrowRight').click(function() {
            var contextId = $(this).parents('.scrollerDiv')[0].id;
            var id = parseInt(contextId.replace('scrollerDiv',''));
            if (animLeft[id]===undefined) animLeft[id]=0;
            if (animLeft[id]-animWidth<-animWidth*animHiddenNum[id]) return false;
            animLeft[id]-=animWidth;
            animHelp=animLeft[id];
            $('#'+contextId+' .scrollerInner').animate({left: animHelp }, 500);
            adjustArrowImgInScrollerBox(contextId);
        });
        $('.scrollerArrowLeft').click(function() {
            var contextId = $(this).parents('.scrollerDiv')[0].id;
            var id = parseInt(contextId.replace('scrollerDiv',''));
            if (animLeft[id]===undefined) animLeft[id]=0;
            if (0<animLeft[id]+animWidth) return false;
            animLeft[id]+=animWidth;
            animHelp=animLeft[id];
            $('#'+contextId+' .scrollerInner').animate({left: animHelp }, 500);
            adjustArrowImgInScrollerBox(contextId);
        });

}
function initAdjustArrowImgInScrollerBox()
{
    $('.scrollerDiv').each(function(index) {
        adjustArrowImgInScrollerBox($(this)[0].id);
    });
}
function adjustArrowImgInScrollerBox(contextId)
{
    var id = parseInt(contextId.replace('scrollerDiv',''));
    if (animLeft[id]===undefined) animLeft[id]=0;
    if (0<animLeft[id]+animWidth) {
        $('#'+contextId+' .scrollerArrowLeft').css('cursor','default');
        $('#'+contextId+' .scrollerArrowLeft').attr('src','/i/tabbox/left_inact.gif');
    }
    else {
        $('#'+contextId+' .scrollerArrowLeft').css('cursor','pointer');
        $('#'+contextId+' .scrollerArrowLeft').attr('src','/i/tabbox/left.gif');
    }
    if (animHiddenNum===undefined) animHiddenNum = new Array;
    if (animHiddenNum[id]===undefined) animHiddenNum[id]=1;
    if (animLeft[id]-animWidth<-animWidth*animHiddenNum[id]) {
        $('#'+contextId+' .scrollerArrowRight').css('cursor','default');
        $('#'+contextId+' .scrollerArrowRight').attr('src','/i/tabbox/right_inact.gif');
    }
    else {
        $('#'+contextId+' .scrollerArrowRight').css('cursor','pointer');
        $('#'+contextId+' .scrollerArrowRight').attr('src','/i/tabbox/right.gif');
    }
}
function adverticumCallback(zoneId,zoneWidth)
{
    id = zoneId.replace('advertSi69Id','');
    adWrap = '.adverticumAdWrap'+id;
    if (!$('#'+zoneId).html()) {
        if (zoneWidth==250) {
            $(adWrap).hide();
            $(adWrap).prev('div.adsep').hide();
            $('#'+zoneId).hide();
        }
        else if(zoneWidth==728) {
            $('#'+zoneId).html($('#adv728HiddenDiv').html());
        }
    }
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function setTabMask(mask,posNum,posVal)
{
    mod = mask % Math.pow(10,posNum);
    ertek = Math.floor(mod / Math.pow(10,posNum-1));
    clearedMask = mask - ertek * Math.pow(10,posNum-1);
    newMask = clearedMask + posVal * Math.pow(10,posNum-1);
    return newMask;
}
function setTabInfo(boxNum,tabNum)
{
    origTabCook = parseInt(readCookie('tabinfocookie'));
    if (!origTabCook) origTabCook=1111111111;//10 jegyű
    newMask = setTabMask(origTabCook,boxNum,tabNum);
    createCookie('tabinfocookie',newMask,14);
}
function getSelTabIdx(mask,posNum)
{
    mod = mask % Math.pow(10,posNum);
    ertek = Math.floor(mod / Math.pow(10,posNum-1));
    return ertek;
}
function selectTabFromCookie()
{
    origTabCook = parseInt(readCookie('tabinfocookie'));
    if (!origTabCook) return;
    $('.tabBoxWrap').each(function(index) {
        var contextId = $(this)[0].id;
        boxNum = parseInt(contextId.replace('tabBox',''));
        tabNum = getSelTabIdx(origTabCook,boxNum);
        $('#'+contextId+' .tabAct').removeClass('tabAct').addClass('tabInact');
        $('#'+contextId+' #tabLink_'+boxNum+'_'+tabNum).removeClass('tabInact').addClass('tabAct');
        setActiveContentInTabbedBox(contextId);
    });
    $('.tabNumBoxWrap').each(function(index) {
        var contextId = $(this)[0].id;
        boxNum = parseInt(contextId.replace('tabNumBox',''));
        tabNum = getSelTabIdx(origTabCook,boxNum);
        $('#'+contextId+' .tabNumAct').removeClass('tabNumAct').addClass('tabNumInact');
        $('#'+contextId+' #tabNumLink_'+boxNum+'_'+tabNum).removeClass('tabNumInact').addClass('tabNumAct');
        setActiveContentInNumTabbedBox(contextId);
    });
    $('.tabZaszloBoxWrap').each(function(index) {
        var contextId = $(this)[0].id;
        boxNum = parseInt(contextId.replace('tabNumBox',''));
        tabNum = getSelTabIdx(origTabCook,boxNum);
        $('#'+contextId+' .tabZaszloAct').removeClass('tabZaszloAct').addClass('tabZaszloInact');
        $('#'+contextId+' #tabNumLink_'+boxNum+'_'+tabNum).removeClass('tabZaszloInact').addClass('tabZaszloAct');
        setActiveContentInZaszloBox(contextId);
    });
}
$(document).ready(function() {
    $('#printpop_0').click(function() {
        var newWin = window.open('/norobot/printinfo/','printpop','status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,width=600,height=400');
        newWin.focus();
        return false;

    });
});
var isSlideMenuOpen = false;
var initSlideMenuHeight = 0;
$(document).ready(function() {
    $('#slideMenuOpener').click(function() {
        if ($('#slideMenuContent a').css('display')=='none') {
            $('#slideMenuContent a').css('display','block');
            $('#slideMenuOpener').html('Bezár');
            $('#portal3ColLeft').css('padding-top',180);
        }
        else {
            $('#slideMenuContent a').css('display','none');
            $('#slideMenuOpener').html('Kinyit');
            $('#portal3ColLeft').css('padding-top',0);
        }
    });
    $('a[href^="http"]').click(function() {
        var url = $(this).attr('href');
        if (!url.match(/^http:\//)) return;
        if (url.match(/^http:\/\/localsi/)) return;
        if (url.match(/^http:\/\/sielok.hu/)) return;
        if (url.match(/^http:\/\/www.sielok.hu/)) return;

        if (typeof(_gaq) != "undefined") _gaq.push(['_trackEvent', 'outgoing', 'click', url]);

        $.get('/outgoing/'+url);
    });
});

