﻿/// <reference path="~/Scripts/jquery-1.4.2.js"/>
/// <reference name="MicrosoftAjax.js"/>
/// <reference path="~/Scripts/MicrosoftAjax.debug.js"/>
/// <reference path="~/Scripts/MicrosoftMvcAjax.debug.js"/>
/// <reference path="~/Scripts/MicrosoftMvcJQueryValidation.js"/>
/// <reference path="~/Scripts/jquery.helper.js"/>
/// <reference path="~/Scripts/jquery.history.js"/>
/// <reference path="~/Scripts/jquery.selectbox.js"/>
/// <reference path="~/scripts/jquery.scrollTo.js"/>
/// <reference path="~/Scripts/Helper.js"/>
/// <reference path="~/Scripts/jquery.js"/>
/// <reference path="~/Scripts/scrolling.js"/>

function encodeMyHtml(data) {
	encodedHtml = escape(data);
	encodedHtml = encodedHtml.replace(/\//g, "%2F");
	encodedHtml = encodedHtml.replace(/\?/g, "%3F");
	encodedHtml = encodedHtml.replace(/=/g, "%3D");
	encodedHtml = encodedHtml.replace(/&/g, "%26");
	encodedHtml = encodedHtml.replace(/@/g, "%40");
	return encodedHtml;
}

var ___global_flag = true;
function Filter(_this) {
	//alert("hi");
	var SelectedId = jQuery(_this).val();
	___global_flag = true;
	if (SelectedId === "-1") {
		jQuery(".StampTypeBlocks").show().each(function (index) {
			if (___global_flag) {
				jQuery(this).addClass("even");
			} else {
				jQuery(this).removeClass("even");
			}
			___global_flag = !___global_flag;
		});
	} else {
		jQuery(".StampTypeBlocks").hide();

		jQuery(".StampType" + SelectedId).show().each(function(index) {
			if (___global_flag) {
				jQuery(this).addClass("even");
			} else {
				jQuery(this).removeClass("even");
			}
			___global_flag = !___global_flag;
		});
	}
}


var AjaxProgressBarTimer1;
var AjaxProgressBarTimer2;
var AjaxProgressBarTimer3;

function ShowAjaxWait() {
    /// <summary>Shows the loading... bar</summary>

    jQuery("#AjaxProgressBar").fadeIn(500);

    jQuery("#AjaxProgressBar #AjaxProgressBarBox #loading-text ").text("Loading.");
        AjaxProgressBarTimer1 = window.setInterval(function () {
        jQuery("#AjaxProgressBar #AjaxProgressBarBox #loading-text ").text("Loading.");
    }, 2000);

    var j = setTimeout(function () {
        jQuery("#AjaxProgressBar #AjaxProgressBarBox #loading-text ").text("Loading..");
        AjaxProgressBarTimer2 = window.setInterval(function () {
            jQuery("#AjaxProgressBar #AjaxProgressBarBox #loading-text ").text("Loading..");
        }, 2000);
    }, 500);

    setTimeout(function () {
        jQuery("#AjaxProgressBar #AjaxProgressBarBox #loading-text ").text("Loading...");
        AjaxProgressBarTimer3 = window.setInterval(function () {
            jQuery("#AjaxProgressBar #AjaxProgressBarBox #loading-text ").text("Loading...");
        }, 2000);
    }, 1000);

}

function HideAjaxWait() {
    /// <summary>Hides the loading... bar</summary>

    window.clearInterval(AjaxProgressBarTimer1);
    window.clearInterval(AjaxProgressBarTimer2);
    window.clearInterval(AjaxProgressBarTimer3);

    jQuery("#AjaxProgressBar").fadeOut(500);
}



function MinimiseList(id) {
    $(id).children().last().after("<li id='more'><a href=\"javascript:MaximiseList( '" + id +
     "' );\">show more (expand)</a></li>");

    var shortened = false;
    $(id).children().each(function (index) {
        if (index >= 6) {
            $(this).hide();
            shortened = true;
        }
    });

    if (shortened == true)
        $(id + " #more").show();
    else
        $(id + " #more").hide();

}

function MaximiseList(id) {
    $(id).children().each(function (index) {
        $(this).slideDown();
    });
    $(id + " #more").hide();
}

