<!--

function ttGI(id) 
{
    return document.getElementById(id);
}


function ttSetAttr(elemId, attrName, value)
{
    var o = ttGI(elemId);
    if (o)
        o[attrName] = value;
}


function ttSetClass(elemId, classname)
{
    var o = ttGI(elemId);
    if (o) 
        o.className = classname;
}


function ttSetStyle(elemId, attrName, value)
{
    var o = ttGI(elemId);
    if (o)
        o.style[attrName] = value;
}


function ttParseNumeric(s, minVal, maxVal)
{
    if (minVal == undefined)
        minVal = 0;
    if (maxVal == undefined)
        maxVal = 100000;
    var n = parseInt('0' + s.replace(/[^0-9]/,''), 10); // avoids NaN
    return n < minVal ? minVal : (n > maxVal ? maxVal : n);
}


function ttBacksearchDataId(node, classToken)      // classToken may be like 'js-MyId-'
{
    if (!node) {
        return '';
    }
    if (typeof(node.className) != 'undefined' && node.className)
    {
        var id = ttGetIdFromClassname(node, classToken);
        if (id !== null)
            return id;
    }
    return ttBacksearchDataId(node.parentNode, classToken)    
}


function ttGetIdFromClassname(node, classToken)    // classToken may be like 'js-MyId-'
{
    if (node.className.indexOf(classToken) >= 0)
    {
        var classes = node.className.split(' ');
        for (var i = 0 ; i < classes.length ; i++)
        {
            if (classes[i].indexOf(classToken) == 0)
            {
                return classes[i].substr(classToken.length);
            }
        }
        return '';
    }
    return null;
}

// -----------------------------------------------------------------------------
// basics
// -----------------------------------------------------------------------------

function ttGetElementsByClassName(basenode, tagname, classname)
{
    var elems  = (tagname == "*" && document.all) ? document.all : basenode.getElementsByTagName(tagname);
    var result = [];
    classname = classname.replace(/\-/g, "\\-");
    var reg = new RegExp("(^|\\s)" + classname + "(\\s|$)");
    for(var i=0 ; i < elems.length; i++) 
    {
        if (reg.test(elems[i].className))
            result.push(elems[i]);
    }
    return (result);
}   


function ttRemoveClass(o, classname)
{
    var reg = new RegExp("\\s" + classname + "(\\s|$)", 'g');
    o.className = (' ' + o.className).replace(reg, ' ').substring(1);
}


function ttAddClass(o, classname)
{
    if ( (' ' + o.className + ' ').indexOf(' ' + classname + ' ') != -1 )
        return;
    o.className = (o.className == '') ? classname : (o.className + ' ' + classname);
}


function ttSwapClass(o, oldClassname, newClassname)
{
//var old = o.className;
    ttRemoveClass(o, oldClassname);
    ttAddClass(o, newClassname);    
//alert(o.id + ': [' + old + '] -> [' + o.className + ']');
}


function ttViewportWidth() 
{
    if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
    if (document.body && document.body.clientWidth ) return document.body.clientWidth;
    return window.innerWidth - 18;
}


function ttViewportHeight() 
{
    if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
    if (document.body && document.body.clientHeight) return document.body.clientHeight;
    return window.innerHeight - 18;
}


function ttViewportScrollX() 
{
    if (document.documentElement && document.documentElement.scrollLeft) return document.documentElement.scrollLeft;
    if (document.body && document.body.scrollLeft) return document.body.scrollLeft;
    if (window.pageXOffset) return window.pageXOffset;
    if (window.scrollX) return window.scrollX;
    return 0;
}


function ttViewportScrollY() 
{
    if (document.documentElement && document.documentElement.scrollTop) return document.documentElement.scrollTop;
    if (document.body && document.body.scrollTop) return document.body.scrollTop;
    if (window.pageYOffset) return window.pageYOffset;
    if (window.scrollY) return window.scrollY;
    return 0;
}


