﻿/// <reference path="../JqueryJs/jquery-1.2.6-vsdoc.js"/>
var alertName = "";
$(function() {
    if ($('input.showPaymentProcessAlert').val().toLowerCase() == "true") {
        showPaymentProcessingAlert();
    }
    if ($('input.showBuyPointsProcessingAlert').val().toLowerCase() == "true") {
        showBuyPointsProcessingAlert();
    }
    $('.NewlyAdded').show();
    $('.MostViewed').show();
    //    $('#s4').after('<div id="nav" class="nav">').cycle({
    //        fx: 'fade',
    //        speed: 'slow',
    //        timeout: 8000,
    //        pager: '#nav'
    //    });
    $('a[rel*=facebox]').facebox({});

    //    $('#homeSlideshowSignUpLink').click(function() {
    //        var url = $('#Login .SignUpLink').attr("info");
    //        signUpWnd = radopen(url, 'rwSignUp');
    //    });

    //    if ($('#itemsGreen a').length > 6) {
    //        $('#scrollable1').scrollable();
    //    }

    //    if ($('#itemsMaroon a').length > 6) {
    //        $('#scrollable2').scrollable();
    //    }
    $('a.prev').css({ "opacity": "0.7" });
    $('a.prev').hover(function() {
        $(this).css({ "opacity": "1" });
    }, function() {
        $(this).css({ "opacity": "0.7" });
    });
    $('a.next').css({ "opacity": "0.7" });
    $('a.next').hover(function() {
        $(this).css({ "opacity": "1" });
    }, function() {
        $(this).css({ "opacity": "0.7" });
    });
    $('#itemsGreen a').each(function() {
        var ListingData = $(this).children('div').children('#listingData').val();
        //var loc = "Listing/ListingDetail.aspx?data=" + ListingData;
        var loc = "Listing/ListingDetail.aspx?Listingid=" + ListingData;
        $(this).attr('href', loc);

        $(this).children('div').unbind('click');
        $(this).children('div').bind('click', function() {
            location.href = loc;
        });
    });
    $('#itemsMaroon a').each(function() {
        var ListingData = $(this).children('div').children('#listingData').val();
        //var loc = "Listing/ListingDetail.aspx?data=" + ListingData;
        var loc = "Listing/ListingDetail.aspx?Listingid=" + ListingData;
        $(this).attr('href', loc);

        $(this).children('div').unbind('click');
        $(this).children('div').bind('click', function() {
            location.href = loc;
        });
    });
    ResizeWindow();
});
function ResizeWindow() {
    if ($('.showSlideshow').val() == "1") {
        $('#TopDivHome').show();
        $('#Slideshow').show();
    }
    else {
        $('#TopDivHome').hide();
        $('#Slideshow').hide();
        if ($('.alerts').height() > 355) {
            var AlertHeight = $('.alerts').height() + 22;
            $('.alertsImage').height(AlertHeight.toString());
            $('.alertsImage').css('height', AlertHeight.toString() + 'px');
        }
        else {
            $('.alerts').height(357);
            $('.alerts').css('height', '357px');
            $('.alertsImage').height(379);
            $('.alertsImage').css('height', (357 + 22).toString() + 'px');
        }
    }
}
function SaveAlertSetting(id, name, chkName) {

    if ($('.' + chkName + ' input[type="checkbox"]').attr("checked") == true) {
        alertName = name;
        IUserInfoService.HideUserAlert(id, onHideAlertSuccess, onHideAlertFailure);
    }
    else {
        jQuery.facebox('Please select the check box.');
    }
    return false;
}
function onHideAlertSuccess(result, context, methodName) {
    if (alertName == "Category") {
        $('.subsribeToEmail').hide();
        $('.addCatgeorySubVisible').val("0");

    }
    else if (alertName == "Profile") {
        $('.addProfile').hide();
        $('.addProfileVisible').val("0");
    }
    if ($('.addProfileVisible').val() == "0" && $('.addCatgeorySubVisible').val() == "0") {
        $('.tips').hide();
    }
    ResizeWindow();
}
function onHideAlertFailure(error, context, methodName) {
    alert(error.get_message());
}
function listingControlEnter(obj, event) {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13) {
        document.getElementById(obj).click();
        StopPropagation(event);
        return false;
    }
    else {
        return true;
    }
}
function LoadHomeIntro() {
    // ResizeWindow();
    if (typeof AC_FL_RunContent == 'function') {
        AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '473',
			'height', '350',
			'src', 'Images/Flash/HomeIntro',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'HomeIntro',
			'bgcolor', '#ffffff',
			'name', 'HomeIntro',
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess', 'sameDomain',
			'movie', 'Images/Flash/HomeIntro',
			'salign', '',
			'documentElement', 'Slideshow'
			); //end AC code
    }
}
function showPaymentProcessingAlert() {
    $.facebox({ div: '#divPaymentProcessing' });
    return false;
}
function showBuyPointsProcessingAlert() {
    $.facebox({ div: '#divBuyPointsProcessing' });
    return false;
}
function closePaymentProcessingAlert() {
    $(document).trigger('close.facebox');
    return false;
} 

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();