   function number_format( number, decimals, dec_point, thousands_sep ) {
	  var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
      var d = dec_point == undefined ? "," : dec_point;
      var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
      var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
      return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
   }

   function in_array(needle, haystack) {
	    var length = haystack.length;
	    for(var i = 0; i < length; i++) {
	        if(haystack[i] == needle) return true;
	    }
	    return false;
	}

   //use it before calling other content in the begining of the script
   function preload_image(image_url){
		var img = new Image();
		img.src = image_url;
   }
   
	var images = new Array()
	function preload_multiple_images() {
		for (i = 0; i < preload.arguments.length; i++) {
			images[i] = new Image()
			images[i].src = preload.arguments[i]
		}
	}
	
/*	Usage for preload_multiple_images:
	preload_multiple_images(
		"http://domain.tld/gallery/image-001.jpg",
		"http://domain.tld/gallery/image-002.jpg",
		"http://domain.tld/gallery/image-003.jpg"
	)   
*/
	
	function confirm_delete(message){
		var ans = confirm(message); 
		if(!ans) 
			return false;
		return true;	
	}

	function opacity(id, opacStart, opacEnd, millisec) { 
	    //speed for each frame 
	    var speed = Math.round(millisec / 100); 
	    createCookie('working', 1, 365);
	    var timer = 0; 
	
	    //determine the direction for the blending, if start and end are the same nothing happens 
	    if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) { 
			    setTimeout("changeOpac(" + i + ",'" + id + "', '"+ opacEnd +"')",(timer * speed)); 
			    timer++; 
			}
	    } else if(opacStart < opacEnd) {
	        for(i = opacStart; i <= opacEnd; i++){
	            setTimeout("changeOpac(" + i + ",'" + id + "', '"+ opacEnd +"')",(timer * speed)); 
	            timer++; 
	        }
	    } 
	} 
	
	//change the opacity for different browsers
	function changeOpac(opacity, id, opacEnd) { 
		//createCookie('working', 1, 365);		        
	    var object = document.getElementById(id).style; 
	    object.opacity = (opacity / 100); 
	    object.MozOpacity = (opacity / 100); 
	    object.KhtmlOpacity = (opacity / 100); 
	    object.filter = "alpha(opacity=" + opacity + ")"; 
	    if(opacity == 0 && opacEnd == 0){
			document.getElementById(id).style.visibility = 'hidden';     	
			//alert(id);
	    }
	    if(opacity == opacEnd){
	    	createCookie('working', 0, 365);
	    	//alert('end');
	    }	
		//createCookie('working', 0, 365);		        
	    
	}

	//Cookies function
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

	 // PHP-compatible urlencode() for Javascript
	function urlencode(s) {
		s = encodeURIComponent(s);
		return s.replace(/~/g,'%7E').replace(/%20/g,'+');
	}
	
	function Toggle(node, id)
	{
		if ( document.getElementById("cont_"+id).style.display == 'none')
		{		
			document.getElementById("stat_img_"+id).src = "images/minus.gif";
			document.getElementById("cont_"+id).style.display = '';
			createCookie('menu_opened_'+id, true, 5);
		}
		else
		{
			document.getElementById("stat_img_"+id).src = "images/plus.gif";
			document.getElementById("cont_"+id).style.display = 'none';
			eraseCookie('menu_opened_'+id);
		}
	}
	
	
	function Toggle_art(node, id)
	{
		if ( document.getElementById("cont_"+id).style.display == 'none')
		{		
			document.getElementById("stat_img_"+id).src = "images/minus.gif";
			document.getElementById("cont_"+id).style.display = '';
			createCookie('art_opened_'+id, true, 5);
		}
		else
		{
			document.getElementById("stat_img_"+id).src = "images/plus.gif";
			document.getElementById("cont_"+id).style.display = 'none';
			eraseCookie('art_opened_'+id);
		}
	}	
