Is there static functions in javascript objects which can be called without instance?

This is my problem this code is wrapped in a object function
and i need to call the “switch image” which is on the gallery class

in php i could declare a functio as static and go to it like that

how do i do that on javascript?

		var id = $(this).attr('id').replace('rec_thumb_', '');
	}, function() {
		} );

You can use call or apply to achieve something similar:

// call,id);

// or apply which takes an array of arguments,[id,..]);

i tried this way and its NOT working :\

I have to access to “obj” object calling method and i cant find a way to do it…
anyone knows what do i need to do ?

function obj(){
	this.calling = function(id) {
		alert("Calling function, catched id: " + id );
	$('.a').hover(function() {
		var id = 0;, id); [COLOR="#FF0000"]// <-- NOT WORKING![/COLOR]
	} );
var newobj = new obj();

I don’t quite get why are you doing certain things in that example, like instantiating a new object when you want to use a function statically. What you can do if you want to use a function statically, or as a method on newly created objects you can use the objects prototype:

You can try this method:

<!DOCTYPE html>
		<a href="#" id="rec_thumb_test1">Link 1</a>
		<a href="#" id="rec_thumb_test2">Link 2</a>		
		<script src=""></script>
			var Gallery = (function () {
				function _switch(id) {
				return {
					'switch_image': _switch
			$('a').click(function(e) {
				var id = $(this).attr('id').substr(10);
					 $(this).attr('id', id);

ok now i can access the function but the next problem is how to i access the variables?

var obj = function(name){ = name;

   $('.a').hover(function() {,; [B][COLOR="#FF0000"]// <-- not returning any result![/COLOR][/B]
   }, function() {} );

obj.prototype = {
    callit: function(name)
        alert("Name: " + name);

var newObj = new obj('Dan');