var char = 0;
var caption = "";
var standby;

function ck() {
    var inputVal = $("#getCode").val(); //.replace(" ","");
    var getUrl = "http://my.harvestmark.com/ResponsePage.aspx?Code=" + inputVal;
    if (inputVal != '' && inputVal != "        |         |         |    ") {
        window.location = getUrl;
    }
}

$(function () {

    $("#getCode").Watermark("        |         |         |    ");
    $("#getUrl").click(ck);
    $(document).keyup(function (e) {
        if (e.keyCode == 13) {
            ck();
        }
    });

    $('#getCode').keyup(function (e) {
        var new_length = $(this).val().length;

        if ((new_length + 1) % 5 == 0 && (e.keyCode != 8 && e.keyCode != 46)) {
            $(this).val($(this).val() + ' ');
        }

        if ($(this).val().length > 19) {
            $(".tracebtn1").addClass("glow");
        }
        if ($(this).val().length < 19) {
            $(".tracebtn1").removeClass("glow");
        }

    });
    $(".homenews").click(function () {
        location.href = $(this).attr("href");
    });
});


function showCaption(obj) {
    caption = obj.attr('title');
    if (caption)
        type();
}

function typefromflash() {
    document.getElementById('getCode').style.color = "#333333";
    caption = "6344 8455 7413 ACM1";
    type();
    showTips();
    return "ok";
}

function showTips() {
    $('#flashLayer').html("").hide();
}

function type() {
    $('.tracecode1').val(caption.substr(0, char++));
    if (char < caption.length + 1)
        setTimeout("type()", 68);
    else {
        char = 0;
        caption = "";
    }

    if (char == 0) {
        $(".tracebtn1").addClass("glow");
    }
}

function autotyping() {
    $('.seeexample').each(function () {
        $(this).click(function () {
            showCaption($(this));
        })
    });
}


$(function () {
    autotyping();
    var tracetutorial = '<object id="tracetutorial" type="application/x-shockwave-flash" data="http://cdn.yottamark.com/media/flash/TraceTutorial.swf" width="377" height="227">' +
            '<param name="movie"  value="http://cdn.yottamark.com/media/flash/TraceTutorial.swf" />' +
            '<param name="allowScriptAccess" value="always" />' +
            '<param name="wmode" value="transparent" />' +
          '</object>';

    $('.seeexample').click(function () {
        //$('.video').addClass("video2");

        $('#flashLayer').html("").html(tracetutorial);
        $('#flashLayer').show();
        showCaption($(this))
    });

});

