// Javascript Document

function unpaid(text, id) {
    $(id).replace(text);
    trackPhone(id);
}

function setManageCat(catId) {
	window.location.href = 'manage-vendor-pages?do=manage&catid='+catId;
	return false;
}

function trackPhone(id) {
    var url = '/ajax/track-unpaid-phone/?id='+id;
    new Ajax.Request(url);
}



window.onload = function() {
    if ( $('incorrect-fact') != null ) {
        var factId = $('incorrect-fact').innerHTML;
        $('incorrect-fact').replace('<a href="mailto:seocontactus@gmail.com?subject=Incorrect Fact in '+factId+ '" class="hover-only">Contact us if this fact is wrong.</a>');
    }

    var marquee = Class.create({
        initialize: function(div) {
            this.div = $(div);
            this.text = this.div.innerHTML;
            this.width = this.div.getWidth();
            this.height = this.div.getHeight();
        },

        startScroll: function() {
            this.div.update('<div id="marquee-wrap">'+this.text+'</div>');
            var wrap = $('marquee-wrap');
            wrap.style.color='red';
            wrap.style.position = 'absolute';
            wrap.style.whiteSpace = 'nowrap';
            wrap.style.left = '0px';
            var counter = 0;
            var repeat = 1/20;
            new PeriodicalExecuter(
                function(pe) {
                    counter--;
                    wrap.style.left = counter+'px';
                    if ( counter < -wrap.getWidth() ) {
                        counter = wrap.up('div').getWidth();
                    }
            }, repeat);
        }
    })

    if ( $('marquee') != null ) {
        var scroll = new marquee('marquee');
        scroll.startScroll();
    }
}

