
function MoaSliderDivMenu(uuid,uuidname) {
	var _objRef = this;
	
	//if($('#'+uuidname+'_dropdownlink').is(":visible"))
	{
		$('#'+uuidname).html("");
	}
	
	var sliderContainer = getDivEle();
	sliderContainer.attr('class', 'viewoptioncontainer');
	sliderContainer.attr('id', uuidname+'_container');
	
	var linkContainer = getDivEle();
	linkContainer.attr('class', uuidname+'_dropdownlink');
	linkContainer.attr('id', uuidname+'_dropdownlink');
	
	var dropdownContainer = getDivEle();
	dropdownContainer.attr('class', 'genericdropdown '+uuidname+'_dropdownmenu');
	dropdownContainer.attr('id', uuidname+'_dropdownmenu');
	
	var spanEle = getSpanEle();
	spanEle.attr('id', uuidname + '_span');
	dropdownContainer.append(spanEle);
	sliderContainer.append(linkContainer);
	sliderContainer.append(dropdownContainer);
	
	$('#'+uuidname).append(sliderContainer);
	MoaSliderclickorhover('#'+uuidname+'_dropdownlink','#'+uuidname+'_dropdownmenu');
	
}

function MoaSliderDivMenuClass(uuid,uuidname,classname,entityId, bottomOffsetEle, alternateBottomOffset, maxOffset, leftPixNormal, leftPixAdjusted, topPixNormal, topPixAdjusted) {
	var _objRef = this;
	$('#'+uuidname+'_container').html("");
	var sliderContainer = getDivEle();
	sliderContainer.attr('class', 'viewoptioncontainer');
	sliderContainer.attr('id', uuidname+'_container');
	
	var linkContainer = getDivEle();
	linkContainer.attr('class', uuidname+'_dropdownlink');
	linkContainer.attr('id', uuidname+'_dropdownlink');
	
	var dropdownContainer = getDivEle();
	dropdownContainer.attr('class', classname);
	dropdownContainer.attr('id', uuidname+'_dropdownmenu');
	
	var spanEle = getSpanEle();
	spanEle.attr('id', uuidname + '_span');
	dropdownContainer.append(spanEle);
	sliderContainer.append(linkContainer);
	sliderContainer.append(dropdownContainer);
	
	$('#'+uuidname).append(sliderContainer);
	//track_dropdown_image3_container
	MoaSliderclickorhover1('#'+uuidname+'','#'+uuidname+'_dropdownmenu', bottomOffsetEle, alternateBottomOffset, maxOffset, leftPixNormal, leftPixAdjusted, topPixNormal, topPixAdjusted);
	
}
function doTrigger(dropdownname) {
	$(dropdownname).find('div.star-rating')
			.trigger('loadRating');
};
function MoaSliderclickorhover(optionsname, dropdownname) {
	
	// Expand Panel
	var onMenu = false;
	var onImg = false;
	
	$(function() {
		$(optionsname).click(function(){
			onImg = true;
			if ($(dropdownname).is(":hidden")) 
			{
				//if (!onMenu) {$(dropdownname).slideDown("fast")};
				setTimeout(function(){if (!onMenu) $(dropdownname).slideDown('fast');},0);
				doTrigger(dropdownname);
			}
			else {
				//$(dropdownname).slideUp('fast');
				setTimeout(function(){$(dropdownname).slideUp('fast');},500);
			}
		});	
		
		$(optionsname).hover(function(){
				onImg = true;
			},function(){
				onImg = false;
				setTimeout(function(){if (!onMenu) $(dropdownname).slideUp('fast');},500);
			}
		);
			
		$(dropdownname).hover(function(){
				onMenu = true;
			},function(){
				onMenu = false;
				setTimeout(function(){if (!onImg) {$(dropdownname).slideUp('fast');}},500);
			}
		);
		
		$(dropdownname).click(function(){
			onMenu = true;
		});
		
	});		
	
}

function MoaSliderclickorhover1(optionsname, dropdownname, bottomOffsetEle, alternateBottomOffset, maxOffset, leftPixNormal, leftPixAdjusted, topPixNormal, topPixAdjusted) {
		// Expand Panel
		var onMenu = false;
		var onImg = false;
		
		$(function() {
		$(optionsname).click(
		function(e){
		onImg = true;

		//Adjust menu position if it overflows beyond the visible area of the playlist
		if(bottomOffsetEle!=null && maxOffset!=null && leftPixNormal!=null && leftPixAdjusted!=null && topPixNormal!=null && topPixAdjusted!=null){
			var offset1 =e.pageY;
			var offset;

			//when the scrolling ads  div is hidden, get the top offset of the div below it
			if($("#" + bottomOffsetEle).css("display") == "block"){
				offset = $("#" + bottomOffsetEle).offset();
			}else if($("#" + alternateBottomOffset).css("display") == "block"){
				offset = $("#" + alternateBottomOffset).offset();
			}

			if((offset.top - offset1) < maxOffset){
				$(dropdownname).attr("style", "top:" + topPixAdjusted + "px; " + "left:" + leftPixAdjusted + "px;");
			}else{
				$(dropdownname).attr("style", "top:" + topPixNormal + "px; " + "left:" + leftPixNormal + "px;");
			}		
		}
		
		if ($(dropdownname).is(":hidden")) 
		{
		setTimeout(function(){
			if (!onMenu) $(dropdownname).slideDown("fast");
			},0);
		doTrigger(dropdownname);
			}
		else {
				setTimeout(function(){
				 $(dropdownname).slideUp('fast');
				},500);
		}
		});
		

		$(optionsname).hover(
		function(){
		onImg = true;
		//$('#menu').fadeIn('fast');
		},
		function(){
		onImg = false;
		setTimeout(function(){
		if (!onMenu) $(dropdownname).slideUp('fast');
		},500);
		}
		);
		$(dropdownname).hover(
		function(){
		onMenu = true;
		},
		function(){
		onMenu = false;
		setTimeout(function(){
		if (!onImg) {$(dropdownname).slideUp('fast');}
		},500);
		}
		);
		
		});	
		
		$(dropdownname).click(
				function(){
					onImg = true;
					return false;
				});
	}

function getDivEle() {
	return $("<div></div>").clone();
}
function getSpanEle() {
	return $("<span></span>").clone();
}
