﻿$(document).ready(function() {
    //DEFAULT SEARCH INPUT
    $('.snQuickSearch_input').val('Keresés');
    var origSearch = $('.snQuickSearch_input');
    var origSearchText = origSearch.val();
    origSearch.focus(function() {
        $(this).val('');
        $(this).css('text-align', 'left');
        $(this).css('color', '#888888');
    })
    origSearch.blur(function() {
        if ($(this).val() == '') {
            $(this).val(origSearchText);
            $(this).css('text-align', 'center');
            $(this).css('color', '#b9b9b9');
        }
    })

    //TARGET BLANK
    $('.blank').click(
		function() {
		    window.open(this.href);
		    return false;
		}
	);
	
	//OTTHONSZERVIZ24 LINK
	$(".Fogaz_SegmentElector a:contains('ÚJ')").text( $(".Fogaz_SegmentElector a:contains('ÚJ')").text().replace('ÚJ', '') );
	var uj = '<span style="color:red;">ÚJ</span>';
	$(".Fogaz_SegmentElector a:contains('24')").append(uj);






    //OFFER
    $('.sendemailPopUp .PopUpFormRow input[type="text"], .sendemailPopUp .PopUpFormRow textarea').val('');

    $('#Fogaz_OfferLink').click(function() {
        $('.sendemailPopUp').css('display', 'block');
        $('.sendemailPopUp .PopUpFormRow input[type="text"], .sendemailPopUp .PopUpFormRow textarea').val('');
        return false;
    });
//POPUP
	$("#popupclose").click(function(){
	$("#popupkep").css('display','none');
	});

    $('.PopUpClose').click(function() {
        $('.sendemailPopUp').css('display', 'none');
        $('.sendemailPopUp .PopUpFormRow input[type="text"], .sendemailPopUp .PopUpFormRow textarea').val('');
    });

    $(".sendemailPopUp #pageURLdiv input").val(document.location.href);
    $(".sendemailPopUp #pageTitlediv input").val($("h1").text());

    $('.PopUpButtonRow input').click(function(fv) {

        $('.PopUpFormRow .tText[type="text"]').each(function() {
            if ($(this).attr('value') == "") {
                $(this).addClass('empty');
                $(this).siblings('span.error').show();
            }
            else {
                $(this).removeClass('empty');
                $(this).siblings('span.error').hide();
            }
        });
        if ($('.PopUpFormRow .empty').length) {
            return false;
        }
        else {
            return true;
        }
    });


    //FAQ LINKS
    $(".Fogaz_FAQs ul li a.cat").click(function() {
        $(this).next("ul").slideToggle("slow")
		.siblings("ul:visible").slideUp("slow")
        return false;
    });

    //FONT SIZE

    var newSize = 11;
    var switchSize = '';
    var fSArr = '';
    var origHolder = $('body');

    $('.fontSwitch').click(function(ev) {
        ev.preventDefault();

        fSArr = $.cookie("bodyFontSize") ? $.cookie("bodyFontSize").split('_') : "fontSize_11".split('_');

        var origSize = parseInt(fSArr[1]);

        if ($(this).attr('id') == 'Fogaz_FontSizeUp') {
            if (origSize < 13) {
                newSize += 1;
                switchSize = 'fontSize_' + newSize;
                origHolder.removeClass('fontSize_' + origSize).addClass('fontSize_' + newSize);
            }
            else {
                return false;
            }
        }
        else {
            if (origSize > 9) {
                newSize -= 1;
                switchSize = 'fontSize_' + newSize;
                origHolder.removeClass('fontSize_' + origSize).addClass('fontSize_' + newSize);
            }
            else {
                return false;
            }
        }

        $.cookie("bodyFontSize", switchSize, { expires: 365 });
    });


//INPUT PHONE
    $('input.tel').parent().prepend('<span style="float: left; margin: 1px 2px 0 0;">+36</span>');
    $('.InputUnit.adatk').children('.IULabel').children('.IULabelTitle').html('<label>A „Küldés” gomb megnyomásával Ön elfogadja az <a target="_blank" href="/nyitooldal/ugyfelszolgalat/legyen_on_is_ugyfelunk/legyen_ugyfel/adatkezelesi_hozzajarulas.pdf" style="text-decoration: underline;"><b>Adatkezelési hozzájárulásban</b></a> foglaltakat</label>');
    $('.InputUnit.megker').children('.IULabel').children('.IULabelTitle').html('<label><a target="_blank" href="/nyitooldal/ugyfelszolgalat/legyen_on_is_ugyfelunk/legyen_ugyfel/reklamkuldesi_hozzajarulas.pdf" style="text-decoration: underline;"><b>Megkeresésekhez történő hozzájárulás</b></a></label>');

	if ($(".snForm").length != 0) {
		$("#aspnetForm").validate();
	}


    $("input.megye").parent().parent().hide();
    $("input.irsz").parent().parent().hide();
    $("select.telepules").click(function() {
        $("select.telepules").change(function() {
            var megye = "";
            var irsz = "";
            $("select.telepules option:selected").each(function() {
                megye += $(this).attr('megye') + " ";
                irsz += $(this).attr('irszam') + " ";
            });
            $("input.megye").parent().parent().show();
            $("input.irsz").parent().parent().show();
            $("input.megye").val(megye);
            $("input.irsz").val(irsz);
        });
    });

    $(".addressML").attr("maxlength", "70");
    $(".addressML[maxlength]").keyup(function() {  
         //get the limit from maxlength attribute  
         var limit = parseInt($(this).attr('maxlength'));  
         //get the current text inside the textarea  
         var text = $(this).val();  
         //count the number of characters in the text  
         var chars = text.length;  
   
         //check if there are more characters then allowed  
         if(chars > limit){  
             //and if there are use substr to get the text before the limit  
             var new_text = text.substr(0, limit);  
   
             //and change the current text with the new text  
             $(this).val(new_text);  
         }
     });


    //FLASH
    $('#Fogaz_BodyFlash').flash(
        { src: '/Root/System/Skins/FogazSkin/img/felho_uszas1920_24_crop.swf',
            width: 1920,
            height: 960,
            wmode: 'transparent'
        },
        { version: 9 }
    );

$('#banner1').flash(
		{ src: '/Root/Fogaz/PromoImages/fogaz_banner_940x180.swf',
			width: 940,
			height: 180
		},
		{ version: 9 }
	);


    //FLASH SAFARI EXCEPTION: 
    var isChrome = (navigator.userAgent.toLowerCase().indexOf("chrome") > -1) ? true : false;
    var isSafari = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
    var isWindows = (navigator.userAgent.indexOf("Windows") != -1) ? true : false;
    var flashBody = $('#Fogaz_BodyFlash');

    if (isSafari == true && isWindows == true && isChrome == false) {
        flashBody.hide().css('z-index', '-1000');
        flashBody.parent().css('background', '#fff url(img/body_bg.png) repeat-x');
    }


    //DROPDOWN MENU
    var timeout = 200;
    var closetimer = 0;
    var ddmenuitem = 0;

    function jsddm_open() {
        jsddm_canceltimer();
        jsddm_close();
        ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
        if ($(this).hasClass('active:not')) {
            ddmenu = $(this).addClass('active');
        }
    }

    function jsddm_close() {
        if (ddmenuitem) {
            ddmenuitem.css('visibility', 'hidden');
            if ($(this).hasClass('active:not')) {
                ddmenu.removeClass('active');
            }
        }
    }

    function jsddm_timer()
    { closetimer = window.setTimeout(jsddm_close, timeout); }

    function jsddm_canceltimer() {
        if (closetimer) {
            window.clearTimeout(closetimer);
            closetimer = null;
        }
    }

    $(document).ready(function() {
        $('#Fogaz_Mainmenu > li').bind('mouseover', jsddm_open);
        $('#Fogaz_Mainmenu > li').bind('mouseout', jsddm_timer);
    });

    document.onclick = jsddm_close;


    //PROMOTION SLIDEBOX
    function formatText(index, panel) {
        return index + "";
    }

    $(function() {
        $('.Fogaz_PromotionSlider').anythingSlider({
            //easing: "easeInOutExpo",      // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
            delay: 7000,                    // How long between slide transitions in AutoPlay mode
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            animationTime: 2000,            // How long the slide transition takes
            hashTags: true,                 // Should links change the hashtag in the URL?
            buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
            pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
            //startText: "Go",                // Start text
            //stopText: "Stop",               // Stop text
            navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
        });

        $("#slide-jump").click(function() {
            $('.Fogaz_PromotionSlider').anythingSlider(6);
        });

    });

    //SLIDEBOX
    $("#Fogaz_UsefulLinks").slideBox({ height: "316px", position: "bottom" });



});

