var felements = new Array();
var flcount = 1;
var preloadnavimg = new Array();
var suid = 2;

function loadFlashElements()
{
    for (x in felements)
    {
        swfobject.embedSWF(felements[x][0], felements[x][1], felements[x][2], felements[x][3], "9.0.115", false, felements[x][4], felements[x][5], felements[x][6]);
    }
}
var selectedFeatureBlock = 0;
var hoverFeatureBlock = -1;
var autoShiftFeatureBlock_int;
var autoShiftFeatureBlock_int_timeout = 8000;
var featureBlockPause = false;
var featureBlockPlaying = false;

function autoShiftFeatureBlock()
{
    if (!featureBlockPause && !featureBlockPlaying)
    {
        var nextFeature = parseInt(selectedFeatureBlock) + 1;
        if (nextFeature >= $('.slidebar_content ul li a').length)
        {
            nextFeature = 0;
        }
        $('.slidebar_content ul li a[pos=' + nextFeature + ']').click();
    }
}

function setChangeFeatureBlock()
{
    selectedFeatureBlock = 0;
    $('#content_img ul li[pos!=0]').fadeOut(0);
    $('#content_desc ul li[pos!=0]').fadeOut(0);
    $('#content_related ul li[pos!=0]').fadeOut(0);
    $('#content_details ul li[pos!=0]').fadeOut(0);
    $('#content_desc,#content_related,#content_details,#content_altdetails').mouseover(function ()
    {
        featureBlockPause = true;
    }).mouseout(function ()
    {
        featureBlockPause = false;
    });
    $('.slidebar_content ul li a[pos=0]').addClass('selected');
    $('.slidebar_content ul li a[pos!=0]').removeClass('selected');
    $('.slidebar_content ul li a').mouseover(function ()
    {
        var n = $(this).attr('pos');
        hoverFeatureBlock = n;
        $(this).addClass('selected');
    }).mouseout(function ()
    {
        var n = $(this).attr('pos');
        if (n == selectedFeatureBlock)
        {
            $(this).addClass('selected');
        }
        else
        {
            $(this).removeClass('selected');
        }
        hoverFeatureBlock = -1;
    }).click(function (event)
    {
        event.preventDefault();
        var n = $(this).attr('pos');
        if (selectedFeatureBlock != n)
        {
            featureBlockPlaying = false;
            $('#player_layer').empty();
            $('#player_layer').css('display', 'none');
            $('#content_img ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
            $('#content_desc ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
            $('#content_related ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
            $('#content_details ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
            $('#content_img ul li[pos=' + n + ']').fadeIn('slow');
            $('#content_desc ul li[pos=' + n + ']').fadeIn('slow');
            $('#content_related ul li[pos=' + n + ']').fadeIn('slow');
            $('#content_details ul li[pos=' + n + ']').fadeIn('slow');
            selectedFeatureBlock = n;
            $('.slidebar_content ul').trigger('slideTo', [$(this).parent(), 0]);
            clearInterval(autoShiftFeatureBlock_int);
            autoShiftFeatureBlock_int = setInterval(autoShiftFeatureBlock, autoShiftFeatureBlock_int_timeout);
            $('.slidebar_content ul li a[pos=' + selectedFeatureBlock + ']').addClass('selected');
            $('.slidebar_content ul li a[pos!=' + selectedFeatureBlock + ']').removeClass('selected');
        }
    });
    clearInterval(autoShiftFeatureBlock_int);
    autoShiftFeatureBlock_int = setInterval(autoShiftFeatureBlock, autoShiftFeatureBlock_int_timeout);
}

function ajaxFrame(elements)
{
    if (!elements)
    {
        elements = '.aframe';
    }
    $(elements).each(afLoad);
}

function afLoad(index)
{
    if ($(this).attr('src') != 'undefined' && $(this).attr('src') != null)
    {
        leftmargin = $(this).width() / 2;
        $(this).prepend("<div style='display:block;width:110px;height:23px;background:silver;opacity:0.4;filter:alpha(opacity=40);position:absolute;z-index:40;margin-left:" + leftmargin + "px;left:-55px;'><div style='padding:5px;color:black;width:100px;height:13px;font-size:11px;text-align:center;font-weight:bold;'>LOADING</div></div>");
        if ($(this).attr('cache') != 'false' && $(this).attr('cache') == 'no' && $(this).attr('cache') != '0')
        {
            uni = 0;
        }
        else
        {
            uni = Math.floor(Math.random() * 121);
        }
        if ($(this).attr('id') == '')
        {
            $(this).attr('id', 'frameid' + index);
        }
        $.get($(this).attr('src'), {
            'uni': uni,
            'frameid': $(this).attr('id')
        }, afLoaded);
    }
}

function afLoaded(data, textStatus)
{
    var queryString = this.url.replace(/^[^\?]+\??/, '');
    var params = afParseQuery(queryString);
    $('#' + params.frameid).text('');
    $('#' + params.frameid).append(data);
    fixVideoLinks();
    setSignupLinks();
    titliseImageLinks();
    $("#" + params.frameid + " a").filter(function ()
    {
        return $(this).attr('target') == null || $(this).attr('target') == '' || $(this).attr('target') == 'undefined' || $(this).attr('target') == '_self'
    }).attr('afparent', params.frameid).click(function (event)
    {
        event.preventDefault();
        targetFrame = $(this).attr('afparent');
        clickSRC = $(this).attr('href');
        $('#' + targetFrame).attr('src', clickSRC);
        ajaxFrame('#' + targetFrame);
    });
    $("#" + params.frameid + " a[target^='af%']").click(function (event)
    {
        event.preventDefault();
        targetFrame = $(this).attr('target').substr(3) + '.aframe';
        clickSRC = $(this).attr('href');
        $('#' + targetFrame).attr('src', clickSRC);
        ajaxFrame('#' + targetFrame);
    });
}

function afParseQuery(query)
{
    var Params = {};
    if (!query)
    {
        return Params;
    }
    var Pairs = query.split(/[;&]/);
    for (var i = 0; i < Pairs.length; i++)
    {
        var KeyVal = Pairs[i].split('=');
        if (!KeyVal || KeyVal.length != 2)
        {
            continue;
        }
        var key = unescape(KeyVal[0]);
        var val = unescape(KeyVal[1]);
        val = val.replace(/\+/g, ' ');
        Params[key] = val;
    }
    return Params;
}

function addGradients(elements)
{
    $(elements).gradient(
    {
        from: 'F9EFEC',
        to: 'ffffff',
        length: 55
    });
}

function setSignupLinks()
{
    $('.signup').each(function ()
    {
        $(this).attr('href', 'https://secure.gunzblazing.com/signup/signup.php?s=' + suid);
        $(this).attr('target', '_top');
        $(this).click(function ()
        {
            breakTop()
        });
        $(this).attr('class', 'signup-fixed');
    });
}

function breakTop()
{
    try
    {
        top.frame.exit = false;
    }
    catch (e)
    {}
}

function titliseImageLinks(elements)
{
    if (!elements)
    {
        elements = 'a';
    }
    $(elements).each(function ()
    {
        var $title = $("img", this).attr("alt");
        if ($title != "" && $title != "undefined" && $title != null && $title != "null")
        {
            $(this).attr("title", $title);
        }
    });
}

function fixVideoLinks()
{
    $('.videoLinks').each(function (n)
    {
        var textArray = $(this).text().split(',');
        var vid = textArray[0];
        var title = '';
        var type = '';
        var ahref = '';
        var siteval = '';
        var outputType = textArray[1];
        title = $(this).attr('title');
        type = $(this).attr('alt');
        ahref = $(this).attr('def');
        siteval = $(this).attr('siteval') * 1;
        var fsize = "";
        var dsize = "";
        var fdsfront = "";
        var tw = "1900";
        var th = "760";
        var playType = "flv";
        var hdtype = false;
        switch (type)
        {
        case 'h.264_1800_normal':
        case '17':
            var fsize = "wh1800";
            var brate = "1800";
            var dsize = "1800";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            var hdtype = true;
            break;
        case 'h.264 1800 normal':
        case '17':
            var fsize = "wh1800";
            var brate = "1800";
            var dsize = "1800";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            var hdtype = true;
            break;
        case 'h.264_1800_wide':
        case '16':
            var fsize = "wh1800ws2";
            var brate = "1800";
            var dsize = "1800";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            var hdtype = true;
            break;
        case 'h.264 1800 wide':
        case '16':
            var fsize = "wh1800ws2";
            var brate = "1800";
            var dsize = "1800";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            var hdtype = true;
            break;
        case 'h.264_1800_wide_HD':
        case '18':
            var fsize = "wh1800ws2hd";
            var brate = "1800";
            var dsize = "1800";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            var hdtype = true;
            break;
        case "h.264 1500 wide":
        case '14':
            var fsize = "wh1500ws2";
            var brate = "1500";
            var fdsfront = "h";
            var dsize = "1500";
            var tw = "1900";
            var th = "760";
            break;
        case "h.264 1500 normal":
        case '15':
            var fsize = "wh1500";
            var brate = "1500";
            var dsize = "1500";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            break;
        case "wmv&flash 700 wide-2":
        case "9":
            var fsize = "wf700ws2";
            var fdsfront = "flash";
            var dsize = "700";
            var tw = "1900";
            var th = "760";
            break;
        case "wmv & flash 700k":
        case "wmvflash700":
        case "7":
            var fsize = "wf700";
            var fdsfront = "flash";
            var dsize = "700";
            var tw = "1900";
            var th = "760";
            break;
        case "wmvflash700_wide2":
        case "9":
            var fsize = "wf700ws2";
            var fdsfront = "flash";
            var dsize = "700";
            var tw = "1900";
            var th = "760";
            break;
        case "h.264 normal":
        case '15':
            var fsize = "wh1500";
            var brate = "1500";
            var dsize = "1500";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            break;
        case "Normal700":
        case '15':
            var fsize = "wh1500";
            var dsize = "1500";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            break;
        case "h.264 wide":
        case '14':
            var fsize = "wh1500ws2";
            var brate = "1500";
            var dsize = "1500";
            var fdsfront = "h";
            var tw = "1900";
            var th = "760";
            break;
        case "wmv700":
        case "5":
            var fsize = "w700";
            var fdsfront = "";
            var dsize = "700";
            var tw = "1900";
            var th = "760";
            playType = "wmv";
            break;
        case "wmv700ws2":
        case "10":
            var fsize = "wf700ws2";
            var fdsfront = "";
            var dsize = "700";
            var tw = "1900";
            var th = "760";
            break;
        case "wmv300":
        case "1":
            var fsize = "w300";
            var fdsfront = "";
            var dsize = "300";
            var tw = "1900";
            var th = "760";
            playType = "wmv";
            break;
        case "Brazil":
        case "13":
            var fsize = "w500";
            var fdsfront = "";
            var dsize = "300";
            var tw = "1900";
            var th = "760";
            playType = "wmv";
            break;
        default:
            break;
        }
        $(this).text('');
        $(this).removeAttr('title');
        $(this).removeAttr('alt');
        $(this).removeAttr('def');
        $(this).removeAttr('siteval');
        if (fsize != "" && vid != "")
        {
            switch (outputType)
            {
            case 'brick_home_img':
                switch (siteval)
                {
                case 108:
                default:
                    $(this).append('<a href="/tour/play.php?siteval=108&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '" title="' + title + '" class="play_up' + ((hdtype) ? 'hd' : '') + '">Play</a>');
                    break;
                case 110:
                    $(this).append('<a href="/tour/play.php?siteval=110&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '" title="' + title + '" class="play_up' + ((hdtype) ? 'hd' : '') + '">Play</a>');
                    break;
                }
                break;
            case 'brick_img':
                switch (siteval)
                {
                case 108:
                default:
                    $(this).append('<a href="/tour/play.php?siteval=108&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '?TB_iframe=true&height=' + th + '&width=' + tw + '" title="' + title + '" class="play' + ((hdtype) ? '_hd' : '') + '">Play</a>');
                    break;
                case 110:
                    $(this).append('<a href="/tour/play.php?siteval=110&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '?TB_iframe=true&height=' + th + '&width=' + tw + '" title="' + title + '" class="play' + ((hdtype) ? '_hd' : '') + '">Play</a>');
                    break;
                }
                break;
            case 'brick_home_action':
                switch (siteval)
                {
                case 108:
                default:
                    $(this).append('<a href="/tour/play.php?siteval=108&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '" title="' + title + '" class="play_up">Play</a>');
                    break;
                case 110:
                    $(this).append('<a href="/tour/play.php?siteval=110&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '" title="' + title + '" class="play_up">Play</a>');
                    break;
                }
                break;
            case 'brick_action':
                switch (siteval)
                {
                case 108:
                default:
                    $(this).append('<a href="/tour/play.php?siteval=108&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '?TB_iframe=true&height=' + th + '&width=' + tw + '" title="' + title + '" class="play">Play</a>');
                    break;
                case 110:
                    $(this).append('<a href="/tour/play.php?siteval=110&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '?TB_iframe=true&height=' + th + '&width=' + tw + '" title="' + title + '" class="play">Play</a>');
                    break;
                }
                break;
            case 'feature_home':
                switch (siteval)
                {
                case 108:
                default:
                    $(this).append('<a href="/tour/play.php?siteval=108&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '" title="' + title + '" class="play_in" style="right:0px;">Play</a>');
                    break;
                case 110:
                    $(this).append('<a href="/tour/play.php?siteval=110&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '" title="' + title + '" class="play_in" style="right:0px;">Play</a>');
                    break;
                }
                break;
            case 'feature':
            default:
                switch (siteval)
                {
                case 108:
                default:
                    $(this).append('<a href="/tour/play.php?siteval=108&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '?TB_iframe=true&height=' + th + '&width=' + tw + '" title="' + title + '" class="play" style="right:0px;">Play</a>');
                    break;
                case 110:
                    $(this).append('<a href="/tour/play.php?siteval=110&type=' + playType + '&path=' + vid + '/' + fdsfront + dsize + '/' + fsize + '?TB_iframe=true&height=' + th + '&width=' + tw + '" title="' + title + '" class="play" style="right:0px;">Play</a>');
                    break;
                }
                break;
            }
        }
        else
        {
            if (ahref != '' && ahref != 'undefined' && ahref != null)
            {
                if (vid != "")
                {
                    switch (outputType)
                    {
                    case 'brick_img':
                        $(this).append('<a href="' + ahref + '" class="play_up" alt="' + title + '">View</a>');
                        break;
                    case 'brick_home_img':
                        switch (siteval)
                        {
                        case 108:
                        default:
                            $(this).append('<a href="/tour/play.php?siteval=108&type=' + playType + '&path=' + vid + '/300/demo" title="' + title + '" class="play_up">Play</a>');
                            break;
                        case 110:
                            $(this).append('<a href="/tour/play.php?siteval=110&type=' + playType + '&path=' + vid + '/300/demo" title="' + title + '" class="play_up">Play</a>');
                            break;
                        }
                        break;
                    case 'brick_action':
                    case 'brick_home_action':
                        $(this).append('<a href="' + ahref + '" class="view" alt="' + title + '">View</a>');
                        break;
                    case 'feature':
                    default:
                        $(this).append('');
                        break;
                    }
                }
                else
                {
                    switch (outputType)
                    {
                    case 'brick_img':
                    case 'brick_home_img':
                        $(this).append('<a href="' + ahref + '" class="view" alt="' + title + '">View</a>');
                        break;
                    case 'brick_simg':
                    case 'brick_home_simg':
                        $(this).append('<a href="' + ahref + '" class="storyview" alt="' + title + '">Read</a>');
                        break;
                    case 'brick_action':
                    case 'brick_home_action':
                        $(this).append('<a href="' + ahref + '" class="view" alt="' + title + '">View</a>');
                        break;
                    case 'brick_saction':
                    case 'brick_home_saction':
                        $(this).append('<a href="' + ahref + '" class="storyview" alt="' + title + '">Read</a>');
                        break;
                    case 'feature':
                    case 'feature_home':
                        $(this).append('<a href="' + ahref + '" class="photoview" alt="' + title + '">View</a>');
                        break;
                    default:
                        $(this).append('');
                        break;
                    }
                }
            }
            else
            {
                if (outputType == 'feature')
                {
                    if (vid != "")
                    {
                        $(this).append('');
                    }
                    else
                    {
                        $(this).append('<span class="photoview" alt="' + title + '">View</span>');
                    }
                }
            }
        }
        if (outputType == "feature_home")
        {
            $(this).find(".play_in").click(function (event)
            {
                event.preventDefault();
                featureBlockPlaying = true;
                var query = $(this).attr('href').split('?');
                query = query[1];
                var qa = afParseQuery(query);
                var patha = qa.path.split('/');
                var vid = patha[0];
                var dsize = patha[1];
                var fsize = patha[2];
                var wideScreen = false;
                var pheight = 480;
                var pwidth = 640;
                var bitrate = dsize;
                var siteval = qa.siteval * 1;
                bitrate = '768';
                switch (fsize)
                {
                case 'wh1800ws2':
                case 'wh1800ws2hd':
                case 'wh1500ws2':
                case 'wf700ws2':
                    wideScreen = true;
                    break;
                }
                var fileext = ".flv";
                var fileroot = 'darkthundertrailers';
                switch (siteval)
                {
                case 108:
                default:
                    fileroot = 'darkthundertrailers';
                    switch (fsize)
                    {
                    case 'wh1800':
                    case 'wh1800ws2':
                    case 'wh1800hd':
                    case 'wh1800ws2hd':
                    case 'wh1500ws2':
                    case 'wh1500':
                        fileroot = 'darkthundertrailers/h264';
                        fileext = ".mp4";
                        break;
                    default:
                        fileext = ".flv";
                        break;
                    }
                    break;
                case 110:
                    fileroot = 'thugorgytrailers';
                    switch (fsize)
                    {
                    case 'wh1800':
                    case 'wh1800ws2':
                    case 'wh1800hd':
                    case 'wh1800ws2hd':
                    case 'wh1500ws2':
                    case 'wh1500':
                        fileroot = 'thugorgytrailers/h264';
                        fileext = ".mp4";
                        break;
                    default:
                        fileext = ".flv";
                        break;
                    }
                    break;
                }
                $('#player_layer').empty();
                if (wideScreen)
                {
                    $('#player_layer').css(
                    {
                        width: '850px',
                        height: '480px',
                        display: 'block'
                    });
                    pwidth = 850;
                }
                else
                {
                    $('#player_layer').css(
                    {
                        width: '640px',
                        height: '480px',
                        display: 'block'
                    });
                    pwidth = 640;
                }
                $('#player_layer').append('<div id="player_layer_flash"></div>');
                $('#player_layer').append('<div id="player_close_button"></div>');
                if (fsize != "demo")
                {
                    var $linkdets = $(this).closest('li').find('.details .title a');
                    var pagelink = "/tour/" + $linkdets.attr('href');
                    var pagetitle = $linkdets.text();
                    var shref = "/sendfriend/?trailer=" + encodeURIComponent(pagelink) + "&TB_iframe=true&height=500&width=550";
                    $('#player_layer').append('<a id="player_sendfriend" class="thickbox" title="Send to a Friend: ' + pagetitle + '" href="' + shref + '"></a>');
                    tb_init('.thumb_link, .thickbox, .vidLinks .play, .vidLinks .play_hd, .vidLinks .play1, .vidLinks .play2, .image .play, .image .play_hd');
                }
                $('#player_close_button').click(function (event)
                {
                    event.preventDefault();
                    featureBlockPlaying = false;
                    $('#player_layer').empty();
                    $('#player_layer').css('display', 'none');
                });
                var flashvars = {};
                if (fsize != "demo" && fsize != "w300" && fsize != "w700" && fsize != "w500")
                {
                    flashvars = {
                        file: fileroot + '/' + vid + '-' + bitrate + fileext,
                        streamer: 'rtmp://flash.pistolmedia.aebn.net/paysiteVOD',
                        controlbar: 'over',
                        bufferlength: '10',
                        autostart: true,
                        repeat: 'always'
                    }
                }
                else
                {
                    switch (suid)
                    {
                    case 39:
                    case '39':
                    default:
                        flashvars = {
                            file: "http://cdn-w.pistolmedia.com/pistolmedia/dt/graphics/flash/darkthundertrailers.mp4",
                            controlbar: 'over',
                            bufferlength: '10',
                            autostart: true,
                            repeat: 'always'
                        }
                        break;
                    case 41:
                    case '41':
                        flashvars = {
                            file: "http://cdn-w.pistolmedia.com/pistolmedia/to/graphics/flash/thugorgytrailers.mp4",
                            controlbar: 'over',
                            bufferlength: '10',
                            autostart: true,
                            repeat: 'always'
                        }
                        break;
                    }
                }
                var params = {
                    wmode: "opaque",
                    allowfullscreen: "true",
                    allowscriptaccess: "always",
                    bgcolor: '#060606'
                }
                var attributes = {}
                swfobject.embedSWF("/images/flash/player.swf?" + Math.round(1000 * Math.random()), 'player_layer_flash', pwidth, pheight, "9.0.115", false, flashvars, params, attributes);
            });
        }
        if (outputType == "brick_home_img" || outputType == "brick_home_action")
        {
            $(this).find(".play_up,.play_uphd").click(function (event)
            {
                event.preventDefault();
                featureBlockPlaying = true;
                var query = $(this).attr('href').split('?');
                query = query[1];
                var qa = afParseQuery(query);
                var patha = qa.path.split('/');
                var vid = patha[0];
                var dsize = patha[1];
                var fsize = patha[2];
                var wideScreen = false;
                var pheight = 480;
                var pwidth = 640;
                var bitrate = dsize;
                var siteval = qa.siteval * 1;
                bitrate = '768';
                switch (fsize)
                {
                case 'wh1800ws2':
                case 'wh1800ws2hd':
                case 'wh1500ws2':
                case 'wf700ws2':
                    wideScreen = true;
                    break;
                }
                var fileext = ".flv";
                var fileroot = 'darkthundertrailers';
                switch (siteval)
                {
                case 108:
                default:
                    fileroot = 'darkthundertrailers';
                    switch (fsize)
                    {
                    case 'wh1800':
                    case 'wh1800ws2':
                    case 'wh1800hd':
                    case 'wh1800ws2hd':
                    case 'wh1500ws2':
                    case 'wh1500':
                        fileroot = 'darkthundertrailers/h264';
                        fileext = ".mp4";
                        break;
                    default:
                        fileext = ".flv";
                        break;
                    }
                    break;
                case 110:
                    fileroot = 'thugorgytrailers';
                    switch (fsize)
                    {
                    case 'wh1800':
                    case 'wh1800ws2':
                    case 'wh1800hd':
                    case 'wh1800ws2hd':
                    case 'wh1500ws2':
                    case 'wh1500':
                        fileroot = 'thugorgytrailers/h264';
                        fileext = ".mp4";
                        break;
                    default:
                        fileext = ".flv";
                        break;
                    }
                    break;
                }
                $('#content_img ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
                $('#content_desc ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
                $('#content_related ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
                $('#content_details ul li[pos=' + selectedFeatureBlock + ']').fadeOut('slow');
                selectedFeatureBlock = -1;
                $('.slidebar_content ul li a[pos!=' + selectedFeatureBlock + ']').removeClass('selected');
                if ($('#content_desc ul li[pos=-1]').length > 0) $('#content_desc ul li[pos=-1]').remove();
                var $wrap_brick = $(this).closest('.home_brick');
                var fetishes = ($wrap_brick.find('.feti').html() != "") ? "<span class=\"fetitlewrap\">Categories</span><span class='fetiwrap'>" + $wrap_brick.find('.feti').html() + "</span>" : "";
                $('#content_desc ul').append('<li pos="-1" style="display: block;"><span class="titlewrap">' + $wrap_brick.find('.title').html() + '</span><span class="textwrap">' + $wrap_brick.find('.longdesc').html() + '</span>' + fetishes + '</li>');
                $('#content_desc ul li[pos=-1] .fetiwrap a').click(function (event)
                {
                    event.preventDefault();
                    var value = $(this).attr('val');
                    $('.brickFilter_Fetish ul li input[value=' + $(this).attr('val') + ']').attr('checked', true);
                    $('.brickFilter_Fetish ul li input[value!=' + $(this).attr('val') + ']').attr('checked', false);
                    load_hompage_content();
                    $.scrollTo('#member_content', 500);
                });
                $('#player_layer').empty();
                if (wideScreen)
                {
                    $('#player_layer').css(
                    {
                        width: '850px',
                        height: '480px',
                        display: 'block'
                    });
                    pwidth = 850;
                }
                else
                {
                    $('#player_layer').css(
                    {
                        width: '640px',
                        height: '480px',
                        display: 'block'
                    });
                    pwidth = 640;
                }
                $('#player_layer').append('<div id="player_layer_flash"></div>');
                $('#player_layer').append('<div id="player_close_button"></div>');
                if (fsize != "demo")
                {
                    var $linkdets = $(this).closest('.home_brick').find('.title a');
                    var pagelink = "/tour/" + $linkdets.attr('href');
                    var pagetitle = $linkdets.text();
                    var shref = "/sendfriend/?trailer=" + encodeURIComponent(pagelink) + "&TB_iframe=true&height=500&width=550";
                    $('#player_layer').append('<a id="player_sendfriend" class="thickbox" title="Send to a Friend: ' + pagetitle + '" href="' + shref + '"></a>');
                    tb_init('.thumb_link, .thickbox, .vidLinks .play, .vidLinks .play_hd, .vidLinks .play1, .vidLinks .play2, .image .play, .image .play_hd');
                }
                $('#player_close_button').click(function (event)
                {
                    event.preventDefault();
                    featureBlockPlaying = false;
                    autoShiftFeatureBlock();
                });
                var flashvars = {};
                if (fsize != "demo" && fsize != "w300" && fsize != "w700" && fsize != "w500")
                {
                    flashvars = {
                        file: fileroot + '/' + vid + '-' + bitrate + fileext,
                        streamer: 'rtmp://flash.pistolmedia.aebn.net/paysiteVOD',
                        controlbar: 'over',
                        bufferlength: '10',
                        autostart: true,
                        repeat: 'always'
                    }
                }
                else
                {
                    switch (suid)
                    {
                    case 39:
                    case '39':
                    default:
                        flashvars = {
                            file: "http://cdn-w.pistolmedia.com/pistolmedia/dt/graphics/flash/darkthundertrailers.mp4",
                            controlbar: 'over',
                            bufferlength: '10',
                            autostart: true,
                            repeat: 'always'
                        }
                        break;
                    case 41:
                    case '41':
                        flashvars = {
                            file: "http://cdn-w.pistolmedia.com/pistolmedia/to/graphics/flash/thugorgytrailers.mp4",
                            controlbar: 'over',
                            bufferlength: '10',
                            autostart: true,
                            repeat: 'always'
                        }
                        break;
                    }
                }
                var params = {
                    wmode: "opaque",
                    allowfullscreen: "true",
                    allowscriptaccess: "always",
                    bgcolor: '#060606'
                }
                var attributes = {}
                swfobject.embedSWF("/images/flash/player.swf?" + Math.round(1000 * Math.random()), 'player_layer_flash', pwidth, pheight, "9.0.115", false, flashvars, params, attributes);
                $.scrollTo('#feature_block', 500);
            });
        }
        $(this).removeClass('videoLinks').addClass('videoLinks-fixed');
    });
    tb_init('.thumb_link, .thickbox, .vidLinks .play, .vidLinks .play_hd, .vidLinks .play1, .vidLinks .play2, .image .play, .image .play_hd');
}

function openSub()
{
    wWidth = 800;
    wHeight = 600;
    wHPos = (screen.width / 2) - (wWidth / 2);
    wVPos = (screen.height / 2) - (wHeight / 2) - 50;
    if (document.all)
    {
        oWin = self.open("/subscribe/", "nvSMP", "width=" + wWidth + ",height=" + wHeight + ",location=no,top=" + wVPos + ",left=" + wHPos + ",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
        oWin.focus()
    }
    else
    {
        oWin = self.open("/subscribe/", "nvSMP", "width=" + wWidth + ",height=" + wHeight + ",location=no,screenY=" + wVPos + ",screenX=" + wHPos + ",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
        oWin.focus()
    }
}

function openApp()
{
    wWidth = 800;
    wHeight = 600;
    wHPos = (screen.width / 2) - (wWidth / 2);
    wVPos = (screen.height / 2) - (wHeight / 2) - 50;
    if (document.all)
    {
        oWin = self.open("/feedback/", "nvSMP", "width=" + wWidth + ",height=" + wHeight + ",location=no,top=" + wVPos + ",left=" + wHPos + ",personalbar=no,menubar=no,scrollbars=yes,status=no,toolbar=no")
        oWin.focus()
    }
    else
    {
        oWin = self.open("/feedback/", "nvSMP", "width=" + wWidth + ",height=" + wHeight + ",location=no,screenY=" + wVPos + ",screenX=" + wHPos + ",personalbar=no,menubar=no,scrollbars=yes,status=no,toolbar=no")
        oWin.focus()
    }
}

function openChat()
{
    wWidth = 800;
    wHeight = 515;
    wHPos = (screen.width / 2) - (wWidth / 2);
    wVPos = (screen.height / 2) - (wHeight / 2) - 50;
    if (document.all)
    {
        oWin = self.open("cams/", "nvSMP", "width=" + wWidth + ",height=" + wHeight + ",location=no,top=" + wVPos + ",left=" + wHPos + ",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
        oWin.focus()
    }
    else
    {
        oWin = self.open("cams/", "nvSMP", "width=" + wWidth + ",height=" + wHeight + ",location=no,screenY=" + wVPos + ",screenX=" + wHPos + ",personalbar=no,menubar=no,scrollbars=no,status=no,toolbar=no")
        oWin.focus()
    }
}
