var formname=location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
var return_value="";
formname=formname.replace(".php", "");
if(document.getElementById("btnNew")!=null){document.getElementById("btnNew").onclick = function() { btnNew_Clicked();}}
if(document.getElementById("btnSave")!=null){document.getElementById("btnSave").onclick = function() {btnSave_clicked();}}
if(document.getElementById("btnClose")!=null){document.getElementById("btnClose").onclick = function() { confirmExit();}}
if(document.getElementById("btnDelete")!=null){document.getElementById("btnDelete").onclick = function() { ShowDelDiv();}}
if(document.getElementById("btnDeleteYes")!=null){document.getElementById("btnDeleteYes").onclick = function() { btnDeleteYes_clicked();}}
if(document.getElementById("IDcField")!=null){ var IDcField=document.getElementById("IDcField").value; }

if(document.getElementById("EponymiaPelati")!=null){ 
	var ep1 = document.getElementById("EponymiaPelati");ep1.addEventListener("keypress", function(event) {
		if (event.key === 'Enter') { event.preventDefault(); pelatis_select(ep1.value); }
	});
}
 
if(document.getElementById("EponymiaProm")!=null){ 
	var ep2 = document.getElementById("EponymiaProm");ep2.addEventListener("keypress", function(event) {
		if (event.key === 'Enter') { event.preventDefault(); prom_select(ep2.value); }
	});
}
 
for (var i = 1 ; i <= 6; i++) {
	 if(document.getElementById("tab"+i)!=null){document.getElementById("tab"+i).onclick = function() { tab_selected(this);}}
    }
	
//if(document.getElementById("tab2")!=null){document.getElementById("tab2").onclick = function() { tab_selected('tab2');}}
 
 
function ShowDelDiv(){document.getElementById('myDelDiv').style.display='block' ; }
function HideDelDiv(){document.getElementById('myDelDiv').style.display='none'; }
if(document.getElementById("myDelDiv")!=null){	
		var modal = document.getElementById('myDelDiv');
		window.onclick = function(event) {if (event.target == modal) { modal.style.display = "none"; } }
}

 

function btnSave_clicked() {
   var jsnl = "\r\n";
   var myform = document.getElementById(formname);
   
   if (formname=="app_add"||formname=="symvolaia_add"||
       formname=="service_add"||formname=="pelates_add"||
	   formname=="notes_add"||formname=="user_add") {
	    if(RequirementsCheck()==false){return};
		 myform.action='_rs.php';myform.submit();
   } else 
	   if (formname=="tameio_add") {
		if(RequirementsCheck()==false){return};
	     var es1=document.getElementById("Esoda").value;
	     var ex1=document.getElementById("Exoda").value;
	    if(es1==0 && ex1==0) {alert("Δεν έχει καταχωρηθεί κανένα ποσό..."); return; }
		 myform.action='_rs.php';myform.submit();
   } else
	   if (formname=="parametroi") {
		var req1=document.getElementById("IDc").value;
		if(req1==''||req1=='0') { alert("ΑΔΥΝΑΤΗ ΚΑΤΑΧΩΡΗΣΗ ΠΑΡΑΜΕΤΡΩΝ");  return; }	    
		myform.action='_rs.php';myform.submit(); 
   }
   else
		{	 if(RequirementsCheck()==false){return};
			myform.action='_rs.php';myform.submit();
		}
   
}
 

function btnDeleteYes_clicked() {
	var IDc=document.getElementById(IDcField).value;
	HideDelDiv();
	var myform = document.getElementById(formname);
	var dlfrm='_dl.php';
    if(formname =="notes_add") {	dlfrm='notes_dl.php'; }
		if(IDc!==0){ myform.action=dlfrm;myform.submit(); }
   }

function btnNew_Clicked(){
	document.cookie = IDcField+"=0" ;
	var myform = document.getElementById(formname); myform.action='_ad.php';myform.submit();
}
 
