// Ξαεροεχενθε

var $BS = $BS || {};

$BS.Init = function()
{
    for (var obj in $BS)
        if (obj.indexOf("_") != 0 && !Function.prototype.isPrototypeOf($BS[obj]) && $BS[obj].Init)
        $BS[obj].Init();
}
$BS.Dispose = function()
{
    for (var obj in $BS)
        if (obj.indexOf("_") != 0 && !Function.prototype.isPrototypeOf($BS[obj]) && $BS[obj].Dispose)
        $BS[obj].Dispose();
}

$BS.ImageResize =
{
    _old: null,
    Init: function()
    {
        $BS.ImageResize._old = window.onresize;
        window.onresize = function(e)
        {
            if ($BS.ImageResize._old)
                $BS.ImageResize._old(e);
            $BS.ImageResize.Process();
        }
        $BS.ImageResize.Process();
    },
    OldSize: "",
    Process: function()
    {
        if (Photos && Photos.length > 0)
        {
            var size = $G.Window.Width() > 1150 ? "1280" : "1024";
            if (size != $BS.ImageResize.OldSize)
            {
                $BS.ImageResize.OldSize = size;
                for (var i = 0; i < Photos.length; i++)
                {
                    var img = $G.GET("#" + Photos[i].id);
                    if (img)
                        img.src = Photos[i][["r", size].join("")];

                    img = null;
                }
            }

            size = null;
        }
    }
}
$BS.UFX =
{
    Init: function()
    {
        var links = document.getElementsByTagName("a");
        for (var i = 0; i < links.length; i++)
        {
            var a = links[i];

            if (!$G.ClassName.Has(a, "anchor") && !a.onclick && (!a.target || a.target.toLowerCase() == "_self"))
            {
                a.onclick = function(e)
                {
                    var e = e || event;
                    if (e.preventDefault)
                        e.preventDefault();
                    e.returnValue = false;
                    $BS.UFX.Fade(this.href);
                } .bind(a);
            }
        }
    },
    //    Dispose: function()
    //    {
    //        if ($BS.UFX.Divs)
    //        {
    //            for (var i = 0; i < $BS.UFX.Divs.length; i++)
    //            {
    //                $BS.UFX.Divs[i].obj.parentNode.removeChild($BS.UFX.Divs[i].obj);
    //            }
    //        }
    //        $BS.UFX.Divs = null;
    //    },
    GetColor: function()
    {
        var color = $BS.UFX.Colors[Math.round(Math.random() * ($BS.UFX.Colors.length - 1))];
        while (color == $BS.UFX.LastColor)
        {
            color = $BS.UFX.Colors[Math.round(Math.random() * ($BS.UFX.Colors.length - 1))];
        }
        $BS.UFX.LastColor = color;
        color = null;
        return $BS.UFX.LastColor;
    },
    LastColor: "",
    InitDivs: function()
    {
        if (!$BS.UFX.Divs)
        {
            var th = Math.max($G.Window.Height(), document.body.offsetHeight);
            var h = 0;
            var divs = [];
            while (h < th)
            {
                var o = {};
                o.h = Math.round(Math.random() * 20 + 30);
                o.up = (Math.random() - 0.5) >= 0;
                o.top = (h + (o.up ? o.h : 0));
                o.color = $BS.UFX.GetColor();
                o.obj = document.createElement("div");
                o.obj.className = "stripe";
                o.obj.style.background = o.color;
                o.obj.style.height = "1px";
                o.obj.style.top = o.top + "px";
                o.obj.style.zIndex = Math.round(Math.random() * 90 + 10).toString();
                h += o.h;
                document.body.appendChild(o.obj);
                divs.push(o);
                o = null;
            }
            $BS.UFX.Divs = divs;
            h = th = divs = null;
        }
    },
    Colors: ["#9966bb", "#bb99cc", "#662277", "#774499"],
    Fade: function(url)
    {
        $BS.UFX.Url = url;
        $BS.UFX.InitDivs();
        if ($G.Browser.Detect.ie)
        {
            var embeds = document.getElementsByTagName("embed") || [];
            for (var i = 0; i < embeds.length; i++)
            {
                if (embeds[i])
                {
                    embeds[i].style.display = "none";
                }
            }
            embeds = document.getElementsByTagName("object") || []
            for (var i = 0; i < embeds.length; i++)
            {
                if (embeds[i])
                {
                    embeds[i].style.display = "none";
                }
            }
            embeds = objects = null;
        }
        for (var i = 0; i < $BS.UFX.Divs.length; i++)
        {
            $FX.Time(800).AnimateStyle($BS.UFX.Divs[i].obj, "height", $BS.UFX.Divs[i].h + 10, ($BS.UFX.Divs[i].h + 11), function() { $BS.UFX.Count(); }, function(f)
            {
                if (this.up)
                    this.obj.style.top = (this.top - f) + "px";
            } .bind($BS.UFX.Divs[i]), Math.random().toString());
        }
    },
    index: 0,
    Count: function()
    {
        $BS.UFX.index++;
        if ($BS.UFX.index == $BS.UFX.Divs.length)
        {
            document.location = $BS.UFX.Url;
        }
    }
}

$BS._old = window.onload;
window.onload = function(e)
{
    if ($BS._old)
        $BS._old(e);
    $BS.Init();
}
$BS._oldUnload = window.onunload;
window.onunload = function(e)
{
    if ($BS._oldUnload)
        $BS._oldUnload(e);
    $BS.Dispose();
}


