$('.iframe').load(function() {
var first = false;
$('.iframe').contents().find("body").bind('keydown', function() {
var countdown = $("#countdown");
var text = $('.iframe').contents().find("body");
var slice = text.html().slice(1,10);
if(!first) {
if (text.html().length > 13) {
text.focus();
var t = slice;
text.html('');
text.html(t);
first = true;
} else {
countdown.val(13-text.html().length);
}
} else {
if (text.html().length > 9) {
text.html(slice);
} else {
countdown.val(10-text.html().length);
}
}
});
});
var first = false;
$('.iframe').contents().find("body").bind('keydown', function() {
var countdown = $("#countdown");
var text = $('.iframe').contents().find("body");
var slice = text.html().slice(1,10);
if(!first) {
if (text.html().length > 13) {
text.focus();
var t = slice;
text.html('');
text.html(t);
first = true;
} else {
countdown.val(13-text.html().length);
}
} else {
if (text.html().length > 9) {
text.html(slice);
} else {
countdown.val(10-text.html().length);
}
}
});
});