
<!-- Begin
// Browsercheck
function browserCheck() {
	browser = (((navigator.appName == "Netscape") &&
	(parseInt(navigator.appVersion) >= 5 )) || 
	((navigator.appName == "Microsoft Internet Explorer") && 
	(parseInt(navigator.appVersion) >= 4 )))
	if (browser) {
	}
	else {
		alert('OPGELET: uw browser is niet ondersteund.\n\nDe volgende browsers zijn ondersteund:\n\nMicrosoft IE 4.x en hoger\nNetscape Navigator 6.x en hoger');
	}
}


//Move list items
function addSrcToDestList(i,j) {
	var destList = window.document.form.elements[j];
	var srcList = window.document.form.elements[i]; 
		
	var len = destList.length;
	for(var i=0;i < srcList.length;i++){
		if(srcList.options[i].selected){
			if ((srcList.options[i] != null)) {
				//Check if this value already exist in the destList or not
				//if not then add it otherwise do not add it.
				var found = false;
				for(var count = 0; count < len; count++) {
					if (destList.options[count] != null) {
						if (srcList.options[i].value == destList.options[count].value) {
							found = true;
							break;
					      }
   					}
				}
				if (found != true) {
					//destList.options[len]=new Option(srcList);
					destList.options[len]= new Option();
					destList.options[len].text = srcList.options[i].text;
					destList.options[len].value= srcList.options[i].value;
					len++;
			
       		  	}
      		}
	  		srcList.options[i]=null;
	  		i--;
		}	
	}
	
	//window.document.form.elements[i].value = "";   	
	//window.document.form.elements[i].focus();		
}

//Move All list items
function addAllSrcToDestList(i,j) {
	var destList = window.document.form.elements[j];
	var srcList = window.document.form.elements[i]; 
	
	for(var k=0;k<srcList.length;k++){
		srcList.options[k].selected=true;
	}
	addSrcToDestList(i,j);

}

function countOptions(field){
	var totOptions = 0;
	for(i = 0; i < field.length; i++){
		if(field.options[i].value != ""){
			totOptions = totOptions + 1; 
		}
	}
	return totOptions;
}

//Delete All list items
function deleteListItems(i) {
	var srcList = window.document.form.elements[i]; 
	
	for(var k=0;k<srcList.length;k++){
		if(srcList.options[k].value != ""){
			srcList.options[k].value = "";
			srcList.options[k].text = "";
		}
	}
}

function addSrcToDestList1(i,j) {
	var destList = window.document.form.elements[j];
	var srcList = window.document.form.elements[i]; 
		
	var len = destList.length;
	for(var i=0;i < srcList.length;i++){
		if(srcList.options[i].selected){
			if ((srcList.options[i] != null)) {
				//Check if this value already exist in the destList or not
				//if not then add it otherwise do not add it.
				var found = false;
				for(var count = 0; count < len; count++) {
					if (destList.options[count] != null) {
						if (srcList.options[i].value == destList.options[count].value) {
							found = true;
							break;
					      }
   					}
				}
				if (found != true) {
					//destList.options[len]=new Option(srcList);
					destList.options[len]= new Option();
					destList.options[len].text = srcList.options[i].text;
					destList.options[len].value= srcList.options[i].value;
					len++;
			
       		  	}
      		}
	  		//srcList.options[i]=null;
	  		//i--;
		}	
	}
	
	//window.document.form.elements[i].value = "";   	
	//window.document.form.elements[i].focus();		
}

function delFromList(i) {
	var srcList = window.document.form.elements[i]; 
	
	for(var k=0;k<srcList.length;k++){
		if(srcList.options[k].selected){
			srcList.options[k] = null;
		}
	}
}

function windowOpen(url,title){
	var options = 'location=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=yes';
	win = window.open(url,title,options);
}

function getradioinfo(thisobj, dn, ret){
	if(thisobj.length == 0){
		thisobj.options[0]= new Option();
	}
	thisobj.options[0].value = dn;
	//thisobj.options[0].text = ret;
	//Decode the single quotes
	thisobj.options[0].text = ret.replace(/’/g,"'");
	//if(otherScriptFields){	otherScriptFields(thisobj);}
}

function getcheckinfo(thisobj, ret){
	var len = thisobj.length;
	var aRet = ret.split("#");
	for(i=0;i<aRet.length-1;i++){
		flag = true;
		for(k=0; k<thisobj.options.length; k++){
			if(thisobj.options[k].value == aRet[i]){
				flag=false;
			}
		}
		if(flag){
			thisobj.options[len] = new Option();
			thisobj.options[len].value = aRet[i];
			i++
			thisobj.options[len].text = aRet[i];
			len++
		} else {
			i++;
		}
	}
	//if(otherScriptFields){	otherScriptFields(thisobj);}
}

function delItems(thisobj){
	if(thisobj.length > 0){
		for(i=thisobj.length-1;i>=0;i--){
			if(thisobj.options[i].selected){
				thisobj.options[i] = null;
			}
		}
	    //if(otherScriptFields){	otherScriptFields(thisobj);}
	}
}

function addToList(list,Id,optionNL,optionUK,optionFR,optionDE,Condition){
  var List = window.document.forms[0].elements[list];
  var len = List.length;
	
  var Id = window.document.forms[0].elements[Id];
  var optionNL = window.document.forms[0].elements[optionNL];
  var optionFR = window.document.forms[0].elements[optionFR];
  var optionDE = window.document.forms[0].elements[optionDE];
  var optionUK = window.document.forms[0].elements[optionUK];
  var Condition = window.document.forms[0].elements[Condition];
  
  if(optionNL.value != ""){
	if(optionFR.value == "")optionFR.value = optionNL.value;
	if(optionDE.value == "")optionDE.value = optionNL.value;
	if(optionUK.value == "")optionUK.value = optionNL.value;	
	if(Condition.value == "")Condition.value = 'true';	
  }
	
  var totOption = Id.value + "#NL#" + optionNL.value + "#FR#" + optionFR.value + "#DE#" + optionDE.value + "#UK#" + optionUK.value + "#COND#" + Condition.value + "#";
	
  List.options[len]= new Option();
  List.options[len].text = totOption;
  List.options[len].value= totOption;
  
  Id.value = "";
  optionNL.value = "";
  optionFR.value = "";
  optionDE.value = "";
  optionUK.value = "";	
  Condition.value = "";	
}

function addToFields(list){
	var List = window.document.forms[0].elements[list];
	
	for(var i=0;i < List.length;i++){
		if(List.options[i].selected){
			var item = List.options[i].value;
			items = item.split("#");
			List.options[i] = null;
			for(var x=0; x<items.length;x++){
				if(x==0){window.document.forms[0].elements["_Id"].value=items[x];}
				if(items[x]=='NL'){window.document.forms[0].elements["_OptieNL"].value=items[x+1];}
				if(items[x]=='FR'){window.document.forms[0].elements["_OptieFR"].value=items[x+1];}
				if(items[x]=='UK'){window.document.forms[0].elements["_OptieUK"].value=items[x+1];}
				if(items[x]=='DE'){window.document.forms[0].elements["_OptieDE"].value=items[x+1];}
				if(items[x]=='COND'){window.document.forms[0].elements["_Condition"].value=items[x+1];}
			}	
		}
	}
}

function moveUp(list){
	var List = window.document.forms[0].elements[list];
	
	var len = List.length;

	for(var i=0;i < List.length;i++){
		if(List.options[i].selected & (i!=0)){
			var tempval = List.options[i-1].value;
			var temptxt = List.options[i-1].text;
			
			List.options[i-1].value = List.options[i].value;
			List.options[i-1].text = List.options[i].text;
			List.options[i].value = tempval;
			List.options[i].text = temptxt;
			
		}
	}
}

function popup(screen){
	popup(screen,'_new','xxx=eee');
}

function popup(screen,target){
	popup(screen,target,'');
}

function popup(screen,target,params){
	if(params != ''){
		params = '&' + params
	}
	window.open('Popup.gs?popup='+screen+params, target, 'location=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=yes');
//	window.open('vlecautopopup.jsp?popup='+screen+params, target, '');
}

function gsMail(params){
	window.open('gsMail.jsp?' + params , 'email', 'location=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=yes');
}

function doc(lib,doc){
	window.open('gsViewDoc.jsp?lib='+lib+'&doc='+doc, "doc", 'location=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=yes');
//	window.open('gsDoc.jsp?lib='+lib+'&doc='+doc, "doc", 'location=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=yes');
}

