﻿function $(id){
	return document.getElementById(id);
}

function $F(id){
	return document.getElementById(id).value.trim();
}

function DrawImage(img,width,height){
if(width==null) width=68;
if(height==null) height=102;
var image=new Image(); 
image.src=img.src;
	if(img.height>height)
	{
		rate=image.width/image.height;
		newWidth=rate*height;
		//img.height=height;
		//img.width=newWidth;
	}
	if(image.width>0 && image.height>0)
	{
	  	rate=image.height/image.width;
	  	newHeight=rate*width;
	  	//img.width=width;
	  	//img.height=newHeight;
	}
}

function setCookie (name, value, days) {
  var expires = new Date();
  expires.setTime (expires.getTime() + (86400 * 1000 * days));
  document.cookie = name + "=" + escape(value) +   "; expires=" + expires.toGMTString() +  "; path=/";
}

function getCookie(name) {
  var search;
  search = name + "="
  offset = document.cookie.indexOf(search) 
  if (offset != -1) {
    offset += search.length ;
    end = document.cookie.indexOf(";", offset) ;
    if (end == -1)
      end = document.cookie.length;
    return unescape(document.cookie.substring(offset, end));
  }
  else
    return "";
}

function deleteCookie(name) {
  var expdate = new Date();
  expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
  setCookie(name, "", expdate);
}

function hideElm(id) {
    var el = document.getElementById(id);
    if(el!=null)
	    el.style.visibility = "hidden";	
}

function displayElm(id) {
    var el = document.getElementById(id);
    if(el!=null)
	    el.style.visibility = "visible";	
}

function getposOffset(what, offsettype) { 
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; 
    var parentEl=what.offsetParent; 
    while (parentEl!=null)
    { 
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; 
         parentEl=parentEl.offsetParent; 
    } 
    return totaloffset; 
} 