var WTDT = function(){}

var GOOGLE_MAPS = {};

var swfTemplate = '<object id="videoPlayer" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" height="525" width="640">';
    swfTemplate+= '<param value="{movie}" name="movie"/>'
    swfTemplate+= '<param value="true" name="allowFullScreen"/>'
    swfTemplate+= '<param value="always" name="allowscriptaccess"/>'
    swfTemplate+= '<param value="transparent" name="wmode">'
    swfTemplate+= '<embed height="525" width="640" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="{movie}"/>'
    swfTemplate+= '</object>'

var submenuDisplayTimer = null;
    
$(function(){
    
    /*if($('#watch-view-count-container').length>0){
        $.get(
            '/tools/flashcount',
            function(data){
                var a = data.match(/<strong class\=\"watch\-view\-count\">(.*?)<\/strong>/i, "$1").toString();
                $('#watch-view-count-container').html($(a));
            }
        )
    }*/
    
    //setTimeout("showSubmenu()", 500);
    showSubmenu();
    
    var galeriaLinkek = $('table.galleryTable a[rel=galeria]');
    galeriaLinkek.each(function(){
        $(this).attr('href', $('img', this).attr('src').replace('120x120_', ''))//.attr('title', $('img', this).attr('alt'))
    });
    
    galeriaLinkek.lightbox()
    
    $('table.galleryTable a[rel=galeriaWingtsun]').lightbox();

    $('#videoPlayerContainer').jqm({
        onHide: function(o){
            o.w.hide(function(){
                $('#videoPlayer').remove();
                o.o.remove();
            })
        }
    });

    $('#videoPlayerContainer').jqmAddClose('#jqmClose'); 
    $('table.galleryTable a.videoGaleriaDisplayer').click(function(){
        $('#videoPlayer').remove();
        
        var swfFile = $('img', $(this)).attr('src').replace('120x120_', '').replace('.jpg', '.swf');

        $('#videoPlayerVideoContainer').html(swfTemplate.replace(/\{movie\}/gi, swfFile));
        
        $('#videoPlayerContainer').jqmShow()
    })
    
    if($('#showPopUp').get(0)){
        setInterval(highLightPopUp, 1000);

    }
    
    $('.faqLink').click(function(){
	$('.faqContent:visible').slideUp();
	$(this).next().slideDown();
	return false;
    })
    $('.faqLink:nth(0)').click();//az elsore automatikusan rabokunk
    
    
    $('#pHeadContainer div.headerBox div.headerBoxBody ul>li').hover(
        function(){
            var offs = $(this).offset();
            $('div.sublevel2', $(this)).css({
                left: (offs.left+65)+'px',
                top: (offs.top-16)+'px'
                
            }).fadeIn('fast');
        },
        function(){
            $('div.sublevel2', $(this)).hide();
        }
    );
})


function highLightPopUp(){
    $('#showPopUp').toggleClass('highLight');
}

function showSubmenu(){
    //$('#subMenuList').slideDown(1000)
    $('#subMenuList').show();
}

function displayMap(name, coordX, coordY){
    GOOGLE_MAPS[name] = null;
    GOOGLE_MAPS[name] = new GMap2(document.getElementById(name));
    GOOGLE_MAPS[name].setCenter(new GLatLng(coordX, coordY), 13);
    GOOGLE_MAPS[name].setUIToDefault();
    var point = new GLatLng(coordX, coordY);
    GOOGLE_MAPS[name].addOverlay(new GMarker(point));
}


