var TextWrapper={_GetNodeListByTagName:function(a){return(a.scopeId?document.getElementById(a.scopeId):document.body).getElementsByTagName(a.tagName)},_GetNodeListByClassName:function(d){var a=[];var c=(d.scopeId?document.getElementById(d.scopeId):document.body).getElementsByTagName("*");for(var b=0;b<c.length;b++){if(c[b].className==d.className){a.push(c[b])}}return a},_GetNodeList:function(b){var a=[];if(b.tagName){a=this._GetNodeListByTagName(b)}else{if(b.className){a=this._GetNodeListByClassName(b)}}return a},_WrapImpSpecific:function(c,a,b){c.innerHTML="<span>"+a.slice(0,b).join(" ")+"</span>&nbsp;"+a.slice(b).join(" ")},_WrapImpAuto:function(b,a){b.innerHTML="<span>"+a.splice(0,Math.floor(a.length/2)).join(" ")+"</span>&nbsp;"+a.join(" ")},_WrapText:function(b,c){var a=b.innerHTML.replace(/^\s+|\s+$/g,"").split(/\s+/);switch(c){case"auto":this._WrapImpAuto(b,a);break;default:this._WrapImpSpecific(b,a,c);break}},Wrap:function(d){var a=this._GetNodeList(d);var c=d.words||"auto";for(var b=0;b<a.length;b++){this._WrapText(a[b],c)}}};

jQuery.noConflict();

jQuery(document).ready(function(){
	var $i_width = '52px'
	var i=0;
	
	count = parseInt(jQuery('#rotator a').size());
	
	var p_link = jQuery('#rotator a:eq(0)');
	var c_link = jQuery('#rotator a:eq(1)');
	var n_link = jQuery('#rotator a:eq(2)');

	jQuery("#rotator a:eq(1)").children('img').width('105px');
	jQuery("#rotator a:eq(0)").children('img').width('54px');
	jQuery("#rotator a:eq(0)").children('img').height('auto');
	jQuery("#rotator a:eq(2)").children('img').width('54px');
	jQuery("#rotator a:eq(2)").children('img').height('auto');
	
	p_link.attr({'id':'p_link'});
	c_link.attr({'id':'c_link'});
	n_link.attr({'id':'n_link'});
	
	jQuery('#rotator a').each(
		function(){
			jQuery(this).attr({'pos':i++});			
		}
	)
	
	jQuery(p_link).before("<div id='p_bt'>&lt;</div><div id='n_bt'>&gt;</div>");
	
		/*jQuery('#n_bt').attr({'title':jQuery("#n_link img").attr('alt')});	
		jQuery('#p_bt').attr({'title':jQuery("#p_link img").attr('alt')});
		jQuery('#c_link').attr({'title':jQuery("#c_link img").attr('alt')});*/
		
			
		
		
		hover_init();
		
		function hover_init(){			
			jQuery('#n_bt').mouseenter(function(){
				jQuery('.tool-tip').html('<div class="tool-title"><!--x--></div><div class="tool-text">'+jQuery("#n_link img").attr('alt')+'</div>');
			});
			jQuery('#p_bt').mouseenter(function(){
				jQuery('.tool-tip').html('<div class="tool-title"><!--x--></div><div class="tool-text">'+jQuery("#p_link img").attr('alt')+'</div>');
			});
			jQuery('#c_link').mouseenter(function(){	
				jQuery('.tool-tip').html('<div class="tool-title"><!--x--></div><div class="tool-text">'+jQuery("#c_link img").attr('alt')+'</div>');
			});
		
			jQuery('#n_bt, #p_bt, #c_link').hover(
				function(){
					$tips = jQuery('.tool-tip');
					$obj_h = jQuery(this).height();								
					$obj_w = jQuery(this).width();								
					var offset = jQuery(this).offset();
					jQuery($tips).css({'visibility':"visible",'left':offset.left+$obj_w/2-70, 'top': offset.top+$obj_h, 'opacity' : ".8",'display':'block'});
					
				},
				function(){
					$tips = jQuery('.tool-tip');
					jQuery($tips).hide();
				}
			);
		}
		

	jQuery('#n_bt').click(function(){
		tmp = parseInt(jQuery('#c_link').attr('pos'));
		
		curr = (tmp+1);
		next = (curr+1);
		prev = (curr-1);
		
		if(curr==(count-1))
		{
			next=0;
		}
		
		if(curr==(count))
		{
			curr = 0;
			next = 1;
		}
		
		
		jQuery('#rotator a').attr({'id':''});	
		jQuery("#rotator a:eq("+(curr)+")").attr({'id':'c_link'});
		jQuery("#rotator a:eq("+(curr)+")").children('img').width('105px');
		jQuery("#rotator a:eq("+(next)+")").attr({'id':'n_link'});
		jQuery("#rotator a:eq("+(next)+")").children('img').width('54px');
		jQuery("#rotator a:eq("+(next)+")").children('img').height('auto');
		jQuery("#rotator a:eq("+(prev)+")").attr({'id':'p_link'});
		jQuery("#rotator a:eq("+(prev)+")").children('img').width('54px');
		jQuery("#rotator a:eq("+(prev)+")").children('img').height('auto');
				
		hover_init();
		jQuery('.tool-tip').html('<div class="tool-title"><!--x--></div><div class="tool-text">'+jQuery("#n_link img").attr('alt')+'</div>');
	});
	
	
	jQuery('#p_bt').click(function(){
		tmp = parseInt(jQuery('#c_link').attr('pos'));
		
		curr = (tmp-1);
		next = (curr+1);
		prev = (curr-1);
		
		if(curr== -1)
		{
			prev=count-2;
			curr=count-1;
			next=0;		
		}
		
		if(curr==0)
		{
			prev=count-1;		
		}
		
		
		jQuery('#rotator a').attr({'id':''});	
		jQuery("#rotator a:eq("+(curr)+")").attr({'id':'c_link'});
		jQuery("#rotator a:eq("+(curr)+")").children('img').width('105px');
		jQuery("#rotator a:eq("+(next)+")").attr({'id':'n_link'});
		jQuery("#rotator a:eq("+(next)+")").children('img').width('54px');
		jQuery("#rotator a:eq("+(next)+")").children('img').height('auto');		
		jQuery("#rotator a:eq("+(prev)+")").attr({'id':'p_link'});
		jQuery("#rotator a:eq("+(prev)+")").children('img').width('54px');
		jQuery("#rotator a:eq("+(prev)+")").children('img').height('auto');		
				
		hover_init();
		jQuery('.tool-tip').html('<div class="tool-title"><!--x--></div><div class="tool-text">'+jQuery("#p_link img").attr('alt')+'</div>');
	});
	
})
