$(document).ready(function () {
var master = "tch_id";
var slave = "std_id";
var master_tmp;
var slave_tmp;
var timer;
var sync = function () {
if ($(this).attr('id') == slave) {
master_tmp = master;
slave_tmp = slave;
master = slave;
slave = master_tmp;
}
$("#" + slave).unbind("scroll");
var ypercentage = this.scrollTop / (this.scrollHeight - this.offsetHeight);
var xpercentage = this.scrollLeft / (this.scrollWidth - this.offsetWidth);
var y = ypercentage * ($("#" + slave).get(0).scrollHeight - $("#" + slave).get(0).offsetHeight);
var x = xpercentage * ($("#" + slave).get(0).scrollWidth - $("#" + slave).get(0).offsetWidth);
$("#" + slave).scrollTop(y);
$("#" + slave).scrollLeft(x);
if (typeof (timer) !== 'undefind')
clearTimeout(timer);
timer = setTimeout(function () { $("#" + slave).scroll(sync) }, 200)
}
$('#' + master + ', #' + slave).scroll(sync);
});