function animateMarquee() {

    var elm = $('#zx-customers ul.zx-customers-content')[0];
    
    if(elm){
    	var width = elm.offsetWidth;
    	var half = 0 - 5200;
    	var scrollPos = 0;
    	var ani;
    	
    	elm.style.width = width + 'px';
    	
    	function marqAni (stop){
            if(stop == 'stop'){
                clearInterval(ani); return;
            }
            
            ani = setInterval(function() {
                if(!window_focus){
                    return false;
                }
                
                scrollPos -= 1;
 				elm.style.left = scrollPos + 'px';
  			
 				if(scrollPos == Math.round(half)) {
                    scrollPos = 0;
                    elm.style.left = 0 + 'px';
                }
  			}, 30);
    	};
    	
    	marqAni();
    	
        elm.onmouseover = function(e){
            if(!e){
                e = window.event;
                target = window.event.srcElement;
            } else {
                target = e.target;
            }
    		
            if(target.nodeName == 'A') {
        		marqAni('stop');
        			
                var a = {name: target.name, url: target.href};
        		var desc = (target.nextSibling.nodeName != '#text') ? target.nextSibling : target.nextSibling.nextSibling;
        		var desc = (desc.textContent) ? desc.textContent : desc.innerText;
        		var mouseX = (e.clientX) ? e.clientX + document.body.scrollLeft : e.pageX;
        		var mouseX = (findPos(target))[0] - 112;
        		var timer = setTimeout(function() {
                    //tip
        		}, 500);
                    
        		target.onmouseout = function(){
                    clearTimeout(timer);
                    marqAni();
        		}
            }
    	};
	}
}		

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
    	do {
    		curleft += obj.offsetLeft;
    		curtop += obj.offsetTop;
    	} while (obj = obj.offsetParent);
    	return [curleft,curtop];
	}
}

$(function(){
    
    animateMarquee();
    
    $('#zx-illegal .slide').bind('click', function(){
        var $T = $(this), $O = $('#zx-illegal .zx-illegal-content'), $O_P = $O.position();
        
        if($T.is('.slide-left')){
            if($O_P.left <= 0){
                $O.animate({'left':'0px'}, { duration: 500, queue: false });
                return false;
            }
            $O.animate({'left':'+=120px'}, { duration: 500, queue: false });
        } else {
            $O.animate({'left':'-=120px'}, { duration: 500, queue: false });
        }
    });
    
});
