﻿$(document).ready(function () {
    $('.bbnav a').each(function (i) {
        if (document.location.pathname == $(this).attr('href'))
            $(this).addClass("active");
    });

    $('#cmsContentBody_Content6_cmsContentBody_CommunitySearch4_rbMembers').attr('checked', true);
    $('#cmsContentBody_Content6_cmsContentBody_CommunitySearch4_lblSearch').text('');
    $('#cmsContentBody_Content6_cmsContentBody_CommunitySearch4_txtSearch').focus(function () {
        $(this).attr('value', '');
    });
    $('#cmsContentBody_Content6_cmsContentBody_CommunitySearch4_txtSearch').blur(function () {
        if ($('#cmsContentBody_Content6_cmsContentBody_CommunitySearch4_txtSearch').attr('value') == "")
            $('#cmsContentBody_Content6_cmsContentBody_CommunitySearch4_txtSearch').attr('value', 'Search for more Babes');
    });
    $('#cmsContentBody_Content6_cmsContentBody_CommunitySearch4_txtSearch').blur();
    $('.bbrnav .mostviewed li:eq(0)').css({ 'border-left': '5px solid #000', 'border-right': '4px solid #000' });
    $('.bbrnav .mostviewed li:eq(2)').css({ 'border-left': '4px solid #000', 'border-right': '5px solid #000' });

    $('.upload input:eq(1)').prependTo('.upload').css({ 'width': '100%', 'margin-bottom': '100px', 'display': 'block' });

    $('#pnlContestantImages li').each(function (i) {
        $(this).find('a').eq(0).text('Make this my profile picture');
        $(this).find('a').eq(1).css({ 'text-transform': 'uppercase', 'background': '#013b8c', 'padding': '5px 0 15px' })
    });

    $('.bbrnav .inviteafriend').parent().css({ 'margin-bottom': '20px' });

    $('.uranswers dt span:eq(1)').css({ 'float': 'right' });

    // remove right margin for every 4th image.
    $('.photo_list li').each(function (i) {
        if (i % 4 == 3) {
            $(this).css({ 'margin-right': '0' });
        }
    });

    RepositionBodyBackgroundForAds();


    if (isIE6()) {
        $('.bbrnav .faceoff .vs').css({ 'background-image': 'url(http://static.zoodaily.com.au/assets/images/beachbabes/2011/vs.gif)' });

        /*
        $('div,img,span').filter(function (index) {
        return $(this).css('float') == 'left' || $(this).css('float') == 'right';
        }).css('display', 'inline');
        */

        // submit button hovers
        $('.form .btn input, .form .button input,.form li.button input, .form_container li.button input, .form .btn .submit_details').hover(
            function () {
                $(this).css({ 'background-position': '0 -209px' });
            },
            function () {
                $(this).css({ 'background-position': '0 -160px' });
            }
        );

        $('.form li input#cmsContentBody_Content8_cmsContentBody_CommunityRegister2_ctl00_btnUsernameVerify').hover(
            function () {
                $(this).css({ 'background-position': '-713px -106px' });
            },
            function () {
                $(this).css({ 'background-position': '-713px -70px' });
            }
        );

        $('.upload .UploadButton').hover(
            function () {
                $(this).css({ 'background-position': '0 -209px' });
            },
            function () {
                $(this).css({ 'background-position': '0 -160px' });
            }
        );
    }
    //    $('img').filter(function (i) {
    //        return $(this).attr('src').startsWith('/assets');
    //    }).each(function(i) {
    //        var src = $(this).attr('src');
    //        $(this).attr('src', src.replace(/^\/assets/g, 'http://zooweekly.com.au/assets'));
    //    });

    $('.bblist .list #profile_list li').each(function (i) {
        if (i % 4 == 3) {
            $(this).css({ 'margin-right': '0' });
        }
    });
});

function isIE6() {
    return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined));
}

function RepositionBodyBackgroundForAds() {
    var DefaultBrandingHeight = 243;

    var bgPositionTop = $('#branding').offset().top - DefaultBrandingHeight + $('#branding').height();
    $('body').css({ 'background-position': 'center ' + bgPositionTop + 'px' });
}

String.prototype.startsWith = function (str) { return (this.match("^" + str) == str) }


