
$.fn.hasAttr = function(name){  
	if(this.attr(name) !== undefined )
		return true;
	else
		return false;
};
	
//IMAGE PRELOAD
var preloaded = new Array();
function preload_images() {
	for (var i = 0; i < arguments.length; i++){
		preloaded[i] = document.createElement('img');
		preloaded[i].setAttribute('src',imageDir + arguments[i]);
	};
};

//Add to bookmark
function addBookmark(title, url) {
	if (window.sidebar) { // firefox
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) { //MSIE
		window.external.AddFavorite( url, title);
	} else if(window.opera && window.print){
		alert('Naciśnij ctrl+D, aby dodać stronę do ulubionych.');
	} else if(window.chrome){
		alert('Naciśnij ctrl+D, aby dodać stronę do ulubionych.');
	}
}
	
	
//EMPTY	
function isEmpty(variable)
{
	
	if( variable == 'undefined' || variable == 'NaN' || variable == '' || typeof( variable ) == 'undefined') 
		return true;
		
	return false; 	
}

//ISSET	
function isset( variable ){
	return( typeof( variable ) != 'undefined' );
}

//REPLACE
function replace(f, r, s){
	var ra = r instanceof Array, sa = s instanceof Array, l = (f = [].concat(f)).length, r = [].concat(r), i = (s = [].concat(s)).length;
	while(j = 0, i--)
		while(s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j < l);
	return sa ? s : s[0];
}

function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}
function doRound(x, places) {
  return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
}
function IncludeJavaScript(jsFile)
{
 
   $("head").append('<script type="text/javascript" src="' + php_root + '/js/' + jsFile + '.js"></scr' + 'ipt>');
}
function Include(jsFile)
{ 
	IncludeJavaScript(jsFile); 
}
function IncludeJS(jsFile)
{ 
	IncludeJavaScript(jsFile); 
}
function IncludeProjectJS(jsFile)
{ 
	$("head").append('<script type="text/javascript" src="' + php_root + '/' + php_project + '/js/' + jsFile + '.js"></scr' + 'ipt>');
}

function IncludeJSCombine(jsFile)
{
	$("head").append('<script type="text/javascript" src="' + jsFile + '.js"></scr' + 'ipt>');
}

function IncludeCSS(cssFile)
{
   $("head").append('<link rel="stylesheet" href="' + php_root + '/' + php_project + '/css/'+ cssFile +'.css" />');
}
