function openSearchablePopup(type,source,popuptype,myWidth,myHeight,path,form,returnField,value_fieldname,value_fieldtype,caption_fieldname,caption_fieldtype,sendval,val)
{		
	
	a=eval("document.forms[form]."+returnField);

	fieldval=a.value;
	
	if (sendval && !val)
	{
		val=fieldval;
	}
	else
	{
		val='';
	}	
	if (!myWidth) myWidth=451;
	if (!myWidth) myWidth=451;
	if (!caption_fieldname) caption_fieldname='';
	if (!caption_fieldtype) caption_fieldtype='';
	additionalURLScript="";
	multi=0;
	if (popuptype == 'record_multi')
	{
		popuptype="record";
		multi=1;
	}
	
	dependency_field=eval("document.forms[form]."+value_fieldname+"_dependency_field");
	dependency_group=eval("document.forms[form]."+value_fieldname+"_dependency_group");
	
	if (dependency_field && dependency_group) 
	{
		temp_dependency_field=eval("document.forms[form]."+dependency_field.value);
		
		if (temp_dependency_field)
		{
			dependency_field_value=temp_dependency_field.value;
		}
		else
		{
			dependency_field_value="";
		}
		additionalURLScript="&dg="+dependency_group.value+"&df="+dependency_field.value+"&dv="+dependency_field_value;
	}
	
	depend_on_refreshedfld=eval("document.forms[form]."+value_fieldname+"_depend_on_refreshedfld");
	
	if (depend_on_refreshedfld)
	{
		temp_depend_on_refreshedfld=eval("document.forms[form]."+depend_on_refreshedfld.value);
		
		if (temp_depend_on_refreshedfld)
		{
			depend_on_refreshedfld_value=temp_depend_on_refreshedfld.value;
		}
		else
		{
			depend_on_refreshedfld_value="";
		}
		
		if (additionalURLScript=='')
		{
			additionalURLScript="&drf="+depend_on_refreshedfld.value+"&drv="+depend_on_refreshedfld_value;
		}
		else
		{
			additionalURLScript=additionalURLScript+"&drf="+depend_on_refreshedfld.value+"&drv="+depend_on_refreshedfld_value;
		}
	}
	
	var myLeft = (screen.width-myWidth)/2;
	var myTop = (screen.height-myHeight)/2;
	window.open(path+'?type='+type+'&source='+source+'&popuptype='+popuptype+'&target_form='+form+'&returnField='+returnField+'&value_fieldname='+value_fieldname+'&caption_fieldname='+caption_fieldname+'&value_fieldtype='+value_fieldtype+'&caption_fieldtype='+caption_fieldtype+'&multi='+multi+'&fv='+fieldval+'&search_text='+val+additionalURLScript,'SearchPopup','menubar=0,status=1,toolbar=0,scrollbars=1,resizable=1,width='+myWidth+',height='+myHeight+',left='+myLeft+',top='+myTop);	
}



var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function calcDate(daydropdown,monthdropdown,yeardropdown,txtdate)
   {
   	var daydropdown_field=document.getElementById(daydropdown);
	var monthdropdown_field=document.getElementById(monthdropdown);
	var yeardropdown_field=document.getElementById(yeardropdown);
	var txtdate_field=document.getElementById(txtdate);
	
   /*checks for a valid date*/
   if (!(validateDate(daydropdown_field,monthdropdown_field,yeardropdown_field)))
      {
	      txtdate_field.value = "";
	     // alert("Invalid Date" + "\n" + "Please Check!");
      }
   else
      {
      //if all 3 dropdowns aren't "- -" then populate txtdate textbox
      if (daydropdown_field.selectedIndex != 0 && monthdropdown_field.selectedIndex != 0 && yeardropdown_field.selectedIndex != 0)
         {
           txtdate_field.value = daydropdown_field.value + "/" + monthdropdown_field.value + "/" + yeardropdown_field.value;
         }
      else
         {
         	txtdate_field.value = "";
         }
      }
   }		

function validateDate(day, month, year)
   //check correct number of day for given month/year
   {
   if (day.selectedIndex != 0 && month.selectedIndex != 0 && year.selectedIndex != 0)
   {
      switch(month.value) 
         {
         case "02" :
            //February
            if (year.value == Math.round(year.value / 4) * 4)
	       //leap year
	       {
		       	if (day.value > 29){
					return false;
				}
           	}
            else
              {
               //non-leap year
               if (day.value > 28){
			   	return false;
			}
              }
              	break;	
         case "04" :
            //April
            if (day.value > 30){
               return false;
            }	
            break;
         case "06":
            //June
            if (day.value > 30){
               return false;
            }	
            break;		
         case "09":
            //September
            if (day.value > 30){
               return false;
            }	
            break;
         case "11":
            //November
            if (day.value > 30)
            {
               return false;
            }	
            break;
         default:
            //date is valid
            return true;
            break;
         }
      }
   }	

function getActualValue(val,field_name,field_id){
	startIndex = val.lastIndexOf('(');
	endIndex = val.lastIndexOf(')');
	if (startIndex != -1 && endIndex != -1)
	{
		var actualvalue = val.substring(startIndex+1,endIndex);
		var displayvalue = val.substring(0,startIndex-1);
		displayvalue = displayvalue.replace(/&/,'%26');
		params= '?actualvalue='+actualvalue+'&displayvalue='+displayvalue+'&field_name='+field_name+'&field_id='+field_id;
		easyAjax('/console/shared/utilities/ec_edit_record/ajax/check_autosuggest.cfm'+params,'ajaxtestForm');
	}
	else if (val != '') 
	{
		document.getElementById(field_name).value = ""
		document.getElementById(field_name+'_display').value = ""
		document.getElementById(field_name).focus();
	}
	else if (val == '')
	{
		document.getElementById(field_name).value = ""
		document.getElementById(field_name+'_display').value = ""
		document.getElementById(field_name).focus();
	}
}



/*
   
function populatedropdown(dayfield, monthfield, yearfield,startYear,noOfYears){
	var today=new Date();
	var dayfield=document.getElementById(dayfield);
	var monthfield=document.getElementById(monthfield);
	var yearfield=document.getElementById(yearfield);
	
	
	for (var i=0; i<31; i++){
		if(i==0){
			dayfield.options[i]=new Option('--',0);
		}
		else{
		//dayfield.options[i]=new Option(i, i+1);
		dayfield.options[i]=new Option(i,i);
		//dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
		}
	}
	
	
	for (var m=0; m<12; m++){
		if(m==0){
			monthfield.options[m]=new Option('--',0);
		}
		else{
			monthfield.options[m]=new Option(monthtext[m], m+1)
			//monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
		}
	}
	
	//Initialisation to current year
	//var thisyear=today.getFullYear();
	
	for (var y=0; y<noOfYears; y++){
		if(y==0){
			yearfield.options[y]=new Option('--',0);
		}
		else{
			yearfield.options[y]=new Option(startYear, startYear)
			startYear+=1;
		}
	}
	
	//yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}

*/