$(document).ready(function() {

    //PROMO
    $('#promo').innerfade({
        animationtype: 'fade',
        speed: 3000,
        timeout: 20000,
        type: 'sequence',
        containerheight: '220px'
    });


    //$(".snQueryItem p.trunc").truncatable();

    $('.Fogaz_WideSegmentElector a.img, .Fogaz_SegmentElector a.img').hover(
		function() {
		    if (this.style.backgroundImage.lastIndexOf("_over.jpg") == -1) {
		        this.style.backgroundImage = this.style.backgroundImage.replace(".jpg", "_over.jpg");
		    }
		},
		function() {
		    if (this.style.backgroundImage.lastIndexOf("_over.jpg") != -1) {
		        this.style.backgroundImage = this.style.backgroundImage.replace("_over.jpg", ".jpg");
		    }
		}
	);

    jQuery.preloadImages = function() {
        for (var i = 0; i < arguments.length; i++) {
            jQuery("<img>").attr("src", arguments[i]);
        }
    }

    $.preloadImages("/Root/Fogaz/NyitoImages/szegmens_uzleti_over.jpg", "/Root/Fogaz/NyitoImages/szegmens_lakossagi_over.jpg",
	"/Root/Fogaz/UzletiUgyfelekSzegmensTartalom/images/nagyfogyasztok_over.jpg", "/Root/Fogaz/UzletiUgyfelekSzegmensTartalom/images/uzfogyasztok_over.jpg",
	"/Root/Fogaz/UzletiUgyfelekSzegmensTartalom/images/intezmenyek_over.jpg", "/Root/Fogaz/UzletiUgyfelekSzegmensTartalom/images/tarsashazak_over.jpg");

	$('#ctl00_WebPartManager1_Login_RegisztracioPortlet2116317788_ctl00_tbBirthDate').click(
	    function() {
	        $('#ctl00_WebPartManager1_Login_RegisztracioPortlet2116317788_ctl00_tbBirthDate').removeAttr("readonly");
	    });


});