function PrintDoc() {
	var toPrint = document.getElementById('printarea');
	var popupWin = window.open('', '_blank', 'width=650,height=450,location=no, resizable=yes,left=200px');
	popupWin.document.open();
	popupWin.document.write('<html><title>::Preview::</title><link rel="stylesheet" type="text/css" href="print.css" /></head><body onload="window.print()">')
	popupWin.document.write(toPrint.innerHTML);
	popupWin.document.write('</html>');
	popupWin.document.close();
 }

function onLoadFocus(){
	var FocusField=document.getElementById("FocusField").value;
	   document.getElementById(FocusField).focus();
 }
 

function chkUpd(element){
	var chk=document.getElementById(element).value;
	if(chk==-1){chk=0;}else{chk=-1;}
	document.getElementById(element).value=chk;	
 } 
 
 function mySubmit(element_name){
	var txt=document.getElementById(element_name).value; 
    document.cookie = element_name+'=' + txt;
   document.location.href = formname+".php?"+element_name+"="+txt; 
}

function confirmExit(){
 
 //	alert  (formname);

 tab_update("tab1");
	switch (formname) {
		case "pelates_add": 
		case "prom_add": 
		case "parametroi":
		case "service_add":	
		case "tameiakes_add":
		case "symvolaia_add" :	
			window.history.go(-1); 
			break;

		case "notes_add": 
		case "tameio_add": 
		case "user_add":
		case "pelates_add_popup":
		case "mitroo_find":
		case "tameio_rectypes_add":
			//window.opener.location.reload();
			//refreshParent;
			//  location.reload();
			///  window.history.go(-2); 
			window.opener.location.reload(false);
			window.close();  
			break;
			
		default:
			window.history.back(-2); 
			break;		
	}

}
 
// ======================================== //
//											//
// ======================================== //

function cbo_select(val1,fndw){

 var w='1000';var h='520';  
 var oPenFrm=val1+"_select.php"+fndw;  
 var left = (screen.width/2)-(w/2); var top = (screen.height-h)/2-50;
 var Pos1 = "top="+top+", Left="+left+", width="+w+", height="+h+" ";
// var NewWindow="";

var NewWindow = window.open( oPenFrm, "ΑΝΑΖΗΤΗΣΗ ΠΕΛΑΤΗ",  Pos1+ ",resizable=no, Linkbar=0, addressbar=no, directories=no, toolbar=no,location=0,status=no, menubar=0, scrollbars=no, modal=yes, copyhistory=no "); 
 NewWindow.focus();
}

function comboChange(e,fldName,IDName){
  document.getElementById(fldName).value = e.options[e.selectedIndex].text;
  
 if(document.getElementById(IDName)!=null){
	 document.getElementById(IDName).value = e.options[e.selectedIndex].value;
	  var myID=document.getElementById(IDName).value
	  if (IDName=='IDPelati'){ pel_change(myID); }
	 }
}


function show_all(c){
 var fileName = location.pathname.split("/").slice(-1);
 if(c.checked){ var chk_val="checked";}else{var chk_val="unchecked";}
	document.cookie =  c.name+'=' + escape(chk_val);
	document.location.href =fileName;
 }
 


// ======================================== //
//			Records Prv, Next				//
// ======================================== //

 function rppupd(e) {
	var RecsPP  = e.options[e.selectedIndex].value;
	document.cookie = e.name +'=' + escape(RecsPP);
   //alert(e.name + " == " +  escape(RecsPP));
	var myform = document.getElementById(formname); myform.action='';myform.submit();
 }
 
 function gtRecPg(e){
	 var o=e.name.split("@");
	 var prefix=o[0]+"@";
	 var btn=o[1];
	  //alert(e.name + " === " + o[0] + ", " + o[1]);
	 var pgNo=Number(document.getElementById(prefix+'pgNo').value); 
	 var FindWhat="";
	 if(document.getElementById(prefix+'FindWhat')!=null){ FindWhat=document.getElementById(prefix+'FindWhat').value;}
	 var pgMax=Number(document.getElementById(prefix+'pgMax').value);  
	 var oCbo=document.getElementById(prefix+'cboRecPP'); 
	 var RecsPP  = oCbo.options[oCbo.selectedIndex].value;
	  document.cookie = prefix+'RecsPP=' + escape(RecsPP);
	 if (btn == 'btnFirst') {pgNo =  1;} else if(btn == 'btnPrv') {pgNo = pgNo - 1;} else if(btn == 'btnNext') {pgNo = pgNo + 1;} else if(btn == 'btnLast') {pgNo = pgMax ;} else if(pgNo == 'rPp') {pgNo =  1;}
	 if (pgNo > pgMax ){pgNo = pgMax ;} if (pgNo < 1 ){pgNo = 1 ;}
	  document.location.href = formname+".php?"+prefix+"FindWhat="+FindWhat + "&"+prefix+"pgNo=" + pgNo; 
 }

