$AR.client.crawltext = {
    //--------- Customization ----------
    linkHover: "#f57d2f", // may ue either HexDec or alpha names
    alignTo: "left", // this ignored if float positioning is used
    floatTo: "top", // float positioning = top, bottom or "", use lower case
    useWidth: 410,  // minimum is 350 pixels, CANNOT use width %;

    crawlText: [],
    linkItem: [],
    crawlContainer: "",
    crawlHolder: "",
    currMsg: 0,
    xV: 0,
    saveXV: 0,
    leftStr: 0,

    openLink: function() {
        var tc = $AR.client.crawltext;
	    document.location.href = tc.linkItem[tc.currMsg];
    },

    stayHome: function() {	
    	var ct = $AR.client.crawltext,
    	    nV = 0;
    	if(!document.body.scrollTop){
    	    nV = document.documentElement.scrollTop;
    	}
    	else {
    	    nV = document.body.scrollTop;
    	}
    	setTimeout("$AR.client.crawltext.stayHome()",50);
    },
    
    startCrawl: function(){
        var ct = $AR.client.crawltext,
    	    currPos = ct.crawlHolder.scrollLeft;
    	if (currPos >= ct.crawlHolder.scrollWidth-parseInt(ct.useWidth))
    		{
    		 if (ct.currMsg < ct.crawlText.length-1)
    			{
    			 ct.currMsg++;
    			}
    		 else 	{
    		 	 ct.currMsg = 0;
    			}
    		 ct.crawlHolder.scrollLeft = 0;
    		 ct.init3();
    		}
    	else 	{
    		 ct.crawlHolder.scrollLeft = currPos + 1.5;
    		 setTimeout("$AR.client.crawltext.startCrawl()",15);
    		}
    },

    buildCrawlBox: function(){
        var ct = $AR.client.crawltext,
            cc = ct.crawlContainer = document.getElementById('iText');
        cc.onmouseover = function(){
            cc.style.cursor = "pointer";
            cc.style.color = ct.linkHover;
        };
         cc.onmouseout = function(){
             cc.style.color = ct.textColor;
        };
        cc.onclick = ct.openLink;
    },
    
    feed: function(xml){
        var ct = $AR.client.crawltext;
        $(xml).find('item').each(function(){
            ct.crawlText.push($(this).find('title').text());
            ct.linkItem.push($(this).find('link').text());
        });
        ct.init2();
    },

    init3: function() {
    	this.crawlContainer.innerHTML = this.crawlText[this.currMsg];
    	this.startCrawl();
    },

    init2: function(){
        var ct = $AR.client.crawltext;
        ct.leftStr = Math.round((screen.width-ct.useWidth-36)/2);
    	ct.crawlContainer = document.getElementById('iText');
    	ct.xV  = document.getElementById('isFloat').offsetTop-4;
    	ct.crawlHolder = document.getElementById('isFloat');
    	ct.crawlHolder.style.width = ct.useWidth;
    	ct.crawlContainer.style.paddingLeft = Math.round(parseInt(document.getElementById('isFloat').style.width)/3)*3+'px';
    	ct.crawlContainer.style.paddingRight = Math.round(parseInt(document.getElementById('isFloat').style.width)/3)*3+'px';
    	ct.stayHome();
    	ct.init3();
    },
    
    init: function(feed){
        this.buildCrawlBox();
        $(document).ready(function(){
            var dataType = ($.browser.msie) ? "text" : "xml";
            $.ajax({
                type: "GET",
                url: "rss.asp?feed=" + feed,
                dataType: dataType,
                success: function(xml) {
                    $AR.client.crawltext.feed($AR.ie_xml(xml));
            	}
            });
        });
    }
};