function selAllData(dit) {
	var destList  = dit;
	for(var i = (destList.options.length-1); i >= 0; i--) {
		destList.options[i].text = destList.options[i].value ;
		destList.options[i].selected = true;
   	}
}

function gsNumeric(dit, defa, mandatory){
	var gsField = dit.value;
    dit.value = dit.value.replace(',','.');
    if(dit.value.indexOf('.') == dit.value.lastIndexOf('.'))
    {
	    return gsInField(dit, '0123456789.', defa, mandatory);
	} 
	else
	{
	    gsMessage(dit);
	    return false;
	}
}

function gsTel(dit, defa, mandatory){
    i = 0;
    while(dit[i])
    {
        if( CheckTel(dit[i].value) == false )
        {
	        dit[i].focus();
	        if(dit[i].select){	dit[i].blur(); dit[i].select();}
	        return false;
        }
        i++;
    }
	return true;    
}

function gsInteger(dit, defa, mandatory){
	return gsInField(dit, "0123456789", defa, mandatory);
}

function gsString(dit, defa, mandatory){
	return gsOutField(dit, "\"", defa, mandatory);
}

function gsPassword(dit, defa, mandatory){
	return gsOutField(dit, "<>\"", defa, mandatory);
}

function gsMemo(dit, defa, mandatory){
	return gsOutField(dit, "", defa, mandatory);
}

function gsHtml(dit, defa, mandatory){
	return gsOutField(dit, "", defa, mandatory);
}

function getReverseDate(dit){
	var gsField = dit.value;
	vdt = gsField.split("/");
	if(!(gsField == "")){
		temp = vdt[2];
		if(vdt[1].length < 2){temp += "0";}
		temp +=  vdt[1];
		if(vdt[0].length < 2){temp += "0";}
		temp +=  vdt[0];
		dit.value=temp;
	}
}

function gsDate(dit, defa, mandatory){
	if(gsInField(dit, "/1234567890", defa, mandatory)){
		var gsField = dit.value;
		var dates = gsField.split("/");
		if(gsField == "" && mandatory == "O"){dit.value = defa; return true;}
		if(dates.length != 3){gsMessage(dit);return false;}
		if(dates[2].length != 4){gsMessage(dit);return false;}  
		mm = parseInt(dates[1]);
		if(dates[1] == "08"){
			mm = 8;
		}	
		if(dates[1] == "09"){
			mm = 9;
		}	
		d = parseInt(dates[0]);
		j = parseInt(dates[2]);
		var dagen = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
		if(mm<1 || mm>12){gsMessage(dit);return false;}
		if(d<0 && d>dagen[mm-1]){gsMessage(dit);return false;}
		if(mm==2 && d==29){
			if(j%4!=0){return false;}
			if(j%100==0 && j%400!=0){gsMessage(dit);return false;}
		}
	} else {
		gsMessage(dit);return false;
	}
	return true;
}

function gsOutField(dit, notvalid, defa, mandatory){
	var gsField = dit.value;
	if(gsField == "")
       {
       	if(dit.options){ if(dit.options[0]) {gsField = dit.options[0].value;}}
       }
	if(gsField == "" && mandatory == "O"){dit.value = defa; return true;}
	if(gsField == "" && mandatory == "MO"){gsMessage(dit);return false;}
	for (var j=0; j<gsField.length; j++) {
		temp = gsField.substring(j, j+1);
		if (notvalid.indexOf(temp) != "-1"){gsMessage(dit);return false;}
	}
	return true;
}


function gsInField(dit, vali, defa, manda){
	var gsField = dit.value;
	if(gsField == "" && manda == "O"){dit.value = defa; return true;}
	if(gsField == "" && manda == "MO"){gsMessage(dit);return false;}
	for (var j=0; j<gsField.length; j++) {
		temp = gsField.substring(j, j+1);
		if (vali.indexOf(temp) == "-1"){gsMessage(dit);return false;}
	}
	return true;
}

function gsAllowedChars(dit, vali, notvalid)
{
    isie = false;
    keynum = -1;
    if(dit.keyCode) 
    {
        if(navigator.appName == "Netscape"){return true;}
        isie = true;
        keynum = dit.keyCode;
    }
    else if(dit.which && navigator.appName == "Netscape") 
    {
        keynum = dit.which;
    }
    if(keynum >= 0)
    {
        temp = String.fromCharCode(keynum);
        if(vali != "")
        {
            if (vali.indexOf(temp) == "-1"){if(isie==true){dit.keyCode=null;};return false;}
        }
	    if (notvalid.indexOf(temp) != "-1"){if(isie==true){dit.keyCode=null;};return false;}
	}
	return true;
}

function gsMailAddress(obj) {
		str = obj.value;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail")
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail")
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail")
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail")
		    return false
		 }
		 // RFC3371 RMM NATO 22/10/2009 Add Validation on 2 characters after dot
 		 var part1 = str.substring(lat);
		 var part2 = part1.substring(part1.indexOf(dot));
		 if(part2.length < 3)
		 { 
		    alert("Invalid E-mail")
		    return false
		 }
 		 return true					
	}

function gsMessage(dit){
	dit.focus();
	if(dit.select){	dit.blur(); dit.select();}
	return false;
}

function gsAlert(dit, text)
{
    obj = document.getElementById(dit);
    if(obj)
    {
		if(text == "")
		{
		    obj.style.visibility = 'hidden';
		} else {
		    obj.style.display = 'block';
		    obj.style.visibility = 'visible';
            obj.innerHTML = text;
        }
    } else {
        if(text != ""){alert(text);}
    }
}

function doScript(script, param){
	document.view.action="gsScript.jsp?script="+script + param;
	document.view.target="script";
	document.view.submit();
}

function startTextArea(obj){
  objTextArea = obj;	
  height = parseInt(obj.style.height);
  interval = setInterval("calcTextArea()",1);
}
function calcTextArea(){
	temp = objTextArea.scrollHeight;
	if(temp > height){
		objTextArea.style.height = temp + "px";
	}
}
function stopTextArea(obj){
  obj.style.height = height;	
  clearInterval(interval);
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};

function trim(value) {
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}

// build a filter
//
function Search(field)
{
    this.form = "document.form.";
    this.field = field;
    this.extrafield = field + "_extra";
    this.extrafield1 = field + "_files";
    this.extrafield2 = field + "_extra2";
    
    x = eval("document.form");
    if(x)
    { 
    	x= eval("document.form." + this.field);
    	if(x)
    	{
	    	eval(this.form + this.field + ".value = ''"); 
	    	eval(this.form + this.extrafield + ".value = ''"); 
	    	eval(this.form + this.extrafield1 + ".value = ''"); 
	    	eval(this.form + this.extrafield2 + ".value = ''"); 
    	}
    }
}

Search.prototype.SetForm = function(frm)
{
    this.form = "document." + frm + ".";
    eval(this.form + this.field + ".value = ''"); 
    eval(this.form + this.extrafield + ".value = ''"); 
    eval(this.form + this.extrafield1 + ".value = ''"); 
    eval(this.form + this.extrafield2 + ".value = ''"); 
}

