﻿//-------------------  KEPCSERE Macromedia

function MM_changeProp(objName, x, theProp, theValue) { //v3.0
    var obj = MM_findObj(objName);
    if (obj && (theProp.indexOf("style.") == -1 || obj.style)) eval("obj." + theProp + "='" + theValue + "'");
}


function MM_swapImage() { //v3.0

    var i, j = 0, x, a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) {
        document.MM_sr[j++] = x;
        if (!x.oSrc) x.oSrc = x.src;
        x.src = a[i + 2];
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) {
            d.MM_p[j] = new Image;
            d.MM_p[j++].src = a[i];
        }
    }
}



function MM_findObj(n, d) { //v4.0
    var p, i, x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && document.getElementById) x = document.getElementById(n);
    return x;
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}


//----------------------------------------------------------------
//------Kepcsere vege---------------------------------------------
//----------------------------------------------------------------

//Function browserCheck() checks the browser

function BrowserCheck() {
    var b = navigator.appName;
    if (b == "Netscape") this.b = "ns";
    else if (b == "Microsoft Internet Explorer") this.b = "ie";
    else this.b = b;
    this.v = parseInt(navigator.appVersion);
    this.ns = (this.b == "ns" && this.v >= 4);
    this.ns6 = (this.b == "ns" && this.v >= 5);
    this.ie = (this.b == "ie" && this.v >= 4);
    this.ie5 = (navigator.userAgent.indexOf('MSIE 5') > 0);
    this.opera = (navigator.userAgent.indexOf('Opera') > 0);
    //if (this.opera) {
    //	this.ns6 = (this.b=="ns" && this.v>=4);
    //}
    this.ismac = (navigator.platform.indexOf('mac') > 0);
    if (this.ie5) this.v = 5;
    this.min = (this.ns || this.ie);
    return true;
}

is = new BrowserCheck()

function verifyCompatibleBrowser() {
    this.agt = navigator.userAgent.toLowerCase();
    this.Pc = this.agt.indexOf("win") != -1 || this.agt.indexOf("16bit") != -1;
    this.ver = navigator.appVersion;
    this.dom = document.getElementById ? 1 : 0;
    this.ie5 = (this.ver.indexOf("MSIE") > -1 && this.dom) ? 1 : 0;
    this.ie4 = (document.all && !this.dom) ? 1 : 0;
    this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
    this.ns4 = (document.layers && !this.dom) ? 1 : 0;
    this.opera = (window.opera) ? 1 : 0;
    this.bw = ((this.ie5 || this.ie4 || this.ns4 || this.ns5) && !this.opera);
    return this;
}

bw = new verifyCompatibleBrowser()

hidden = bw.ns4 ? "hide" : "hidden";
visible = "visible";


function fejmenu_megnyit(ee) {


    //    var _button = $get(ee);



    //    var div = $get("fejmenu_alap");
    //        
    //    var _bounds = Sys.UI.DomElement.getBounds(_button);

    //    Sys.UI.DomElement.setLocation(div, _bounds.x, -5);

    //    if (Sys.UI.DomElement.containsCssClass(div, "dn")) 
    //    {
    //        Sys.UI.DomElement.removeCssClass(div, "dn");
    //        Sys.UI.DomElement.addCssClass(div, "db");
    //    }
    //    else 
    //    {
    //        Sys.UI.DomElement.addCssClass(div, "db");
    //    
    //    }

    var _b = $("#" + ee);

    var div = $("#fejmenu_alap");

    if (div) {

        var p = _b.offset();

        div.css({ top: p.top - 5, left: p.left });

//        if (div.hasClass("dn")) {
//            div.removeClass("dn");
//        }

//        div.addClass("db");
        //

        div.show();
    }

}

function bezar() {
//    var div = $get("fejmenu_alap");

//    if (Sys.UI.DomElement.containsCssClass(div, "db")) {
//        Sys.UI.DomElement.removeCssClass(div, "db");
//        Sys.UI.DomElement.addCssClass(div, "dn");
//    }
//    else {
//        Sys.UI.DomElement.addCssClass(div, "dn");

//    }


    var div = $("#fejmenu_alap");

    if (div) {
        div.hide();
    }


}

var mytimer;

function gototop() {
    //    mytimer = setTimeout("gototop2()", 400);

    $('html, body').animate({ scrollTop: 0 }, 350);
}

function gototop2() {
    window.scrollTo(0, 0);
    clearTimeout(mytimer);
}

function biztos() {
    return confirm("Biztos törölni akarja?");
}

function biztosajanlat() {
    return confirm("Valóban el akarja küldeni az ajanlatkérést?");
}


function emailkuldes() {
    return confirm("Elküldhetem a hírlevelet a felhasználóknak?");
}

//-----------------------------------------------------------------------------

function lenyit(divid, objname, norm, open) {

    var div = document.getElementById(divid);
    var obj = document.getElementById(objname);

    if (div.style.display == 'none') {
        div.style.display = 'block';
        obj.src = open;
    }
    else {
        div.style.display = 'none';
        obj.src = norm;

    }

}

function menusor(command, args) {
    if (command == 'felsomenu') {
        switch (args) {
            case 'elerhetoseg':
                window.open("elerhetoseg.html", "", "width=520,height=450,status=no,menubar=no,resizable=no,scrollbars=no,location=no,directories=no,toolbar=no,titlebar=no");
                break;
            case 'vasarlasi':
                window.open("vasarlasi.html", "", "width=260,height=390,status=no,menubar=no,resizable=no,scrollbars=no,location=no,directories=no,toolbar=no,titlebar=no");
                break;
            case 'kiado':
                window.open("kiado.html", "", "width=520,height=450,status=no,menubar=no,resizable=no,scrollbars=no,location=no,directories=no,toolbar=no,titlebar=no");
                break;

        }
    }
}

