function hideShow(id){
 var elem = document.getElementById(id);
 if (elem.style.display == "")
  elem.style.display = "none";
 else
  elem.style.display = "";
}
function mailWindow(url) {
	var currentPage = window.location;
	var currentTitle = window.document.title;
	var fullurl = url;
	if(url.indexOf('?')>=0)
		fullurl += "&";
	else
		fullurl +="?";
		
	fullurl += "value(referrerToUrl)="+encodeURIComponent(currentPage)+"&value(referrerToTitle)="+encodeURIComponent(currentTitle)+"%0A%0A";
	myWindow = window.open(fullurl, "", "toolbar,width=630,height=535,menubar=no,location=no,status=no,toolbar=no,scrollbars=yes,screenX=50,screenY=50");
	return false;
}
function insuranceWindow(url) {
	var currentPage = window.location;
	var currentTitle = window.document.title;
	var fullurl = url;
	if(url.indexOf('?')>=0)
		fullurl += "&";
	else
		fullurl +="?";
		
	fullurl += "value(referrerToUrl)="+encodeURIComponent(currentPage)+"&value(referrerToTitle)="+encodeURIComponent(currentTitle)+"%0A%0A";
	myWindow = window.open(fullurl, "", "toolbar,width=875,height=770,menubar=no,location=no,status=no,toolbar=no,scrollbars=yes,screenX=50,screenY=50");
	return false;
}
function newWindow(url) {
	var currentPage = window.location;
	var currentTitle = window.document.title;
	myWindow = window.open(url, "", "toolbar,width=875,height=770,menubar=no,location=no,status=no,toolbar=no,scrollbars=yes,screenX=50,screenY=50");
	return false;
}
function mailWindowId(url, id) {
	var fullurl = url;
	if(url.indexOf('?')>=0)
		fullurl += "&";
	else
		fullurl +="?";
		
	fullurl += "id="+id;
	myWindow = window.open(fullurl, "", "toolbar,width=630,height=535,menubar=no,location=no,status=no,toolbar=no,scrollbars=yes,screenX=50,screenY=50");
	return false;
}

function mailDetailsWindow(url, type) {
	var currentPage = window.location.host;
	var currentTitle = window.document.title;
	var fullurl = url;
	if(url.indexOf('?')>=0)
		 fullurl += "&";
	else
		 fullurl += "?";
	var mailedUrl = "http://"+currentPage+"/DLBe/type.do?id="+type;
	fullurl += "value(referrerToTitle)="+encodeURIComponent(currentTitle)+"%0A%0A&value(referrerToUrl)="+encodeURIComponent(mailedUrl);
	myWindow = window.open(fullurl, "", "toolbar,width=630,height=535,menubar=no,location=no,status=no,toolbar=no,scrollbars=yes,screenX=50,screenY=50");
	return false;
}

function open_popup(url, title) {
	return open_popup(url, title, 400, 400);
}
function open_popup(url, title, width, height) {
	if (!width) width = 400;
	if (!height) height = 400;
	window.open(url,name,'status=no,toolbar=no,location=yes,menubar=no,width='+width+',height='+height+',resizable=yes,scrollbars=yes');
	return false;
}  

var field;
var fullname;

function setValue(value, name) {
	if (field.type == "select-multiple") {
		done= false;
  		for( var i=0; i < field.length; i++ ) {
			if( i == field.selectedIndex) {
				field.options[i].text  = name;
				field.options[i].value = value;
				done = true;
			}
   		}
   		if (done == false) {
   			field.options[field.length] = new Option(name, value);	
   		}
	}
	if (field.type == "text") {
	  	field.value = value;	
	  	if (fullname) {
			fullname.innerHTML = name;
		}
	}
	if (field.type == "hidden") {
	  	field.value = value;	
	  	if (fullname) {
			fullname.innerHTML = name;
		}
	}

}

function setForm(inputfield) {
	field = inputfield;
	fullname="";
}

function selectUser (fullname1, username1) {
	fullname = fullname1;
	field = username1;
}

function showIfSelected(switchId, shownIds) {
 var switchFld = document.getElementsByName(switchId);
 if (switchFld.length == 0) {
   alert('switch field '+switchId+' not found');
   return;
 }
 for( var i=0; i < shownIds.length; i++ ) {
  var curId = shownIds[i];
  var curFld = document.getElementById(curId+'Field');
  if (!curFld) {
    alert('row '+curId+' not found');
    return;
  }
  if (switchFld[0].checked)
   curFld.style.display = '';
  else
   curFld.style.display = 'none';
 }
}