/**
 * Set focus on the element of the given id.
 * @param id The id of the element to set focus on.
 */
function setFocus(id) {
    var element = document.getElementById(id);
    if (element && element.focus) {
        element.focus();
    }
}

/**
 * Set highlight on the elements of the given ids. It basically sets the classname of the elements
 * to 'highlight'. This require at least a CSS style class '.highlight'.
 * @param ids The ids of the elements to be highlighted, comma separated.
 */
function setHighlight(ids) {
    var idsArray = ids.split(",");
    for (var i = 0; i < idsArray.length; i++) {
        var element = document.getElementById(idsArray[i]);
        if (element) {
            element.className = 'highlight';
        }
    }
}


/**
 * Set the scroll position of the window to the given element id. 
 * In here it should be the client ID of the element in the page.
 * @param id
*/
function scrollToElePos(id){
	var element = document.getElementById(id);
	var xPos = findPosX(element);
	var yPos = findPosY(element);
	window.scrollTo(xPos,yPos);
}

/**
 * Finding the X Position of the element in the window.<br>
 * @param element/obj 
*/
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

/**
 * Finding the Y Position of the element in the window.<br>
 * @param element/obj
*/
  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
  /**
  * setting default value in textbox and works with onfocus and onblur events.
  */
	function textChange(thisField, defaultText)
	{
	  if(thisField.value == defaultText)
	   {
	      thisField.value ="";
	   }
	   else if(thisField.value =="")
	   {
	      thisField.value = defaultText;
	   }
	}

