﻿function hotspotRedirect(url, target, imagePath) {
	if (target == '_blank') {
		window.open(url, 'hotspot_window');
	} else {
		location.href = url;
	}
}

$(document).ready(function () {

	$(".tiptip").tipTip();

	$('.watermarked').each(function () {
		$(this).watermark('watermark', $(this).attr('title'));
	});

	$('select.transparent').each(function () {


		if (this.options.length > 0) {
			var option = this.options[this.selectedIndex];
			var val = $(this).val();
			var text = $(option).text();
			if (val == undefined || val == '')
				val = text;

			$(this).parent().find('.optiontext').text(text);

			$(this).bind('change', function () {
				var option = this.options[this.selectedIndex];
				var val = $(this).val();
				var text = $(option).text();
				if (val == undefined || val == '')
					val = text;

				$(this).parent().find('.optiontext').text(text);
			});
		}

	});


	$("#recoverPasswordForm").bind("submit", function () {

		var email = $("#recoverPasswordEmail").val();

		if (email.length < 1) {
			$("#recoverPasswordEmailValidation").show();
			$.fancybox.resize();
			return false;
		}

		$("#recoverPasswordEmailValidation").hide();
		$.fancybox.resize();
		$.fancybox.showActivity();

		$.ajax({
			type: "GET",
			cache: false,
			url: "/async/RecoverPassword.aspx",
			dataType: 'json',
			data: { email: email },
			success: function (data) {
				var cssClass = 'error';
				if (data.statusCode == 'Ok') {
					cssClass = 'success';
				}

				$.fancybox('<div class="' + cssClass + '">' + data.message + '</div>');
			}
		});
		return false;
	});



});


function CheckBoxRequired_ClientValidate(source, args) {
	args.IsValid = $("input[type='checkbox']").is(':checked');
}


window.onload = function () {
	$('.widgetRow').each(function () {
		var maxHeight = 0;
		$(this).find('.box').each(function () {
			maxHeight = Math.max(maxHeight, $(this).height());
		}).css('min-height', maxHeight + 'px');
	});
}