function OpenFormADD(IDFieldName,IDc,frm,OnNewTab='_self'){
	document.cookie = IDFieldName+'=' + IDc;	
	var NewWindow = window.open(frm+".php", OnNewTab  );  NewWindow.focus();
 }
 
function OpenFormADD_onWin(IDFieldName,IDc,frm,w,h){
	
if(frm=="notes_add") {}
if(IDFieldName!=""){ document.cookie = IDFieldName+'=' + IDc; }

 deleteCookie(frm+'@tab');
	var oPenFrm=frm+".php" ;  
	var left1 = parseInt((screen().width-w)/2);
	var top1 = parseInt((screen().height-h)/2 );
	var Pos1="top="+top1+", Left="+left1+", width="+w+", height="+h+" ";
	var NewWindow = window.open( oPenFrm, "",  Pos1+ ",resizable=no, Linkbar=0, addressbar=no, directories=no, toolbar=no,location=no,status=no, menubar=no, scrollbars=no, modal=yes, copyhistory=no "); 
	NewWindow.focus();
}

function grdsrt(val){
	var a=document.getElementById('SortFLD').value; 
	document.cookie = a +'=' + val + "; max-age=60*60*8 ";
	location.reload(); 
}

function time_now_set(e){
	var currentTime = Date.now()
	var GMT = -(new Date()).getTimezoneOffset()/60;
	var totalSeconds = Math.floor(currentTime/1000);
	seconds = ('0' + totalSeconds % 60).slice(-2);
	var totalMinutes = Math.floor(totalSeconds/60);
	minutes = ('0' + totalMinutes % 60).slice(-2);
	var totalHours = Math.floor(totalMinutes/60);
	hours = ('0' + (totalHours+GMT) % 24).slice(-2);
	var timeDisplay = hours + ":" + minutes + ":" + seconds;

 e.value=timeDisplay;
}

function date_now_set(e){
var m_date=new Date();
	
	 e.value= [
    padTo2Digits(m_date.getDate()),
    padTo2Digits(m_date.getMonth() + 1),
    m_date.getFullYear(),
  ].join('/');
 
}

function padTo2Digits(num) {
  return num.toString().padStart(2, '0');
}
 
function getCookie111(name) {
    function escape(s) { return s.replace(/([.*+?\^$(){}|\[\]\/\\])/g, '\\$1'); }
    var match = document.cookie.match(RegExp('(?:^|;\\s*)' + escape(name) + '=([^;]*)'));
	var m=match[1].replace( '%2F','/');
	alert(m);
	return  m  ;
	
}