function ttPageX(elem)
{
    return elem.offsetParent ? elem.offsetLeft + ttPageX(elem.offsetParent) : elem.offsetLeft;
}


function ttPageY(elem)
{
    return elem.offsetParent ? elem.offsetTop + ttPageY(elem.offsetParent) : elem.offsetTop;
}


function ttHorzCenterInWindow(width)
{
    var x = (ttViewportWidth() - width) / 2 + ttViewportScrollX();
    return isNaN(x) ? 0 : x;
}


function ttVertCenterInWindow(height)
{
    var y = (ttViewportHeight() - height) / 2 + ttViewportScrollY();
    return isNaN(y) ? 0 : y;    
}


function TT_PageXY(baseElemId)
{
    var baseX = null;
    var baseY = null;
    this.info  = null;    
    
    this.getX = function(elem)        
    {
        //if (this.info !== null) console.info('getX ['+this.info+']');                                
        if (elem.id == baseElemId) {
            if (baseX === null)
                baseX = ttPageX(document.getElementById(baseElemId));        
            return baseX                    
        }
        return elem.offsetParent ? elem.offsetLeft + this.getX(elem.offsetParent) : elem.offsetLeft;            
    }
        
    this.getY = function(elem)        
    {
        //if (this.info !== null) console.info('getY ['+this.info+']');                                
        if (elem.id == baseElemId) {
            if (baseY === null)
                baseY = ttPageY(document.getElementById(baseElemId));        
            return baseY
        }
        return elem.offsetParent ? elem.offsetTop + this.getY(elem.offsetParent) : elem.offsetTop;
    }
}


// -----------------------------------------------------------------------------
// Ajax Request
// -----------------------------------------------------------------------------

var TT_HTTP = {};
TT_HTTP._factory = null;
TT_HTTP._factories = [
    function() { return new XMLHttpRequest(); },
    function() { return new ActiveXObject("Msxml2.XMLHTTP"); },
    function() { return new ActiveXObject("Microsoft.XMLHTTP"); }
];


TT_HTTP.newRequest = function()
{
    // if an appropriate factory was already found, use it
    if (TT_HTTP._factory != null)
        return TT_HTTP._factory();
    // else search a working factory, one that creates a request
    for(var i = 0; i < TT_HTTP._factories.length; i++)
    {
        try
        {
            var factory = TT_HTTP._factories[i];
            var request = factory();
            if (request != null) {
                TT_HTTP._factory = factory;
                return request;
            }
        }
        catch(e) { continue; }
    }
    // no factory method did work, each did throw an exception
    TT_HTTP._factory = function() {
        throw new Error("XMLHttpRequest not supported");
    }
    TT_HTTP._factory(); // throw exception
}

// -----------------------------------------------------------------------------
// common onload
// -----------------------------------------------------------------------------

function TT_onLoad()
{
    // on LoadFuncs is a global var used to add functions that are called onLoad

    if (typeof onLoadFuncs != 'undefined' && onLoadFuncs != null)
    {
        for (var i = 0 ; i < onLoadFuncs.length ; i++)
        {
            // alert(onLoadFuncs[i]);
            onLoadFuncs[i]();
        }
        onLoadFuncs = null;    
    }
/**    
    if (typeof window.tt_onload_callback == 'string')
    {
        eval( window.tt_onload_callback );
        window.tt_onload_callback = null;
    }

    try
    {   // accessing window.opener.tt_onload_callback can cause exception
        if (window.opener && typeof window.opener.tt_onload_callback == 'string')
        {
            eval( window.opener.tt_onload_callback );    
            window.opener.tt_onload_callback = null;
        }
    }
    catch(e) {}    
**/    
}

// -----------------------------------------------------------------------------
// handling tabboxes for agencies, videos etc
// -----------------------------------------------------------------------------

