var browser = 'unknown';

// JavaScript Document
/*
// ///////////////////////////
// isdefined v1.0
// 
// Check if a javascript variable has been defined.
// 
// Author : Jehiah Czebotar
// Website: http://www.jehiah.com
// Usage  : alert(isdefined('myvar'));
// ///////////////////////////
*/
function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function tilt_show() {
    //$('#tilt').width($('body').width());
    $('#tilt').height($('body').height());
    $('#tilt').show();
}

function tilt_hide(folder) {    
    $('#tilt').hide();
    document.location.href = folder+"tilt_hide";
}




function tilt2_hide(folder) {    
    $('#tilt2').hide();
    document.location.href = folder+"tilt_hide";
}



// amikor a magasabb hatterrel kell menni a weblapnak, ez a cucc lecsereli a kepet, es megnyujtja a body-t es lerakja a footert
function bgreplace(img) {
    
    $('#body_content').css('background-image', 'url('+img+'/bg2.jpg)');
    $('#body_content').css('height', '1234px');
    $('#footer').css('top', '1190px');
   if(browser=='IE7') {
        $('#wsa_logo_ie7').css('top', ($('body').height()-104)+'px');
    }
    
}

function bgreplace_bg3(img) {
    
    $('#body_content').css('background-image', 'url('+img+'/bg3.jpg)');
    
    //$('#body_content').css('height', '1234px');
    //$('#footer').css('top', '1190px');
   //if(browser=='IE7') {
   //     $('#wsa_logo_ie7').css('top', ($('body').height()-104)+'px');
   // }
}

// CR partnerek hatter..
function bgreplace_bg4(img) {
    
    $('#body_content').css('background-image', 'url('+img+'/bg4.png)');
    
}

function iefix(img, site) {  
    if(browser=='IE7'){
        $('.submenu').css('left', '0px');
        $('.submenu').css('top', '15px');
        $('.submenu').css('line-height', '10px');


iefixtopper = 0;
if(site=='index')iefixtopper = 66;
if(site=='bemutatkozas')iefixtopper = -100;
if(site=='hireink')iefixtopper = -249;
if(site=='termekeink')iefixtopper = -185; // TODO termeklap!!!!
if(site=='dijaink')iefixtopper = -239;
if(site=='galeria')iefixtopper = -271;
if(site=='partnerek'); // TODO partnerek
if(site=='kapcsolat')iefixtopper = -39;
// TODO itt be kell pozicionalni a top-ot majd a footer top-jatol fuggoen, de!!! a footer a bgreplace-ek utan lejebb feljebb kerul!!! tehat akkor ez is allitodik...
//alert(site+'/'+iefixtopper+'/'+($('#footer').css('top')));

        //$('#body_content').append('<IMG  id="wsa_logo_ie7" src="'+img+'wsa_logo.png" style="position:relative; z-index:9999; left:881px; top:'+(268+iefixtopper)+/*($('body').height()-700)+*/'px;">');
        $('#wsa_logo').hide();
        
        $('.wave_half_left_little_small').height( $('.wave_half_left_little_small').height()+20);
        
        $('.index_wave_box_img_frame *').click(function(){
            $(this).parent().click();
        });
        

        if($('.termek_lista_elem').length < 6 && $('.termek_lista_elem').length > 0){
            $('.wave_half_right_big .wave_center').css('height', '220px');
        }
        

        // TODO footer sub-menu
        /*
        $('#footer .menu .hassubmenu .submenu').each(function(){            
            $(this).css('top', '-'+$(this).height()+'px');
            
            var submenu = $(this).html();
            $('body').append('<div id="submenu_hook">'+submenu+'</div>');
            $('#submenu_hook').css('position', 'absolute');
            //$('#submenu_hook').css('top', '-'+$('#submenu_hook').height()+'px');
            //alert($(this).height());
            $('#submenu_hook').css('top', ($('body').height()-$(this).height()) + 'px');
        });
        */
       
       $('#egyedi_select').hide();
       $('select[name=osztaly]').show();
       
       
       
    }
    
    
    if(isdefined(browser_ie7)){if(browser_ie7){
        $('body').append('<ul id="submenu_hook"></ul>');
        $('#footer .menu .hassubmenu .submenu').each(function(){
            $('#submenu_hook').append($(this).html());            
        });
        $('#footer .menu .hassubmenu .submenu').each(function(){
            $(this).remove();
        });    
        var topp = $('body').height() - 90;
        $('#submenu_hook').css('top', topp+ 'px');
        $('#footer .menu .hassubmenu').mousemove(function(){
            $('#submenu_hook').show();
        });
        $('#footer .menu .hassubmenu').mouseleave(function(){
            $('#submenu_hook').hide();
        });
        $('#submenu_hook').mousemove(function(){
            $('#submenu_hook').show();
        });
        $('#submenu_hook').mouseleave(function(){
            $('#submenu_hook').hide();
        });
    }}

    
    
    
    if(browser=='IE8'){
        setTimeout('galery_page_bugfix()', 300);
    }

}

