var Settings_MainSection = "Menu_Users",Settings_SubSection=Settings_LastLinkViewed="SubMenu_Users", Settings_SubSectionHightlight = -1;

function iWatch(sOption,iID) {
	// if (!protectMembers()) return false;
}

function iDidNotWatch(sOption,iID) {
	if (UserIsOnline) {
		$.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-movies.asp?rnd="+new Date().getTime(),
		   data: {act:"updateViewStatus",id:iID,viewStatus:0},
		   success: function(msg){
				
		   }
		});
	}
}

function ShowOverviewModel(sModelID) {

	$("#DetailsFrameObjects").children().css("display","none");
	$("#"+sModelID).css("display","block");

	if (sModelID == "model_overview" || sModelID == "model_watch") {
		if ($("#"+sModelID+"_userreviews").html() != "")
			return;
		var sModelToTakeTheCode = sModelID == "model_overview" ? "model_watch" : "model_overview";
		$("#"+sModelID+"_userreviews").html($("#"+sModelToTakeTheCode+"_userreviews").html());
		$("#"+sModelToTakeTheCode+"_userreviews").html("");

		$("#more-button").css("display",sModelID == "model_watch"?"block":"none");
		
	}

	Overview_SetButtonHovers();
	location.href = "#"+sModelID.replace("model_","");
	SwitchBottomBanner();

	if (sModelID == "model_overview")
	{
		SwitchBanner("leftPanel-nov","leftPanel-nov");
		SwitchBanner("banner468x60overviewNov","468x60overviewNov");
	}

}

function LoadOverviewModel(sModel,iMovieID,oEl) {

	if (!oEl)
		var oEl = $("#tab-item-"+sModel).get(0).parentNode;

	$(oEl).parent().children().removeClass("selected");
	$(oEl).addClass("selected");

	$("#DetailsFrameObjects").children().css("display","none");
	$("#details-frame-loader").css("display","block");
	
	var sModelID = "model_"+sModel;
	if (!$("#"+sModelID).length) {
		var oParams = {act:"getModelSource",id:iMovieID,list:sModel};
		if (sModel == "overview" || sModel == "watch") {
			oParams.getreviews = $("#model_overview_userreviews").html()=="" && $("#model_watch_userreviews").html()=="";
		}
		$.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-movies.asp?rnd="+new Date().getTime(),
		   data: oParams,
		   success: function(msg) {
				$("#DetailsFrameObjects").append(msg);
				ShowOverviewModel(sModelID);			
		   }
		});
	} else {
		ShowOverviewModel(sModelID);
	}
}

function Wizard(sIdToHide,sIdToShow,bFade) {
	if (!bFade) {
		document.getElementById(sIdToHide).style.display = 'none';
		document.getElementById(sIdToShow).style.display = 'block';
	} else {
		$("#"+sIdToHide).css("display","none");
		$("#"+sIdToShow).fadeIn(300);
	}
}


function WannaSee(want,fFunc,bShowLoginIfNeeded) {

	//if (UserIsOnline) {

		$.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-movies.asp?rnd="+new Date().getTime(),
		   data: { act:"updateViewStatus",id:movieId,viewStatus:want ? 2 : 3 },
		   success: function(msg){

			if (fFunc)
				fFunc();
		   }
		});

	if (!UserIsOnline && bShowLoginIfNeeded)
		protectMembers();

	/*} else if (bShowLoginIfNeeded)
	{
		
	}*/
}

function ResizeBox() {
	var iActorImgSize = document.getElementById("actorimg").offsetHeight;
	document.getElementById("picOval").style.marginTop = (iActorImgSize+2) + "px";
	document.getElementById("actorRCnt").style.height = (iActorImgSize-8) + "px";
}

var iCommentsPage = 1;
function ShowNextComments(type,params) {

	$("#Overview_ShowMoreItems").html("<img src=\"/images/icons/status/ajax-loader.gif\" style=\"padding-top:4px;\" alt=\"\" />");
	getComment(type,params,function(msg) {

		$("#comments-list").append(msg);
		CommentsCurrentSettings.pageIndex++;

		if (CommentsCurrentSettings.pageIndex > CommentsCurrentSettings_PageCount)
			$("#comments-more-button").css("display","none");

		$("#Overview_ShowMoreItems").html("more");
		$("#comments-list").children("LI").removeClass("last").filter(":last").addClass("last");
	});

}

function OverviewTab_Hover(oEvent) {

	var oEl = window.addEventListener ? oEvent.target : oEvent.srcElement;

	if (oEl.tagName == "UL")
		return;

	if (oEl.tagName != "LI")
		oEl = $(oEl).parents("LI:first").get(0);

	$(oEl).addClass("selected");
	
}

function OverviewTab_Out(oEvent) {
	var oEl = window.addEventListener ? oEvent.target : oEvent.srcElement;
	if (oEl.tagName == "UL")
		return;

	if (oEl.tagName != "LI")
		oEl = $(oEl).parents("LI:first").get(0);


	$(oEl).removeClass("selected");


}

function Overview_SwapButton() {
	$(".watchwizclick").each(function() {
		this.onclick = function() {
			location.href = $(this).attr("data-request-url");
		}
	});
	$(".btnaddtowatchlist").fadeOut(200);
	setTimeout(function() {
		$(".watchlistaddedstatus").fadeIn(500);
	},205);
}

function Overview_SetButtonHovers() {
		$(".btn-gradiant-grey-ingreybg").filter(function() {
		
			return (!$(this).hasClass("no-events"));


		}).bind("mouseover",function() {
			$(this).addClass("btn-gradiant-grey-ingreybg-hover");
		}).bind("mouseout",function() {
			$(this).removeClass("btn-gradiant-grey-ingreybg-hover");
		});

		$(".btn-gradiant-grey").bind("mouseover",function() {
			$(this).addClass("btn-gradiant-grey-hover");
		}).bind("mouseout",function() {
			$(this).removeClass("btn-gradiant-grey-hover");
		});
}

function ShowStars(iAnswerSelected,objectName) {

	document.getElementById('title_question').innerHTML = 'You ranked this '+objectName+' as';

	for (var i=1;i<=10;i++) {
		document.getElementById("star"+i).className = document.getElementById("star"+i).className.replace(/\-full/gi,"-empty");
		document.getElementById("startwo_"+i).className = document.getElementById("startwo_"+i).className.replace(/\-full/gi,"-empty");
	}

	for (var i=1;i<=iAnswerSelected;i++) {
		document.getElementById("star"+i).className = document.getElementById("star"+i).className.replace(/\-empty/gi,"-full");
		document.getElementById("startwo_"+i).className = document.getElementById("startwo_"+i).className.replace(/\-empty/gi,"-full");
	}

	$("#list-action-staractivator").addClass("hover");
	$("#StarsDialogNov").children().css("display","none");
	$("#Wizard_Watched2").css("display","block");
	$("#starscontainer2").css("display","block");
	$("#StarsDialogNov").css("display","block");		

	AddFlopMessage(iAnswerSelected);
	$("#hit-tooltip").css("display","none");
	$("#flop-tooltip").css("display","none");
	_CurrentStarRate = iAnswerSelected;
}
