﻿(function() {
    var originalAjaxMethod = jQuery.ajax;
    jQuery.extend({
        ajax: function(s) {
            if ($.browser.msie && s.type.toUpperCase() == 'GET') {
                if (s.data) {
                    s.data['ieGetTimeStamp'] = (new Date()).getTime().toString();
                } else {
                    s.data = {'ieGetTimestap' : (new Date()).getTime().toString() };
                }
            }
            return originalAjaxMethod.call(this, s);
        }
    });
})();

var path_to_root = (window.location.host == 'localhost') ? '/BizPlan/' : '/';


function togglePanel(panelId, collapsed) {
	var collPanel = null;
	if (typeof (panelId) == 'string') collPanel = $find(panelId);
	else collPanel = $(panelId).get(0);
	collPanel.set_Collapsed(collapsed);
}

String.prototype.startsWith = function(t) {
    return (t == this.substring(0, t.length));
}

String.prototype.endsWith = function(t) {
    return (t == this.substring(this.length - t.length));
}

String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function () {
    return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function () {
    return this.replace(/\s+$/, "");
}


$(document).ready(function() {
	$('.DefaultButtonContainer').bind('keypress', function(e) {
		var e = e || window.event;
		var key = e.keyCode || e.which;

		if (key == 13) {
			__doPostBack($(this).find('.DefaultButton:first').attr('id').replace(/_/g, '$'), '')
			return false;
		}
		return true;
	});
	$('.ModalPanel .button.close').click(function() { $(this).parents('.ModalPanel:first').get(0).hide();return false; });
});
