setInterval(
    function () {
        $('#loading').animate({rotate: '+=10deg'}, 0);
    },
    20
);

$(function () {
	var slidenum = 1;
	$("#slide_right").click (function () {
		var maxLeft = (940*10) * -1;
		var currentPOS = $("#form_slide").css("marginLeft");
		currentPOS = currentPOS.replace("px", "");
		currentPOS = currentPOS*1;
		if (!$("#form_slide").is(':animated')) {
			if (currentPOS == maxLeft) {
				$("#form_slide").animate({ marginLeft: "0px" }, 500, "swing");
				slidenum = 1;
				document.getElementById("slide_stage").innerHTML=slidenum;
			} else {
				currentPOS-=940;
				$("#form_slide").animate({ marginLeft: currentPOS }, 500, "swing");
				++slidenum;
				document.getElementById("slide_stage").innerHTML=slidenum;
			}
		}
	});
	$("#slide_left").click (function () {
		var maxLeft = (940*10) * -1;
		var currentPOS = $("#form_slide").css("marginLeft");
		currentPOS = currentPOS.replace("px", "");
		currentPOS = currentPOS*1;
		if (!$("#form_slide").is(':animated')) {
			if (currentPOS == 0) {
				$("#form_slide").animate({ marginLeft: maxLeft }, 500, "swing");
				slidenum = 11;
				document.getElementById("slide_stage").innerHTML=slidenum;
			} else {
				currentPOS = (currentPOS+940);
				$("#form_slide").animate({ marginLeft: currentPOS }, 500, "swing");
				--slidenum;
				document.getElementById("slide_stage").innerHTML=slidenum;
			}
		}
	});
	$("#slide_cancel").click (function () {
		window.location = "http://www.nviff.com/manage/score.cfm";
	});
	$("#slide_cancel_scored").click (function () {
		window.location = "http://www.nviff.com/manage/my_scores.cfm";
	});
	rotateIt();
	$('.error').hide();
});

function showValue(newValue,i) {
    RoundValue = (Math.floor(newValue*100))/100;
    if (i == 10) {
    	document.getElementById("range_"+i).innerHTML = RoundValue.toFixed(2);
    } else {
    	document.getElementById("range_"+i).innerHTML = RoundValue;
    }
    TotalValue = 0;
    for ( var x=1, y=10; x<y; ++x ) {
    	TotalValue = TotalValue + parseFloat(document.getElementById("range_"+x).innerHTML);
    }
    TotalValue = (TotalValue/90)*100;
    RoundedTotal = (Math.floor(TotalValue*100))/100;
    document.getElementById("range_total").innerHTML = RoundedTotal;
	document.getElementById("score_total").value = RoundedTotal;
}

function showLightBox(screener, wab) {
	$("#lightbox").css({visibility:"visible"});
	if (wab == "yes") {
		$("#please-wait").css({visibility:"visible"});
		$("#screener").css({width:"575px",height:"628px",visibility:"hidden"});
		$("#screener").attr("src", screener);
		$("#screener").load(showIFRAME());
		$("#video-mask").css({width:"440px",height:"440px",margin:"-220px 0px 0px -220px"});
		$("#video-player").css({marginTop:"-188px",marginLeft:"-135px",width:"575px",height:"628px"});
		//rotateIt();
	} else if (wab == "no") {
		$("#please-wait").css({visibility:"hidden"});
		$("#screener").css({width:"640px",height:"480px",visibility:"hidden"});
		$("#screener").attr("src", "http://www.nviff.com/manage/screener.cfm?id=" + screener);
		$("#screener").load(showIFRAME());
		$("#video-mask").css({width:"640px",height:"480px",margin:"-240px 0px 0px -320px"});
		$("#video-player").css({margin:"0px",width:"640px",height:"480px"});
	} else if (wab == "maybe") {
		$("#please-wait").css({visibility:"hidden"});
		$("#screener").css({width:"640px",height:"480px",visibility:"hidden"});
		$("#screener").attr("src", "http://www.nviff.com/manage/request.cfm?id=" + screener);
		$("#screener").load(showIFRAME());
		$("#video-mask").css({width:"640px",height:"480px",margin:"-240px 0px 0px -320px"});
		$("#video-player").css({margin:"0px",width:"640px",height:"480px"});
	} else if (wab == "vimeo") {
		$("#please-wait").css({visibility:"hidden"});
		$("#screener").css({width:"640px",height:"363px",visibility:"hidden"});
		$("#screener").attr("src", screener);
		$("#screener").load(showIFRAME());
		$("#video-mask").css({width:"660px",height:"564px",margin:"-201px 0px 0px -20px"});
		$("#video-player").css({margin:"0px",width:"640px",height:"363px"});
	}
}

function rotateIt() {
	//$('#loading').animate({ WebkitTransform: 'rotate(' + degree + 'deg)' }, 600, "linear", rotateIt(180));
	//$('#loading').animate({rotate: '+=10deg'}, 1000, 'linear', rotateIt());
}

function showIFRAME() {
	//$("#please-wait").css({visibility:"hidden"});
	$("#screener").css({visibility:"visible"});
}

function hideLightBox() {
	$("#please-wait").css({visibility:"hidden"});
	$("#lightbox").css({visibility:"hidden"});
	$("#screener").attr("src", "");
}

function showINFO(tracking) {
	$('.' + tracking).slideToggle('easeOutElastic');
	toggleButton(tracking);
}

function toggleButton(tracking) {
	var sCheck = $('.' + tracking + '_button').html();
	if (sCheck == '[') {
		$('.' + tracking + '_button').html(']');
	} else if (sCheck == ']') {
		$('.' + tracking + '_button').html('[');
	}
}

function filmCategories(category) {
	if (category == "All") {
		$('.film_container').show();
	} else {
		$('.film_container').hide();
		$('.film_container#' + category).show();
	}
	$('.film_category_active').removeClass("film_category_active").addClass("film_category");
	$('#' + category + '_tab').removeClass("film_category").addClass("film_category_active");
}
