function storeCaret(field_nam)
{
 if (field_nam.createTextRange) 
 {
  field_nam.caretPos = document.selection.createRange().duplicate();
 }
}
 
function storeForm(form_nam) {
	document.currentForm = form_nam;
}


function refreshParent()
{
 window.opener.location.reload();
}

function reloadParent(_url)
{
if (document.images) {
         window.opener.location.replace(_url);}
    else {
	 window.opener.location.href = _url;}

 return;
}

function reloadWin(_url)
{
if (document.images) {
         window.location.replace(_url);}
    else {
	 window.location.href = _url;}

 return;
}

function insertText(txt,field_nam) {
	var txtarea = field_nam;
	var caretPos = txtarea.caretPos;
	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? txt + ' ' : txt;
	txtarea.focus();
}


function newImage(img_file)
{
 if (document.images)
 {
   rslt = new Image();
   rslt.src = img_file;
   return rslt;
 }
}

//imageid: img-tag-name, imageobj: object-source, action: mouseout/mouseover.

function replaceImage(imageid, imageobj)
{
 if (document.images)
 {
  document.images[imageid].src=eval(imageobj + ".src")
 }
 return;
}

function changeValue(val, field_name)
{
  document.getElementById(field_name).value = val;
}

function getValue(field_name)
{
  return document.getElementById(field_name).value;
}

function replaceText(txtstring, field_name)
{
  document.getElementById(field_name).innerHTML = txtstring;
}

		function toggle( targetId ){ 
		  if (document.getElementById){ 
		        target = document.getElementById( targetId ); 
		           if (target.style.display == "none"){ 
		              target.style.display = ""; 
		           } else { 
		              target.style.display = "none"; 
		           } 
		     } 
		} 

function setContent(url_page, frame_name){

if (document.images) {
        parent[frame_name].location.replace(url_page);}
    else {
	parent[frame_name].location.href = url_page;}

 return;
}

function selectionAdd(pre, suf, field_name) //pre: prefix, suf: suffix, field_name: form-field-id.
{
 theSelection = document.selection.createRange();
 if (theSelection.text)
 {
  theSelection.text = pre + theSelection.text + suf;
  theSelection.text = '';
  document.selection.empty();
 }
 field_name.focus();
 return;
}

function searchPOP(x_coord, y_coord, page_url, wintitle, width, height, scroll)
{
	this.rest= 'width='+width+',height='+height+',,,,scrollbars='+scroll+',left='+x_coord+',top='+y_coord;
	this.searchwords = getValue('searchwords');
	this.searchsite = getValue('searchsite');
	this[wintitle] = window.open(page_url+'?searchwords='+this.searchwords+"&searchsite="+this.searchsite,wintitle,this.rest);
	this[wintitle].focus();
}

//x_coord, y_coord: top-left corner offset
//page_url: URI
//wintitle: window-object-name
//width,height: !
//scroll: yes/no

function winPOP(x_coord, y_coord, page_url, wintitle, width, height, scroll)
{
	this.rest= 'width='+width+',height='+height+',,,,scrollbars='+scroll+',left='+x_coord+',top='+y_coord;
	this[wintitle] = window.open(page_url,wintitle,this.rest);
	this[wintitle].focus();
}


             function imageOver(imageid)
             {
                if (document.images)
                {
                    document.images[imageid].src=eval(imageid + "Over.src")
                }
                return;
             }
             function imageOut(imageid)
             {
                if (document.images)
                {
                    document.images[imageid].src=eval(imageid + "Out.src")
                }
                return;
             }
             
             function preloadImage(imageid, imagesuffix) {
                this[imageid] = new Image(); 
                this[imageid].src = "CVimages/" + imageid + "." + imagesuffix;
      
             }
             function preloadButton(imageid, imagesuffix) {
                preloadImage(imageid + "Out", imagesuffix);
                preloadImage(imageid + "Over", imagesuffix);
 
             }


		function toggle( targetId ){ 
		  if (document.getElementById){ 
		        target = document.getElementById( targetId ); 
		           if (target.style.display == "none"){ 
		              target.style.display = ""; 
		           } else { 
		              target.style.display = "none"; 
		           } 
		     } 
		} 