function svShowTabbox(group, index)
{
    for (var i = 0 ; ; i++)
    {
        var idTabhead = group + '_tabbox_head_' + i;    
        var oHead = document.getElementById(group + '_tabbox_head_' + i);   
        var oBody = document.getElementById(group + '_tabbox_body_' + i);           
        if (oHead == null || oBody == null)
            break;
        if (i == index) {
            ttSwapClass(oHead, 'inactive', 'active');
            ttSwapClass(oBody, 'inactive', 'active');            
        }
        else {
            ttSwapClass(oHead, 'active', 'inactive');
            ttSwapClass(oBody, 'active', 'inactive');            
        }
    }
}

// -----------------------------------------------------------------------------
// switching the default video player
// -----------------------------------------------------------------------------

function svGuessDefaultPlayer()
{
//  var p = (navigator.platform == 'Win32') ? 'w' : 'q';
    var p = 'f';
//  alert('svGuessDefaultPlayer() returns: ' + p);
    return p;
}


function svSetDefaultPlayer(p)
{
    if (p != 'q' && p != 'w' && p != 'f')
        p = svGuessDefaultPlayer();
    var cookie = TT_getCookie("svPlayer");
    var tech = cookie ? cookie.charAt(2) : 'd';
    if (tech != 'd' && tech != 's')
        tech = 'd';
    var c = p+','+tech;
    TT_setCookie("svPlayer", c, new Date(2020, 0, 1), '/');
    svUpdatePlayer();
    return false;
}

function svUpdatePlayer()
{
    var cookie = TT_getCookie("svPlayer");
    var p = cookie ? cookie.charAt(0) : svGuessDefaultPlayer();
    
    var img;
    if ( (img = document.getElementById('player_' + p)) )
        img.src = player_img_check[p];
        
    var players = ['q', 'w', 'f'];
    for (var i = 0 ; i < players.length ; i++)
    {
        var otherp = players[i];
        if (otherp != p && (img = document.getElementById('player_' + otherp)))
            img.src = player_img_nocheck[otherp];        
    }
}

function svStartUpdatePlayerLoop()
{
    svUpdatePlayer();
    window.setTimeout("svStartUpdatePlayerLoop()", 500);
}


// -----------------------------------------------------------------------------
// cookie helpers
// -----------------------------------------------------------------------------


// Sets a Cookie with the given name and value.
//
// name       Name of the cookie
// value      Value of the cookie
// [expires]  Expiration date of the cookie (default: end of current session)
// [path]     Path where the cookie is valid (default: path of calling document)
// [domain]   Domain where the cookie is valid
//            (default: domain of calling document)
// [secure]   Boolean value indicating if the cookie transmission requires a
//            secure transmission

function TT_setCookie(name, value, expires, path, domain, secure)
{
    if (!domain)
    {
        var matches = window.location.hostname.match(/([^.]+[.][^.]+)$/);
        if (matches) {
            domain = matches[1] + ':';
            if ( (usesPort = domain.indexOf(':')) )
                domain = domain.substr(0, usesPort);
            domain = '.' + domain;
        }
    }

    var s = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path)    ? "; path=" + path : "") +
        ((domain)  ? "; domain=" + domain : "") +
        ((secure)  ? "; secure" : "");
    //alert('cookie: ' + name + ' length=' + s.length);
    document.cookie = s;
}


// Gets the value of the specified cookie.
//
// name  Name of the desired cookie.
// Returns a string containing value of specified cookie, or null if cookie does not exist.

function TT_getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


// Deletes the specified cookie.
//
// name      name of the cookie
// [path]    path of the cookie (must be same as path used to create cookie)
// [domain]  domain of the cookie (must be same as domain used to create cookie)

