var li="<a href='http://www.liveinternet.ru/click' "+"target=_blank><img src='http://counter.yadro.ru/hit?t42.2;r"+escape(document.referrer)+((typeof(screen)=="undefined")?"":";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+";"+Math.random()+"' alt='' title='LiveInternet' "+"border='0' width='31' height='31'><\/a>";

// calculate the current window width //
function pageWidth() {
  return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

// calculate the current window height //
function pageHeight() {
  return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() {
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() {
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
} 

function randomString(length) {
    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
    
    if (! length) {
        length = Math.floor(Math.random() * chars.length);
    }
    
    var str = '';
    for (var i = 0; i < length; i++) {
        str += chars[Math.floor(Math.random() * chars.length)];
    }
    return str;
}


function ShowSpinner() {
	var left = leftPosition();
	var top = topPosition();
	var width = pageWidth();
	var height = pageHeight();
	var topposition = top + parseInt(height / 2)-100;
	var leftposition = left + parseInt(width / 2) -150;
	$('#spinner').css( "top", topposition + "px");
	$('#spinner').css( "left", leftposition + "px");
	$('#spinner').css( "display", "block");
}

function HideSpinner() {
	$('#spinner').css( "display", "none");
}

function objDump (obj, except) { 
 return  _objDump (obj, [obj], 0);
}
 
function inArray (arr, elt){
 for (var i = 0; i < arr.length; i++)
   if (elt == arr[i]) return i;
 return false;
}

function _objDump (obj, used, level) { 
var rez = '';
var spaces = "";
for (var i = 0; i < level; i++)
  spaces += "  ";
  rez += spaces+('---Dumping object: ' + obj.toString () + "\n"); 
  for (var i in obj) { 
    if (used && inArray(used ,obj[i]) !== false) {
      rez += spaces+"->"+"!Self Reference"+"\n";
      continue; 
    }
    rez += (spaces+"->" + i + ': '); 
    if ( (typeof obj[i]) == "object"){
     try{
      rez += _objDump (obj[i], used.slice(0).push(obj[i]), 1 +level) +"\n";
     }catch (eee) {rez += spaces+"->"+"!Error"+"\n";}
    }
    else
      rez +=(spaces+"->"+obj[i] + "\n"); 
  } 
  return  rez; 
}