// Native Extensions

// jQuery Extensions

$.extend({
	CreateDotNetRemoteMethodCall : function(endpoint,methodname){ 
		endpoint += "/" + methodname+"?";  
		for (var i = 2; i < arguments.length; i++) {
			endpoint += (i-2)+"="+ escape(JSON.stringify(arguments[i])) +"&"; 
		 } 
		return endpoint;
	}
});

$.extend({
	getUrlParam : function (param) {
		var regex = '[?&]' + param + '=([^&#]*)';
		var results = (new RegExp(regex)).exec(window.location.href);
		if(results) return results[1];
		return '';
	}
});

$.extend({
     formatCurrency : function (num) {
        num = num.toString().replace(/\£|\,/g,'');

        if(isNaN(num))
            num = "0";

        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num * 100 + 0.50000000001);
        pence = num % 100;
        pounds = Math.floor(num / 100).toString();

        if(pence < 10)
            pence = "0" + pence;

        for (var i = 0; i < Math.floor((pounds.length - (1 + i)) / 3); i++)
            pounds = pounds.substring(0, pounds.length - (4 * i + 3)) + ',' + pounds.substring(pounds.length - (4 * i + 3));

        // Note the use of the unicode expansion for a pound sign...
        return (((sign)?'':'-') + '\u00A3' + pounds + '.' + pence);
    }

});

$.fn.extend({
	setHrefNoAction : function( ){
         return this.each(function() {
				$(this).attr("href","#"); 
				$(this).bind("click",function(event){
					event.preventDefault();
				})  
          }); 
    }
});

