function getRadioButtonSelectedValue(radioObj) {
  if(!radioObj)	return "";
  var radioLength = radioObj.length;
  if(radioLength == undefined) {
    if(radioObj.checked) 
      return radioObj.value;
    else 
      return "";
  }
  for(var i = 0; i < radioLength; i++) {
    if(radioObj[i].checked) return radioObj[i].value;
  }
  return "";
}

function WindowSize(whichSize) {
  var myWidth = 0, myHeight = 0;  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(whichSize=='WIDTH') return myWidth;
  if(whichSize=='HEIGHT') return myHeight;
}

function MyUrlEncode(uri) {
  text  = uri.replace(/\n/g, '<br>');
  text = text.replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A');
  return encodeURIComponent(text);
}

function MyTrim (str) {
  str = str.replace(/^\s+/, '');
  for (var i = str.length; i--;)
    if (/\S/.test(str.charAt(i))) return str.substring(0, ++i);
  return str;
}

function AdjustHomePictHeight(factor) { 
  var img = document.getElementById('pictImg'); 
  img.style.height = WindowSize('HEIGHT')* factor;
}

function AdjustHomeSignatureHeight(factor) { 
  var img = document.getElementById('signImg'); 
  img.style.height = WindowSize('HEIGHT')* factor;
}

function AdjustHomeImages() { 
  AdjustHomePictHeight(0.69);
  AdjustHomeSignatureHeight(0.13);
}

function AdjustPortfolioImagesWidth() { 
  var factor = 0.15;
  var id = 'exhibImg';
  var idlen = id.length;
  
  var width = WindowSize('WIDTH');
  width = width * factor
  elements = document.getElementsByTagName("img");
  for (i=0; i<elements.length; i++) {
    var elemid = elements[i].id;
    if(elemid.substring(0,idlen)==id) elements[i].style.width = width;
  }
}

function AdjustExhibImagesWidth() { 
  var factor = 0.14;
  var id = 'pictImg';
  var idlen = id.length;
  
  var width = WindowSize('WIDTH');
  width = width * factor;
  elements = document.getElementsByTagName("img");
  for (i=0; i<elements.length; i++) {
    var elemid = elements[i].id;
    if(elemid.substring(0,idlen)==id) elements[i].style.width = width;
  }
}
