﻿//jQuery.fn.isTextBox = function () {
//	return $(this).is("input[type='text'],input[type='password']");
//}

//jQuery.fn.isDropDownList = function () {
//	return $(this).is("select");
//}

//jQuery.fn.isCheckBox = function () {
//	return $(this).is(":checkbox");
//}

//jQuery.fn.isRadioButton = function () {
//	return $(this).is(":radio");
//}

$(document).ready(function () {
	$("#city-select-text").click(function () {
		$("ul.subnav").slideDown('fast');
		return false;
	});

	$("ul.topnav").hover(function () {},
		function () { $("ul.subnav").slideUp('normal'); }
	);
});

var dealTimerInstance;

function dealTimer()
{
	var currentTime = new Date().getTime();
	currentTime = dealEndTime - currentTime + offset;
	var msec = currentTime % 1000;
	currentTime = (currentTime - msec) / 1000;
	var sec = (currentTime % 60 < 0) ? 0 : currentTime % 60;
	currentTime = (currentTime - sec) / 60;
	var min = (currentTime % 60 < 0) ? 0 : currentTime % 60;
	currentTime = (currentTime - min) / 60;
	var hour = (currentTime % 24 < 0) ? 0 : currentTime % 24;
	currentTime = (currentTime - hour) / 24;
	var day = (currentTime < 0) ? 0 : currentTime;
	if (day == 0)
	{
		$("#counter_day_span").hide();
		$("#countdown").css("font-size", "13px");
	}
	$("#counter_day").html(day);
	if (day == 0 && hour == 0) {
		$("#counter_hour_span").hide();
		$("#countdown").css("font-size", "14px");
	}
	$("#counter_hour").html(hour);
	if (day == 0 && hour == 0 && min == 0) {
		$("#counter_min_span").hide();
		$("#countdown").css("font-size", "15px");
	}
	$("#counter_min").html(min);
	$("#counter_sec").html(sec);

	if (day == 0 && hour == 0 && min == 0 && sec == 0)
	{
		clearTimeout(dealTimerInstance);
		window.location.reload(true);
		return;
	}

	dealTimerInstance = window.setTimeout("dealTimer()", 1000);
}

function setProgress(red, green)
{
	$("#red").width(red / 100 * 64);
	$("#green").width(green / 100 * 118);
}

function bindModalOnClick(id, url)
{
	var u = url;
	$(id).click(function(e)
	{
		e.preventDefault();
		$.modal('<iframe src="' + u + '" frameborder="0" style="border:0;width:580px;height:510px">', {
			overlayId: 'terms-overlay',
			containerId: 'terms-container',
			escClose: false
		});
	});
}

function gcct(ccfirstdigit) {
	if (!ccfirstdigit || ccfirstdigit.length != 1)
		return "unk";
	if (ccfirstdigit == "4")
		return "visa";
	if (ccfirstdigit == "5")
		return "mc";
	if (ccfirstdigit == "3")
		return "amex";
}

//var oldValidatorUpdateDisplay;
//var oldPage_ClientValidate;
//$(document).ready(function () {
//	if (typeof ValidatorUpdateDisplay != 'undefined') {
//		oldValidatorUpdateDisplay = ValidatorUpdateDisplay;
//		ValidatorUpdateDisplay = function (validator) {
//			if (validator.controltovalidate == undefined)
//				return;

//			//console.log(validator.controltovalidate + " " + validator.isvalid);

//			var controlToValidate = $("#" + validator.controltovalidate);
//			if (controlToValidate.length == 0)
//				return;

//			if (!controlToValidate.get(0).allValidatorsValid)
//				return;

//			if (validator.isvalid)
//				controlToValidate.removeClass("invalid_control");
//			else
//				controlToValidate.addClass("invalid_control");

//			controlToValidate.get(0).allValidatorsValid = controlToValidate.get(0).allValidatorsValid && validator.isvalid;
//		};
//	}

//	if (typeof Page_ClientValidate != 'undefined') {
//		oldPage_ClientValidate = Page_ClientValidate;

//		Page_ClientValidate = function (validationGroup) {
//			if (typeof (Page_Validators) == "undefined") {
//				console.log("no page validators");
//				return true;
//			}

//			$(Page_Validators).each(function (i, k) {
//				console.log(k);
//				document.getElementById(k.controltovalidate).allValidatorsValid = true;
//			});

//			return oldPage_ClientValidate(validationGroup);
//		}
//	}
//});