Search.prototype.IsText = function(ldapName, fieldName, extraInfo)
{
    fld = eval(this.form + fieldName + ".value" );
    if(fld.trim() != "")
    {
        if(extraInfo)
        {
            retValue = "(vlecextrainfo=" + ldapName + "#" + fld + ")";
        }
        else 
        {
            retValue = "(" + ldapName + "=" + fld + ")";
        }
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.Inner = function(value)
{
    i = value.indexOf('"');
    if(i<0){return value;}
    j = value.indexOf('"', i+1);
    if(j<0){return value.substring(i+1);}
    return value.substring(i+1, j);
}

Search.prototype.Outer = function(value)
{
    i = value.indexOf('"');
    if(i<0){return value;}
    j = value.indexOf('"', i+1);
    if(j<0){return value.substring(i);}
    return value.substring(i, j+1);
}

Search.prototype.InDocument = function(fieldName)
{
    fld = eval(this.form + fieldName + ".value" );
    if(fld == ""){return;}
    while(fld.indexOf('"') >= 0)
    {
        tmp = this.Inner(fld).replace(" ", "$");
        fld = fld.replace(this.Outer(fld), tmp);
    } 
    arr1 = trim(fld).split(" ");
    for(ii =0; ii < arr1.length; ii++)
    {
        tmp = trim(arr1[ii]).replace("$"," ");
        if(tmp.substring(0,1) == "+")
        {
            tmp = "#*" + tmp.substring(1) + "*";
        } else if(tmp.substring(0,1) == "-")
        {
            tmp = "-*" + tmp.substring(1) + "*";
        } else {
            tmp = "*" + tmp + "*";
        }
        eval(this.form + this.extrafield1 + ".value += '" + tmp + " '");
    }
    //alert(eval(this.form + this.extrafield1 + ".value"));
}

Search.prototype.InText = function(ldapName, fieldName, extraInfo)
{
    retValue = "";
    fld = eval(this.form + fieldName + ".value" );
    if(fld == ""){return;}
    while(fld.indexOf('"') >= 0)
    {
        tmp = this.Inner(fld).replace(" ", "$");
        fld = fld.replace(this.Outer(fld), tmp);
    } 
    arr1 = trim(fld).split(" ");
    ortmp = "";
    andtmp = "";
    for(ii =0; ii < arr1.length; ii++)
    {
        if(extraInfo)
        {
            retValue = "(vlecextrainfo=" + ldapName + "#*)";
            eval(this.form + this.extrafield + ".value += '[vlecextrainfo;" + ldapName + ";" + "*" + ";" + trim(arr1[ii]).replace("$"," ") + "]'"); 
        }
        else 
        {
            tmp = trim(arr1[ii]).replace("$"," ");
            if(tmp.substring(0,1) == "+")
            {
                tmp = "*" + tmp.substring(1) + "*";
                andtmp += "(" + ldapName + "=" + tmp + ")";
            } else if(tmp.substring(0,1) == "-")
            {
                tmp = "*" + tmp.substring(1) + "*";
                andtmp += "(!(" + ldapName + "=" + tmp + "))";
            } else {
                tmp = "*" + tmp + "*";
                ortmp += "(" + ldapName + "=" + tmp + ")";
            }
        }
    }
    if(ortmp != "")
    {
        retValue += "(|" + ortmp + ")" ;
    }
    if(andtmp != "")
    {
        retValue += andtmp ;
    }
    eval(this.form + this.field + ".value += '"  + retValue  + "'"); 
    //alert(eval(this.form + this.extrafield + ".value"));
}

Search.prototype.InText2 = function(ldapName, fieldName, extraInfo)
{
   
    retValue = "";
    fld = eval(this.form + fieldName + ".value" );
    if(fld == ""){return;}
    while(fld.indexOf('"') >= 0)
    {
        tmp = this.Inner(fld).replace(" ", "$");
        fld = fld.replace(this.Outer(fld), tmp);
    } 
    arr1 = trim(fld).split(" ");
    extratemp = "";
    ortmp = "";
    andtmp = "";
    exfield = "";
    exfield2 = "";
    for(ii =0; ii < arr1.length; ii++)
    {
        for(k=0; k < ldapName.length ;k++)
        {
            if(extraInfo[k])
            {
                //retValue += "(vlecextrainfo=" + ldapName[k] + "#*)";
                extratemp += "(vlecextrainfo=" + ldapName[k] + "#*)";
                if(exfield != "")
                {
                    exfield = exfield + "$" + ldapName[k];
                    exfield2 = exfield2 + "$vlecextrainfo";
                } else {
                    exfield = exfield + ldapName[k];
                    exfield2 = exfield2 + "vlecextrainfo";
                }
            }
            else 
            {
                tmp = trim(arr1[ii]).replace("$"," ");
                if(tmp.substring(0,1) == "+")
                {
                    tmp = "*" + tmp.substring(1) + "*";
                    andtmp += "(" + ldapName[k] + "=" + tmp + ")";
                } else if(tmp.substring(0,1) == "-")
                {
                    tmp = "*" + tmp.substring(1) + "*";
                    andtmp += "(!(" + ldapName[k] + "=" + tmp + "))";
                } else {
                    tmp = "*" + tmp + "*";
                    ortmp += "(" + ldapName[k] + "=" + tmp + ")";
                }
                if(exfield != "")
                {
                    exfield = exfield + "$" + ldapName[k];
                    exfield2 = exfield2 + "$" + ldapName[k];
                } else {
                    exfield = exfield + ldapName[k];
                    exfield2 = exfield2 + ldapName[k];
                }
            }
        }
        if(exfield != "")
        {
            eval(this.form + this.extrafield + ".value += '[" + exfield2 + ";" + exfield + ";" + "*" + ";" + trim(arr1[ii]).replace("$"," ") + "]'"); 
        }
        exfield = "";
    }
    if(extratemp != "")
    {
        ortmp +=  extratemp  ;
    }
    if(ortmp != "")
    {
        retValue += "(|" + ortmp + ")" ;
    }
    if(andtmp != "")
    {
        retValue += andtmp ;
    }
    eval(this.form + this.field + ".value += '"  + retValue  + "'"); 
    //alert(eval(this.form + this.field + ".value"));
    //alert(eval(this.form + this.extrafield + ".value"));
}

Search.prototype.IsCheckbox = function(ldapName, fieldName, extraInfo)
{
    fld = eval(this.form + fieldName + ".value" );
    if(fld.trim() != "*")
    {
        if(extraInfo)
        {
            retValue = "(vlecextrainfo=" + ldapName + "#" + fld + ")";
        }
        else 
        {
            retValue = "(" + ldapName + "=" + fld + ")";
        }
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.InList = function(ldapName, fieldName, extraInfo)
{
	retValue = "";
	count = eval(this.form + fieldName + ".options.length-1" );
	for(var i = count; i >= 0; i--) 
	{
        fld = eval(this.form + fieldName + ".options[i].value" );
        if(fld != "")
        {
	        if(extraInfo)
	        {
	            retValue += "(vlecextrainfo=" + ldapName + "#" + fld + ")";
	        }
	        else 
	        {
	            retValue += "(" + ldapName + "=" + fld + ")";
	        }
	     }
	}
	if(retValue != "")
	{
		retValue = "(|" + retValue + ")";
	}
    if(count >= 0)
    {
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.InList2 = function(ldapName, fieldName, extraInfo, type, score)
{
	retValue = "";
	count = eval(this.form + fieldName + ".options.length-1" );
	for(var i = count; i >= 0; i--) 
	{
        fld = eval(this.form + fieldName + ".options[i].value" );
        if(extraInfo)
        {
            retValue += "[vlecextrainfo;" + ldapName + ";*;" + fld + ";" + type + ";" + score + "]";
        }
        else 
        {
            retValue += "[" + ldapName + ";" + ldapName + ";*;" + fld + ";" + type + ";" + score + "]";
        }
	}
    if(count >= 0)
    {
        eval(this.form + this.extrafield2 + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.Skills = function(ldapName, fieldName, extraInfo)
{
    table = document.getElementById(fieldName+"_table");
    retValue = "";
    Rows = table.getElementsByTagName('TR');
    for(i=0; i < Rows.length; i++)
    {
       if(Rows[i].id)
       {
           if(Rows[i].id.substring(0,5) == "lang_")
           {
              code = Rows[i].id.substring(5);
              obj = document.getElementById(fieldName + "_" + code)
              if(obj)
              {
                value = obj.value;
                j = value.indexOf("#");
                if(j>0)
                {
                    value = value.substring(j+1);
                } else 
                {
                value = "";
                }
                eval(this.form + this.field + ".value+='(" + ldapName + "=" + ldapName + "_" + code + "#*)';");
                eval(this.form + this.extrafield + ".value+='["+ ldapName + ";" + ldapName + "_" + code + ";>=;" + value + "]';");
              }
           }
       }
    }
}

Search.prototype.Skills2 = function(ldapName, fieldName, extraInfo, type, score)
{
    table = document.getElementById(fieldName+"_table");
    retValue = "";
    Rows = table.getElementsByTagName('TR');
    for(i=0; i < Rows.length; i++)
    {
       if(Rows[i].id)
       {
           if(Rows[i].id.substring(0,5) == "lang_")
           {
              code = Rows[i].id.substring(5);
              obj = document.getElementById(fieldName + "_" + code)
              if(obj)
              {
                value = obj.value;
                j = value.indexOf("#");
                if(j>0)
                {
                    value = value.substring(j+1);
                } else 
                {
                value = "";
                }
                eval(this.form + this.extrafield2 + ".value+='["+ ldapName + ";" + ldapName + "_" + code + ";>=;" + value + ";" + type + ";" + score + "]'");
              }
           }
       }
    }
   // alert(eval(this.form + this.extrafield2 + ".value"));
}

Search.prototype.Skills3 = function(ldapName, fieldName, extraInfo, type, score)
{
    table = document.getElementById(fieldName+"_table");
    retValue = "";
    Rows = table.getElementsByTagName('TR');
    for(i=0; i < Rows.length; i++)
    {
       if(Rows[i].id)
       {
           if(Rows[i].id.substring(0,5) == "lang_")
           {
              code = Rows[i].id.substring(5);
              obj = document.getElementById(fieldName + "_" + code)
              if(obj)
              {
                value = obj.value;
                j = value.indexOf("#");
                if(j>0)
                {
                    value = value.substring(j+1);
                } else 
                {
                value = "";
                }
                eval(this.form + this.extrafield2 + ".value+='["+ ldapName + ";" + ldapName + "_" + code + ";<=;" + value + ";" + type + ";" + score + "]'");
              }
           }
       }
    }
   // alert(eval(this.form + this.extrafield2 + ".value"));
}

Search.prototype.BirthDay = function(ldapName, fieldName, extraInfo)
{
    fld1 = eval(this.form + fieldName + "_from.value" );
    fld2 = eval(this.form + fieldName + "_to.value" );
    if(fld1.trim() != "" || fld2.trim() != "")
    {
        fld1 = ReverseDate(fld1);
        fld1 = fld1.substring(4);
        fld2 = ReverseDate(fld2);
        fld2 = fld2.substring(4);
        if(extraInfo)
        {
            // not working correctly
            retValue = "(&(vlecextrainfo>=" + ldapName + "#" + fld1 + ")";
            retValue += "(vlecextrainfo<=" + ldapName + "#" + fld2 + "))";
        }
        else 
        {
            retValue = "(&(" + ldapName + ">=" + fld1 + ")";
            retValue += "(" + ldapName + "<=" + fld2 + "))";
        }
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.FromToText = function(ldapName, fieldName, extraInfo)
{
    fld1 = eval(this.form + fieldName + "_from.value" );
    fld2 = eval(this.form + fieldName + "_to.value" );
    if(fld1.trim() != "" || fld2.trim() != "")
    {
        if(extraInfo)
        {
            retValue = "(vlecextrainfo=" + ldapName + "#*)";
            //retValue += "(vlecextrainfo=" + ldapName + "#*)";
            eval(this.form + this.extrafield + ".value += '[vlecextrainfo;" + ldapName + ";" + ">=" + ";" + fld1 + "]'"); 
            eval(this.form + this.extrafield + ".value += '[vlecextrainfo;" + ldapName + ";" + "<=" + ";" + fld2 + "]'"); 
        }
        else 
        {
            retValue = "(" + ldapName + ">=" + fld1 + ")";
            retValue += "(" + ldapName + "<=" + fld2 + ")";
        }
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.FromToNumeric = function(ldapName, fieldName, extraInfo)
{
    fld1 = eval(this.form + fieldName + "_from.value" );
    fld2 = eval(this.form + fieldName + "_to.value" );
    if(fld1.trim() != "" || fld2.trim() != "")
    {
        if(extraInfo)
        {
            retValue = "(vlecextrainfo=" + ldapName + "#*)";
            //retValue += "(vlecextrainfo=" + ldapName + "#*)";
            eval(this.form + this.extrafield + ".value += '[vlecextrainfo;" + ldapName + ";" + ">=" + ";" + fld1 + ";N]'"); 
            eval(this.form + this.extrafield + ".value += '[vlecextrainfo;" + ldapName + ";" + "<=" + ";" + fld2 + ";N]'"); 
        }
        else 
        {
            retValue = "(" + ldapName + ">=" + fld1 + ")";
            retValue += "(" + ldapName + "<=" + fld2 + ")";
        }
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.FromToNumeric2 = function(ldapName, fieldName, extraInfo, type, score)
{
    fld1 = eval(this.form + fieldName + "_from.value" );
    fld2 = eval(this.form + fieldName + "_to.value" );
    if(fld1.trim() != "" || fld2.trim() != "")
    {
        if(extraInfo)
        {
            //eval(this.form + this.extrafield2 + ".value += '[vlecextrainfo;" + ldapName + ";" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]'"); 
            //eval(this.form + this.extrafield2 + ".value += '[vlecextrainfo;" + ldapName + ";" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]'"); 
            
            eval(this.form + this.extrafield2 + ".value += '[vlecextrainfo;" + ldapName + ";" + "#" + ";" + fld1 + "$" + fld2 + ";" + type + ";" + score + "]'"); 
        }
        else 
        {
            //eval(this.form + this.extrafield2 + ".value += '["+ ldapName + ";" + ldapName + ";" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]'"); 
            //eval(this.form + this.extrafield2 + ".value += '["+ ldapName + ";" + ldapName + ";" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]'"); 

            eval(this.form + this.extrafield2 + ".value += '["+ ldapName + ";" + ldapName + ";" + "#" + ";" + fld1 + "$" + fld2 + ";" + type + ";" + score + "]'"); 
        }
    }
}

Search.prototype.FromToNumeric3 = function(ldapName, fieldName, extraInfo, type, score)
{
    fld1 = eval(this.form + fieldName + ".value" );
    //fld2 = eval(this.form + fieldName + "_to.value" );
    if(fld1.trim() != "")
    {
        if(extraInfo)
        {
            eval(this.form + this.extrafield2 + ".value += '[vlecextrainfo;" + ldapName + "_from;" + "<=" + ";" + fld1 + ";" + type + ";" + score + "]'"); 
            eval(this.form + this.extrafield2 + ".value += '[vlecextrainfo;" + ldapName + "_to;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]'"); 
            
            //eval(this.form + this.extrafield2 + ".value += '[vlecextrainfo;" + ldapName + ";" + "#" + ";" + fld1 + "$" + fld2 + ";" + type + ";" + score + "]'"); 
        }
        else 
        {
            eval(this.form + this.extrafield2 + ".value += '["+ ldapName + ";" + ldapName + "_from;" + "<=" + ";" + fld1 + ";" + type + ";" + score + "]'"); 
            eval(this.form + this.extrafield2 + ".value += '["+ ldapName + ";" + ldapName + "_to;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]'"); 

            //eval(this.form + this.extrafield2 + ".value += '["+ ldapName + ";" + ldapName + ";" + "#" + ";" + fld1 + "$" + fld2 + ";" + type + ";" + score + "]'"); 
        }
    }
}

Search.prototype.FromToNumericFromTo = function(ldapName, fieldName, extraInfo, type, score)
{
    fld1 = eval(this.form + fieldName + "_from.value" );
    fld2 = eval(this.form + fieldName + "_to.value" );
    retValue = "[";
    if(fld1.trim() != "")
    {
        if(extraInfo)
        {
            retValue += "[vlecextrainfo;" + ldapName + "_from;" + "<=" + ";" + fld1 + ";" + type + ";" + score + "]"; 
            retValue += "[vlecextrainfo;" + ldapName + "_to;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]"; 
        }
        else 
        {
        	retValue += "["+ ldapName + ";" + ldapName + "_from;" + "<=" + ";" + fld1 + ";" + type + ";" + score + "]"; 
        	retValue += "["+ ldapName + ";" + ldapName + "_to;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]"; 
        }
    }
    if(fld2.trim() != "")
    {
        if(extraInfo)
        {
            retValue += "[vlecextrainfo;" + ldapName + "_to;" + ">=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
            retValue += "[vlecextrainfo;" + ldapName + "_from;" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
        }
        else 
        {
        	retValue += "["+ ldapName + ";" + ldapName + "_to;" + ">=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
        	retValue += "["+ ldapName + ";" + ldapName + "_from;" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
        }
    }
    retValue += "]";
    if(retValue != "[]"){
    	eval(this.form + this.extrafield2 + ".value +='" + retValue + "';");
    }
}

Search.prototype.FromToNumericFromTo3 = function(ldapName, fieldName, extraInfo, type, score)
{
    fld1 = eval(this.form + fieldName + "_from.value" );
    fld2 = eval(this.form + fieldName + "_to.value" );
    retValue = "[";
    if(fld1.trim() != "")
    {
        if(extraInfo)
        {
            retValue += "[vlecextrainfo;" + ldapName + "_from;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]";
            retValue += "[vlecextrainfo;" + ldapName + "_to;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]"; 
        }
        else 
        {
        	retValue += "["+ ldapName + ";" + ldapName + "_from;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]"; 
        	retValue += "["+ ldapName + ";" + ldapName + "_to;" + ">=" + ";" + fld1 + ";" + type + ";" + score + "]"; 
        }
    }
    if(fld2.trim() != "")
    {
        if(extraInfo)
        {
            retValue += "[vlecextrainfo;" + ldapName + "_to;" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
            retValue += "[vlecextrainfo;" + ldapName + "_from;" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
        }
        else 
        {
        	retValue += "["+ ldapName + ";" + ldapName + "_to;" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
        	retValue += "["+ ldapName + ";" + ldapName + "_from;" + "<=" + ";" + fld2 + ";" + type + ";" + score + "]"; 
        }
    }
    retValue += "]";
    if(retValue != "[]"){
    	eval(this.form + this.extrafield2 + ".value +='" + retValue + "';");
    }
}

Search.prototype.isDate = function(ldapName, fieldName, extraInfo)
{
    fld = eval(this.form + fieldName + ".value" );
    if(fld.trim() != "")
    {
        fld = ReverseDate(fld);
        if(extraInfo)
        {
            retValue = "(vlecextrainfo=" + ldapName + "#" + fld + ")";
        }
        else 
        {
            retValue = "(" + ldapName + "=" + fld + ")";
        }
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}

Search.prototype.FromToDate = function(ldapName, fieldName, extraInfo)
{
    fld1 = eval(this.form + fieldName + "_from.value" );
    fld2 = eval(this.form + fieldName + "_to.value" );
    if(fld1.trim() != "" || fld2.trim() != "")
    {
        fld1 = ReverseDate(fld1);
        fld2 = ReverseDate(fld2);
        if(extraInfo)
        {
            //retValue = "(&(vlecextrainfo>=" + ldapName + "#" + fld1 + ")";
            //retValue += "(vlecextrainfo<=" + ldapName + "#" + fld2 + "))";
            retValue = "(vlecextrainfo=" + ldapName + "#*)";
            eval(this.form + this.extrafield + ".value += '[vlecextrainfo;" + ldapName + ";" + "<=" + ";" + fld1 + "]'"); 
            eval(this.form + this.extrafield + ".value += '[vlecextrainfo;" + ldapName + ";" + ">=" + ";" + fld2 + "]'"); 
        }
        else 
        {
            retValue = "(&(" + ldapName + ">=" + fld1 + ")";
            retValue += "(" + ldapName + "<=" + fld2 + "))";
        }
        eval(this.form + this.field + ".value += '" + retValue + "'"); 
    }
}


function ReverseDate(dit){
	if(dit.trim() == "")
	{
	    return ""
	}
	vdt = dit.split("/");
	temp = vdt[2];
	if(vdt[1].length < 2){temp += "0";}
	temp +=  vdt[1];
	if(vdt[0].length < 2){temp += "0";}
	temp +=  vdt[0];
	return temp;
}
//--------------------------------------------------------------------------------------

/*
	document.form.step.value = y;
	old = document.form.build.value;
	if(x=='keyword'){
		temp = "<keyword><value>" + document.form._Field1.value + "</value></keyword>";
	} else {
	if(x=='Type'){
		temp = "<option><value>" + document.form.Type.value + "</value></option>";
	} else {
		temp = "<"+x+">";
		for(i=0; i<eval("document.form."+x+".length"); i++){
		temp = temp + "<value>" + eval("document.form."+x+".options["+i+"].value") + "</value>";
		}
		temp = temp + "</"+x+">";
	}
	}
	i = old.indexOf("<"+x+">");
	if(i>=0){
		if(i==0){
			part1 = "";
		} else {
			part1 = old.substring(0,i);
		}
		old = old.substring(i+1);
		i = old.indexOf("</"+x+">");
		if(i>=0){
			part2 = old.substring(i+3+x.length);
			old = part1 + part2;
		} 
	}	
	document.form.build.value = old + temp;
}
*/
//  End -->

/*

//---------Functions for Telephone Field


function Telephone(name)
{
    this.remember = -1;
    this.txt = document.getElementById(name+"_txt");
    this.div = document.getElementById(name+"_div");
    this.obj = document.getElementById(name);
    
    this.div.style.width = this.obj.style.width;
	this.txt.style.width = this.obj.style.width;
	this.resize();
}

Telephone.prototype.resize = function()
{
	if(this.obj.length > 3)
	{
        this.obj.size = this.obj.options.length;
    } else {
        this.obj.size = 3;
    }
}

Telephone.prototype.hide = function()
{
    if(this.validate(this.txt.value) != true)
    {
	    alert("Wrong telephone format");
	    this.txt.focus();
	    return false;
	} else {
        this.div.style.visibility = "hidden";
        for(var i= this.obj.options.length-1;i>=0;i--)
        {
	        if(this.obj.options[i].text == "")
	        {
	            this.obj.options[i] = null;
	        }
        }
        this.resize();
        return true;
    }
}

Telephone.prototype.edit = function()
{
    if(this.obj.options.length >0)
    {
        this.div.style.display = 'block';
	    this.div.style.visibility = 'visible';
        this.remember = this.obj.selectedIndex; 
        this.txt.value = this.obj.options[this.obj.selectedIndex].text;
        var newx = findPosX(this.obj.options[this.obj.selectedIndex]); 
        //var newy = findPosY(this.obj.options[this.obj.selectedIndex]);
        var tmpy = findPosY(this.obj);
        newy = tmpy + 13 * this.remember;  
        this.div.style.top = newy + 'px';
        this.div.style.left = newx + 'px';
        //alert(this.remember + "-" + newy + "-" + tmpy);
        this.txt.focus();
    }
}

Telephone.prototype.add = function() 
{
    this.obj.options[this.obj.options.length] = new Option("","");
    this.obj.options.selectedIndex = this.obj.options.length-1;
    this.resize();
    this.edit();
}

Telephone.prototype.remove = function() 
{
	for(var i=this.obj.options.length-1;i>=0;i--){
		if(this.obj.options[i].selected == true)
		{
		    this.obj.options[i] = null;
		}
	}
    this.resize();
}

Telephone.prototype.addOption = function()
{
    this.obj.options[this.remember].value = this.txt.value;
    this.obj.options[this.remember].text = this.txt.value;
}

Telephone.prototype.validate = function(val)
{
    if(val.trim() == "")
    {
        return true;
    }
    if(val.substring(0,1) == "+")
    {
        if(val.length > 10)
        {
            tst = "+0123456789";
            for(var j = 0; j < val.length; j++)
            {
                if(tst.indexOf(val.substring(j,j+1)) < 0)
                {
                    return false;
                }
            }
            return true;
        }
    }
    return false;
}

*/
//---------Functions for PopupField Field

function LinkField(action, linkField, options)
{
	action += "&linkField=";
	if(linkField != "")
	{
	    this.obj = document.getElementById(linkField);
	    if(obj)
	    {
		    if(this.obj.value == "")
		    {		            
		        action += obj.options[0].value;
		    } else {
		        action += obj.value;
		    }
	    }
	}
	window.open(action, "popup" , options);
}

///-------------------------------------------------------
//-Needed for preview of Associates-----

var xhr = false;
var xdn = "";


function ShowPreview(sender, displayDiv, dn, params)
{		
	
   GetPreview(sender, displayDiv, dn, params);
   return false;

	
}

function HidePreview(displayDiv)
{   
    var obj = document.getElementById(displayDiv);   
   
   
    if(obj)
    {
    	obj.style.visibility = "hidden";
    }
}

function GetPreview(sender, displayDiv, dn, params)
{	
	
	var obj = document.getElementById(displayDiv);	
	if(!obj)
	{
	    obj = document.createElement('DIV');
	    obj.id = displayDiv;
		obj.style.display = 'block';
		obj.style.visibility = 'visible';
		obj.style.position = "absolute";
		obj.style.zIndex = 5;
		document.body.appendChild(obj);
	}
	var obj = document.getElementById(displayDiv);	
    if(xdn != "p"+dn){    	
    	xdn = "p"+dn;
	    url = "viewAssociate.gs?dn=" + dn + "&" + params;
	    url= url + "&" + Math.random();	   
	    if(window.XMLHttpRequest) 
	    {
			xhr = new XMLHttpRequest();
			
		} else {
		    if (window.ActiveXObject) 
		    {		    	
			    var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp" ];
			    for(var i=0; i<aVersions.length; i++){
				    try
				    {
					    xhr = new ActiveXObject(aVersions[i]);
				    } catch (oError) {  }
			    }
			 }
		}		
		if(xhr)
		{
			
			xhr.onreadystatechange = function()
			{
				if (xhr.readyState==4 || xhr.readyState=="complete"){ 
					obj.innerHTML = xhr.responseText;
					var newx = findPosX(sender); 					
			        var newy = findPosY(sender);			       
					obj.style.top = newy + 5 + 'px';				
					obj.style.left = newx + 10 + 'px';
	                obj.style.width = 400 + 'px';               	
					obj.style.display = 'block';					
				    obj.style.visibility = 'visible';
				    
				    obj.onmouseleave=function()
				    {								
					    HidePreview(displayDiv);					
				    }				
				
				} 
			}		
			xhr.open("GET", url, true);
			xhr.send(null);
		}
	} else {
		
			obj.style.display = 'block';
			obj.style.visibility = 'visible';
			obj.style.width = 400 + 'px';
	}  
    //Added  for tree structure.
    setTimeout(function(){convertTrees(dn)},500);    
    //End for tree structure.
}


function HideActions()
{   
    var obj = document.getElementById('__actions');
    if(obj)
    {
    	obj.style.visibility = "hidden";
    }
}

function ShowActions(sender, displayDiv, dn, params)
{
    GetActions(sender, displayDiv, dn, params);
    return false;
}

function GetActions(sender, displayDiv, dn, params)
{
	var obj = document.getElementById('__actions');
	if(!obj)
	{
	    obj = document.createElement('DIV');
	    obj.id = "__actions";
		obj.style.display = 'block';
		obj.style.visibility = 'visible';
		obj.style.position = "absolute";
		obj.style.zIndex = 5;
		document.body.appendChild(obj);
	}
	var obj = document.getElementById('__actions');
    if(xdn != "a"+dn){
    	xdn = "a"+dn;
	    url = "viewActions.gs?dn=" + dn + "&" + params;
	    url= url + "&" + Math.random();

	    if(window.XMLHttpRequest) 
	    {
			xhr = new XMLHttpRequest();
		} else {
		    if (window.ActiveXObject) 
		    {
			    var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp" ];
			    for(var i=0; i<aVersions.length; i++){
				    try
				    {
					    xhr = new ActiveXObject(aVersions[i]);
				    } catch (oError) {  }
			    }
			 }
		}
		
		if(xhr)
		{
			xhr.onreadystatechange = function()
			{
				if (xhr.readyState==4 || xhr.readyState=="complete"){ 
					obj.innerHTML = xhr.responseText;
					var newx = findPosX(sender); 
			        var newy = findPosY(sender); 
					obj.style.top = newy + 5 + 'px';
					obj.style.left = newx + 10 + 'px'
	                obj.style.width = 400 + 'px';
					obj.style.display = 'block';
					obj.style.visibility = 'visible';
					obj.onmouseout = function() {  }
				} 
			}
			xhr.open("GET", url, true);
			xhr.send(null);
		}
	} else {
			obj.style.display = 'block';
			obj.style.visibility = 'visible';
			obj.style.width = 400 + 'px';
	}
}
//-Needed for changing values-------------------------------------------------------------------
var xhs = false;

function UpdateObject(code)
{
    UpdateObject(code, false);
}

function UpdateObject(code, close)
{
    code = escape(code);
    url = "updateObject.gs?code=" + code;
	var obj = document.getElementById('preview');
	if(!obj)
	{
	    obj = document.createElement('DIV');
	    obj.id = "preview";
		obj.style.display = 'block';
		obj.style.visibility = 'visible';
		obj.style.position = "absolute";
		obj.style.zIndex = 5;
		document.body.appendChild(obj);
	}
	var obj = document.getElementById('preview');
    if(window.XMLHttpRequest) 
    {
		xhs = new XMLHttpRequest();
	} else {
	    if (window.ActiveXObject) 
	    {
		    var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp" ];
		    for(var i=0; i<aVersions.length; i++){
			    try
			    {
				    xhs = new ActiveXObject(aVersions[i]);
			    } catch (oError) {  }
		    }
		 }
	}
	
	if(xhs)
	{
		xhs.onreadystatechange = function()
		{
			if (xhs.readyState==4 || xhs.readyState=="complete"){ 
				    obj.innerHTML = xhs.responseText;
				    obj.style.display = 'block';
				    obj.style.visibility = 'visible';
				    obj.onmouseout = function() { HidePreview("preview"); }
			} 
		}
		xhs.open("GET", url, true);
		xhs.send(null);
	}
}

//-----------------Actions on a list---------------------------------------

function GetListActions(sender, displayDiv, dn, params)
{
	var obj = document.getElementById(displayDiv);
	var newx = findPosX(sender); 
    var newy = findPosY(sender); 
    obj.innerHTML = "<li>Action 1</li><li>Action 2</li><li>Action 3</li><li>......</li>";
	obj.style.top = newy + 5 + 'px';
	obj.style.left = newx - 210 + 'px';
	obj.style.width = 200 + 'px';
	obj.style.display = 'block';
	obj.style.visibility = 'visible';
	obj.onmouseout = function() { HidePreview(displayDiv); }
}


//----------------Language Skills--------------------------------------------
function List(table)
{  
	this.name = table;      
    this.table = document.getElementById(table+"_table");
    this.body = this.table.tBodies[0];
}

List.prototype.check = function()
{
    var obj = document.getElementById("lang_"+this.name+"_add");
    if(obj)
    {
        var x = document.getElementById("lang_"+this.name+"_null");
        if(x)
        {
           if(x.options[x.selectedIndex].value != "")
           {
                if(this.contains(x.options[x.selectedIndex].value)==false)
                {
                    obj.style.display = 'block';
		            obj.style.visibility = 'visible';
		        }
		        else 
		        {
                    obj.style.visibility = 'hidden';
		        }
           } else 
           {
                obj.style.visibility = 'hidden';
           }
        }
    }
}

List.prototype.remove = function(id)
{
    var row = document.getElementById(id);    
    if(row)
    {
        row.parentNode.removeChild(row);
    }
}

List.prototype.calc = function(obj, inp)
{
   var x = document.getElementById(this.name + "_" + inp);
    if(x && obj)
    {
        x.value = this.name + "_" + inp + "#" + obj.options[obj.selectedIndex].value;
    }
}


List.prototype.add = function()
{
	
    this.insert(this.table.rows.length-1);
}

List.prototype.addComp = function(dn, desc, Comp)
{
    this.insert(this.table.rows.length-1, dn, desc, Comp);
}

List.prototype.insert = function(rowNumber)
{   
	var x = document.getElementById("lang_"+this.name+"_null");
    if(x)
    {
        temp = x.options[x.selectedIndex].value;
        if(temp != "")
        {
            defa = "";
            sel = document.getElementById(this.name+ "_div");
            div = document.createElement('DIV');
            sels = sel.getElementsByTagName('SELECT');
            if(sels[0])
            {
                if(sels[0].options[0])
                {
                  defa = sels[0].options[0].value;  
                }
            }
            tmp1 = sel.innerHTML.replace("<SELECT ", "<select ")
            tmp1 = tmp1.replace("<select ", "<select onchange=\""+ this.name +"_lst.calc(this,'"+temp+"');\" ")
            
            tmp = "<table><tr id='lang_" + temp + "'><td>" + x.options[x.selectedIndex].text + "</td>";
            tmp += "<td colspan='2'>" + tmp1;
            tmp += "&nbsp;<a href='#' onclick=\""+ this.name +"_lst.remove('lang_" + temp + "');\"><img src=\"images/del.gif\" style=\"border:0\" /></a>";
            tmp += "<input type='hidden' name=\"" + this.name + "\" id=\"" + this.name + "_" + temp +"\" value=\"";
			tmp += this.name + "_" + temp + "#" + defa + "\" /></td>";
            tmp += "</tr></table>"; 
            
            div.innerHTML = tmp;         
     
            document.body.appendChild(div); 
            
            Rows = div.getElementsByTagName('TR'); 
            for (i=0; i<Rows.length; i++)
            {
              var newCell
              var newRow = this.body.insertRow(rowNumber)
              newRow.id = "lang_" + temp;
              Cols = Rows[i].getElementsByTagName('TD');
              for (j=0; j<Cols.length; j++)
                {
                newCell = newRow.insertCell(j);
                newCell.innerHTML = Cols[j].innerHTML;
                if(j==1)
                { 
                    newCell.colSpan = 3;
                }
                newCell.className = "text_form";     
                }
            }
            document.body.removeChild(div); 
            x.selectedIndex = 0;
            this.check();
        }
    }
}

List.prototype.contains = function(id)
{
    var obj = document.getElementById("lang_" + id); 
    if(obj)
    {
        return true;
    }
    return false;
}

List.prototype.change = function(id)
{
    found = false;
    rowNumber = -1;
    var row = document.getElementById(id);
    if(row)
    {
        Rows = row.parentNode.getElementsByTagName('TR'); 
        for (i=0; i<Rows.length; i++)
        {
            if(Rows[i].id == id)
            {
                rowNumber = i;
                found = true;
                i= Rows.length + 1;
            }
        }
    }
    if(rowNumber >= 0 && found == true)
    {
        this.remove(id);
        this.insert(rowNumber);
    }
}
//----------------List Popup --------------------------------------------
function ListPopup(id)
{  
	this.name = id;      
    this.win;
}

ListPopup.prototype.go = function(sURL, sDefaList)
{
	if(sURL != "")
	{
		this.url = sURL;
	}
	if(sDefaList != "")
	{
		if(sDefaList != "*")
		{
			this.defaList = sDefaList;
		}
	}
	filter = "";
	//this.getCompetences();
	for(i=0; i<this.array.length;i++)
	{
		tmp = this.array[i];
		k = tmp.indexOf("CN=");
		if(k>=0)
		{
			tmp = tmp.substring(k);
			k = tmp.indexOf(",");
			if(k>=0)
			{
				filter += "(" + tmp.substring(0,k) + ")";	
			}
		}
	}
	if(filter != "")
	{
		filter = "&SELFILTER=(|" + filter + ")";
	} else {
		if(sDefaList != "*" && this.defaList != "")
		{
			filter = "&list=" + this.defaList;
		} else {
			filter = "&SELFILTER=(cn=null)";
		}
	}
	var options = 'location=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=yes';
	this.win = window.open(this.url + filter,'comp',options);
}

//----------------Competences --------------------------------------------
function Competence(table, width)
{  
	this.name = table;      
    this.table = document.getElementById(table+"_table");
    this.body = this.table.tBodies[0];
    this.array = [];
    this.url = "";
    this.defaList = "";
    this.win;
    this.width = width;
}

Competence.prototype.getCompetences = function()
{
	x = eval("document.form." + this.name);
	this.array = [];
	if(x){
	if(x[0] == null)
	{
		if(x != null)
		{
			this.array = [1];
			this.array[0] = x.value.replace(this.name+"_" , "");
		}
	} else {
		this.array = [x.length];
		for(i=0; i<x.length; i++)
		{
			this.array[i] = x[i].value.replace(this.name+"_" , "");
		}
	}
	}
	return this.array;
}

Competence.prototype.check = function()
{
    var obj = document.getElementById("lang_"+this.name+"_add");
    if(obj)
    {
        var x = document.getElementById("lang_"+this.name+"_null");
        if(x)
        {
           if(x.options[x.selectedIndex].value != "")
           {
                if(this.contains(x.options[x.selectedIndex].value)==false)
                {
                    obj.style.display = 'block';
		            obj.style.visibility = 'visible';
		        }
		        else 
		        {
                    obj.style.visibility = 'hidden';
		        }
           } else 
           {
                obj.style.visibility = 'hidden';
           }
        }
    }
}

Competence.prototype.removeClose = function(id)
{
	this.close();
	var row = document.getElementById(id);    
    if(row)
    {
        row.parentNode.removeChild(row);
    }
}

Competence.prototype.remove = function(id)
{
	var row = document.getElementById(id);    
    if(row)
    {
        row.parentNode.removeChild(row);
    }
}

Competence.prototype.close = function()
{
	if(this.win)
    {
    	this.win.close();  
    }
}

Competence.prototype.calc = function(obj, inp)
{
    var x = document.getElementById(this.name + "_" + inp);
    if(x && obj)
    {
        x.value = this.name + "_" + inp + "#" + obj.options[obj.selectedIndex].value;
    }
}

Competence.prototype.calcClose = function(obj, inp)
{
    this.close();
	var x = document.getElementById(this.name + "_" + inp);
    if(x && obj)
    {
        x.value = this.name + "_" + inp + "#" + obj.options[obj.selectedIndex].value;
    }
}

Competence.prototype.add = function()
{
	
    this.insert(this.table.rows.length-1);
}

Competence.prototype.addComp = function(dn, desc, comp)
{
    found = false;
    rowNumber = -1;
    dn = dn.toUpperCase();
    id = "lang_" + dn;
    var row = document.getElementById(id);
    if(row)
    {
        Rows = row.parentNode.getElementsByTagName('TR'); 
        for (i=0; i<Rows.length; i++)
        {
            if(Rows[i].id == id)
            {
                rowNumber = i;
                found = true;
                i= Rows.length + 1;
            }
        }
    }
    if(rowNumber >= 0 && found == true)
    {
        this.remove(id);
        this.insert(rowNumber, dn, desc, comp);
    } else {
        this.insert(this.table.rows.length-1, dn, desc, comp);
    }
    
}

Competence.prototype.removeComp = function(dn)
{
    found = false;
    rowNumber = -1;
    dn = dn.toUpperCase();
    id = "lang_" + dn;
    var row = document.getElementById(id);
    if(row)
    {
        Rows = row.parentNode.getElementsByTagName('TR'); 
        for (i=0; i<Rows.length; i++)
        {
            if(Rows[i].id == id)
            {
                rowNumber = i;
                found = true;
                i= Rows.length + 1;
            }
        }
    }
    if(rowNumber >= 0 && found == true)
    {
        this.remove(id);
    }
}

Competence.prototype.insert = function(rowNumber, dn, desc, comp)
{   
	//var x = document.getElementById("lang_"+this.name+"_null");
        //temp = x.options[x.selectedIndex].value;
        temp = dn;
        if(temp != "")
        {
            defa = "";
            sel = document.getElementById(this.name+ "_div");
            div = document.createElement('DIV');
            sels = sel.getElementsByTagName('SELECT');
            if(sels[0])
            {
                if(sels[0].options[comp])
                {
                  defa = sels[0].options[comp].value; 
                } 
            }
            tmp1 = sel.innerHTML.replace("<SELECT ", "<select ")
            tmp1 = tmp1.replace("<select ", "<select id='lang_" + temp + "_v' onchange=\""+ this.name +"_lst.calcClose(this,'"+temp+"');\" ")
            
            //tmp = "<table><tr id='lang_" + temp + "'><td>" + x.options[x.selectedIndex].text + "</td>";
            tmp = "<table><tr id='lang_" + temp + "'><td>" + desc + "</td>";
            tmp += "<td colspan='2'>" + tmp1;
            tmp += "&nbsp;<a href='#' onclick=\""+ this.name +"_lst.removeClose('lang_" + temp + "');\"><img src=\"images/del.gif\" style=\"border:0\" /></a>";
            tmp += "<input type='hidden' name=\"" + this.name + "\" id=\"" + this.name + "_" + temp +"\" value=\"";
			tmp += this.name + "_" + temp + "#" + defa + "\" /></td>";
            tmp += "</tr></table>"; 
            
            div.innerHTML = tmp;         
     
            document.body.appendChild(div); 
            
            Rows = div.getElementsByTagName('TR'); 
            for (i=0; i<Rows.length; i++)
            {
              var newCell
              var newRow = this.body.insertRow(rowNumber)
              newRow.id = "lang_" + temp;
              Cols = Rows[i].getElementsByTagName('TD');
              for (j=0; j<Cols.length; j++)
                {
                newCell = newRow.insertCell(j);
                newCell.innerHTML = Cols[j].innerHTML;
                if(j==1)
                { 
                    newCell.colSpan = 3;
                }
                newCell.className = "text_form";
                newCell.width = this.width + "px";
                }
            }
            document.body.removeChild(div);
            x = document.getElementById("lang_" + temp + "_v");
            if(x)
            {
                x.selectedIndex = comp;
            }
             
            //x.selectedIndex = 0;
            this.check();
        }
}

Competence.prototype.contains = function(id)
{
    var obj = document.getElementById("lang_" + id); 
    if(obj)
    {
        return true;
    }
    return false;
}

Competence.prototype.change = function(id)
{
    found = false;
    rowNumber = -1;
    var row = document.getElementById(id);
    if(row)
    {
        Rows = row.parentNode.getElementsByTagName('TR'); 
        for (i=0; i<Rows.length; i++)
        {
            if(Rows[i].id == id)
            {
                rowNumber = i;
                found = true;
                i= Rows.length + 1;
            }
        }
    }
    if(rowNumber >= 0 && found == true)
    {
        this.remove(id);
        this.insert(rowNumber);
    }
}

Competence.prototype.go = function(sURL, sDefaList)
{
	if(sURL != "")
	{
		this.url = sURL;
	}
	if(sDefaList != "")
	{
		if(sDefaList != "*")
		{
			this.defaList = sDefaList;
		}
	}
	filter = "";
	this.getCompetences();
	for(i=0; i<this.array.length;i++)
	{
		tmp = this.array[i];
		k = tmp.indexOf("CN=");
		if(k>=0)
		{
			tmp = tmp.substring(k);
			k = tmp.indexOf(",");
			if(k>=0)
			{
				filter += "(" + tmp.substring(0,k) + ")";	
			}
		}
	}
	if(filter != "")
	{
		filter = "&SELFILTER=(|" + filter + ")";
	} else {
		if(sDefaList != "*" && this.defaList != "")
		{
			filter = "&list=" + this.defaList;
		} else {
			filter = "&SELFILTER=(cn=null)";
		}
	}
	var options = 'location=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=yes';
	this.win = window.open(this.url + filter,'comp',options);
}

Competence.prototype.getComp = function()
{
	comp = [];
	this.getCompetences();
	for(i=0; i<this.array.length;i++)
	{
		tmp = this.array[i];
		k = tmp.indexOf("#");
		if(k>=0)
		{
			comp[i] = tmp.substring(k);
		}		
		k = tmp.indexOf("CN=");
		if(k>=0)
		{
			tmp = tmp.substring(k+3);
			k = tmp.indexOf(",");
			if(k>=0)
			{
				comp[i] = tmp.substring(0,k) + comp[i];	
			}
		}
	}
	return comp;
}
//----------------------------------------------------------------------------------------------------------------------------------------

function  getDivId() 
{
    var d = document.getElementById('myDIV');	 
    var pars=d.getElementsByTagName("DIV");
    var sIDs;
    for (var z=0;z<pars.length;z++){
    	sIDs = sIDs + "#;#" + pars[z].id;
    }	  
  
}

//---------Send email---------------------------------------------------------------
function SendMail(subject, to, cc, bc)
{
   var url = "gsMail.jsp?TO=" + to + "&CC=" + cc + "&BC=" + bc;
   window.open(url, 'mail');
}

//--------Check Tel-----------------------------------------------------------------
function CheckTel(val)
{
	if(val == ""){return true;}
	if(val.substring(0,1) == "+")
	{
    	if(val.length > 10)
    	{
        	tst = "+0123456789";
        	for(var j = 0; j < val.length; j++)
        	{
            	if(tst.indexOf(val.substring(j,j+1)) < 0)
            	{
			        return false;
            	}
        	}
        	return true;
    	}
	}
	return false;
}

//--------------Get Help-------------------------------------------------------------
function GetHelp(displayDiv, dn, params)
{
	var obj = document.getElementById(displayDiv);
	if(!obj)
	{
        return;
	}
	if(dn=="")
	{
		obj.innerHTML = "";
		obj.style.visibility = 'hidden';
	    return;
	}
    url = "findObject.gs?dn=" + dn + "&" + params;
    url= url + "&" + Math.random();

    if(window.XMLHttpRequest) 
    {
		xhr = new XMLHttpRequest();
	} else {
	    if (window.ActiveXObject) 
	    {
		    var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp" ];
		    for(var i=0; i<aVersions.length; i++){
			    try
			    {
				    xhr = new ActiveXObject(aVersions[i]);
			    } catch (oError) {  }
		    }
		 }
	}
	
	if(xhr)
	{
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState==4 || xhr.readyState=="complete"){ 
				obj.innerHTML = xhr.responseText;
				obj.style.display = 'block';
				obj.style.visibility = 'visible';
			} 
		}
		xhr.open("GET", url, true);
		xhr.send(null);
	}
}
//----------------Check unique record------------------------------------------------
function checkId(display, params, id)
{
	var obj = document.getElementById(display);
	if(!obj)
	{
        return;
	}
    url = "checkId.gs?" + params;
    url= url + "&" + Math.random();

    if(window.XMLHttpRequest) 
    {
		xhr = new XMLHttpRequest();
	} else {
	    if (window.ActiveXObject) 
	    {
		    var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp" ];
		    for(var i=0; i<aVersions.length; i++){
			    try
			    {
				    xhr = new ActiveXObject(aVersions[i]);
			    } catch (oError) {  }
		    }
		 }
	}
	
	if(xhr)
	{
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState==4 || xhr.readyState=="complete"){
			    obj.value = xhr.responseText;
			    if(obj.value.indexOf("Not found") >= 0)
			    {
			        obj.value = id;
			    }
			} 
		}
		xhr.open("GET", url, true);
		xhr.send(null);
	}
}


function checkVATNumber (toCheck) {
 
  var vatexp = new Array ();
  
  var defCCode = "GB";
  
  vatexp.push (/^(BE)(\d{9,10})$/);                         //** Belgium 
  vatexp.push (/^(LU)(\d{8})$/);                            //** Luxembourg 
  vatexp.push (/^(NL)(\d{9,10})[a-zA-Z]\d{2}$/);                      //** Netherlands
  
  var VATNumber = toCheck;
  var valid = false;                         
  
  // Check the string against the types of VAT numbers
  for (i=0; i<vatexp.length; i++) {
    if (vatexp[i].test(VATNumber)) {
      
      var cCode = RegExp.$1;                             // Isolate country code
      var cNumber = RegExp.$2;                           // Isolate the number
      if (cCode.length == 0) cCode = defCCode;           // Set up default country code
      
      // Now look at the check digits for those countries we know about.
      switch (cCode) {     
       
        case "BE":
          valid = BEVATCheckDigit (cNumber);
          break;          
        case "LU":
          valid = LUVATCheckDigit (cNumber);
          break;            
        case "NL":
          valid = NLVATCheckDigit (cNumber);
          break;             
        
        default:
          valid = true;
      }
            
      // Load new VAT number back into the form element
      if (valid) valid = VATNumber;
      // We have found that the number is valid - break from loop
      break;
    }
  }
  
  // Return with either an error or the reformatted VAT number
  return valid;
}

function BEVATCheckDigit (vatnumber) {
	
  if (vatnumber.length == 10)
	 
    return true
  else 
    return false;
}

function LUVATCheckDigit (vatnumber) {

	if (vatnumber.length == 8)
	    return true
	  else 
	    return false;
	}

function NLVATCheckDigit (vatnumber) {
	
	if (vatnumber.length == 9)
	
	    return true
	  else 
	    return false;
	}

function checkHRVATNumber(toCheck) {
	  var vatexp = new Array ();
	  
	  var defCCode = "GB";
	  
	  vatexp.push (/^(BE)(\d{1,100})$/);                         //** Belgium 
	  vatexp.push (/^(LU)(\d{1,100})$/);                            //** Luxembourg 
	  vatexp.push (/^(NL)(\d{1,100})$/);                     //** Netherlands
	  
	  var VATNumber = toCheck;
	  var valid = false;                         
	  
	  // Check the string against the types of VAT numbers
	  for (i=0; i<vatexp.length; i++) {
	    if (vatexp[i].test(VATNumber)) {
	      
	      var cCode = RegExp.$1;                             // Isolate country code
	      var cNumber = RegExp.$2;                           // Isolate the number
	      if (cCode.length == 0) cCode = defCCode;           // Set up default country code
	      
	      // Now look at the check digits for those countries we know about.
	      switch (cCode) {     
	       
	        case "BE":
	          valid = HRVATCheckDigit (cNumber);
	          break;          
	        case "LU":
	          valid = HRVATCheckDigit (cNumber);
	          break;            
	        case "NL":
	          valid = HRVATCheckDigit (cNumber);
	          break;             
	        
	        default:
	          valid = true;
	      }
	            
	      // Load new VAT number back into the form element
	      if (valid) valid = VATNumber;
	     
	      // We have found that the number is valid - break from loop
	      break;
	    }
	  }
	  
	  // Return with either an error or the reformatted VAT number
	  return valid;
	}
function HRVATCheckDigit (hrvatnumber) {
	
	  if (hrvatnumber.length!=0)
		  
	    return true
	  else 
		  
	    return false;
	}

// RFC3370 remarks of UAT items in combobox should be sorted!
function sortComboBox(lb) {

	// Reminding values	
	arrTexts = new Array();
	arrValues = new Array();
       arrTextsToSort = new Array();
	for(i=0; i<lb.length; i++)  {
	  arrTexts[i] = lb.options[i].text;
	  arrValues[i] = lb.options[i].value;
	  arrTextsToSort[i] = lb.options[i].text;
	}

	// Sorting values in as sorted order
	arrTextsToSort.sort();

	// Restoring values
	for(i=0; i<lb.length; i++)  {

          // Setting text to combobox
	   lb.options[i].text = arrTextsToSort[i];
          
          // Setting values for the sorted text
          v = "not found";
          for(ii=0;ii<arrTexts.length;ii++){
            if(arrTexts[ii] == arrTextsToSort[i]){
              v = arrValues[ii];
              ii = arrTexts.length + 1;
            }
          }
	   lb.options[i].value = v;

	}
}





//End