function printpage() {
    var htmlStr = $("div.uszo_keret").html();
    $(this).remove();
    $("div").css("display", "none");
    $(this).css("border", "red");

    $("body").prepend("<div class='printkontener' id='printkontener'></div>");
    $("div.printkontener").prepend("").append(htmlStr + "<p><a class='printkontener' title='Vissza normál nézetbe' href='javascript:window.location.reload();'>Vissza normál nézetbe</a></p><p>Felh&iacute;vjuk figyelm&eacute;t, hogy a foglal&aacute;s sor&aacute;n a rendszer &aacute;ltal adott 5 jegyű foglal&aacute;si k&oacute;dot sz&iacute;veskedj&eacute;k feljegyezni &eacute;s az &uuml;gyint&eacute;z&eacute;shez mag&aacute;val hozni, mert azt az &uuml;gyf&eacute;lh&iacute;v&oacute; termin&aacute;lon a sorsz&aacute;mk&eacute;r&eacute;s sor&aacute;n meg kell adnia! Amennyiben a foglal&aacute;s megkezd&eacute;sekor az e-mail mezőben megadja e-mail c&iacute;m&eacute;t, az időpont foglal&aacute;s&aacute;r&oacute;l erre az e-mail c&iacute;mre a rendszer visszaigazol&aacute;st k&uuml;ld, amelyben a foglal&aacute;si k&oacute;d is szerepel.</p><p>Az &uuml;gyint&eacute;z&eacute;s gyors&iacute;t&aacute;sa &eacute;rdek&eacute;ben &uuml;gyf&eacute;l azonos&iacute;t&oacute; k&oacute;dj&aacute;t is hozza mag&aacute;val. Az &uuml;gyint&eacute;z&eacute;shez sz&uuml;ks&eacute;ges tov&aacute;bbi dokumentumokr&oacute;l k&eacute;rj&uuml;k, t&aacute;j&eacute;koz&oacute;djon honlapunkon.</p><p>Felh&iacute;vjuk sz&iacute;ves figyelm&eacute;t, hogy &uuml;gyf&eacute;lszolg&aacute;lati irod&aacute;inkban időpont foglal&aacute;si k&eacute;relm&eacute;t csak az &Ouml;n &aacute;ltal megjel&ouml;lt időpontban &eacute;s &uuml;gyt&iacute;pusban tudjuk elfogadni. Amennyiben megkeres&eacute;se a rendszerben megjel&ouml;lt &uuml;gy&ouml;n t&uacute;l egy&eacute;b &uuml;gyint&eacute;z&eacute;st is ig&eacute;nyel, azt k&uuml;l&ouml;n kell lefolytatnia, mivel elektronikus foglal&aacute;s&aacute;t csak az eredetileg megadott param&eacute;terek alapj&aacute;n &aacute;ll m&oacute;dunkban teljes&iacute;teni. Az egy&eacute;b &uuml;gyek int&eacute;z&eacute;s&eacute;t az esetben &eacute;rkez&eacute;si sorrend alapj&aacute;n tudja v&eacute;gezni.</p><p>T&aacute;j&eacute;koztatjuk, hogy az &Ouml;n &aacute;ltal foglalt időponthoz k&eacute;pest irod&aacute;inkban az &uuml;gyf&eacute;lh&iacute;v&oacute; rendszereink +/- 15 percen bel&uuml;l tudj&aacute;k a foglal&aacute;s&aacute;t figyelembe venni. K&eacute;rj&uuml;k, sz&iacute;veskedjen az &uuml;gyf&eacute;lszolg&aacute;lati irod&aacute;kban ezen időtartam alatt a megadott foglal&aacute;si k&oacute;ddal sorsz&aacute;mot ig&eacute;nyelni.</p>");
    $("div.printkontener input").remove();
    $("div.printkontener a.print").remove();
    print();
    return false;
}

function callprint(strid) {
    var prtContent = document.getElementById(strid);
    var WinPrint = window.open('', '', 'left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
    $("div.printkontener").css('display', 'block');
    WinPrint.document.write(prtContent.innerHTML);
    $("div.printkontener").css('display', 'none');
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
    WinPrint.close();
    //prtContent.innerHTML = strOldOne;
}

function ShowConfirmationPopup() {
    $('<div id="popupbg"></div>').appendTo('body').css({'height' : $(document).height()});
    $("#popup").css({ 'top': ($(window).height() - $('#popup').height()) / 2 - 10, 'left': ($(window).width() - $('#popup').width()) / 2}).show();
}

function hideConfirmationPopup() {
    $("#popupbg").remove();
    $("#popup").hide();
    return false;
}