function getCookie(cname) {
  let name = cname + "=";
  let decodedCookie = decodeURIComponent(document.cookie);
  let ca = decodedCookie.split(';');
  for(let i = 0; i <ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}

function getCookie222(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
	alert(ca);
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function RequirementsCheck(){
  var my_elem = document.getElementById(formname).querySelectorAll("[required]") ;
  if(my_elem.length==0){return true;}
  for(var i=0;i<my_elem.length;i++ ){
	if(my_elem[i].value=="") {
			alert("Δεν έχει συμπληρωθεί το πεδίο: " + getInputLabel(my_elem[i]));
			document.getElementById(my_elem[i].id).focus();
			return false;
	}
  }
  return true;
}

function getInputLabel(e) {
   var lbl = document.getElementsByTagName('label');
   for( var j = 0; j < lbl.length; j++ ) {
      if (lbl[j].htmlFor == e.id)
           return lbl[j].textContent;
   }
} 

function deleteAllCookies() {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        var eqPos = cookie.indexOf("=");
        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
        document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}

function ShowAllCookies() {
    var cookies = document.cookie.split(";");
var e=document.getElementById('Sxolia');
    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        var eqPos = cookie.indexOf("=");
        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
       
	   e.innerHTML=e.innerHTML+name+"="+"<br>";
	   
	   // document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}

function tab_selected(e){
	 document.cookie = formname+'@tab=' + escape(e.id);
// alert (e.id ); 	
 //  listCookies();
}

function listCookies() {
    var theCookies = document.cookie.split(';');
    var aString = '';
    for (var i = 1 ; i <= theCookies.length; i++) {
        aString += i + ' ' + theCookies[i-1] + "\n";
    }
	aString+=aString.length;
	
    alert(aString);
	//return aString;
}

function setCookie(name,value) {
    //    var name            = params.name,
    //        value           = params.value,
    //        expireDays      = params.days,
   //         expireHours     = params.hours,
    //        expireMinutes   = params.minutes,
    //        expireSeconds   = params.seconds;

     //   var expireDate = new Date();
    //    if (expireDays) {
    //        expireDate.setDate(expireDate.getDate() + expireDays);
    //    }
    //    if (expireHours) {
    //        expireDate.setHours(expireDate.getHours() + expireHours);
    //    }
    //    if (expireMinutes) {
    //        expireDate.setMinutes(expireDate.getMinutes() + expireMinutes);
    //    }
    //    if (expireSeconds) {
    //        expireDate.setSeconds(expireDate.getSeconds() + expireSeconds);
     //   }
  
	var expireDate = new Date();
			expireDate.setSeconds(expireDate.getSeconds() + 86400);


        document.cookie = name +"="+ escape(value) +
				";domain=" +
				";path=/"+
				";expires="+expireDate.toUTCString();
    }

function deleteCookie(name) {
        setCookie({name: name, value: "", seconds: 1});
    }
	
// ==============================================
//
// ==============================================
	
function delete_file(id, loc){
   const response = confirm("Διαγραφή συσχετιζόμενου εγγράφου;");
	if (response) {	   
			var myform = document.getElementById(formname)
			var p="upload_delete.php?id="+id+"&loc="+loc;
			myform.action=p;myform.submit();
		  //  alert( "Ok was pressed" );
		} else {
		   // alert( "Cancel was pressed" ); 	
		}
}
	
	
function screen(){
	
	 var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
	var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	
	return {width: width + window.scrollY, height: height+ window.scrollX};
}	



function pelatis_select(m_Find){
		var fw="pelates_find.php?pelates_find@FindWhat="+m_Find;
   		var w=850;var h=450; 
		var left1 = parseInt((screen().width-w)/2);	var top1 = parseInt((screen().height-h)/2 );
		var Pos1="top="+top1+", Left="+left1+", width="+w+", height="+h+" ";
		var NewWindow1 = window.open( fw, "pelates_find",  Pos1+ ", resizable=no, Linkbar=0, addressbar=no, directories=no, toolbar=no,location=no,status=no, menubar=no, scrollbars=no, modal=yes, copyhistory=no "); 
		NewWindow1.focus();	
}

function prom_select(m_Find){
		var fw="prom_find.php?prom_find@FindWhat="+m_Find;
   		var w=850;var h=450;
		var oPenFrm1="prom_find.php" ;  
		var left1 = parseInt((screen().width-w)/2);	var top1 = parseInt((screen().height-h)/2 );
		var Pos1="top="+top1+", Left="+left1+", width="+w+", height="+h+" ";
		var NewWindow1 = window.open( fw, "prom_find",  Pos1+ ", resizable=no, Linkbar=0, addressbar=no, directories=no, toolbar=no,location=no,status=no, menubar=no, scrollbars=no, modal=yes, copyhistory=no "); 
		NewWindow1.focus();	
}

 
function pelatis_update(IDc){
	 var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
			var mval=this.responseText.trim(); 
			var mval=mval.split("\n");
			for (var i = 0; i < mval.length; ++i) {
				 var myrec=mval[i].split('=');
				if(document.getElementById(myrec[0])) {
					document.getElementById(myrec[0]).value = myrec[1];
				}
			}
		   }
        };
        xmlhttp.open("GET", "_PelRecRead.php?q="+IDc, true);
        xmlhttp.send();  
}

function tam_model_update(IDc){
 
	 var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
			var mval=this.responseText.trim(); 
			var mval=mval.split("\n");
			for (var i = 0; i < mval.length; ++i) {
				 var myrec=mval[i].split('=');
				if(document.getElementById(myrec[0])) {
					document.getElementById(myrec[0]).value = myrec[1];
				}
			}
		   }
        };
        xmlhttp.open("GET", "tam_model_rec_read.php?q="+IDc, true);
        xmlhttp.send();  
}

