$(document).ready(function(){
		$('.mainmenu>li').hover(function() {
				$('ul', this).show();
				$('ul>li>ul', this).hide();
			}, function() {
				$('ul', this).hide(); 
			});
		$('.panel>li').hover(function() {
				$('ul', this).show();
			}, function() {
				$('ul', this).hide();
			});
		$('.mainmenu>li>ul>li').hover(function() {
			var curleft = contleft = 0;
			if(this.offsetParent){
				curleft = this.offsetWidth;
				obj = this;
				do{
					curleft += obj.offsetLeft;
				}while(obj = obj.offsetParent);
				
				obj = $('#layout')[0];
				contleft = obj.offsetWidth;
				do{
					contleft += obj.offsetLeft;
				}while(obj = obj.offsetParent);
			}
			
			var tmp = $('ul', this);
			if(curleft + 200 > contleft){
				tmp.addClass('posright');
			}
			tmp.show();
		}, function(){
			$('ul', this).hide();
		});
		
		$("#inner .poll ul li ul:first").addClass('active');
		
		var pollID = $("#inner .poll ul li>a:first").attr('id');;
		var active = pollID;
			
		$("#inner .poll ul li>a").live('click', function() {
			// Show content
			pollID = $(this).attr("id");
			$("."+active).removeClass("active");
			$("."+pollID).addClass("active");
			active = pollID;
			return false;
		});
		
});