// JavaScript Document
var http = false;
var nocache = 0;

function getObj(name)
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
	}
	else if (document.all)
	{
		this.obj = document.all[name];
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
	}
return this.obj;
}

function WinOpen(FN,PATH,REN) {

var FieldName = FN;
var Path = PATH;
var Rename = REN;

NewWin=window.open("upload.php?FieldName=" + FieldName + "&Path=" + PATH + "&Rename=" + REN,"UploadWindow","height=100,width=400,location=no,menubar=no,statusbar=no");

NewWin.opener = window;

}

function ShowPic(Pic) {

NewWin=window.open("showpic.php?Pic=" + Pic,"PicWindow","height=255,width=255,location=no,menubar=no,scrollbars=no,resizable=no,statusbar=no");

NewWin.opener = window;

}

function Delay(Div){	
	getObj(Div).innerHTML = "<img src='loading_transp.gif' width='87' height='24' />";
}

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
} 

// MEMBERS
function Register() {
  http.open("POST", "member_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "username2=" + getObj('username2').value;
  data += "&password2=" + getObj('password2').value;
  data += "&password3=" + getObj('password3').value;  
  data += "&email2=" + getObj('email2').value;    
  data += "&epon=" + getObj('epon').value;    
  data += "&afm=" + getObj('afm').value;    
  data += "&doy=" + getObj('doy').value;    
  data += "&addrtel=" + getObj('addrtel').value;    
  
  data += "&Action=Register";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
    if(http.readyState == 4) {
	  	getObj('res3').innerHTML = http.responseText;		  
	}	
  }
  http.send(data);
  }

function Update() {
  http.open("POST", "member_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "username2=" + getObj('username2').value;
  data += "&password2=" + getObj('password2').value;
  data += "&password3=" + getObj('password3').value;  
  data += "&email2=" + getObj('email2').value;    
  data += "&epon=" + getObj('epon').value;    
  data += "&afm=" + getObj('afm').value;    
  data += "&doy=" + getObj('doy').value;    
  data += "&addrtel=" + getObj('addrtel').value;    
  
  data += "&Action=Update";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
    if(http.readyState == 4) {
      getObj('res3').innerHTML = http.responseText;
	}	
  }
  http.send(data);
  }
  
  function Remind() {
  http.open("POST", "member_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "email=" + getObj('email').value;
  data += "&Action=Remind";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
	if(http.readyState == 4) {
      getObj('res2').innerHTML = http.responseText;
	}	
  }
  	  
  http.send(data);
  }
  
  function Login() {
  http.open("POST", "member_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "username=" + getObj('username').value;
  data += "&password=" + getObj('password').value;  
  data += "&Action=Login";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
    if(http.readyState == 4) {		
      if (http.responseText == "[OK]") {
	  	location.href='services1.php';
	  }
	  else {
	  	getObj('res1').innerHTML = http.responseText;		  
	  }
	}	
  }
  http.send(data);
  } 
  
  function Logout() {
  http.open("POST", "member_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "Action=Logout";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
    if(http.readyState == 4) {		
      if (http.responseText == "[OK]") {
		alert('Επιτυχές Logout!');  
	  	location.href='register.php';
	  }
	  else {
	  	getObj('res1').innerHTML = http.responseText;		  
	  }
	}	
  }
  http.send(data);
  }   


