function getFooterYear(){
	yr = (new Date()).getYear();
	if (yr < 2000){
		yr += 1900;
	}
	return yr;
}
function fnOpenFixedWindow(url,w,h){
	var x = (screen.width - w) / 2;
	var y = (screen.height - h) / 2;
	popper = window.open(url, 'new_window', 'resizable=no,scrollbars=no,width='+w+',height='+h+',top='+y+',left='+x);
	popper.focus();
}
function fnOpenScrollingWindow(url,w,h){
	var x = (screen.width - w) / 2;
	//var y = (screen.height - h) / 2;
	var y = 20;
	popper = window.open(url, 'new_window', 'resizable=yes,scrollbars=yes,width='+w+',height='+h+',top='+y+',left='+x);
	popper.focus();
}
function openInOpener(url){
	if (window.opener){
		window.opener.location = url;
		window.opener.focus();
		window.close();
	} else {
		window.location = url;
	}
}
function trimLeft(s) {
	var whitespaces = " \t\n\r";
	for(n = 0; n < s.length; n++) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n > 0) ? s.substring(n, s.length) : s; }
	return("");
}
function trimRight(s){
	var whitespaces = " \t\n\r";
	for(n = s.length - 1; n  > -1; n--) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n < (s.length - 1)) ? s.substring(0, n+1) : s; }
	return("");
}
function trim(s) {return ((s == null) ? "" : trimRight(trimLeft(s))); }

function popOpenerRefresh(closePop){
	if (window.opener){
		window.opener.location = window.opener.location.toString();
		window.opener.focus();
	}
	if (closePop){
		window.close();
	}
}
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function shareFacebook() {
	u=location.href;
	t=document.title;
	if(window.OVERWRITE_SHARE_URL!=undefined){
		u=OVERWRITE_SHARE_URL;
	}
	if(window.OVERWRITE_SHARE_TITLE!=undefined){
		t=OVERWRITE_SHARE_TITLE;
	}
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
}
function shareTwitter() {
	u=location.href;
	t=document.title;
	window.open('http://twitter.com/home?status=Currently%20visiting%20'+encodeURIComponent(t)+"%20"+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=800,height=600');
}
function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}
function serialize(obj)
{
  var returnVal;
  if(obj != undefined){
  switch(obj.constructor)
  {
   case Array:
    var vArr="[";
    for(var i=0;i<obj.length;i++)
    {
     if(i>0) vArr += ",";
     vArr += serialize(obj[i]);
    }
    vArr += "]"
    return vArr;
   case String:
    returnVal = escape("'" + obj + "'");
    return returnVal;
   case Number:
    returnVal = isFinite(obj) ? obj.toString() : null;
    return returnVal;    
   case Date:
    returnVal = "#" + obj + "#";
    return returnVal;  
   default:
    if(typeof obj == "object"){
     var vobj=[];
     for(attr in obj)
     {
      if(typeof obj[attr] != "function")
      {
       vobj.push('"' + attr + '":' + serialize(obj[attr]));
      }
     }
      if(vobj.length >0)
       return "{" + vobj.join(",") + "}";
      else
       return "{}";
    }  
    else
    {
     return obj.toString();
    }
  }
  }
  return null;
}
