/*
this file will extend the jquery

*/
$.extend({
	/* Get object of URL parameters
			var allVars = $.getUrlVars();

		// Getting URL var by its nam
		var byName = $.getUrlVar('name');
	*/
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('#!') + 2).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});


// this is to center the popup div
jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}


function toggleDragDiv(div,ForceShowHide){
	if (typeof ForceShowHide == 'undefined' ){
		ForceShowHide = null;
	}
	$('#'+div).toggle(ForceShowHide).center().draggable();
	
}
function IsraAjax(Url // this is the URL
				,UrlData // this is the data this works only on GET method
				,DivId // this is the ID where the results are going to show, if you set to false it will not do anything.
				,SuccessFunc // the function to run on success
				,BeforeFunc // the function to run before ajax process
				,AjaxType // Type: GET,POST,json
				){
	/*$.ajaxSetup({  });
	if (typeof DivId != 'undefined' &&DivId!=false  ){
		$.ajaxSetup({ success: function(msg){
		 $('#'+DivId).html( msg );
	   } });
	}
	if (typeof SuccessFunc != 'undefined' ){
		$.ajaxSetup({ success: SuccessFunc});
	}
	if (typeof BeforeFunc != 'undefined' ){
		$.ajaxSetup({ beforeSend: BeforeFunc});
	}*/
	if (typeof AjaxType == 'undefined' ){
		AjaxType = 'GET';
	}
	
	//alert(Data);
	$.ajax({
		url: Url
   		,type: AjaxType
   		,success: SuccessFunc
		, beforeSend: BeforeFunc
		, data: UrlData
   	});
}

