(function() {
    function readQuerystring( name ) {
        name = name.replace( /[\[]/, "\\\[" ).replace( /[\]]/, "\\\]" );
        var regexS = "[\\?&]" + name + "=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if ( results == null ) {
            return null;
        }
        else {
            return results[1];
        }
    }

    function writeCookie() {
        if ( arguments.length < 2 ) {
            return;
        }
        var n = arguments[0];
        var v = arguments[1];
        var d = 0;
        if ( arguments.length > 2 ) {
            d = parseInt( arguments[2] );
        }
        var exp = '';
        if ( d > 0 ) {
            var now = new Date();
            then = now.getTime() + (d * 24 * 60 * 60 * 1000);
            now.setTime( then );
            exp = '; expires=' + now.toGMTString();
        }
        document.cookie = n + "=" + escape( String( v ) ) + '; path=/' + exp;
    } // function SetCookie()

    function readCookie( n ) {
        var cookiecontent = new String();
        if ( document.cookie.length > 0 ) {
            var cookiename = n + '=';
            var cookiebegin = document.cookie.indexOf( cookiename );
            var cookieend = 0;
            if ( cookiebegin > -1 ) {
                cookiebegin += cookiename.length;
                cookieend = document.cookie.indexOf( ";", cookiebegin );
                if ( cookieend < cookiebegin ) {
                    cookieend = document.cookie.length;
                }
                cookiecontent = document.cookie.substring( cookiebegin, cookieend );
            }
        }
        return unescape( cookiecontent );
    }

    if ( ( !screen || screen.width >= 700 ) // must be a non-small screen
        && swfobject.getFlashPlayerVersion().major > 0
        && readCookie("useflash") !== "0"
        && readQuerystring("useflash") !== "0" ) {
        window.location = '../index2.php?useflash=1';
    }
    else {
        writeCookie("useflash", "0");
    }
})();

