jQuery.validator.addMethod("checkIPURL", function(value, element) {//if the value is IP or URL --> validates
	if (value.match(/^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/) || value.match(/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/)) {
		return true;
	} else {
		return false;
	}
}, "Letters or punctuation only please"); 


jQuery.validator.addMethod("checkPushBoxcarAddress", function(value, element) {												   														   													
	if(value.indexOf('@push.boxcar') >= 0) {   
		return false;
	} else {
		return true;
	}
}, ""); 




$(document).ready(function() {  
						   					   
	jQuery.extend({ //function to get response of an ajax request
		getValues: function(url) {
			var result = null;
			$.ajax({
				url: url,
				type: 'get',
	
				async: false,
				success: function(data) {
					result = data;
				}
			});
			return result;
		}
	});						   
						   
						   
	$("#startNowBox").hide();
	$("#signInBox").hide();
	$("#forgotPasswordForm").hide();
	$("#signUpFormSuccess").hide();
	$("#signInFormSuccess").hide();
	$("#forgotPasswordFormSuccess").hide();
	$("#resendUserActivationEmailLink").hide();
	$("#resendUserActivationEmailSuccess").hide();
	$("#addNewMonitorBalloon").hide();
	$("#newMonitorFormSuccess").hide();
	$("#editPersonalInfoFormSuccess").hide();
	$("#editEmailInfoForm").hide();
	$("#editEmailInfoFormSuccess").hide();
	$("#addMobileAlertContactFormSuccess").hide();
	$("#addEmailAlertContactFormSuccess").hide();
	$("#addTwitterAlertContactFormSuccess").hide();
	$("#addIOSPushAlertContactFormSuccess").hide();
	$("#addIOSPushAlertContactFormInstantSuccess").hide();
	$(".errorStartStopAlertContact").hide();
	$("#addMobileAlertContactForm").hide();
	$("#addEmailAlertContactForm").hide();
	$("#addTwitterAlertContactForm").hide();
	$("#addIOSPushAlertContactForm").hide();
	$("#mobileAlertContactValueWrap").hide();
	$("#newHTTPMonitorHTTPAuthenticationWrap").hide();
	$("#newKeywordMonitorHTTPAuthenticationWrap").hide();
	$("#monitorSpecificAPIKeyNotExists").hide();
	$("#monitorSpecificAPIKeyExists").hide();
	$("#settingPageAPIWrapper").hide();
	$("#monitorSpecificAPIKeyMonitorID").val(0);
	
	
	
	$("#newHTTPMonitor").hide();
	$("#newKeywordMonitor").hide();
	$("#newPingMonitor").hide();
	$("#newPortMonitor").hide();
	
	$("#newPortMonitorCustomPortWrapper").hide();
	
	if ($("#apiKeyDisplay").html()){
		$("#apiKeyNotExists").hide();
	} else {
		$("#apiKeyDisplayWrapperHidden").hide();
	}
	
	
	
	
	
	


	$("#settingPageAPITitleShowHide").click( function() {
		if ($("#settingPageAPIWrapper").is(":hidden")) {
			$("#settingPageAPIWrapper").slideToggle("slow");
			$("#settingPageAPITitleShowHide").html("hide details");
		} else {
			$("#settingPageAPIWrapper").slideToggle("slow");
			$("#settingPageAPITitleShowHide").html("show details");
		}
	}); 

 

	
	$(".startNow").click( function() {
		if ($("#startNowBox").is(":hidden")) {
			$("#signInBox").fadeOut("slow");
			$("#startNowBox").fadeIn("slow");
		} else {
			$("#startNowBox").fadeOut("slow");
		}
	});  
	$(".signIn").click(function() {
		if ($("#signInBox").is(":hidden")) {
			$("#startNowBox").fadeOut("slow");
			$("#signInBox").fadeIn("slow");
		} else {
			$("#signInBox").fadeOut("slow");
		}
	}); 
	$("#forgotPasswordText").click(function() {
		$("#signInForm").fadeOut("slow", function(){
			$("#forgotPasswordForm").fadeIn("slow");									
		});
	}); 
	$("#signInText").click(function() {
		$("#forgotPasswordForm").fadeOut("slow", function(){
			$("#signInForm").fadeIn("slow");									
		});
	}); 
	$("#signInTextFromForgotPass").click(function() {
		$("#forgotPasswordFormSuccess").fadeOut("slow", function(){
			$("#signInForm").fadeIn("slow");									
		});
	}); 
	$("#resendUserActivationEmail").click(function() {
		$.ajax({
			type: "POST",
			url: "includes/dml/userDML.asp?action=resendUserActivationEmail&userEmail=" + $("#signInEmail").val(),
			success: function(theResponse){
				if (theResponse == "false") {

				} else {
					$("#resendUserActivationEmailLink").hide();
					$(".errorSignIn").html("");
					$("#resendUserActivationEmailSuccess").show();
				}
			}
		});
	});
	
	
	$(".addNewMonitor").click(function(){
		if ($("#addNewMonitorBalloon").is(":hidden")) {
			$("#addNewMonitorBalloon").fadeIn("slow");
		} else {
			$("#addNewMonitorBalloon").fadeOut("slow");
		}		
	});
	
	$("#monitorType").change(function() {
		if ($("#monitorType").val() == 0){	
			$("#newHTTPMonitor").slideUp("slow");
			$("#newKeywordMonitor").slideUp("slow");
			$("#newPingMonitor").slideUp("slow");
			$("#newPortMonitor").slideUp("slow");
		}
										 
		if ($("#monitorType").val() == 1){
			if ($("#newKeywordMonitor").is(":visible")) {
				$("#newKeywordMonitor").slideUp("slow", function(){
					$("#newHTTPMonitor").slideDown("slow");
				});
			} else if ($("#newPingMonitor").is(":visible")) {
				$("#newPingMonitor").slideUp("slow", function(){
					$("#newHTTPMonitor").slideDown("slow");
				});
			} else if ($("#newPortMonitor").is(":visible")) {
				$("#newPortMonitor").slideUp("slow", function(){
					$("#newHTTPMonitor").slideDown("slow");
				});
			} else {
				$("#newHTTPMonitor").slideDown("slow");
			}
			$("#HTTPMonitorContactsWrap").load("includes/dml/monitorDML.asp?action=GetAlertContactsListBox");
		}
		
		if ($("#monitorType").val() == 2){
			if ($("#newHTTPMonitor").is(":visible")) {
				$("#newHTTPMonitor").slideUp("slow", function(){
					$("#newKeywordMonitor").slideDown("slow");
				});
			} else if ($("#newPingMonitor").is(":visible")) {
				$("#newPingMonitor").slideUp("slow", function(){
					$("#newKeywordMonitor").slideDown("slow");
				});
			} else if ($("#newPortMonitor").is(":visible")) {
				$("#newPortMonitor").slideUp("slow", function(){
					$("#newKeywordMonitor").slideDown("slow");
				});
			} else {
				$("#newKeywordMonitor").slideDown("slow");
			}
			$("#KeywordMonitorContactsWrap").load("includes/dml/monitorDML.asp?action=GetAlertContactsListBox");
		}
		
		if ($("#monitorType").val() == 3){
			if ($("#newHTTPMonitor").is(":visible")) {
				$("#newHTTPMonitor").slideUp("slow", function(){
					$("#newPingMonitor").slideDown("slow");
				});
			} else if ($("#newKeywordMonitor").is(":visible")) {
				$("#newKeywordMonitor").slideUp("slow", function(){
					$("#newPingMonitor").slideDown("slow");
				});
			} else if ($("#newPortMonitor").is(":visible")) {
				$("#newPortMonitor").slideUp("slow", function(){
					$("#newPingMonitor").slideDown("slow");
				});
			} else {
				$("#newPingMonitor").slideDown("slow");
			}
			$("#PingMonitorContactsWrap").load("includes/dml/monitorDML.asp?action=GetAlertContactsListBox");
		}
		if ($("#monitorType").val() == 4){
			if ($("#newHTTPMonitor").is(":visible")) {
				$("#newHTTPMonitor").slideUp("slow", function(){
					$("#newPortMonitor").slideDown("slow");
				});
			} else if ($("#newKeywordMonitor").is(":visible")) {
				$("#newKeywordMonitor").slideUp("slow", function(){
					$("#newPortMonitor").slideDown("slow");
				});
			} else if ($("#newPingMonitor").is(":visible")) {
				$("#newPingMonitor").slideUp("slow", function(){
					$("#newPortMonitor").slideDown("slow");
				});
			} else {
				$("#newPortMonitor").slideDown("slow");
			}
			$("#PortMonitorContactsWrap").load("includes/dml/monitorDML.asp?action=GetAlertContactsListBox");
		}
	});
	
	$("#newHTTPMonitorHTTPAuthenticationWrapLink").click( function() {
		$("#newHTTPMonitorHTTPAuthenticationWrap").slideToggle("slow");
	});
	$("#newKeywordMonitorHTTPAuthenticationWrapLink").click( function() {
		$("#newKeywordMonitorHTTPAuthenticationWrap").slideToggle("slow");
	});

	
	$("#newPortMonitorPort").change(function() {
		if ($("#newPortMonitorPort").val() == 99){	
			$("#newPortMonitorCustomPortWrapper").slideDown("slow");
		} else {
			$("#newPortMonitorCustomPortWrapper").slideUp("slow");
		}
	});
	
	
	$(".editMonitor").live("click", function(){
		var editMonitorIDValSplitter 	= (this.id).split("_");
		var editMonitorIDVal 			= editMonitorIDValSplitter[1];	
		if ($("#editMonitorBalloon").is(":visible")) {

		} else {
			$("#editMonitorWrap_" + editMonitorIDVal).load("includes/editMonitor.asp?monitorID=" + editMonitorIDVal).fadeIn("slow");
			$("#editMonitorFormSuccess").hide();
		}
	});
	
	$(".closeEditMonitor").live("click", function(){
		if ($("#editMonitorBalloon").is(":visible")) {
			$("#editMonitorBalloon").fadeOut("slow", function(){
				$("#editMonitorBalloon").empty()
				$("#editMonitorBalloon").remove()
			});
		}
	});

	$(".startStopMonitor").live("click", function(){
		var startStopMonitorIDValSplitter 	= (this.id).split("_");
		var startStopMonitorIDVal 			= startStopMonitorIDValSplitter[1];	
		$.ajax({
			type: "POST",
			url: "includes/dml/monitorDML.asp?action=startStopMonitor&monitorID=" + startStopMonitorIDVal,
			success: function(theResponse){
				$("#startStopMonitorLink_" + startStopMonitorIDVal).empty();
				$("#startStopMonitorLink_" + startStopMonitorIDVal).html(theResponse);
				//alert (theResponseString);
				if ((theResponse).indexOf("play") > 0) { //checking if the response includes keyword: "play"
					$("#statusCSS_" + startStopMonitorIDVal).css({'background-color' : '#000000'});
				} else {
					$("#statusCSS_" + startStopMonitorIDVal).css({'background-color' : '#9c9b9b'});
				}
			}
		});
	});
	
	
	$(".deleteMonitor").live("click", function(){
		var deleteMonitorIDValSplitter 	= (this.id).split("_");
		var deleteMonitorIDVal 			= deleteMonitorIDValSplitter[1];	
		if ($("#deleteMonitorBalloon").is(":visible")) {

		} else {
			$("#deleteMonitorWrap_" + deleteMonitorIDVal).load("includes/deleteMonitor.asp?monitorID=" + deleteMonitorIDVal).fadeIn("slow");
			$("#deleteMonitorFormSuccess").hide();
		}
	});
	
	$(".closeDeleteMonitor").live("click", function(){
		if ($("#deleteMonitorBalloon").is(":visible")) {
			$("#deleteMonitorBalloon").fadeOut("slow", function(){
				$("#deleteMonitorBalloon").empty()
				$("#deleteMonitorBalloon").remove()
			});
		}
	});
	

	$(".refreshMonitor").live("click", function(){
		var refreshMonitorIDValSplitter 	= (this.id).split("_");
		var refreshMonitorIDVal 			= refreshMonitorIDValSplitter[1];	
		if ($("#refreshMonitorBalloon").is(":visible")) {

		} else {
			$("#refreshMonitorWrap_" + refreshMonitorIDVal).load("includes/refreshMonitor.asp?monitorID=" + refreshMonitorIDVal).fadeIn("slow");
			$("#refreshMonitorFormSuccess").hide();
		}
	});
	
	
	$(".reportMonitor").live("click", function(){
		var reportMonitorIDValSplitter 	= (this.id).split("_");
		var reportMonitorIDVal 			= reportMonitorIDValSplitter[1];	
		if ($("#reportMonitorBalloon").is(":visible")) {

		} else {
			$("#reportMonitorWrap_" + reportMonitorIDVal).load("includes/reportMonitor.asp?monitorID=" + reportMonitorIDVal).fadeIn("slow");
			$("#reportMonitorFormSuccess").hide();
		}
	});
	
	$(".closeReportMonitor").live("click", function(){
		if ($("#reportMonitorBalloon").is(":visible")) {
			$("#reportMonitorBalloon").fadeOut("slow", function(){
				$("#reportMonitorBalloon").empty();
				$("#reportMonitorBalloon").remove();
			});
		}
	});
	
	$(".infoMonitorEvent").live("click", function(){
												  
		var infoMonitorEventIDValSplitter 	= (this.id).split("_");
		var infoMonitorEventIDVal 			= infoMonitorEventIDValSplitter[1];

		if ($("#infoMonitorEventSpanID_" + infoMonitorEventIDVal).length ) { //if alert details are already inserted or not
			
		} else {
			$("#infoMonitorEvent_" + infoMonitorEventIDVal).hide();
			$("#loaderMonitorEvent_" + infoMonitorEventIDVal).html('<img src="images/loaderTrans.gif" width="16px" height="16px"/>')
			var contactsAlerted = $.getValues('includes/dml/monitorDml.asp?action=getAlertLogContacts&alertLogID=' + infoMonitorEventIDVal);
			var whichRow 		= $(this).parent().parent().parent();
			var whichRowClass 	= $(this).parent().parent().parent().attr("class");
			var htmlToInsert 	= '<tr width="470px" class="infoMonitorEventTr ' + whichRowClass + '" id="infoMonitorEventTrID_' + infoMonitorEventIDVal + '"><td style="background:#FFF"></td><td colspan="2"><strong>Alert Contacts Notified:</strong><br /><br /><span id="infoMonitorEventSpanID_' + infoMonitorEventIDVal + '">' + contactsAlerted + '</span></td><td style="background:#FFF"></td></tr>'
			$(whichRow).after(htmlToInsert);
			$("#loaderMonitorEvent_" + infoMonitorEventIDVal).empty();	
			$("#closeMonitorEvent_" + infoMonitorEventIDVal).html('<img src="images/close-light.png" width="16px" height="16px"/>')
		}
	});
	
	$(".closeMonitorEvent").live("click", function(){
		var closeMonitorEventIDValSplitter 	= (this.id).split("_");
		var closeMonitorEventIDVal 			= closeMonitorEventIDValSplitter[1];
		$("#closeMonitorEvent_" + closeMonitorEventIDVal).empty();
		$("#infoMonitorEvent_" + closeMonitorEventIDVal).show();
		$("#infoMonitorEventTrID_" + closeMonitorEventIDVal).empty();
		$($(this).parent().parent().parent()).animate({opacity: 0.4}, 1000,  function() {
			$($(this)).animate({opacity: 1}, 1000);
		});	
	});	
	
	
			/*LATEST EVENTS PAGING - START*/
			$("#latestEventsNext").live("click", function(event){
				event.preventDefault();
				$("#latestEventsLoader").show();
				$(".monitorReportListing").fadeTo("fast", 0.33);

		
				$.ajax({
					type: "POST",
					url: "includes/dml/monitorDML.asp?action=GetNextEvents&monitorID=" + $("#reportMonitorID").html() + "&page=" + ($("#latestEventsPageID").html()*1 + 1),
					success: function(theResponse){
						$("#latestEventsLoader").hide();
						$(".monitorReportListing").fadeTo("fast", 1);
						if (theResponse == "false") {
		
						} else {
							$("#latestEvents").html(theResponse);
							$("#latestEventsPageID").html($("#latestEventsPageID").html()*1 + 1);
							if ($("#latestEventsPageID").html()*1 == 2){
								$("#latestEventsAtStart").hide();
								$("#latestEventsPrev").show();
							}
							if ($("#latestEventsPageID").html()*1 == $("#latestEventsMaxPageID").html()*1){
								$("#latestEventsAtEnd").show();
								$("#latestEventsNext").hide();
							}
							$("#latestEventsPaginator").val($("#latestEventsPageID").html()*1);
						}
					}
				});
			});
			
			
			$("#latestEventsPrev").live("click", function(event){
				event.preventDefault();
				$("#latestEventsLoader").show();
				$(".monitorReportListing").fadeTo("fast", 0.33);
		
				$.ajax({
					type: "POST",
					url: "includes/dml/monitorDML.asp?action=GetNextEvents&monitorID=" + $("#reportMonitorID").html() + "&page=" + ($("#latestEventsPageID").html()*1 - 1),
					success: function(theResponse){
						$("#latestEventsLoader").hide();
						$(".monitorReportListing").fadeTo("fast", 1);
						if (theResponse == "false") {
		
						} else {
							$("#latestEvents").html(theResponse);
							$("#latestEventsPageID").html($("#latestEventsPageID").html()*1 - 1);
							if ($("#latestEventsPageID").html()*1 == 1){
								$("#latestEventsAtEnd").hide();
								$("#latestEventsNext").show();
								$("#latestEventsPrev").hide();
								$("#latestEventsAtStart").show();
							}
							if ($("#latestEventsMaxPageID").html()*1 - $("#latestEventsPageID").html()*1 == 1){
								$("#latestEventsAtEnd").hide();
								$("#latestEventsNext").show();
							}
							$("#latestEventsPaginator").val($("#latestEventsPageID").html()*1);
						}
					}
				});
			});
			
			
			$("#latestEventsPaginator").live("change", function(event){
				event.preventDefault();
				$("#latestEventsLoader").show();
				$(".monitorReportListing").fadeTo("fast", 0.33);
				
				$.ajax({
					type: "POST",
					url: "includes/dml/monitorDML.asp?action=GetNextEvents&monitorID=" + $("#reportMonitorID").html() + "&page=" + ($("#latestEventsPaginator").val()*1),
					success: function(theResponse){
						$("#latestEventsLoader").hide();
						$(".monitorReportListing").fadeTo("fast", 1);
						if (theResponse == "false") {
		
						} else {
							$("#latestEvents").html(theResponse);
							$("#latestEventsPageID").html($("#latestEventsPaginator").val());
							if ($("#latestEventsPageID").html()*1 == 1){
								$("#latestEventsPrev").hide();
								$("#latestEventsAtStart").show();
							}
							if ($("#latestEventsMaxPageID").html()*1 == $("#latestEventsPaginator").val()){
								$("#latestEventsAtEnd").show();
								$("#latestEventsNext").hide();
							}
							if ($("#latestEventsPageID").html()*1 < $("#latestEventsMaxPageID").html()*1){
								$("#latestEventsAtEnd").hide();
								$("#latestEventsNext").show();
							}
							if ($("#latestEventsPageID").html()*1 > 1){
								$("#latestEventsAtStart").hide();
								$("#latestEventsPrev").show();
							}
							
						}
					}
				});											   
			
			});
			/*LATEST EVENTS PAGING - END*/	


	/*24 HOUR STATUS FORMATTER - START*/

	while($("#hours24Listed").height() / parseInt($("#hours24Listed").css("line-height")) >= 1.5) {
		size = parseInt($("#hours24Listed li").css("font-size")) - 0.1;
		$("#hours24Listed li").css("font-size", size);

	}

	$("#hours24Listed li").css("marginLeft", (342 - ($("#hours24Listed li").width() * 24)) / 24);

	/*24 HOUR STATUS FORMATTER - START*/
	
	
	$("#showHideEditEmailInfoForm").click(function(){
		$("#editEmailInfoForm").slideToggle();	
	});
	
	
	$(".activateAlertContact").live("click", function(){
		var activateAlertContactIDValSplitter 	= (this.id).split("_");
		var activateAlertContactIDVal 			= activateAlertContactIDValSplitter[1];	
		if ($("#activateAlertContactBalloon").is(":visible")) {

		} else {
			$("#alertContactWrap_" + activateAlertContactIDVal).load("includes/activateAlertContact.asp?alertContactID=" + activateAlertContactIDVal).fadeIn("slow");
			$("#activateAlertContactFormSuccess").hide();
		}
	});
	
	$(".closeActivateAlertContact").live("click", function(){
		if ($("#activateAlertContactBalloon").is(":visible")) {
			$("#activateAlertContactBalloon").fadeOut("slow", function(){
				$("#activateAlertContactBalloon").empty()
				$("#activateAlertContactBalloon").remove()
			});
		}
	});
	
	
	
	$(".deleteAlertContact").live("click", function(){
		var deleteAlertContactIDValSplitter 	= (this.id).split("_");
		var deleteAlertContactIDVal 			= deleteAlertContactIDValSplitter[1];	
		if ($("#deleteAlertContactBalloon").is(":visible")) {

		} else {
			$("#deleteAlertContactWrap_" + deleteAlertContactIDVal).load("includes/deleteAlertContact.asp?alertContactID=" + deleteAlertContactIDVal).fadeIn("slow");
			$("#deleteAlertContactFormSuccess").hide();
		}
	});
	
	$(".closeDeleteAlertContact").live("click", function(){
		if ($("#deleteAlertContactBalloon").is(":visible")) {
			$("#deleteAlertContactBalloon").fadeOut("slow", function(){
				$("#deleteAlertContactBalloon").empty()
				$("#deleteAlertContactBalloon").remove()
			});
		}
	});
	
	
	
	$(".startStopAlertContact").live("click", function(){
		var startStopAlertContactIDValSplitter 	= (this.id).split("_");
		var startStopAlertContactIDVal 			= startStopAlertContactIDValSplitter[1];	
		$.ajax({
			type: "POST",
			url: "includes/dml/userDML.asp?action=startStopAlertContact&alertContactID=" + startStopAlertContactIDVal,
			success: function(theResponse){
				if (theResponse == "false") {
					$(".errorStartStopAlertContact").fadeIn("slow", function(){
						setTimeout(function() {
							$(".errorStartStopAlertContact").fadeOut("slow");
						}, 3000);												   
					});
				} else {
					$("#startStopAlertContactLink_" + startStopAlertContactIDVal).empty();
					$("#startStopAlertContactLink_" + startStopAlertContactIDVal).html(theResponse);
				}
			}
		});
	});
	
	
	
	$(".startStopDefaultAlertContact").live("click", function(){	
		$.ajax({
			type: "POST",
			url: "includes/dml/userDML.asp?action=startStopDefaultAlertContact",
			success: function(theResponse){
				if (theResponse == "false") {
					$(".errorStartStopAlertContact").fadeIn("slow", function(){
						setTimeout(function() {
							$(".errorStartStopAlertContact").fadeOut("slow");
						}, 3000);												   
					});
				} else {
					$("#startStopDefaultAlertContactLink").empty();
					$("#startStopDefaultAlertContactLink").html(theResponse);
				}
			}
		});
	});
	

	$("#mobileProviderID").live("change", function(){
 
         var mobileProviderID = $("option:selected", this).val();
		 if (mobileProviderID == '') {
         	$("#mobileAlertContactValueWrap").hide();
		 } else {
			$.ajax({
				type: "POST",
				url: "includes/dml/userDML.asp?action=getMobileProviderDetails&mobileProviderID=" + mobileProviderID,
				success: function(theResponse){
					var mobileProviderDetails 		= (theResponse).split(";");
					if (mobileProviderDetails[0] == '-') {
						var mobileProviderPrefix		= '';
					} else {
						var mobileProviderPrefix		= '&nbsp;&nbsp;' + mobileProviderDetails[0];
					}
					if (mobileProviderDetails[1] == '-') {
						var mobileProviderSuffix		= '';
					} else {
						var mobileProviderSuffix		= mobileProviderDetails[1];
					}
						var mobileProviderNumberLimit	= mobileProviderDetails[2];
						var mobileProviderNumberLimitUp	= mobileProviderDetails[3];
					$(".mobileProviderPrefix").html(mobileProviderPrefix);
					$(".mobileProviderSuffix").html(mobileProviderSuffix);
					if (mobileProviderNumberLimit == mobileProviderNumberLimitUp) {
						$(".mobileProviderNumberLimit").html(mobileProviderNumberLimit);
					} else {
						$(".mobileProviderNumberLimit").html(mobileProviderNumberLimit + '-' + mobileProviderNumberLimitUp);
					}


				}
			});
			 
			 $("#mobileAlertContactValueWrap").show();
		 }
		
	})
	


	$("#addEmailAlertContactButton").click(function() {
		if ($("#addEmailAlertContactForm").is(":hidden")) {
			if ($("#addMobileAlertContactForm").is(":visible")) {
				$("#addMobileAlertContactForm").slideUp("slow", function() {
					$("#addEmailAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addTwitterAlertContactForm").is(":visible")) {
				$("#addTwitterAlertContactForm").slideUp("slow", function() {
					$("#addEmailAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addIOSPushAlertContactForm").is(":visible")) {
				$("#addIOSPushAlertContactForm").slideUp("slow", function() {
					$("#addEmailAlertContactForm").slideDown("slow");
				});
			} else {
				$("#addEmailAlertContactForm").slideDown("slow");
			}
		} else {
			$("#addEmailAlertContactForm").slideUp("slow");
		}
	}); 
	

	$("#addMobileAlertContactButton").click(function() {
		if ($("#addMobileAlertContactForm").is(":hidden")) {
			if ($("#addEmailAlertContactForm").is(":visible")) {
				$("#addEmailAlertContactForm").slideUp("slow", function() {
					$("#addMobileAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addTwitterAlertContactForm").is(":visible")) {
				$("#addTwitterAlertContactForm").slideUp("slow", function() {
					$("#addMobileAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addIOSPushAlertContactForm").is(":visible")) {
				$("#addIOSPushAlertContactForm").slideUp("slow", function() {
					$("#addMobileAlertContactForm").slideDown("slow");
				}); 
			} else {
				$("#addMobileAlertContactForm").slideDown("slow");
			}
		} else {
			$("#addMobileAlertContactForm").slideUp("slow");
		}
	}); 
	

	$("#addTwitterAlertContactButton").click(function() {
		if ($("#addTwitterAlertContactForm").is(":hidden")) {
			if ($("#addEmailAlertContactForm").is(":visible")) {
				$("#addEmailAlertContactForm").slideUp("slow", function() {
					$("#addTwitterAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addMobileAlertContactForm").is(":visible")) {
				$("#addMobileAlertContactForm").slideUp("slow", function() {
					$("#addTwitterAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addIOSPushAlertContactForm").is(":visible")) {
				$("#addIOSPushAlertContactForm").slideUp("slow", function() {
					$("#addTwitterAlertContactForm").slideDown("slow");
				}); 
			} else {
				$("#addTwitterAlertContactForm").slideDown("slow");
			}
		} else {
			$("#addTwitterAlertContactForm").slideUp("slow");
		}
	});
	
	
	$("#addIOSPushAlertContactButton").click(function() {
		if ($("#addIOSPushAlertContactForm").is(":hidden")) {
			if ($("#addEmailAlertContactForm").is(":visible")) {
				$("#addEmailAlertContactForm").slideUp("slow", function() {
					$("#addIOSPushAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addMobileAlertContactForm").is(":visible")) {
				$("#addMobileAlertContactForm").slideUp("slow", function() {
					$("#addIOSPushAlertContactForm").slideDown("slow");
				}); 
			} else if ($("#addTwitterAlertContactForm").is(":visible")) {
				$("#addTwitterAlertContactForm").slideUp("slow", function() {
					$("#addIOSPushAlertContactForm").slideDown("slow");
				}); 
			} else {
				$("#addIOSPushAlertContactForm").slideDown("slow");
			}
		} else {
			$("#addIOSPushAlertContactForm").slideUp("slow");
		}
	}); 



	$("#monitorSpecificAPIKeyMonitorID").live("change", function(){
 
         var monitorID = $("option:selected", this).val();
		 if (monitorID == 0) {
         	$("#monitorSpecificAPIKeyNotExists").hide();
			$("#monitorSpecificAPIKeyExists").hide();
		 } else {
			$.ajax({
				type: "POST",
				url: "includes/dml/monitorDML.asp?action=getMonitorSpecificAPIKeyDetails&monitorID=" + monitorID,
				success: function(theResponse){
					if (theResponse == "false") {
						$("#monitorSpecificAPIKeyNotExists").show();
						$("#monitorSpecificAPIKeyExists").hide();
					} else {
						
						$("#monitorSpecificAPIKeyDisplay").html(theResponse);
						$("#monitorSpecificAPIKeyNotExists").hide();
						$("#monitorSpecificAPIKeyExists").show();
					}
				}
			});	 
		 }
		
	})


	var loader = jQuery('<img src="images/loader.gif" alt="loading..." />')
		.hide()
		.appendTo(".loader");
	jQuery().ajaxStart(function() {
		loader.show();
	}).ajaxStop(function() {
		loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;
	});

	
	
	
	var signUpV = jQuery("#signUpForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						signUpV.resetForm();			
						$("#signUpForm").hide("slow",  function() {
							$("#signUpFormSuccess").fadeIn("slow");
						});
					} else if (theResponse == "false") {
						$(".errorSignUp").html("E-mail is in use. Please login using your e-mail.").show();
					} else if (theResponse == "IPRestrictions") {
						$(".errorSignUp").html("Frequent sign-ups from the same IP. Please try again in a few hours.").show();
					}

				},
				
				error: function(label) {
					alert ("noooo");
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorSignUp",
		rules: {
			userFirstLastName: {
				required: true
			},
			userEmail: {
				required: true,
				email: true,
				remote: "includes/dml/userDML.asp?action=checkEmail"
			},
			userPassword: {
				required: true,
				minlength: 6
			},
			userPassword2: {
				required: true,
				equalTo: "#userPassword"
			}
		},
		messages: {
			userFirstLastName: {
				required: "Name is required, "
			},
			userEmail: {
				required: "E-mail is required, ",
				email: "Enter a valid e-mail, ",
				remote: jQuery.format("E-mail is in use, ")
			},
			userPassword: {
				required: "Password required, ",
				minlength: "Password minimum 6 characters, "
			},
			userPassword2: {
				required: "Re-Password required, ",
				equalTo: "Passwords must match"
			}

		}

	});
	
	
	var signInV = jQuery("#signInForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						signInV.resetForm();			
						$("#signInForm").hide("slow",  function() {
							$("#signInFormSuccess").fadeIn("slow",  function() {
								top.location.href = 'myMonitors.asp';																		 
							});
						});
					} else if (theResponse == "userStatusPassive") {
						$("#resendUserActivationEmailSuccess").hide();
						$(".errorSignIn").html("The account is not activated. Please check your e-mail.").show();
						$("#resendUserActivationEmailLink").show();
					} else if (theResponse == "false") {
						$("#resendUserActivationEmailSuccess").hide();
						$(".errorSignIn").html("Wrong e-mail and/or password. Please try again.").show();
					}
					
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorSignIn",
		rules: {
			signInEmail: {
				required: true,
				email: true
			},
			signInPassword: {
				required: true,
				minlength: 6
			}
		},
		messages: {
			signInEmail: {
				required: "E-mail is required, ",
				email: "Enter a valid e-mail, "
			},
			signInPassword: {
				required: "Password required, ",
				minlength: "Password minimum 6 characters, "
			}

		}

	});
	
	
	
	var forgotPasswordV = jQuery("#forgotPasswordForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						forgotPasswordV.resetForm();			
						$("#forgotPasswordForm").hide("slow",  function() {
							$("#forgotPasswordFormSuccess").fadeIn("slow",  function() {																		 
							});
						});
					} else {
						$(".errorForgotPassword").html("E-mail doesn't exist, please make sure you mention the right address.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorForgotPassword",
		rules: {
			forgotPasswordEmail: {
				required: true,
				email: true
			}
		},
		messages: {
			forgotPasswordEmail: {
				required: "E-mail is required.",
				email: "Enter a valid e-mail."
			}

		}

	});
	
	
	
	var newHTTPMonitorV = jQuery("#newHTTPMonitorForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						newHTTPMonitorV.resetForm();
						$("#addNewMonitorHideAfterSuccess").slideUp("slow");
						$("#addNewMonitorBalloonCenter").slideUp("slow",  function() {
							$("#newMonitorFormSuccess").fadeIn("slow",  function() {
								top.location.href = 'myMonitors.asp';																		
							});
						});
					} else {
						$(".errorNewMonitor").html("This monitor is already in the list.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorNewMonitor",
		rules: {
			newHTTPMonitorFriendlyName: {
				required: true
			},
			newHTTPMonitorURL: {
				required: true,
				url: true
			},
			newHTTPMonitorUsername: {
				required: function(element) {
        			return $("#newHTTPMonitorPassword").val() != "";
      			}
			},
			newHTTPMonitorPassword: {
				required: function(element) {
        			return $("#newHTTPMonitorUsername").val() != "";
      			}
			}
		},
		messages: {
			newHTTPMonitorFriendlyName: {
				required: "Friendly Name is required, "
			},
			newHTTPMonitorURL: {
				required: "URL is required, ",
				url: "Enter a valid URL"
			},
			newHTTPMonitorUsername: {
				required: "User-pass should be both filled or empty."
			},
			newHTTPMonitorPassword: {
				required: "User-pass should be both filled or empty."
			}
		}

	});
	
	
	
	var newKeywordMonitorV = jQuery("#newKeywordMonitorForm").validate({	
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						newKeywordMonitorV.resetForm();
						$("#addNewMonitorHideAfterSuccess").slideUp("slow");
						$("#addNewMonitorBalloonCenter").slideUp("slow",  function() {
							$("#newMonitorFormSuccess").fadeIn("slow",  function() {
								top.location.href = 'myMonitors.asp';																		
							});
						});
					} else {
						$(".errorNewMonitor").html("This monitor is already in the list.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorNewMonitor",
		rules: {
			newKeywordMonitorFriendlyName: {
				required: true
			},
			newKeywordMonitorURL: {
				required: true,
				url: true
			},
			newKeywordMonitorKeywordValue: {
				required: true
			},
			newKeywordMonitorUsername: {
				required: function(element) {
        			return $("#newKeywordMonitorPassword").val() != "";
      			}
			},
			newKeywordMonitorPassword: {
				required: function(element) {
        			return $("#newKeywordMonitorUsername").val() != "";
      			}
			}
		},
		messages: {
			newKeywordMonitorFriendlyName: {
				required: "Friendly Name is required, "
			},
			newKeywordMonitorURL: {
				required: "URL is required, ",
				url: "Enter a valid URL, "
			},
			newKeywordMonitorKeywordValue: {
				required: "Keyword is required"
			},
			newKeywordMonitorUsername: {
				required: "User-pass should be both filled or empty."
			},
			newKeywordMonitorPassword: {
				required: "User-pass should be both filled or empty."
			}
		}

	});
	
	

	var newPingMonitorV = jQuery("#newPingMonitorForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						newPingMonitorV.resetForm();
						$("#addNewMonitorHideAfterSuccess").slideUp("slow");
						$("#addNewMonitorBalloonCenter").slideUp("slow",  function() {
							$("#newMonitorFormSuccess").fadeIn("slow",  function() {
								top.location.href = 'myMonitors.asp';																		
							});
						});
					} else {
						$(".errorNewMonitor").html("This monitor is already in the list.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorNewMonitor",
		rules: {
			newPingMonitorFriendlyName: {
				required: true
			},
			newPingMonitorURL: {
				required: true,
				checkIPURL: true
			}
		},
		messages: {
			newPingMonitorFriendlyName: {
				required: "Friendly Name is required, "
			},
			newPingMonitorURL: {
				required: "URL is required, ",
				checkIPURL: "Enter a valid URL (or IP)."
			}
		}

	});
	
	
	var newPortMonitorV = jQuery("#newPortMonitorForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						newPortMonitorV.resetForm();
						$("#addNewMonitorHideAfterSuccess").slideUp("slow");
						$("#addNewMonitorBalloonCenter").slideUp("slow",  function() {
							$("#newMonitorFormSuccess").fadeIn("slow",  function() {
								top.location.href = 'myMonitors.asp';																		
							});
						});
					} else {
						$(".errorNewMonitor").html("This monitor is already in the list.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},


	   errorLabelContainer: ".errorNewMonitor",
		rules: {
			newPortMonitorFriendlyName: {
				required: true
			},
			newPortMonitorURL: {
				required: true,
				checkIPURL: true
			},
			newPortMonitorPort: {
				min: 1
			},
			newPortMonitorCustomPort: {
				required: function(element) {
        			return $("#newPortMonitorPort").val() == 99;
      			},
				number: true,
				min: 1,
				max: 65535
			}			
		},
		messages: {
			newPortMonitorFriendlyName: {
				required: "Friendly Name is required, "
			},
			newPortMonitorURL: {
				required: "URL is required, ",
				checkIPURL: "Enter a valid URL (or IP), "
			},
			newPortMonitorPort: {
				min: "Port is required, "
			},
			newPortMonitorCustomPort: {
				required: "Custom port is required, ",
				number: "Custom port should be an integer",
				min: "Custom port must be bigger than 0",
				max: "Custom port must be smaller than 65536"
			}
		}

	});
	
	
	var editPersonalInfoV = jQuery("#editPersonalInfoForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						$("#userOldPassword").val('');
						$("#userPassword").val('');
						$("#userPassword2").val('');
							$("#editPersonalInfoFormSuccess").fadeIn("slow",  function() {
								setTimeout(function() {
									$("#editPersonalInfoFormSuccess").fadeOut("slow");
								}, 3000);											   
							});
					} else {
						$(".errorEditPersonalInfo").html("An error occurred. Please try again.").show();
					}

				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorEditPersonalInfo",
		rules: {
			userFirstLastName: {
				required: true
			},
			userOldPassword: {
				required: "#userPassword:filled",
				minlength: 6
			},
			userPassword: {
				required: "#userOldPassword:filled",
				minlength: 6
			},
			userPassword2: {
				required: "#userPassword:filled",
				equalTo: "#userPassword"
			}
		},
		messages: {
			userFirstLastName: {
				required: "Name is required, "
			},
			userOldPassword: {
				required: "Current password required, ",
				minlength: "Password minimum 6 characters, "
			},
			userPassword: {
				required: "New password required, ",
				minlength: "Password minimum 6 characters, "
			},
			userPassword2: {
				required: "Re-Password required, ",
				equalTo: "Passwords must match"
			}

		}

	});




	var editEmailInfoV = jQuery("#editEmailInfoForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						$("#editEmailInfoFormSuccess").fadeIn("slow",  function() {
							setTimeout(function() {
								$("#editEmailInfoFormSuccess").fadeOut("slow",  function() {
									
								});
							}, 1000);											   
						});
					} else {
						$(".errorEditEmailInfo").html("E-mail is in use. Please try another address.");
					}

				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorEditEmailInfo",
		rules: {
			userNewEmail: {
				required: true,
				email: true,
				remote: "includes/dml/userDML.asp?action=checkEditEmail"
			}
		},
		messages: {
			userNewEmail: {
				required: "E-mail is required.",
				email: "Enter a valid e-mail.",
				remote: jQuery.format("E-mail is in use by another user.")
			}

		}

	});
	
	
	
	var addMobileAlertContactV = jQuery("#addMobileAlertContactForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == 2) {
						addMobileAlertContactV.resetForm();			
							$("#addMobileAlertContactFormSuccess").fadeIn("slow",  function() {
								setTimeout(function() {
									top.location.href = 'mySettings.asp';
								}, 3000);		
																										 
							});
					}
					if (theResponse != 0 && theResponse != 2) {
						$(".errorAddMobileAlertContact").html(theResponse).show();
					}
					if (theResponse == 0) {
						$(".errorAddMobileAlertContact").html("The contact is already in your list.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorAddMobileAlertContact",
		rules: {
			mobileProviderID: {
				required: true
			},
			mobileAlertContactValue: {
				required: true,
				number: true
			}
		},
		messages: {
			mobileProviderID: {
				required: "Mobile provider is required, "
			},
			mobileAlertContactValue: {
				required: "Mobile number is required, ",
				number: "Mobile number must be a number, "
			}

		}

	});
	
	
	
	var addEmailAlertContactV = jQuery("#addEmailAlertContactForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {
						addEmailAlertContactV.resetForm();			
							$("#addEmailAlertContactFormSuccess").fadeIn("slow",  function() {
								setTimeout(function() {
									top.location.href = 'mySettings.asp';
								}, 3000);		
																										 
							});
					} else {
						$(".errorAddEmailAlertContact").html("The contact is already in your list.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorAddEmailAlertContact",
		rules: {
			emailAlertContactValue: {
				required: true,
				email: true
			}
		},
		messages: {
			emailAlertContactValue: {
				required: "E-mail is required, ",
				email: "Please use a valid e-mail address."
			}

		}

	});
	
	
	
	var addTwitterAlertContactV = jQuery("#addTwitterAlertContactForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "2") {
						addTwitterAlertContactV.resetForm();			
							$("#addTwitterAlertContactFormSuccess").fadeIn("slow",  function() {
								setTimeout(function() {
									top.location.href = 'mySettings.asp';
								}, 3000);		
																										 
							});
					} else {
						if (theResponse == "0") {
							$(".errorAddTwitterAlertContact").html("The contact is already in your list.").show();
						}
						if (theResponse == "1") {
							$(".errorAddTwitterAlertContact").html('You must be following <a href="http://twitter.com/uptimerobot" target="_blank">@uptimerobot</a> Twitter user to get alerts.').show();
						}
						
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorAddTwitterAlertContact",
		rules: {
			twitterAlertContactValue: {
				required: true
			}
		},
		messages: {
			twitterAlertContactValue: {
				required: "Twitter user is required."
			}

		}

	});
	


	var addIOSPushAlertContactV = jQuery("#addIOSPushAlertContactForm").validate({			  
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(theResponse) {
					if (theResponse == "true") {			
						$("#addIOSPushAlertContactFormSuccess").fadeIn("slow",  function() {
							setTimeout(function() {
								top.location.href = 'mySettings.asp';
							}, 3000);																				 
						});
					} else if (theResponse == "instantTrue") {
						$("#addIOSPushAlertContactFormInstantSuccess").fadeIn("slow",  function() {
							setTimeout(function() {
								top.location.href = 'mySettings.asp';
							}, 3000);																				 
						});
					} else if (theResponse == "notFound") {
						$(".errorAddIOSPushAlertContact").html("The e-mail is not a registered Boxcar account. Please get a Boxcar account.").show();
					} else if (theResponse == "no@pushAddressError") {
						$(".errorAddIOSPushAlertContact").html("Couldn't get a response from Boxcar, Please try again in a few minutes.").show();
					} else if (theResponse == "false") {
						$(".errorAddIOSPushAlertContact").html("The contact is already in your list.").show();
					}
				},
				
				error: function(label) {
					loader.hide();
				}		
			});					
		},

	   errorLabelContainer: ".errorAddIOSPushAlertContact",
		rules: {
			iOSPushAlertContactValue: {
				required: true,
				email: true,
				checkPushBoxcarAddress: true
			}
		},
		messages: {
			iOSPushAlertContactValue: {
				required: "E-mail is required, ",
				email: "Please use a valid e-mail address.",
				checkPushBoxcarAddress: "Please mention the e-mail address that you used to sign-up Boxcar (@push.boxcar e-mail addresses are not supported)."
			}

		}

	});
	
	
	$("#createApiKey").live("click", function(){
		$.ajax({
			type: "POST",
			url: "includes/dml/userDML.asp?action=createApiKey",
			success: function(theResponse){
				if (theResponse == "false") {

				} else {
					$("#apiKeyDisplay").html(theResponse);
					$("#apiKeyDisplayWrapperHidden").show();
					$("#apiKeyNotExists").hide();
				}
			}
		});
	});
	
	
	$("#deleteApiKey").live("click", function(){
		$.ajax({
			type: "POST",
			url: "includes/dml/userDML.asp?action=deleteApiKey",
			success: function(theResponse){
				if (theResponse == "false") {

				} else {
					$("#apiKeyDisplayWrapperHidden").hide();
					$("#apiKeyNotExists").show();
				}
			}
		});
	});


	$("#createMonitorSpecificAPIKey").live("click", function(){
		$.ajax({
			type: "POST",
			url: "includes/dml/monitorDML.asp?action=createApiKey&monitorID=" + $("option:selected", "#monitorSpecificAPIKeyMonitorID").val(),
			success: function(theResponse){
				if (theResponse == "false") {

				} else {
					$("#monitorSpecificAPIKeyDisplay").html(theResponse);
					$("#monitorSpecificAPIKeyNotExists").hide();
					$("#monitorSpecificAPIKeyExists").show();
				}
			}
		});
	});
	
	
	$("#deleteMonitorSpecificAPIKey").live("click", function(){
		$.ajax({
			type: "POST",
			url: "includes/dml/monitorDML.asp?action=deleteApiKey&monitorID=" + $("option:selected", "#monitorSpecificAPIKeyMonitorID").val(),
			success: function(theResponse){
				if (theResponse == "false") {

				} else {
					$("#monitorSpecificAPIKeyNotExists").show();
					$("#monitorSpecificAPIKeyExists").hide();
				}
			}
		});
	});

		
});