// SERVICES
  function RegisterComp() {
	
  var CompFacilArray1 = new Array(10);
  if (getObj('comp_facil1').checked) { CompFacilArray1[0] = getObj('comp_facil1').value; } else { CompFacilArray1[0] = '0'; }
  if (getObj('comp_facil2').checked) { CompFacilArray1[1] = getObj('comp_facil2').value; } else { CompFacilArray1[1] = '0'; }
  if (getObj('comp_facil3').checked) { CompFacilArray1[2] = getObj('comp_facil3').value; } else { CompFacilArray1[2] = '0'; }
  if (getObj('comp_facil4').checked) { CompFacilArray1[3] = getObj('comp_facil4').value; } else { CompFacilArray1[3] = '0'; }
  if (getObj('comp_facil5').checked) { CompFacilArray1[4] = getObj('comp_facil5').value; } else { CompFacilArray1[4] = '0'; }
  if (getObj('comp_facil6').checked) { CompFacilArray1[5] = getObj('comp_facil6').value; } else { CompFacilArray1[5] = '0'; }
  if (getObj('comp_facil7').checked) { CompFacilArray1[6] = getObj('comp_facil7').value; } else { CompFacilArray1[6] = '0'; }
  if (getObj('comp_facil8').checked) { CompFacilArray1[7] = getObj('comp_facil8').value; } else { CompFacilArray1[7] = '0'; }
  if (getObj('comp_facil9').checked) { CompFacilArray1[8] = getObj('comp_facil9').value; } else { CompFacilArray1[8] = '0'; }
  if (getObj('comp_facil10').checked) { CompFacilArray1[9] = getObj('comp_facil10').value; } else { CompFacilArray1[9] = '0'; }

  var CompFacilArray2 = new Array(5);
  if (getObj('comp_facil21').checked) { CompFacilArray2[0] = getObj('comp_facil21').value; } else { CompFacilArray2[0] = '0'; }
  if (getObj('comp_facil22').checked) { CompFacilArray2[1] = getObj('comp_facil22').value; } else { CompFacilArray2[1] = '0'; }
  if (getObj('comp_facil23').checked) { CompFacilArray2[2] = getObj('comp_facil23').value; } else { CompFacilArray2[2] = '0'; }
  if (getObj('comp_facil24').checked) { CompFacilArray2[3] = getObj('comp_facil24').value; } else { CompFacilArray2[3] = '0'; }
  if (getObj('comp_facil25').checked) { CompFacilArray2[4] = getObj('comp_facil25').value; } else { CompFacilArray2[4] = '0'; }

  http.open("POST", "services_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "areas=" + document.AdvFrm.areas.options[document.AdvFrm.areas.selectedIndex].value;
  data += "&subareas=" + document.AdvFrm.subareas.value;  
  data += "&type_id=" + document.AdvFrm.type_id.options[document.AdvFrm.type_id.selectedIndex].value;  
  data += "&cat_id=" + document.AdvFrm.cat_id.options[document.AdvFrm.cat_id.selectedIndex].value;  
  data += "&name_gr=" + getObj('name_gr').value;  
  data += "&name_en=" + getObj('name_en').value;  
  data += "&descr_gr=" + getObj('descr_gr').value;  
  data += "&descr_en=" + getObj('descr_en').value;  
  data += "&offer_gr=" + getObj('offer_gr').value;  
  data += "&offer_en=" + getObj('offer_en').value;  
  data += "&address_gr=" + getObj('address_gr').value;  
  data += "&address_en=" + getObj('address_en').value;  
  data += "&email=" + getObj('email').value;  
  data += "&url=" + getObj('url').value;  
  data += "&price=" + document.AdvFrm.price.options[document.AdvFrm.price.selectedIndex].value;  
  data += "&dist=" + document.AdvFrm.dist.options[document.AdvFrm.dist.selectedIndex].value;  
  data += "&CompFacilArray1=" + CompFacilArray1;  
  data += "&CompFacilArray2=" + CompFacilArray2;    
  data += "&Action=RegisterComp";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
    if(http.readyState == 4) {
      getObj('res1').innerHTML = http.responseText;
	}	
  }
  http.send(data);
  } 
  
  function ChangeComp(ID) {
	
  var CompFacilArray1 = new Array(10);
  if (getObj('comp_facil1').checked) { CompFacilArray1[0] = getObj('comp_facil1').value; } else { CompFacilArray1[0] = '0'; }
  if (getObj('comp_facil2').checked) { CompFacilArray1[1] = getObj('comp_facil2').value; } else { CompFacilArray1[1] = '0'; }
  if (getObj('comp_facil3').checked) { CompFacilArray1[2] = getObj('comp_facil3').value; } else { CompFacilArray1[2] = '0'; }
  if (getObj('comp_facil4').checked) { CompFacilArray1[3] = getObj('comp_facil4').value; } else { CompFacilArray1[3] = '0'; }
  if (getObj('comp_facil5').checked) { CompFacilArray1[4] = getObj('comp_facil5').value; } else { CompFacilArray1[4] = '0'; }
  if (getObj('comp_facil6').checked) { CompFacilArray1[5] = getObj('comp_facil6').value; } else { CompFacilArray1[5] = '0'; }
  if (getObj('comp_facil7').checked) { CompFacilArray1[6] = getObj('comp_facil7').value; } else { CompFacilArray1[6] = '0'; }
  if (getObj('comp_facil8').checked) { CompFacilArray1[7] = getObj('comp_facil8').value; } else { CompFacilArray1[7] = '0'; }
  if (getObj('comp_facil9').checked) { CompFacilArray1[8] = getObj('comp_facil9').value; } else { CompFacilArray1[8] = '0'; }
  if (getObj('comp_facil10').checked) { CompFacilArray1[9] = getObj('comp_facil10').value; } else { CompFacilArray1[9] = '0'; }

  var CompFacilArray2 = new Array(5);
  if (getObj('comp_facil21').checked) { CompFacilArray2[0] = getObj('comp_facil21').value; } else { CompFacilArray2[0] = '0'; }
  if (getObj('comp_facil22').checked) { CompFacilArray2[1] = getObj('comp_facil22').value; } else { CompFacilArray2[1] = '0'; }
  if (getObj('comp_facil23').checked) { CompFacilArray2[2] = getObj('comp_facil23').value; } else { CompFacilArray2[2] = '0'; }
  if (getObj('comp_facil24').checked) { CompFacilArray2[3] = getObj('comp_facil24').value; } else { CompFacilArray2[3] = '0'; }
  if (getObj('comp_facil25').checked) { CompFacilArray2[4] = getObj('comp_facil25').value; } else { CompFacilArray2[4] = '0'; }

  http.open("POST", "services_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "areas=" + document.AdvFrm.areas.options[document.AdvFrm.areas.selectedIndex].value;
  data += "&subareas=" + document.AdvFrm.subareas.value;  
  data += "&type_id=" + document.AdvFrm.type_id.options[document.AdvFrm.type_id.selectedIndex].value;  
  data += "&cat_id=" + document.AdvFrm.cat_id.options[document.AdvFrm.cat_id.selectedIndex].value;  
  data += "&name_gr=" + getObj('name_gr').value;  
  data += "&name_en=" + getObj('name_en').value;  
  data += "&descr_gr=" + getObj('descr_gr').value;  
  data += "&descr_en=" + getObj('descr_en').value;  
  data += "&offer_gr=" + getObj('offer_gr').value;  
  data += "&offer_en=" + getObj('offer_en').value;  
  data += "&address_gr=" + getObj('address_gr').value;  
  data += "&address_en=" + getObj('address_en').value;  
  data += "&email=" + getObj('email').value;  
  data += "&url=" + getObj('url').value; 
  data += "&comp_im1=" + getObj('comp_im1_txt').value; 
  data += "&comp_im2=" + getObj('comp_im2_txt').value; 
  data += "&comp_im3=" + getObj('comp_im3_txt').value; 
  data += "&comp_im4=" + getObj('comp_im4_txt').value;   
  data += "&comp_im5=" + getObj('comp_im5_txt').value;     
  data += "&price=" + document.AdvFrm.price.options[document.AdvFrm.price.selectedIndex].value;  
  data += "&dist=" + document.AdvFrm.dist.options[document.AdvFrm.dist.selectedIndex].value;  
  data += "&CompFacilArray1=" + CompFacilArray1;  
  data += "&CompFacilArray2=" + CompFacilArray2;    
  data += "&comp_id=" + ID;
  data += "&Action=ChangeComp";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
    if(http.readyState == 4) {
      getObj('res1').innerHTML = http.responseText;
	}	
  }
  http.send(data);
  } 


  function BuyServices() {
	
  http.open("POST", "services_model.php", true);  
  http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  var data = "";
  data += "ServArray=" + SArray; 
  data += "&Comments=" + getObj('comments').value;
  data += "&PayStr=" + PayStr;
  data += "&Action=BuyServices";
  data += "&nocache=" + nocache;
  http.onreadystatechange=function() {   
    if(http.readyState == 4) {
	  	if (http.responseText == 'OK') {
			location.href='services3.php';		
		}
		else {
			getObj('res1').innerHTML = 'Επιλέξτε υπηρεσία/υπηρεσίες και Τρόπο Πληρωμής...';	
		}	
	}	
  }
  http.send(data);
  } 
    