function TT_deleteCookie(name, path, domain)
{
    if (!domain)
    {
        var matches = window.location.hostname.match(/([^.]+[.][^.]+)$/);
        if (matches) {
            domain = matches[1] + ':';
            if ( (usesPort = domain.indexOf(':')) )
                domain = domain.substr(0, usesPort);
            domain = '.' + domain;
        }
    }

    if (TT_getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


/**
 * Object PHP_Serializer
 *  JavaScript to PHP serialize / unserialize class.
 * This class converts php variables to javascript and vice versa.
 *
 * PARSABLE JAVASCRIPT < === > PHP VARIABLES:
 *  [ JAVASCRIPT TYPE ]     [ PHP TYPE ]
 *  Array       < === >     array
 *  Object      < === >     class (*)
 *  String      < === >     string
 *  Boolean     < === >     boolean
 *  null        < === >     null
 *  Number      < === >     int or double
 *  Date        < === >     class
 *  Error       < === >     class
 *  Function    < === >     class (*)
 *
 * (*) NOTE:
 * Any PHP serialized class requires the native PHP class to be used, then it's not a
 * PHP => JavaScript converter, it's just a usefull serilizer class for each
 * compatible JS and PHP variable types.
 * Lambda, Resources or other dedicated PHP variables are not usefull for JavaScript.
 * There are same restrictions for javascript functions*** too then these will not be sent.
 *
 * *** function test(); alert(php.serialize(test)); will be empty string but
 * *** mytest = new test(); will be sent as test class to php
 * _____________________________________________
 *
 * EXAMPLE:
 *  var php = new PHP_Serializer(); // use new PHP_Serializer(true); to enable UTF8 compatibility
 *  alert(php.unserialize(php.serialize(somevar)));
 *  // should alert the original value of somevar
 * ---------------------------------------------
 * @author              Andrea Giammarchi
 * @site        www.devpro.it
 * @date                2005/11/26
 * @lastmod             2006/05/15 19:00 [modified stringBytes method and removed replace for UTF8 and \r\n]
 *          [add UTF8 var again, PHP strings if are not encoded with utf8_encode aren't compatible with this object]
 *          [Partially rewrote for a better stability and compatibility with Safari or KDE based browsers]
 *          [UTF-8 now has a native support, strings are converted automatically with ISO or UTF-8 charset]
 *
 * @specialthanks   Fabio Sutto, Kentaromiura, Kroc Camen, Cecile Maigrot, John C.Scott, Matteo Galli
 *
 * @version             2.2, tested on FF 1.0, 1.5, IE 5, 5.5, 6, 7 beta 2, Opera 8.5, Konqueror 3.5, Safari 2.0.3
 */

function PHP_Serializer(UTF8)
{

    /** public methods */
    function serialize(v) {
        // returns serialized var
        var s;
        switch(v) {
            case null:
                s = "N;";
                break;
            default:
                s = this[this.__sc2s(v)] ? this[this.__sc2s(v)](v) : this[this.__sc2s(__o)](v);
                break;
        };
        return s;
    };

    function unserialize(s) {
        // returns unserialized var from a php serialized string
        __c = 0;
        __s = s;
        return this[__s.substr(__c, 1)]();
    };

    function stringBytes(s) {
        // returns the php lenght of a string (chars, not bytes)
        return s.length;
    };

    function stringBytesUTF8(s) {
        // returns the php lenght of a string (bytes, not chars)
        var     c, b = 0,
            l = s.length;
        while(l) {
            c = s.charCodeAt(--l);
            b += (c < 128) ? 1 : ((c < 2048) ? 2 : ((c < 65536) ? 3 : 4));
        };
        return b;
    };

    /** private methods */
    function __sc2s(v) {
        return v.constructor.toString();
    };

    function __sc2sKonqueror(v) {
        var f;
        switch(typeof(v)) {
            case ("string" || v instanceof String):
                f = "__sString";
                break;
            case ("number" || v instanceof Number):
                f = "__sNumber";
                break;
            case ("boolean" || v instanceof Boolean):
                f = "__sBoolean";
                break;
            case ("function" || v instanceof Function):
                f = "__sFunction";
                break;
            default:
                f = (v instanceof Array) ? "__sArray" : "__sObject";
                break;
        };
        return f;
    };

    function __sNConstructor(c) {
        return (c === "[function]" || c === "(Internal Function)");
    };

    function __sCommonAO(v) {
        var b, n,
            a = 0,
            s = [];
        for(b in v) {
            n = v[b] == null;
            if(n || v[b].constructor != Function) {
                s[a] = [
                    (!isNaN(b) && parseInt(b).toString() === b ? this.__sNumber(b) : this.__sString(b)),
                    (n ? "N;" : this[this.__sc2s(v[b])] ? this[this.__sc2s(v[b])](v[b]) : this[this.__sc2s(__o)](v[b]))
                ].join("");
                ++a;
            };
        };
        return [a, s.join("")];
    };

    function __sBoolean(v) {
        return ["b:", (v ? "1" : "0"), ";"].join("");
    };

    function __sNumber(v) {
        var     s = v.toString();
        return (s.indexOf(".") < 0 ? ["i:", s, ";"] : ["d:", s, ";"]).join("");
    };

    function __sString(v) {
        return ["s:", v.length, ":\"", v, "\";"].join("");
    };

    function __sStringUTF8(v) {
        return ["s:", this.stringBytes(v), ":\"", v, "\";"].join("");
    };

    function __sArray(v) {
        var     s = this.__sCommonAO(v);
        return ["a:", s[0], ":{", s[1], "}"].join("");
    };

    function __sObject(v) {
        var     o = this.__sc2s(v),
            n = o.substr(__n, (o.indexOf("(") - __n)),
            s = this.__sCommonAO(v);
        return ["O:", this.stringBytes(n), ":\"", n, "\":", s[0], ":{", s[1], "}"].join("");
    };

    function __sObjectIE7(v) {
        var     o = this.__sc2s(v),
            n = o.substr(__n, (o.indexOf("(") - __n)),
            s = this.__sCommonAO(v);
        if(n.charAt(0) === " ")
            n = n.substring(1);
        return ["O:", this.stringBytes(n), ":\"", n, "\":", s[0], ":{", s[1], "}"].join("");
    };

    function __sObjectKonqueror(v) {
        var o = v.constructor.toString(),
            n = this.__sNConstructor(o) ? "Object" : o.substr(__n, (o.indexOf("(") - __n)),
            s = this.__sCommonAO(v);
        return ["O:", this.stringBytes(n), ":\"", n, "\":", s[0], ":{", s[1], "}"].join("");
    };

    function __sFunction(v) {
        return "";
    };

    function __uCommonAO(tmp) {
        var a, k;
        ++__c;
        a = __s.indexOf(":", ++__c);
        k = parseInt(__s.substr(__c, (a - __c))) + 1;
        __c = a + 2;
        while(--k)
            tmp[this[__s.substr(__c, 1)]()] = this[__s.substr(__c, 1)]();
        return tmp;
    };

    function __uBoolean() {
        var b = __s.substr((__c + 2), 1) === "1" ? true : false;
        __c += 4;
        return b;
    };

    function __uNumber() {
        var sli = __s.indexOf(";", (__c + 1)) - 2,
            n = Number(__s.substr((__c + 2), (sli - __c)));
        __c = sli + 3;
        return n;
    };

    function __uStringUTF8() {
        var     c, sls, sli, vls,
            pos = 0;
        __c += 2;
        sls = __s.substr(__c, (__s.indexOf(":", __c) - __c));
        sli = parseInt(sls);
        vls = sls = __c + sls.length + 2;
        while(sli) {
            c = __s.charCodeAt(vls);
            pos += (c < 128) ? 1 : ((c < 2048) ? 2 : ((c < 65536) ? 3 : 4));
            ++vls;
            if(pos === sli)
                sli = 0;
        };
        pos = (vls - sls);
        __c = sls + pos + 2;
        return __s.substr(sls, pos);
    };

    function __uString() {
        var     sls, sli;
        __c += 2;
        sls = __s.substr(__c, (__s.indexOf(":", __c) - __c));
        sli = parseInt(sls);
        sls = __c + sls.length + 2;
        __c = sls + sli + 2;
        return __s.substr(sls, sli);
    };

    function __uArray() {
        var a = this.__uCommonAO([]);
        ++__c;
        return a;
    };

    function __uObject() {
        var     tmp = ["s", __s.substr(++__c, (__s.indexOf(":", (__c + 3)) - __c))].join(""),
            a = tmp.indexOf("\""),
            l = tmp.length - 2,
            o = tmp.substr((a + 1), (l - a));
        if(eval(["typeof(", o, ") === 'undefined'"].join("")))
            eval(["function ", o, "(){};"].join(""));
        __c += l;
        eval(["tmp = this.__uCommonAO(new ", o, "());"].join(""));
        ++__c;
        return tmp;
    };

    function __uNull() {
        __c += 2;
        return null;
    };

    function __constructorCutLength() {
        function ie7bugCheck(){};
        var o1 = new ie7bugCheck(),
            o2 = new Object(),
            c1 = __sc2s(o1),
            c2 = __sc2s(o2);
        if(c1.charAt(0) !== c2.charAt(0))
            __ie7 = true;
        return (__ie7 || c2.indexOf("(") !== 16) ? 9 : 10;
    };

    /** private variables */
    var     __c = 0,
        __ie7 = false,
        __b = __sNConstructor(__c.constructor.toString()),
        __n = __b ? 9 : __constructorCutLength(),
        __s = "",
        __a = [],
        __o = {},
        __f = function(){};

    /** public prototypes */
    PHP_Serializer.prototype.serialize = serialize;
    PHP_Serializer.prototype.unserialize = unserialize;
    PHP_Serializer.prototype.stringBytes = UTF8 ? stringBytesUTF8 : stringBytes;

    /** serialize: private prototypes */
    if(__b) { // Konqueror / Safari prototypes
        PHP_Serializer.prototype.__sc2s = __sc2sKonqueror;
        PHP_Serializer.prototype.__sNConstructor = __sNConstructor;
        PHP_Serializer.prototype.__sCommonAO = __sCommonAO;
        PHP_Serializer.prototype[__sc2sKonqueror(__b)] = __sBoolean;
        PHP_Serializer.prototype.__sNumber =
        PHP_Serializer.prototype[__sc2sKonqueror(__n)] = __sNumber;
        PHP_Serializer.prototype.__sString = PHP_Serializer.prototype[__sc2sKonqueror(__s)] = UTF8 ? __sStringUTF8 : __sString;
        PHP_Serializer.prototype[__sc2sKonqueror(__a)] = __sArray;
        PHP_Serializer.prototype[__sc2sKonqueror(__o)] = __sObjectKonqueror;
        PHP_Serializer.prototype[__sc2sKonqueror(__f)] = __sFunction;
    }
    else { // FireFox, IE, Opera prototypes
        PHP_Serializer.prototype.__sc2s = __sc2s;
        PHP_Serializer.prototype.__sCommonAO = __sCommonAO;
        PHP_Serializer.prototype[__sc2s(__b)] = __sBoolean;
        PHP_Serializer.prototype.__sNumber =
        PHP_Serializer.prototype[__sc2s(__n)] = __sNumber;
        PHP_Serializer.prototype.__sString = PHP_Serializer.prototype[__sc2s(__s)] = UTF8 ? __sStringUTF8 : __sString;
        PHP_Serializer.prototype[__sc2s(__a)] = __sArray;
        PHP_Serializer.prototype[__sc2s(__o)] = __ie7 ? __sObjectIE7 : __sObject;
        PHP_Serializer.prototype[__sc2s(__f)] = __sFunction;
    };

    /** unserialize: private prototypes */
    PHP_Serializer.prototype.__uCommonAO = __uCommonAO;
    PHP_Serializer.prototype.b = __uBoolean;
    PHP_Serializer.prototype.i =
    PHP_Serializer.prototype.d = __uNumber;
    PHP_Serializer.prototype.s = UTF8 ? __uStringUTF8 : __uString;
    PHP_Serializer.prototype.a = __uArray;
    PHP_Serializer.prototype.O = __uObject;
    PHP_Serializer.prototype.N = __uNull;
};

-->