/**************************************Simple functions**************************************/

function encodeURLdata(data) {
	var temp = data.replace(/\+/g, "||||");
  temp = escape(temp);
  return temp;
}

function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 20;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function getDeviceDPI() {
  var a=document.documentElement.clientWidth>=480?'1':'0';
  return a;
}

function scroll_To(target) {
  var speedscroll = 30;
  var temp_scroll_position = document.documentElement.scrollTop;
  if(temp_scroll_position < target) {
    while(temp_scroll_position < target) {
      document.documentElement.scrollTop = temp_scroll_position + Math.ceil(((target - temp_scroll_position) / speedscroll) + 1);
      temp_scroll_position = document.documentElement.scrollTop;
    }
  } else if(temp_scroll_position > target) {
    while(temp_scroll_position > target) {
      document.documentElement.scrollTop = temp_scroll_position - Math.ceil(((temp_scroll_position - target) / speedscroll) + 1);
      temp_scroll_position = document.documentElement.scrollTop;
    }
  }
  return false;
}
