$(document).ready(function () {

	//$('<div style=\'margin-bottom:10px; text-align: center;\'><a href=\'http://softwarepeople.ru/?utm_source=edconf&utm_medium=banner\' target=\'_blank\'><img src=\'images/banners/swp-430x70.gif\' alt=\'Software People 2010\' title=\'Software People 2010\' /></a></div>').prependTo('#TextBlock');

	//$('<div style="text-align:center; color:green; padding-top:50px; font-weight:bold; font-size:16px;">Сейчас идет бесплатная Online-трансляция конференции</div>').insertBefore($('#TranslationTV div'));

	var imgQuant = $(".img-container ul li").length;

	for (i = 1; i <= imgQuant; i++) {
		$(".quant-img").append("<div class='go-btn " + i + "'></div>");
	}

	$(".1").addClass("yellow-dot");

	$(".go-btn").click(function () {
		$(".go-btn").removeClass("yellow-dot");
		$(this).addClass("yellow-dot");
	});

	$(".prev").click(function () {
		$(".yellow-dot").prev().addClass("yellow-dot");
		$(".yellow-dot").next().removeClass("yellow-dot");
	});

	$(".next").click(function () {
		$(".yellow-dot").next().addClass("yellow-dot");
		$(".yellow-dot").prev().removeClass("yellow-dot");
	});


	$(".img-container").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		scroll: 1,
		visible: 1,
		circular: false,
		start: 0,
		speed: 150,

		btnGo:
		[".1", ".2", ".3", ".4", ".5", ".6", ".7", ".8", ".9"],

		beforeStart: function () {

		},
		afterEnd: function () {

		}
	});

	$("#cinform").bind("focusin", function () { if ($("#cinform").val() !== "Введите e-mail") { } else $("#cinform").val("") });
	$("#cinform").bind("focusout", function () { if ($("#cinform").val() !== "") { } else $("#cinform").val("Введите e-mail") });

});


function openReference() {
	$("#Ref").css({
		'background': 'none',
		'background-color': '#F3F9FC'
	});
	Silverlight.createObjectEx({
		source: "video/VideoPlayer.xap",
		parentElement: document.getElementById("Ref"),
		id: "SilverlightControl",
		properties: {
			initParams: "SourceUri=http://www.microsoft.com/ru-ru/events/edconf/video/CatalogRef.xml",
			width: "100%",
			height: "290",
			version: "1.1",
			enableHtmlAccess: "true"
		}
	});
}


//Registration form VALIDATOR

function checkInputs() {
	document.getElementById("count_alert").style.display = "none";

	if (document.getElementById("order-quantity").value == "") {
		document.getElementById("count_alert").style.display = "block";
		return false;
	}
	else {
		return true;
	}
}

function checkEmail() {
	document.getElementById("email_alert1").style.display = "none";
	document.getElementById("email_alert2").style.display = "none";

	if (document.getElementById("order-email").value == "") {
		document.getElementById("email_alert1").style.display = "block";
		return false;
	}
	else {
		var emailrule = new RegExp("^[0-9a-z]{1}([-_.]?[0-9a-z]{1})*[@]{1}[0-9a-z]{1}([-.]?[0-9a-z]{1})*[.]{1}[a-z]{2,4}$", "ig");
		if (emailrule.test(document.getElementById("order-email").value)) {
			document.getElementById("email_alert2").style.display = "none";
			return true;
		}
		else {
			document.getElementById("email_alert2").style.display = "block";
			document.getElementById("order-email").focus();
			return false;
		}
	}
}

function checkForm() {
	if (!(checkInputs() && checkEmail())) {
		checkEmail();
		return false;
	}
	else {
		return true;
	}
}

function renderDate() {
	var today = new Date();
	return (today.getFullYear().toString() + today.getMonth().toString() + today.getDate().toString() + today.getHours().toString() + today.getMinutes().toString() + today.getSeconds().toString());
}

function numberParticipants() {
	var number = $('#number-participants-select').val();

	switch (number) {
		case "1":
			var sum = 10000;
			var dis = (sum / 100) * 5;
			var sum = sum - dis;

			$('#AMOUNT').val(sum);
			$('#amount-view').html(sum);
			break
		case "2":
			var sum = 15000;
			var dis = (sum / 100) * 5;
			var sum = sum - dis;

			$('#AMOUNT').val(sum);
			$('#amount-view').html(sum);
			break
		default:
			var sum = (number - 2) * 7000 + 15000;
			var dis = (sum / 100) * 5;
			var sum = sum - dis;

			$('#AMOUNT').val(sum);
			$('#amount-view').html(sum);
	}
}