function galery_page_bugfix() {
    $('#image_preview').attr('src', $('input[name=image_slide_data_image_'+$('input[name=image_slide_data_akt]').val()+']').val());
    $('#image_akt_span').html(parseInt($('input[name=image_slide_data_akt]').val())+1);
    setTimeout('galery_page_bugfix()', 300);
}




function inits(no_scroll, bgreplace_, img, site) {
    
    var noscroll = no_scroll;

    // footer menu almenuje felfele nyiljon ki...
    $('#footer .submenu').each(function(){
        $(this).css('top', '-'+$(this).height()+'px');
    });

    // ha nincs bal oldal akkor teljes szeles a content
    if($('#left').html()=='') {
        if(site != 'termekeink' && site != 'hireink' && site != 'kostolohaz' && site != 'kapcsolat') {
            $('#main').addClass('alone');
        }
    } else {
        // ha van bal oldal akkor nem lehet scroll!!!
        noscroll = true;
    }

    // scroll felrakas
    if(site!='hireink')if($('#main_content_lead').height()>400 && !noscroll){
        $('#main_content_lead').addClass('scroll-pane');
        if($('.photo_frame').html()==''){
            $('#main_content_lead').css('width', '910px');
        } else {
            // kis hack, hogy a scrollbar menjen...
            $('#main_content_lead').css('width', '603px');
            $('#main_content_lead').css('margin-left', '0px');
        }
        $('#main_content_lead').append('<br><br>');
        $('#main_content_lead').jScrollPane({showArrows:true});
    }

    // kostolohaz (ami szinten hirfolyam) pl. nem kell a scroll semmikeppen, csak ha a hosszabb hatterbol is kilog!
    if(!noscroll) {
        //scroll felrakas a hirekhez ha kell (tul hosszu a tartalmi resz)
        if(site!='hireink')if($('#hirek_right').height() > 500) {
            $('#hir').addClass('scroll-pane');
            $('#hir').css('width', '686px');
            $('.hir_photo_frame').css('margin-top', '0px');
            $('#hir p').append('<br><br><br><br><br><br><br><br><br><br>');
            $('#hir').jScrollPane({showArrows:true});
        }
    }

    // a kostolohaznal pl. ha hosszu a tartalom akkor elobb hattercsere, es ha ugy is hosszu akkor scroll
    if(bgreplace_) {
        if($('#hirek_right').height() > 500){
            // hatter lecserelese
            $('#body_content').css('background-image', 'url('+img+'/bg2.jpg)');
            $('#body_content').css('height', '1234px');
            $('#footer').css('top', '1190px');
            if(browser=='IE7') {
                $('#wsa_logo_ie7').css('top', ($('body').height()-104)+'px');
            }
            
            //scroll felrakas a hirekhez ha kell (tul hosszu a tartalmi resz, meg a hosszu hatterrel is)
            if(site!='hireink')if($('#hirek_right').height() > 600){
                $('#hir').addClass('scroll-pane');
                $('#hir').height(600);
                $('#hir').css('width', '686px');
                $('.hir_photo_frame').css('margin-top', '10px');
                $('#hir p').append('<br><br><br><br>');
                $('#hir').jScrollPane({showArrows:true});                
            }
            
        }
    }




    //scroll felrakas a kapcsolat form alatti reszhez, ha kell
    //itt ha tul hosszu a kapcsolat form alatti szoveg, akkor lecsereljuk a body hatteret, es nyutjuk az oldalt. ha a szoveg igy is tul hosszu, akkor rarakjuk a scrollt    
    
    if($('#kapcsolat_text').height() > 42) {
        bgreplace(img); 
        $('#kapcsolat_text').addClass('scroll-pane');
        $('#kapcsolat_text').jScrollPane({showArrows:true});
    }

    
    
    if(site=='hireink') {        
        $('#hir_text').height(308);
    }
    
    

    
    
    
            // BUGFIXEK ========================
            
            
    // hirek fejlec ha tobb soros...
    $('#hir_title_h1').height($('#hir_title_h1 span').height()+20);
    
    
    // partnerek cimek becsuszasa a kis nyilacskaba....
    //bugfix_partnerek();
    $('.wave_partner_title_caption').css('left', '35px');
    $('.wave_partner_title_shadow').css('left', '35px');
    
    

    // nyitolapra kostolohaz
    if(site=='index' || site=='') {
        bgreplace_bg3(img);
        $('#partnereink').css('padding-top', '0px');
    }
    
    //nyitolapon az also menu lila - modositas: mindenhol lila
    //if(site=='index' || site=='') {
        $('#footer').css('background-color', '#361752');
    //}
    
    if(site=='partnerek') {
        $('.wave_partner_title_caption').each(function(){
            if($(this).height()>30){
                $(this).parent().parent().height(40);
            }
        });
    }
    
   
}


$(function(){

});



/**
 * Hozzáadva: 2011. 11. 24.
 * RebelRouse
 */

function setCookie(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 getCookie(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 deleteCookie(name) 
{
    setCookie(name,"",-1);
}

