﻿HHus = {}
HHus.Web = {}
HHus.Web.CommonMethods = function() {};





var initCaller = new Array();
var ajaxCaller = new Number();
var UrlBase = "http://" + window.location.hostname;
var AjaxServiceUrl = UrlBase + '/Web/WebServices/AJAXService.asmx';

HHus.Web.CommonMethods.SendEmail = function(onSuccess, onFail, email) {
    if (HHus.Web.CommonMethods.ShowAjax("SendEmail")) 
    {
        $.ajax({
            type: "POST",
            url: AjaxServiceUrl + "/SendEmail",
            data: $.toJSON(email),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: onSuccess,
            fail: onFail
        });
        pageTracker._trackPageview("/tipafriend/sent");
    }
};

HHus.Web.CommonMethods.IsNumeric = function(form_value) {
    if (form_value.match(/^\d+$/) == null)
        return false;
    else
        return true;
};

HHus.Web.CommonMethods.ShowAjax = function(functionName) {
    if (ajaxCaller[functionName] == null) {
        ajaxCaller[functionName] = new Date();
        $("div.ajaxLoading").show();
        return true;
    }
    return false;
};

HHus.Web.CommonMethods.HideAjax = function(functionName) {
    if (ajaxCaller[functionName] != null) {
        ajaxCaller[functionName] = null;
    }

    for (var obj in ajaxCaller) {
        if (ajaxCaller[obj] != null) {
            return;
        }
    }
    
    $("div.ajaxLoading").hide();
   
};

$(document).ready(function() {
    
    // Equalize heights in columns in footer
    equalHeight($("div.eQ"));
    //hint all elements with title!=''
     $('input[title!=undefined]').hint();
     $('textarea[title!=undefined]').hint();
    if (initCaller != null) {
        for (var j = 0; j < initCaller.length; j++) {
            eval(initCaller[j].toString());
        }
    }
    
    // hide on load
    $(".onLoadHide").hide();
    
     // toggle next tag with class .toggleThis on click
    $(".toggleNext").click(function() {
        $(this).nextAll(".toggleThis").slideToggle("fast");
        return false;
    });
    
    $("a.blank").live("click", function() {
        var el = $(this);
        window.open(el.attr("href"));
        return false;
    });

    
});

Array.prototype.contains = function(element) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == element) {
            return true;
        }
    }
    return false;
}