function pos_model_update(IDc){
 
	 var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
			var mval=this.responseText.trim(); 
			var mval=mval.split("\n");
			for (var i = 0; i < mval.length; ++i) {
				 var myrec=mval[i].split('=');
				if(document.getElementById(myrec[0])) {
					document.getElementById(myrec[0]).value = myrec[1];
				}
			}
		   }
        };
        xmlhttp.open("GET", "pos_model_rec_read.php?q="+IDc, true);
        xmlhttp.send();  
}

function prom_update(IDc){
	 var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
			var mval=this.responseText.trim(); 
			var mval=mval.split("\n");
			for (var i = 0; i < mval.length; ++i) {
				 var myrec=mval[i].split('=');
				if(document.getElementById(myrec[0])) {
					document.getElementById(myrec[0]).value = myrec[1];
				}
			}
		   }
        };
        xmlhttp.open("GET", "_PromRecRead.php?q="+IDc, true);
        xmlhttp.send();  
}		




function formatDate11(date) {
  return [
    padTo2Digits(date.getDate()),
    padTo2Digits(date.getMonth() + 1),
    date.getFullYear(),
  ].join('/');
}

function pelatis_remove(){ 
	if(document.getElementById("IDPelati")!=null) {document.getElementById("IDPelati").value=0; }
	if(document.getElementById("EponymiaPelati")!=null) {document.getElementById("EponymiaPelati").value='';}  
}

function prom_remove(){
	if(document.getElementById("IDProm")!=null) {document.getElementById("IDProm").value=0; }
	if(document.getElementById("EponymiaProm")!=null) {document.getElementById("EponymiaProm").value='';}
}


function tab_update(e){
 
	 var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
			//var mval=this.responseText.trim(); 
			// var mval=mval.split("\n");
			 //for (var i = 0; i < mval.length; ++i) {
				 // var myrec=mval[i].split('=');
				 // alert(myrec[0] +": " +myrec[1] );
				//if(document.getElementById(myrec[0])) {
				//	document.getElementById(myrec[0]).value = myrec[1];
				//}
			 //}
		   }
        };
        xmlhttp.open("GET", "_tab_no_update.php?frm="+formname+"&n="+e, true);
        xmlhttp.send();  
	 

} 

function export_excel(mSQL){

alert(mSQL);
 

var NewWindow = window.open( "tools/excel_output.php", "",   " resizable=no, Linkbar=0, addressbar=no, directories=no, toolbar=no,location=no,status=no, menubar=no, scrollbars=no, modal=yes, copyhistory=no "); 
	NewWindow.focus();
	

}