function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

var preloadFlag = false;

function preloadImages() {
//    MM_preloadImages("images/fejmenu_01_02-over.jpg",
//                        "images/fejmenu_01_03-over.jpg",
//                        "images/fejmenu_01_04-over.jpg",
//                        "images/baloldal_01_05_02-over.jpg",
//                        "images/baloldal_01_05_03-over.jpg",
//                        "images/baloldal_01_05_02_2-over.jpg",
//                        "images/baloldal_01_05_03_3-over.jpg");
    //
}

var bookmarkurl = "http://www.kosarbavele.hu";
var bookmarktitle = "'Kosárba vele' Webáruház";

function addbookmark() {
    if (confirm("Fel kívánja venni a 'Kosárba vele' Webáruház oldalát a kedvencek közé?")) {
        if (document.all) {
            window.external.AddFavorite(bookmarkurl, bookmarktitle);
        }
        else {
            var chr = 'CTRL-D';
            var agt = navigator.userAgent.toLowerCase();
            if (agt.substr(agt.indexOf('opera') + 6, 1) < 9) chr = 'CTRL-T';

            alert("A lap felvételéhez kérem nyomja meg a '" + chr + "' billentyűket.");
        }
    }
}

function show_flash(url, w, h) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" width="' + w + '" height="' + h + '" id="multilink">');
    document.write('<param name="movie" value="' + url + '">');
    document.write('<param name="quality" value="high">');
    document.write('<embed src="' + url + '" quality="high" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="multilink">');
    document.write('</embed>');
    document.write('</object>');
}


function biztos_reg() {
    return confirm("Biztos regisztrálni akar?");
}

/*--------------------------------------*/

var kedvezmeny_timer;
var lampaszalon_timer;

var szalonszamlalo = 0;

function showmodal_start() {
    kedvezmeny_timer = setTimeout("show_kedvezmenymodal()", 1000);

}

function show_kedvezmenymodal() {
    if (kedvezmeny_timer) {
        var modalPopupBehavior2 = $find('programmaticModalPopupBehavior2');
        if (modalPopupBehavior2 != null) {
            modalPopupBehavior2.show();
        }

        cleartimeout();
    }
}

function hide_kedvezmenymodal() {
    var modalPopupBehavior2 = $find('programmaticModalPopupBehavior2');
    if (modalPopupBehavior2 != null) {
        modalPopupBehavior2.hide();
    }
}



function cleartimeout() {
    clearTimeout(kedvezmeny_timer);
    kedvezmeny_timer = null;

    clearTimeout(lampaszalon_timer);
    lampaszalon_timer = null;

    szalonszamlalo = 0;
}

function showmodal2_start() {
    lampaszalon_timer = setTimeout("show_kedvezmenymodal2()", 1000);

}



function show_kedvezmenymodal2() {
    if (lampaszalon_timer) {
        var modalPopupBehavior1 = $find('programmaticModalPopupBehavior1');

        if (modalPopupBehavior1 != null) {
            modalPopupBehavior1.show();
            cleartimeout();
        }
        else {
            cleartimeout();
            if (szalonszamlalo < 10) {
                szalonszamlalo++;
                showmodal2_start();
            }

        }



    }
}

function hide_kedvezmenymodal2() {
    var modalPopupBehavior1 = $find('programmaticModalPopupBehavior1');
    if (modalPopupBehavior1 != null) {
        modalPopupBehavior1.hide();
    }
}

function showkatalogus(kat, bolt) {
    var width = 950;
    var height = 760;
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=no';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open("Katalogus/" + bolt + "/" + kat, "Katalogus", params);
    //    newwin = window.open("Katalogus.aspx?" + bolt + "&" + kat , "Katalogus", params);
    if (window.focus) { newwin.focus() }
    return false;
}


var thousand_sep = " ";
var decimal_point = ".";
var default_precision = 0;

function formatFloat(aFloat, aPrecision) {
    try {
        precision = default_precision;
        if (!isNaN(aPrecision))
            if (Math.abs(aPrecision) <= 10)
            precision = aPrecision;
    }
    catch (e) {
        precision = default_precision;
    }

    try {
        number = parseFloat(aFloat + '');
        if (isNaN(number))
            return "NaN";
    }
    catch (e) {
        return "NaN";
    }

    number = Math.round(number * Math.pow(10, precision)) / Math.pow(10, precision);
    integerpart = '' + ((number < 0) ? Math.ceil(number) : Math.floor(number));
    decimalpart = Math.abs(Math.round((number - integerpart) * (Math.pow(10, precision))));

    if (decimalpart < 10)
        decimalpart = "0" + decimalpart;
    if (decimalpart == 0)
        decimalpart = "00";

    var buff = "";

    for (j = -1, i = integerpart.length; i >= 0; i--, j++) {
        if ((j % 3) == 0 && j > 1)
            buff = thousand_sep + buff;
        buff = integerpart.charAt(i) + buff;
    }

    if (precision > 0)
        return buff + decimal_point + decimalpart;

    return buff;
}

function formatInt(aInt) {
    return formatFloat(aInt, 0);
}

//$(function preLoadImages() {

//    var cache = [];

//    var argsl = arguments.length();

//    for (var i = argsl; i--) {
//        var cacheimg = document.createElement('img');
//        cacheimg.src = arguments[i];
//        cache.push(cacheimg);
//    }

//    window.status = argsl + " kep cachelve";

//});

