﻿var inTransition = false;
function ExpandStartGift() {
    if (BrowserDetect.browser == "Explorer" && BrowserDetect.version <= 6) {
        window.location.href = "/ge-en-gava"; return;
    }
    if (!inTransition) {
        inTransition = true;
        if ($('startgive').style.left == '175px')
            new Effect.Move('startgive', {duration: 0.5, x: 650, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, afterFinish: function() { inTransition = false; } });
        else
            new Effect.Move('startgive', { duration: 0.5, x: 175, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, afterFinish: function() { inTransition = false; } });
    }
}

function ExpandMGift() {
    if (BrowserDetect.browser == "Explorer" && BrowserDetect.version <= 7) {
        window.location.href = "/ge-en-gava";return;
    }
     
    if (!inTransition) {
        inTransition = true;
        if ($('mgive').style.left == '-443px')
            new Effect.Move('mgive', { duration: 0.5, x: 12, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, afterFinish: function() { inTransition = false; } });
        else
            new Effect.Move('mgive', { duration: 0.5, x: -443, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, afterFinish: function() { inTransition = false; } });
    }
}

function ExpandMGift2() {
    if (BrowserDetect.browser == "Explorer" && BrowserDetect.version <= 7) {
        window.location.href = "/ge-en-gava"; return;
    }

    if (!inTransition) {
        var height = $('rc2incp').offsetHeight + 20
        var cheight = $('rc2incp2').offsetHeight + 20
        inTransition = true;
        if ($('mgive').style.left == '-443px') {
            new Effect.Move('mgive', { duration: 0.6, x: 12, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, afterFinish: function() { inTransition = false; } });
            new Effect.Fade('rc2inner', { duration: 0.3, afterFinish: function() {
                $('rc2inner').style.height = '0px';
                $('rc2inner').show();
            }
            });
            new Effect.Morph('rc2inner2', {
                style: 'height:' + cheight + 'px;', // CSS Properties
                duration: 0.5 // Core Effect properties
            });
            //Effect.BlindUp('rc2inner', { duration: 0.5, scaleMode: 'box' });
//            new Effect.Morph('rc2inner', {
//                style: 'height:0px;', // CSS Properties
//                duration: 0.4, // Core Effect properties
//                afterFinish: function() {
//                    new Effect.Morph('rc2inner2', {
//                        style: 'height:' + cheight + 'px;', // CSS Properties
//                        duration: 0.4 // Core Effect properties
//                    });
//                }
//            });
        }
        else { //expand
            new Effect.Move('mgive', { duration: 0.5, x: -443, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal, afterFinish: function() { inTransition = false; } });
            new Effect.Fade('rc2inner2', { duration: 0.3, afterFinish: function() {
                $('rc2inner2').style.height = '0px';
                $('rc2inner2').show();
            }
            });
            new Effect.Morph('rc2inner', {
                style: 'height:' + height + 'px;', // CSS Properties
                duration: 0.5 // Core Effect properties
            });
//            new Effect.Morph('rc2inner2', {
//                style: 'height:0px;', // CSS Properties
//                duration: 0.4, // Core Effect properties
//                afterFinish: function() {
//                    new Effect.Morph('rc2inner', {
//                        style: 'height:' + height + 'px;', // CSS Properties
//                        duration: 0.4 // Core Effect properties
//                    });
//                }
//            });
            //Effect.BlindDown('rc2inner', { duration: 1, scaleMode: 'box' });
        }
    }
}

function SwitchImgS2() {
    var obj = $('giveis');
    if (obj.src.indexOf('/Images/giftsmall.jpg') >= 0)
        obj.src = '/Images/giftsmallo2.jpg';
    else
        obj.src = '/Images/giftsmall2.jpg';
}

function SwitchImg() {
    var obj = $('givei');
    if (obj.src.indexOf('/Images/gift.jpg') >= 0)
        obj.src = '/Images/gifto.jpg';
    else
        obj.src = '/Images/gift.jpg';
}

function ShowDDMenu(id) {

    if (curid > 0 && curid != id) {
        var obj2 = $('ddmenu_' + curid);
        if (obj2) {
            obj2.hide();
            curid = 0;
        }
    }
    
    if (timeo) {
        clearTimeout(timeo);
        timeo = undefined;
    }

    var obj = $('ddmenu_' + id);
    if (curid != id && obj) {
        curid = id;
        var width = 5;
        obj.style.visibility = 'hidden';
        obj.show();
        obj.select('ul.arrowl').each(function(el) {
            width += el.getWidth()+30;
        });
        if (width < $('menu_' + id).getWidth()) {
            width = $('menu_' + id).getWidth()+20;
        }
        obj.select('div.tab').each(function(el) {
            el.style.width = ($('menu_'+id).getWidth() + 8) + 'px';
        });
        obj.style.width = width + 'px';
        obj.style.visibility = 'visible';
    }
}

function OpenNews(el) {
    var hide = false;
    var pnode = $(el.parentNode.parentNode);
    if (pnode.className.indexOf('expanded')>-1)
        hide = true;
        
    $$('#newslist div.expanded').each(function(e) {
        e.removeClassName('expanded');
    });
    
    if(!hide)
        $(pnode).addClassName('expanded');
}

function fonth(data) {
    return data + "&b=2&blc=255%2c255%2c255";
}

function gotPageList(data) {
    if (window.addthis) {
        window.addthis.ost = 0;
        window.addthis.ready();
    }
}

var timeo = undefined;
var curid = 0;
function HideDDMenu(id) {
    var obj = $('ddmenu_' + id);
    currentMenu = undefined;
    if (obj && !timeo) {
        timeo = setTimeout(function() { obj.hide(); curid = 0; }, 100);
    }
}
var BrowserDetect = {
    init: function() {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function(data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function(dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
BrowserDetect.init();