﻿/// <reference path="../jquery/1.2.6-vsdoc.js"/>
// global variables
var signUpWnd = null;
var resetPassWnd = null;
$(function() {
    if ($('.contestHighlight').length) {

        $('.contestHighlight').effect("pulsate", { times: 5 }, "slow");
        $('.GiveAwaysDiv').mouseover(function() {
            $('.contestHighlight').effect("highlight", { 'color': '#842439' }, 2000);
            $('.pointerCursor').css({ 'cursor': 'pointer' });
        });
    }
    $('.floatingFeedback').aqFloater({ attach: 'se' });
    $('.floatingFeedback').click(function() {
        $.dimScreen(500, 0.7, function() {
            jQuery.facebox({ div: '#showfeedback' });
            setupFeedback();
        });

    });


    $('.RightHoverAccordion').show();
    //show the correct login controls
    if ($('.nickname').val() != "" && $('.greendollar').val() != "") {
        $('#headerCatchPhrase').css("display", "none");
        $('.Login').css("display", "none");
        $('.LoginError').css("display", "none");
        $('.LoginSuccessful').css("display", "block");
        //$('.LoginSuccessfulMessage').html("Welcome, " + $('.nickname').val() + "!<br/><div style='float: left; margin-top: 5px; padding-top: 2px;'>You have </div><div class='greenDollarAmount greenDollarAmountinDB'><font class='WineFontColor'>" + $('.greendollar').val() + "</div></font><div style='float: left; margin-top: 5px; padding-top: 2px;'> trading points.</div>")
        //$('.LoginSuccessfulMessage').html("Welcome, " + $('.nickname').val() + "!<br/><div style='float: left; margin-top: 5px; padding-top: 2px;'>You have </div><div id='greenDollarAmount' style='margin-left:3px;width:12px; float:Left' class='greenDollarAmount floatLeft'></div><div style='float: left;margin-top:7px;margin-right:2px'><font class='WineFontColor'>" + $('.greendollar').val() + "</font></div><div style='float: left; margin-top: 5px; padding-top: 2px;'> trading points.</div>")
        $('.LoginSuccessfulMessage').html("Welcome, " + $('.nickname').val() + "!<br/><div style='float: left; margin-top: 5px; padding-top: 2px;'></div><div id='greenDollarAmount' style='margin-left:3px;width:12px; float:Left' class='greenDollarAmount floatLeft'></div><div style='float: left;margin-top:7px;margin-right:2px' class='GDALabel'><font class='WineFontColor'>" + $('.greendollar').val() + "</font></div><div style='float: left; margin-top: 5px; padding-top: 2px;'> trading points </div><div style='float:left;margin-top: 5px; padding-top: 2px;'></div><div id='walletAmount' style='margin-left:3px;float:Left' class='walletAmount floatLeft'></div><div style='float: left;margin-top:7px;margin-right:2px;margin-left:3px;' class='walletALabel'><font class='WineFontColor'>" + $('.walletA').val() + "</font></div><div style='float: left; margin-top: 5px; padding-top: 2px;'> wallet balance</div>")

        $('.LoginSuccessfulMessage').css("display", "block");

        //firefox 2 does not support inline-block
        if (BrowserDetect.browser == "Firefox") {
            if (BrowserDetect.version < 3) {
                $('.TheDBMenu').css({ "display": "inline" });
            }
            else {
                $('.TheDBMenu').css({ "display": "inline-block" });
            }
        }
        else {
            $('.TheDBMenu').css({ "display": "inline-block" });
        }

        $('.GeneralMenu').css({ "display": "none" });
    }
    else {
        //$('#pendingTasksContainer').css("display", "none");
    }

    if ($('.inthenewshidden').val() != "0") {
        $('.inthenews').css("display", "inline");
    }
    else {
        $('.inthenews').css("display", "none");
    }

    $('.sellerLink').each(function() {
        $(this).bind('click', function() {
            var url = $(this).attr('info');
            //radopen(url, 'rwSeller');
            jQuery.showAkModal(url, 'Profile', 700, 500, true);
            return false;
        });
    });

    if ($('.buyPointsHidden').val() == "1") {
        $('.BuyPointsMenu').css("display", "inline");
        $('.BuyPointsMenu').click(function() {
            if ($('.isHomePage').val() == "Yes") {
                jQuery.showAkModal("MessageForms/BuyTradingPoints.aspx?page=" + $('.pageurl').val(), "Buy Trading Points", 600, 270);
            }
            else {
                jQuery.showAkModal("../MessageForms/BuyTradingPoints.aspx?page=" + $('.pageurl').val(), "Buy Trading Points", 600, 270);
            }

            return false;
        });
    }
    else {
        $('.BuyPointsMenu').css("display", "none");
    }
});



function ShowSignUp() {
    var url = $('#Login .SignUpLink').attr("info");
    //signUpWnd = radopen(url, 'rwSignUp');
    location.href = url;
    return false;
}
function ShowForgotPassword() {
    var url = $('#Login .forgotPasswordLink').attr("info");
    //resetPassWnd = radopen(url, 'rwPass');
    location.href = url;
    return false;
}
function closeRadWindows() {
    if (signUpWnd != null)
        signUpWnd.close();
    if (resetPassWnd != null)
        resetPassWnd.close();
}
function HandleKeyDown(e) {
    var key = e.keyCode || e.charCode;
    if (key == 13) {
        setTimeout('Search()', 500);
    }
    return false;
}
function Search() {
    var sText = $('.txtSearch1')[0].value;
    var catId = $('.saveCatid')[0].value;
    var includeTitleDesc = $('.includeTitleDesc input[type=checkbox]').attr('checked');
    PurpleParrot.SwapSite.WebUI.Services.Search.getSearchLink(sText, catId, includeTitleDesc, onHandleKeySucc, onHandleKeyFailure);
    return false;
}
function onUserPwdKeyDown(e) {
    var key = e.keyCode || e.charCode;
    if (key == 13) {
        loginUser();
    }
}
function onHandleKeySucc(result) {
    window.location = result;
}
function onHandleKeyFailure(error) {
    alert(error.get_message());
}


if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();