﻿function ShowAuditComment(elImgId, elTextId) {

	if ($("#" + elTextId).parent().css("display") != "block") {
		var divHTML = $("#" + elTextId).val().replace(/(\r\n|[\r\n])/g, "<br />");
		var divAuditComment = $("#" + elTextId).parent().prev();
		divAuditComment.html(divHTML);
		divAuditComment.show();
		var position = $("#" + elImgId).position();
		divAuditComment.css("top", (position.top + 20) + "px");
		divAuditComment.css("left", (position.left - 220) + "px");
	}
}

function HideAuditComment(elImgId, elTextId) {
	$("#" + elTextId).parent().prev().hide();
}

function ConfirmPropertyAuditSubmit() {
	return confirm("Are you sure you would like to submit your audit?");
}

function ConfirmPropertyAuditNotSubmit() {
	return confirm("Are you sure that you don't want to submit for this audit year?");
}

function ConfirmDisableAllProperties() {
	return confirm("Are you sure that you want to disable all records?");
}

function ConfirmDeleteQuestion() {
	return confirm("Are you sure that you want to delete this question?");
}

function ValidatePassword(source, args) {
	var pwd = jQuery.trim(args.Value);
	args.IsValid = !(pwd.length < 6);
}

function TogglePassword(showLink, target, pass, hidden) {
	var elShowLink = $("#" + showLink);
	var elTarget = $("#" + target);

	if (elShowLink.html() == 'show') {
		elTarget.html(pass);
		elShowLink.html('hide');
	}
	else {
		elTarget.html(hidden);
		elShowLink.html('show');
	}

	return false;
}
function ChangePage(module, contentOrder, highlightText) {

	var url = "../ajax/DisplayHelp.aspx?mod=" + module + "&ord=" + contentOrder + "&hl=" + highlightText + "&random=" + Math.random();
	//alert(url);
	jQuery("#helpProgress").show();
	jQuery('#divHelp').fadeOut(200, function() {
		jQuery('#divHelp').load(url, {}, function() {
			jQuery("#helpProgress").fadeOut(200);
			jQuery('#divHelp').fadeIn(200);
		});
	});
	//
	//	jQuery.ajax({
	//	   type: "GET",
	//	   url: "../ajax/DisplayHelp.aspx",
	//	   data: "mod="+module+"&ord="+contentOrder+"&hl="+highlightText+"&dt="+dateString,
	//	   processData: true,
	//	   dataType: "html",
	//	   success: function(data){		 
	//		 
	//			/*var fullhtml = jQuery(data).html();
	//			alert(fullhtml);
	//			var html = fullhtml.getElementById("divDisplay");
	//			alert(html);
	//			 $('#divContent').html(html);*/
	//			
	//			 jQuery('#divHelp').html(data);			
	//			 
	//			 //ensure content is visible
	//			 if ( jQuery(".pnlContentSearch").length > 0 ) jQuery(".pnlContentSearch").hide();
	//			 if ( jQuery(".pnlContentData").length > 0 ) jQuery(".pnlContentData").show();
	//			 
	//			 //set visibility of nav buttons and set nav text
	//			 /*
	//			 if (arrContentOrder.length > 0 && contentPage > -1){
	//				index = jQuery.inArray(contentPage, arrContentOrder);
	//				if (index > -1){
	//				
	//					if (index > 0){
	//					
	//						$('#PrevLink').show();
	//					}
	//					else {
	//						$('#PrevLink').hide();
	//					}
	//					if (index < arrContentOrder.length - 1){
	//						$('#NextLink').show();
	//					}
	//					else {
	//						$('#NextLink').hide();
	//					}
	//				}
	//				$('#divPages').html((index + 1).toString() + ' of ' + arrContentOrder.length); 
	//				window.scrollTo(0,0);
	//			}			
	//			*/
	//	   },
	//			complete: function(){	
	//				jQuery("#contentProgress").hide();
	//				ContentLoad();
	//	   },
	//			error: function(XMLHttpRequest, textStatus, errorThrown){
	//			jQuery('#divHelp').html("Error");	
	//			//window.location = window.location;
	//		}
	//	});	 
}

function bcId(elName) {
	if (typeof elName == "string") {
		return $('#' + elName);
	}
	else {
		return $(elName)
	}
}

function bcClass(className) {
	return $('.' + className);
}

function bcShow(elName) {
	bcId(elName).show();
}

function bcHide(elName) {
	bcId(elName).hide();
}

function bcToggle(elName) {
	bcId(elName).toggle();
}

function bcRolloverAppear(elName, dur) {
	bcFadeIn(elName, dur);
}

function bcRolloverFade(elName, dur) {
	bcFadeOut(elName, dur);
}

function bcFadeIn(elName, dur) {
	if (dur == null) dur = 1.0;
	dur = dur * 1000;
	bcId(elName).fadeIn(dur);
}

function bcFadeOut(elName, dur) {
	if (dur == null) dur = 1.0;
	dur = dur * 1000;
	bcId(elName).fadeOut(dur);
}

function bcBlindUp(elName, dur) {
	if (dur == null) dur = 1.0;
	dur = dur * 1000;
	bcId(elName).slideUp(dur);
}

function bcBlindDown(elName, dur) {
	if (dur == null) dur = 1.0;
	dur = dur * 1000;
	bcId(elName).slideDown(dur);
}
function bcToggleBlind(elName, dur) {
	if (dur == null) dur = 1.0;
	dur = dur * 1000;
	bcId(elName).slideToggle(dur);
	//bcId(elName).toggle(dur);
}
function bcPulsate(elName, num, dur) {
	el = bcId(elName);
	if (num == null) num = 3;
	if (dur == null) dur = 2;
	speed = dur * 100;
	el.animate({ opacity: 0.1 }
		, speed
		, function() {
			$(this).animate({ opacity: 1.0 }, speed);
			if (num - 1 > 0) bcPulsate(elName, num - 1, dur);
		});
}

function bcHighlight(elName, beginColor, dur) {
	if (beginColor == null) beginColor = '#ffff33';
	if (dur == null) dur = 1.0;
	dur = dur * 1000;
	bcId(elName).colorBlend([{ fromColor: beginColor, toColor: "#FFFFFF", cycles: 0.5, duration: dur}]);
}