function pelatis_show(){ 
 
	var frm="pelates_add_popup";
	var IDFieldName="IDPelati";
	var IDc=0;
	var w = parseInt( screen().width-(screen().width/7)  );
	var h = parseInt( screen().height-(screen().height/7));
	if(document.getElementById("IDPelati")!=null) {var IDc=document.getElementById("IDPelati").value; }
	if(IDFieldName!=""){ document.cookie = IDFieldName+'=' + IDc; }
	deleteCookie(frm+'@tab');
	var oPenFrm=frm+".php" ;  
	var left1 = parseInt((screen().width-w)/2);
	var top1 = parseInt((screen().height-h)/2 );
	var Pos1="top="+top1+", Left="+left1+", width="+w+", height="+h+" ";
	
	// alert (IDc);
	
	var NewWindow = window.open( oPenFrm, "",  Pos1+ ",resizable=no, Linkbar=0, addressbar=no, directories=no, toolbar=no,location=no,status=no, menubar=no, scrollbars=no, modal=yes, copyhistory=no "); 
	NewWindow.focus();	

	
}

function runSpeechRecognition(myField_Name) {
		        // get output div reference
	 		
		        var output = document.getElementById(myField_Name);
				//alert(output.type);
		        // get action element reference
		        var action = document.getElementById("action");
                // new speech recognition object
                var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
                var recognition = new SpeechRecognition();
            
                // This runs when the speech recognition service starts
                recognition.onstart = function() {
                    action.innerHTML = "<small>Ακρόαση, παρακαλώ μιλήστε...</small>";
                };
                
                recognition.onspeechend = function() {
                    action.innerHTML = "<small>stopped listening, hope you are done...</small>";
                    recognition.stop();
                }
              
                // This runs when the speech recognition service returns result
                recognition.onresult = function(event) {
                    var transcript = event.results[0][0].transcript;
                    var confidence = event.results[0][0].confidence;
                   // output.innerHTML = "<b>Text:</b> " + transcript + "<br/> <b>Confidence:</b> " + confidence*100+"%";
                   // output.classList.remove("hide");
				   output.value = output.value+transcript.toUpperCase() ; 
				   if (output.type=="textarea") {output.innerHTML = output.value + transcript.toUpperCase();}; 
                };
              
                 // start recognition
                 recognition.start();
	        }

// ========================================
//  MHTROO
// ========================================
function mitroo_form_show(){
 
		var fw="mitroo_find.php";
   		var w=900;var h=500; 
		var left1 = parseInt((screen().width-w)/2);	var top1 = parseInt((screen().height-h)/2 );
		var Pos1="top="+top1+", Left="+left1+", width="+w+", height="+h+" ";
		var NewWindow1 = window.open( fw, "mitroo_find",  Pos1+ ", resizable=no, Linkbar=0, addressbar=no, directories=no, toolbar=no,location=no,status=no, menubar=no, scrollbars=no, modal=yes, copyhistory=no "); 
		NewWindow1.focus();	
}

function mitroo_get_value(){
	var afm=document.getElementById("FindWhat").value;
	// alert(formname + " afm="+afm);
	var url="_mitroo_get2.php?afm="+afm;
	//alert(url);
	 var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
			 var mval=this.responseText.trim(); 
			// alert(url + "         mval="+mval);
			 
			 var mval=mval.split("\n");
			 return_value=mval;
			 for (var i = 0; i < mval.length; ++i) {
				  var myrec=mval[i].split('=');
				  // alert(myrec[0] +": " +myrec[1] );
				 if(document.getElementById(myrec[0])) {
				 	document.getElementById(myrec[0]).value = myrec[1];
				 }
			  }
		   }
        };
        xmlhttp.open("GET", url , true);
        xmlhttp.send();  	
}

function mitroo_accept_value(){
 
	var iName="";
	var iVal="";
	var inputs = document.getElementsByTagName("input");
	
	for (i=0; i<inputs.length; i++){
			iName=inputs[i].name;
			iVal=inputs[i].value;
			if( window.opener.document.getElementById(iName)) {
			 window.opener.document.getElementById(iName).value = iVal;
		 }
	}
 //if (return_value.length==0){ window.close();}
 
//	for (var i = 0; i < return_value.length; ++i) {
//		  var myrec=return_value[i].split('=');
//		  // alert(myrec[0] +": " +myrec[1] );
//		 if( window.opener.document.getElementById(myrec[0])) {
//			 window.opener.document.getElementById(myrec[0]).value = myrec[1];
//		 }
//	  }
			  
  window.close();
}
	
 

