﻿/// <reference path="../../webedit/dotnet/js/jquery-1.3.1-vsdoc.js" />

$(document).ready(function() {
    $('#btn_widget1').click(function() {
        window.location = "travel_offers_search.asp?terid=1015&DestinationID=" + $("#Widget1DestinationID").val() + "&TypeID=" + $("#Widget1TypeID").val();
    });

    $(".counter-number").each(function(i) {
        $(this).attr('id', 'num' + i);
    });
    loadinput();

    if ($('#motoring_postcode').length > 0) {
        $('#motoring_postcode').watermark('Enter suburb or postcode');
    }
    //    if ($('#numgo'.length > 0)) {
    //        setInterval("loadinput()", 47000);
    //    }

    $('#motoring_btn').click(function() {
        var p = ($('#motoring_postcode').val() == "Enter suburb or postcode") ? "" : $('#motoring_postcode').val();
        var m = ($('#motoring_surround').attr("checked")) ? "false" : "";
        window.location = "your_car_results.asp?TerID=208&repairer=" + $('#motoring_repairer').val() + "&postcode=" + p + "&surround=" + m;
        return false;
    });

    if ($('#car_review').length > 0) {
        $('#car_review').watermark('Enter make and/or model');
    }

    $('#btn_widget9').click(function() {
        var p = ($('#car_review').val() == "Enter make and/or model") ? "" : "&action=SEARCH&keyword=" + $('#car_review').val();
        window.location = "tech_library_search.asp?SecID=95" + p;
        return false;
    });



    $('#widget10').flash(
        { src: 'assets2009/flash/widget.swf',
            width: 773,
            height: 70,
            wmode: 'transparent',
            flashvars: { btn_link: 'http://www.raa.com.au/page.aspx?TerID=1295' }
        },
        { version: 8 }
    );

    $('#widget11').flash(
        { src: 'assets2009/flash/widget2.swf',
            width: 773,
            height: 70,
            wmode: 'transparent',
            flashvars: { btn_link: 'http://www.raa.com.au/page.aspx?TerID=1341' }
        },
        { version: 8 }
    );


});



function loadinput() {
    var newval = $(".numgo").val();  //parseInt($(".numgo").val());
    //$(".numgo").val(newval + 1)
    loadticker(newval);
}

function loadticker(ticnum) {
    var fticnum = ticnum;
    var numheight = 28;
    addticker(fticnum);
    if (ticnum && ticnum != 0) {
        var s = String(fticnum);

        for (i = s.length; i >= 0; i--) {
            var onum = s.charAt(i);
            $("#num" + i).attr('value', onum);
        }

        $(".counter-number").each(function() {
            var nval = $(this).attr("value");

            if (!isNaN(nval)) {
//                if (nval == 0) {
//                    $(this).css('top','0px');
//                }
//                else
//                {
                    var nheight = Number(nval) * numheight * -1;
                    $(this).animate({ top: nheight + 'px' }, 1500);
                //}
            }
        });
    }
}

function addticker(newnum) {
    var digitcnt = $(".counter-number").size();
    var nnum = String(newnum).length;
    var digitdiff = Number(nnum - Number(digitcnt));
    if (digitdiff < 0) {
        var ltdig = (Number(nnum) - 1);
        $(".counter-number:gt(" + ltdig + ")").remove();
    }

    for (i = 1; i <= digitdiff; i++) {
        $(".counter-wrap").append('<div class="counter-number" id="num' + (Number(digitcnt + i - 1)) + '">&nbsp;</div>');
    }
}
