﻿//Trim()
String.prototype.trim = function() {
	return (this.replace(/^\s+|\s+$/g,""));
}
//Ltrim()
String.prototype.ltrim = function() {
	return (this.replace(/^\s*/,""));
}
//Rtrim()
String.prototype.rtrim = function() {
	return (this.replace(/\s*$/,""));
}
Date.prototype.toFormatString = function(format){
    return (format.replace(/yyyy/g,this.getFullYear()).replace(/MM/g,this.getMonth()+1).replace(/dd/g,this.getDate()).replace(/HH/g,this.getHours()).replace(/mm/g,this.getMinutes()).replace(/ss/g,this.getSeconds()));
}
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = decodeURI(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
function $(id){return document.getElementById(id)}
function ImageResize(img){
	var i=new Image();
	i.src=img.src;
	if(i.width>img.width){
		i.height= i.height * (img.width/i.width)
		i.width=img.width;
	}
	if(i.height>img.height){
		i.width=i.width*(img.height/i.height);
		i.height=img.height;
	}
	img.height=i.height;
	img.width=i.width;
}