function trimInputs() {		
	for (i = 0; i < document.forms.length; i++) {
		for (j = 0; j < document.forms[i].elements.length; j ++) {				
			if (document.forms[i].elements[j].type == "text" || document.forms[i].elements[j].type == "textarea") {				
				if (document.forms[i].elements[j].addEventListener) {
					document.forms[i].elements[j].addEventListener('blur',
						function (e) {																		
							value = this.value;
							while (value.substring(0,1) == ' ') {
								value = value.substring(1, value.length);
							}
							while (value.substring(value.length-1, value.length) == ' ') {
								value = value.substring(0,value.length-1);
							}
							this.value = value;
						}
					,'true');
				}
				else {
					if ( document.forms[i].elements[j].attachEvent ) {
						document.forms[i].elements[j].attachEvent('onblur', function (e) {																		
							value = e.srcElement.value;
							while (value.substring(0,1) == ' ') {
								value = value.substring(1, value.length);
							}
							while (value.substring(value.length-1, value.length) == ' ') {
								value = value.substring(0,value.length-1);
							}
							e.srcElement.value = value;
						});								
					}
				}
			}				
		}			
	}
}
//mypopulate xmlHttp
var idul;
var busy;
var parent;
var loadingimg=new Image();
loadingimg.src='images/loading.gif';

function deleteImage(imageName, supplier, id)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
var url="ajax/fillsel.php?id=" + Math.random() + "&deleteImage=" + imageName  + "&supplierT=" + supplier
//alert(url);
xmlHttp=GetXmlHttpObject(stateChanged_image)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 




///############# Verify for existing Supplier in the database ///######################
function verifyIfSupplierExists(supplierName,suppType,admin)
{
//alert('ok');
	//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
if(supplierName.length > 3)
	{
	if(admin == 1)
			var url="ajax/fillsel.php?id=" + Math.random() + "&verifySupplier=" + supplierName  + "&suppType=" + suppType
		else
			var url="ajax/fillsel.php?id=" + Math.random() + "&verifySupplier=" + supplierName  + "&suppType=" + suppType	
	xmlHttp=GetXmlHttpObject(stateChanged_verifySupplier)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)	
	}
}

///############# Verify for existing customer  in the database ///######################
function VerifyCustomerLogin(customerName,customerEmail,customerCompany)
{
alert('cn='+customerName+'ce='+customerEmail+'CC='+customerCompany)
	
	/*var url="ajax/fillsel.php?id=" + Math.random() + "&verifyCustomer=" + customerName  + "&ce=" + customerEmail + "&cc=" + customerEmail 		
	xmlHttp=GetXmlHttpObject(stateChanged_verifyCustomer)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)	*/
}



//################################## Confirm on Rq Booking get rates when a roomtype is changed
function getPayableRates(bookingCode,newRoomtype,rowNr)
{ 

//alert(bookingCode + ' - '+ newRoomtype + ' - ' + rowNr)
//alert("Please wait until the system autoloads with contracted rates for selected room type");
var zaId = "suppRate_"+rowNr+"_1";
document.getElementById(zaId).focus();
//document.getElementById("SupplierCancelation_"+rowNr).value="";

openDivPopUp(360,250);
var theHtml = document.getElementById("pleasewait").innerHTML;
setContentDivPopUp(theHtml);
var url="myadmin/ajax/fillsel.php?id=" + Math.random() + "&getRates=" + bookingCode  + "&nrt=" + newRoomtype  + "&newrow=" + rowNr
xmlHttp=GetXmlHttpObject(stateChanged_payableRates)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 


function getPayableRates_extranet(bookingCode,newRoomtype,rowNr, supplierextranet)
{ 

//alert(bookingCode + ' - '+ newRoomtype + ' - ' + rowNr)
//alert("Please wait until the system autoloads with contracted rates for selected room type");
var zaId = "suppRate_"+rowNr+"_1";
document.getElementById(zaId).focus();
//document.getElementById("SupplierCancelation_"+rowNr).value="";
openDivPopUp(360,250);
var theHtml = document.getElementById("pleasewait").innerHTML;
setContentDivPopUp(theHtml);
if(supplierextranet == 1)
	var url="myadmin/ajax/fillsel.php?id=" + Math.random() + "&getRates=" + bookingCode  + "&nrt=" + newRoomtype  + "&newrow=" + rowNr
else
	var url="../myadmin/ajax/fillsel.php?id=" + Math.random() + "&getRates=" + bookingCode  + "&nrt=" + newRoomtype  + "&newrow=" + rowNr
xmlHttp=GetXmlHttpObject(stateChanged_payableRates)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 


//################################## Profile Notes
function addProfileNote(noteHash,mysubject,mymessage)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
var url="ajax/fillsel.php?id=" + Math.random() + "&addProfileNote=" + noteHash  + "&mysubject=" + mysubject + "&mymessage=" + mymessage
xmlHttp=GetXmlHttpObject(stateChanged_note)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 

function deleteProfileNote(noteId)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
var url="ajax/fillsel.php?id=" + Math.random() + "&deleteProfileNote=" + noteId
xmlHttp=GetXmlHttpObject(stateChanged_note_d)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 

function extractProfileNote(noteId)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
var url="ajax/fillsel.php?id=" + Math.random() + "&editProfileNote=" + noteId
xmlHttp=GetXmlHttpObject(stateChanged_note_e)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 

function saveProfileNote(noteHash,mysubject,mymessage,noteID)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)

var url="ajax/fillsel.php?id=" + Math.random() + "&saveProfileNote=" + noteHash  + "&mysubject=" + mysubject + "&mymessage=" + mymessage + "&noteId=" + noteID
xmlHttp=GetXmlHttpObject(stateChanged_note_s)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 
//###################################

//Profile Supplier Docs
function addDocNote(noteHash,mysubject,mymessage,insertedid)
{ 
	//idul = id;
	alert(str + ' - '+ chg + ' - ' + blr)
	//alert(imageName+'');
	var url="ajax/fillsel.php?id=" + Math.random() + "&addDocNote=" + noteHash  + "&mysubject=" + mysubject + "&mymessage=" + mymessage+ "&insertedid="+inserted
	xmlHttp=GetXmlHttpObject(stateChanged_addDoc)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
} 

function deleteDocNote(noteId)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
var url="ajax/fillsel.php?id=" + Math.random() + "&deleteDocNote=" + noteId
xmlHttp=GetXmlHttpObject(stateChanged_delDoc)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 

function extractDocNote(noteId)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
var url="ajax/fillsel.php?id=" + Math.random() + "&editDocNote=" + noteId
xmlHttp=GetXmlHttpObject(stateChanged_editDoc)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 

function saveDocNote(noteHash,mysubject,mymessage,noteID)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)

var url="ajax/fillsel.php?id=" + Math.random() + "&saveDocNote=" + noteHash  + "&mysubject=" + mysubject + "&mymessage=" + mymessage + "&noteId=" + noteID
xmlHttp=GetXmlHttpObject(stateChanged_saveDoc)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 

//###### End supplier Documentation




function resendLink(trCode,servType)
{
	//alert(servType+' - '+trCode);
	var height = parseInt(document.body.offsetHeight);
	var height2 = parseInt(window.innerHeight);
	if(height2>height) height=height2;
	var e=document.getElementById('pleasewait');
	if(e){
		e.style.height = height;
		e.style.display='';
	}
	var url="ajax/fillsel.php?id=" + Math.random() + "&resendLink=yes&cod=" + trCode + "&servType=" + servType
	xmlHttp=GetXmlHttpObject(stateChanged_resendlink)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function sendId(trCode,servType)
{
	var height = parseInt(document.body.offsetHeight);
	var height2 = parseInt(window.innerHeight);
	if(height2>height) height=height2;
	var e=document.getElementById('pleasewait');
	if(e){
		e.style.height = height;
		e.style.display='';
	}
	var url="ajax/fillsel.php?id=" + Math.random() + "&sendIdandPass=yes&cod=" + trCode + "&servType=" + servType
	xmlHttp=GetXmlHttpObject(stateChanged_sendIdandPass)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function makeLive(trCode,servType)
{
	//alert(servType+' - '+trCode);
	if(confirm('Are you sure you want to make live this '+servType))
	{	
		var url="ajax/fillsel.php?id=" + Math.random() + "&makeLive=yes&cod=" + trCode + "&servType=" + servType
		xmlHttp=GetXmlHttpObject(stateChanged_makeLive)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
}
function hotelmakeLive(trCode,servType)
{
	//alert(servType+' - '+trCode);
	if(confirm('Are you sure you want to make live this '+servType))
	{	
		var height = document.body.offsetHeight;
		var height2 = parseInt(window.innerHeight);
		if(height2>height) height=height2;
		var e=document.getElementById('pleasewait');
		if(e){
			e.style.height = height;
			e.style.display='';
		}
		var url="ajax/fillsel.php?id=" + Math.random() + "&makeLive=yes&cod=" + trCode + "&servType=" + servType
		xmlHttp=GetXmlHttpObject(stateChanged_hotelmakeLive)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
}
function apartmentmakeLive(trCode,servType)
{
	//alert(servType+' - '+trCode);
	if(confirm('Are you sure you want to make live this '+servType))
	{	
		var height = document.body.offsetHeight;
		var height2 = parseInt(window.innerHeight);
		if(height2>height) height=height2;
		var e=document.getElementById('pleasewait');
		if(e){
			e.style.height = height;
			e.style.display='';
		}
		var url="ajax/fillsel.php?id=" + Math.random() + "&makeLive=yes&cod=" + trCode + "&servType=" + servType
		xmlHttp=GetXmlHttpObject(stateChanged_apartmentmakeLive)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	}
}

//-----------------------------------
function deleteImage_Supp(imageName, supplier, id)
{ 
//idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
//alert(imageName+'');
var url="ajax/fillsel.php?id=" + Math.random() + "&deleteImage=" + imageName  + "&supplierT=" + supplier
xmlHttp=GetXmlHttpObject(stateChanged_image)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)

} 

//generate a tour or transfer contract if was't generated yet
function generateContract(code,type){
	
//alert(document.getElementById('mycontractArea').innerHTML);	
document.getElementById('mycontractArea').innerHTML='<div class="normalText" align="center">Please wait while the contract is generated.....</div>';	
var url="ajax/fillsel.php?id=" + Math.random() + "&generateContract=" + code  + "&type=" + type
xmlHttp=GetXmlHttpObject(stateChanged_contract)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}


//---- fills Cities given a country and defines onchange and onblur events
function fillCities(str, id, chg, blr)
{ 
idul = id;
//alert(str + ' - '+ chg + ' - ' + blr)
var url="ajax/fillsel.php?id=" + Math.random() + "&q=" + str  + "&change=" + chg + "&blur=" + blr
xmlHttp=GetXmlHttpObject(stateChanged3)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 

function fillCitiesNrOrdine(str, id, nrOrdine, chg, blr)
{ 
idul = id;
//alert(str + ' - '+ id + ' - ' + nrOrdine + ' - '+chg + ' - ' + blr)
var url="ajax/fillsel.php?id=" + Math.random() + "&qOrd=" + str  + "&nrOrdine=" + nrOrdine + "&change=" + chg + "&blur=" + blr
xmlHttp=GetXmlHttpObject(cityChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 

function fillCitiesFromStates(str, id)
{ 
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&qq=" + str
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
} 

function fillLocations(str, id)
{ 
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&w=" + str
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function checkCountry(str, id)
{
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&c=" + str
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function checkRegion(str, id) {
	idul = id;
	var url="ajax/fillsel.php?id=" + Math.random() + "&regionName=" + str
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function checkEditRegion(str, id, code) {
	idul = id;
	var url="ajax/fillsel.php?id=" + Math.random() + "&editRegionName=" + str + "&code=" + code
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)	
}

//--- checks if a given state name exist in the database 
function checkStateAdd(stateName, countryCode, id)
{
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&stateName=" + stateName + "&countryCode=" + countryCode
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}


function checkEditCountry(str, id, code)
{
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&cc=" + str + "&code=" + code
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function testCountry(str, id)
{
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&s=" + str
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function testCountry2(str, id)
{
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&s=" + str
xmlHttp=GetXmlHttpObject(stateChanged2)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function testCountryNrOrdine(str, id, nrOrdine)
{
idul = id;
nrOrd = nrOrdine;
var url="ajax/fillsel.php?id=" + Math.random() + "&sOrd=" + str + "&nrOrdine=" + nrOrdine
xmlHttp=GetXmlHttpObject(stateChangedNrOrdine)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function CheckBranch()
{
if(!document.getElementById('branch') || document.getElementById('branch').value=='0') {
	alert('Please select a Branch, in order to continue!');
	return false;
}
else
	return true;
}

function MiscBranch()
{
if(!CheckBranch()) return false;
var url="ajax/fillsel.php?misc=11&bcode="+document.getElementById('branch').value;
xmlHttp=GetXmlHttpObject(MiscBranchChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function MiscSourceType()
{
if(!CheckBranch()) {
	document.getElementById('sourceType')[0].selected = true;
	return false;
}
var url="ajax/fillsel.php?misc=12&bcode=" + document.getElementById('branch').value+"&stype="+document.getElementById('sourceType').value;
xmlHttp=GetXmlHttpObject(MiscSourceTypeChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function MiscStatus()
{
if(!CheckBranch()) {
	document.getElementById('miscStatus')[0].selected = true;
	return false;
}
var miscValue=document.getElementById('miscStatus').value;
if(miscValue=='1665' || miscValue=='1668') {
	document.getElementById('LookUpBySypplierName1').style.display='none';
	document.getElementById('LookUpBySypplierName2').style.display='none';
}
else {
	document.getElementById('LookUpBySypplierName1').style.display='';
	document.getElementById('LookUpBySypplierName2').style.display='';	
}
var url="ajax/fillsel.php?misc=13&bcode=" + document.getElementById('branch').value+"&stype="+document.getElementById('sourceType').value+"&mstatus="+document.getElementById('miscStatus').value;
xmlHttp=GetXmlHttpObject(MiscStatusChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function MiscSourceMarket()
{
if(!CheckBranch()) {
	document.getElementById('sourceMarket')[0].selected = true;
	return false;
}
var url="ajax/fillsel.php?misc=14&bcode=" + document.getElementById('branch').value+"&stype="+document.getElementById('sourceType').value+"&mstatus="+document.getElementById('miscStatus').value+"&smarket="+document.getElementById('sourceMarket').value;
xmlHttp=GetXmlHttpObject(MiscSourceMarketChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function MiscServiceCity()
{
if(!CheckBranch()) {
	document.getElementById('serviceCity')[0].selected = true;
	return false;
}
var url="ajax/fillsel.php?misc=15&bcode=" + document.getElementById('branch').value+"&stype="+document.getElementById('sourceType').value+"&mstatus="+document.getElementById('miscStatus').value+"&smarket="+document.getElementById('sourceMarket').value+"&scity="+document.getElementById('serviceCity').value;
xmlHttp=GetXmlHttpObject(MiscServiceCityChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function MiscCustomerType()
{
if(!CheckBranch()) {
	document.getElementById('customerType')[0].selected = true;
	return false;
}
var url="ajax/fillsel.php?misc=16&bcode=" + document.getElementById('branch').value+"&stype="+document.getElementById('sourceType').value+"&mstatus="+document.getElementById('miscStatus').value+"&smarket="+document.getElementById('sourceMarket').value+"&scity="+document.getElementById('serviceCity').value+"&ctype="+document.getElementById('customerType').value;
xmlHttp=GetXmlHttpObject(MiscCustomerTypeChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function MiscCustomerCity()
{
if(!CheckBranch()) {
	document.getElementById('customerCity')[0].selected = true;
	return false;
}
var url="ajax/fillsel.php?misc=17&bcode=" + document.getElementById('branch').value+"&stype="+document.getElementById('sourceType').value+"&mstatus="+document.getElementById('miscStatus').value+"&smarket="+document.getElementById('sourceMarket').value+"&scity="+document.getElementById('serviceCity').value+"&ctype="+document.getElementById('customerType').value+"&ccity="+document.getElementById('customerCity').value;
xmlHttp=GetXmlHttpObject(MiscCustomerCityChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function GroupsGetHotelsFromCity(defaultSelect)
{
var url="ajax/fillsel.php?id=" + Math.random() + "&action=gethotelsfromcity&city=" + document.getElementById('DestCity').value+"&category="+document.getElementById('HotelCategory').value;
if(defaultSelect!=null)
	url+="&defaultSelect="+defaultSelect;
xmlHttp=GetXmlHttpObject(GroupsGetHotelsFromCityChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function testCountryXX(str, id)
{
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&s=" + str
xmlHttp=GetXmlHttpObject(stateChanged22)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function testCountry3(str, cod, id)
{
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&ss=" + str + "&codul=" + cod
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

//--- check city ADD
function checkCityInput(str, sc, cntr, id)
{
idul = id;
	
//alert(str+' - '+sc+' - '+cntr+' - '+id);

var url="ajax/fillsel.php?id=" + Math.random() + "&city=" + str + "&sc=" + sc + "&cntr=" + cntr
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

//--- check city ADD
function checkCityInputS(str, sc, cntr, st, id)
{
idul = id;
	
//alert(str+' - '+sc+' - '+cntr+' - '+id);

var url="ajax/fillsel.php?id=" + Math.random() + "&city=" + str + "&sc=" + sc + "&cntr=" + cntr + "&st=" +st
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}


//--- check city EDIT
function checkCityInputEdit(str, sc, cntr, id, citycode)
{
idul = id;
	
//alert(str+' - '+sc+' - '+cntr+' - '+id);
//alert('check fara state');

var url="ajax/fillsel.php?id=" + Math.random() + "&city2=" + str + "&sc2=" + sc + "&cntr2=" + cntr + "&citycode2=" + citycode
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

//--- check city EDIT
function checkCityInputSEdit(str, sc, cntr, st, id, citycode)
{
idul = id;
	
//alert(str+' - '+sc+' - '+cntr+' - '+id);
//alert('check cu state');

//var url="ajax/fillsel.php?id=" + Math.random() + "&city2=" + str + "&sc2=" + sc + "&cnt2r=" + cntr + "&st2=" +st + "&citycode2=" + citycode
var url="ajax/fillsel.php?id=" + Math.random() + "&city2=" + str + "&sc2=" + sc + "&cntr2=" + cntr + "&st2=" +st + "&citycode2=" + citycode
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

//--- check if a location can be added in the database
function checkLocationInput(loc, city, id)
{
idul = id;
//alert(loc+' - '+country+' - '+city+' - '+id);
//alert('ok');
var url="ajax/fillsel.php?id=" + Math.random() + "&loc=" + loc + "&cityc=" + city 
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

//--- check if a location can be edited 
function checkLocationInputEdit(loc, city, id, loccod)
{
idul = id;
//alert(loc+' - '+country+' - '+city+' - '+id);
//alert('ok');
var url="ajax/fillsel.php?id=" + Math.random() + "&loc2=" + loc + "&cityc2=" + city  + "&loccod2=" + loccod
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

//--- check if a new contact can be added in the database
function checkNewContact(contName, contCity, id)
{
idul = id;
//alert(contName+' - '+contCity+' - '+id);

var url="ajax/fillsel.php?id=" + Math.random() + "&contactN=" + contName + "&contactCi=" + contCity
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}


//--- check if a new branch can be added in the database
function checkNewBranch(branchN, codeB, id)
{
idul = id;
//alert(contName+' - '+contCity+' - '+id);

var url="ajax/fillsel.php?id=" + Math.random() + "&branchN=" + branchN + "&codeB=" + codeB
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

//---- check if a nearby city exists
function checkNearByCity(nearbyCityName, id)
{
idul = id;
alert(nearbyCityName);
var url="ajax/fillsel.php?id=" + Math.random() + "&nearbyCity=" + nearbyCityName
xmlHttp=GetXmlHttpObject(stateChanged4)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function checkNearByCity2(nearbyCityName, id)
{
idul = id;
alert(nearbyCityName);
var url="ajax/fillsel.php?id=" + Math.random() + "&nearbyCity2=" + nearbyCityName
xmlHttp=GetXmlHttpObject(stateChanged4)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}


function sortSignUpTable(sortCriteria, id, type,myfilter)
{
//alert('aaaaa - myFilters = '+myfilter);
	//alert(sortCriteria+" - "+id+" - "+type);
//alert(id);
	idul = id;
if(type!='hotels'){
//document.getElementById('waitTd').innerHTML = '<BR><div> Please wait while the Data is loading.....</div><BR>';
document.getElementById('wait').style.display = '';
if (document.getElementById(id)) document.getElementById(id).innerHTML = '&nbsp;';
}

if (type=='Tour')
	var url="ajax/fillsel.php?id=" + Math.random() + "&tourCriteria=" + sortCriteria+ "&myfilter=" + myfilter;
else 
	if (type=='hotels')
		var url="ajax/fillsel.php?id=" + Math.random() + "&hotelCriteria=" + sortCriteria;
	else
		var url="ajax/fillsel.php?id=" + Math.random() + "&criteria=" + sortCriteria + "&myfilter=" + myfilter;;
xmlHttp=GetXmlHttpObject(stateChangedSignup);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}

function delTransfer(transferCode, id)
{
//alert('ok');
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&delTransfer=" + transferCode
xmlHttp=GetXmlHttpObject(stateChanged83)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function delTour(tourCode, id)
{
//alert('ok');
idul = id;
var url="ajax/fillsel.php?id=" + Math.random() + "&delTour=" + tourCode
xmlHttp=GetXmlHttpObject(stateChanged84)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function sendLink(supId,type,id)
{
	idul = id;
	var url="ajax/fillsel.php?id=" + Math.random() + "&sendLink=ok" + "&sLSuppCode=" + supId
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function sendLoginDetails(cid) {
	var url="ajax/fillsel.php?id=" + Math.random() + "&sendLoginDetails=ok" + "&cid=" + cid
	xmlHttp=GetXmlHttpObject(sentLoginDetails)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function sendHowToPayDetails(cid) {
	var url="ajax/fillsel.php?id=" + Math.random() + "&sendHowToPayDetails=ok" + "&cid=" + cid
	xmlHttp=GetXmlHttpObject(sentHowToPayDetails)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function sentLoginDetails() {
	if (xmlHttp.readyState == 'complete' || xmlHttp.readyState == 4)
		alert("Login details have been sent to the customer!");	
}
function sentHowToPayDetails() {
	if (xmlHttp.readyState == 'complete' || xmlHttp.readyState == 4)
		alert("How to pay us details have been sent to the customer!");	
}

//==========================================================================================
//******************************************************************************************
//==========================================================================================
function supplierDataCheck(elem,curr){
if(elem&&elem.value.length>0){
	var pars='';
	pars=elem.value;
	if(curr != undefined || curr !='') var pars2=curr;
	var url="ajax/fillsel.php?id=" + Math.random() + "&action=supplierCheck&supplierName="+pars;
	var myxmlHttp=newXMLHttpRequest()
	var handlerFunction = getReadyStateHandler(myxmlHttp,supplierAction,Array(elem,pars2));
	myxmlHttp.onreadystatechange = handlerFunction;
	myxmlHttp.open("GET", url , true);
	myxmlHttp.send(null);
	}
}

function supplierAction(result,paramArray){
	result=result.replace(/^\s+|\s+$/g,'');
	if(result=="0"){
		var e=document.getElementById('supplierData');
		e.style.display='';
		var e=document.getElementById('companyid');
		e.value='0';
	}
	else{
		var tmpArray=result.split(",");
		var suppId=tmpArray[0];
		var suppCountry=tmpArray[1];
		var branchid=tmpArray[2];
		var e=document.getElementById('supplierData');
		e.style.display='none';
		var e1=document.getElementById('companyid');
		e1.value=suppId;
		if(paramArray[1] != undefined) var sel=paramArray[1];
		else sel='';
		returnOptionsExtended(Array(branchid,suppCountry),'getallcurrency','TipValuta','','','',sel);		
	}
}

function returnOptionsExtended(fieldarray,action,id,id2,ehandler,nhandler,choose,asyncvar)
{
var elem=document.getElementById(id);
var async=(asyncvar==undefined?true:false);
if(elem){
	removeAllOptions(elem);
	addOption(elem,"Loading...",-1,'');
	idul = id;
	var pars='';
	//for(var i in fieldarray) pars=pars+"&fieldid[]="+fieldarray[i];
	for(var i=0;i<fieldarray.length;i++) pars=pars+"&fieldid[]="+fieldarray[i];
	var url="ajax/fillsel.php?id=" + Math.random() + "&action="+action+pars;
	var myxmlHttp=newXMLHttpRequest()
	var handlerFunction = getReadyStateHandler(myxmlHttp,myPopulateOption,Array(id,id2,ehandler,nhandler,choose,fieldarray[i]));
	myxmlHttp.onreadystatechange = handlerFunction;
	myxmlHttp.open("GET", url , async);
	myxmlHttp.send(null);
	}
}
function returnMarket(fieldarray,action,id,func)
{
	var elem=document.getElementById(id);
	if(elem){
		removeAllOptions(elem);
		addOption(elem,"Loading...",0,'');
		var pars='';
		for(var i in fieldarray) pars=pars+"&fieldid[]="+fieldarray[i];
		var url="ajax/fillsel.php?id=" + Math.random() + "&action="+action+pars;
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,myPopulateMarket,Array(id,func));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("GET",url,true);
		myxmlHttp.send(null);
	}
}
function returnOptions(fieldid,action,id,id2,ehandler,nhandler)
{
var elem=document.getElementById(id);
if(elem){
	removeAllOptions(elem);
	addOption(elem,"Loading...",0,'');
	idul = id;
	var url="ajax/fillsel.php?id=" + Math.random() + "&action="+action+"&fieldid=" + fieldid;
	var myxmlHttp=newXMLHttpRequest()
	var handlerFunction = getReadyStateHandler(myxmlHttp,myPopulateOption,Array(id,id2,ehandler,nhandler));
	myxmlHttp.onreadystatechange = handlerFunction;
	myxmlHttp.open("GET", url , true);
	myxmlHttp.send(null);
	}
}
function returnOptionsContact(fieldid,action,id,id2,ehandler,nhandler)
{
var elem=document.getElementById(id);
if(elem){
	removeAllOptions(elem);
	addOption(elem,"Loading...",0,'');
	idul = id;
	var url="ajax/fillsel.php?id=" + Math.random() + "&action="+action+"&fieldid=" + fieldid
	var myxmlHttp=newXMLHttpRequest()
	var handlerFunction = getReadyStateHandler(myxmlHttp,myPopulateOption,Array(id,id2,ehandler,nhandler));
	myxmlHttp.onreadystatechange = handlerFunction;
	myxmlHttp.open("GET", url , true);
	myxmlHttp.send(null);
	}
}

function postForm(form,id,hotelCode,action){
	var url="Ajax.php";
	//alert(action);
	var str=formget(form);
	var e1=document.getElementById("RoomTypeSubmit");
	if(e1) e1.style.display='none';
	var e=document.getElementById(id);		
	if(e){
		e.innerHTML='<div style="width:150px"><div style="float:right"><img src="images/loading.gif" border="0"/></div><div style="color:red;font-size:10px;font-family:Arial">Loading... Please Wait.</div></div>';
		str=str+"&id=" + Math.random() + "&action="+action;
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,getContent2,Array(id,hotelCode));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("POST", url , true);
		myxmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		myxmlHttp.send(str);
	}
}
function postForm2(form,id,hotelCode,action){
	var url="Ajax.php";
	var str=formget(form);
	var e1=document.getElementById("ApartmentSubmit");
	if(e1) e1.style.display='none';
	var e=document.getElementById(id);
	if(e){
		e.innerHTML='<div style="width:150px"><div style="float:right"><img src="images/loading.gif" border="0"/></div><div style="color:red;font-size:10px;font-family:Arial">Loading... Please Wait.</div></div>';
		str=str+"&id=" + Math.random() + "&action="+action;
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,getContent3,Array(id,hotelCode));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("POST", url , true);
		myxmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		myxmlHttp.send(str);
	}
}
function getRoomTypeContent(roomtypecode,id,hcode){
	var e=document.getElementById(id);
	var e1=document.getElementById("RoomTypeSubmit");
	if(e1) e1.style.display='none';
	if(parseInt(roomtypecode)==-1) var url="Ajax.php?id=" + Math.random() + "&action=getroomtype&roomtypecode=" + roomtypecode+"&hotelcode="+hcode;
	else var url="Ajax.php?id=" + Math.random() + "&action=getroomtype&roomtypecode=" + roomtypecode;
	if(e&&parseInt(roomtypecode)>=-1){
		e.innerHTML='<div style="width:150px"><div style="float:right"><img src="images/loading.gif" border="0"/></div><div style="color:red;font-size:10px;font-family:Arial">Loading... Please Wait.</div></div>';
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,getContent,Array(id,0));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("GET", url , true);
		myxmlHttp.send(null);
	}
}
function getApartmentContent(apartmentcode,id,acode){
	var e=document.getElementById(id);
	var e1=document.getElementById("ApartmentSubmit");
	if(e1) e1.style.display='none';
	if(parseInt(apartmentcode)==-1) var url="Ajax.php?id=" + Math.random() + "&action=getapartment&apartmentcode=" + apartmentcode+"&acode="+acode;
	else var url="Ajax.php?id=" + Math.random() + "&action=getapartment&apartmentcode=" + apartmentcode;
	if(e&&parseInt(apartmentcode)>=-1){
		e.innerHTML='<div style="width:150px"><div style="float:right"><img src="images/loading.gif" border="0"/></div><div style="color:red;font-size:10px;font-family:Arial">Loading... Please Wait.</div></div>';
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,getContent,Array(id,0));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("GET", url , true);
		myxmlHttp.send(null);
	}
}
function mysortSignUpTable(ide,sortCriteria,start,type,action,fid){
	document.getElementById('message').innerHTML='';
	document.getElementById('message').style.display='none';
	var e=document.getElementById(ide);
	var url="ajax/fillsel.php?id=" + Math.random() + "&start="+start+"&fid="+fid+"&type="+type+"&action="+action+"&hotelCriteria=" + sortCriteria;
	if(e)
	{
		e.innerHTML='<table><tr><td><div style="width:150px"><div style="float:right"><img src="images/loading.gif" border="0"></div><div style="color:red;font-size:10px;font-family:Arial">Loading... Please Wait.</div></div></td></tr></table>';
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,getSignupContent,Array(ide,sortCriteria,start));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("GET", url ,true);
		myxmlHttp.send(null);
	}
}
function myapartmentsortSignUpTable(ide,sortCriteria,start,type,action,fid){
	document.getElementById('message').innerHTML='';
	document.getElementById('message').style.display='none';
	var e=document.getElementById(ide);
	var url="ajax/fillsel.php?id=" + Math.random() + "&start="+start+"&fid="+fid+"&type="+type+"&action="+action+"&apartmentCriteria=" + sortCriteria;
	if(e)
	{
		e.innerHTML='<table><tr><td><div style="width:150px"><div style="float:right"><img src="images/loading.gif" border="0"></div><div style="color:red;font-size:10px;font-family:Arial">Loading... Please Wait.</div></div></td></tr></table>';
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,getSignupContent,Array(ide,sortCriteria,start));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("GET", url ,true);
		myxmlHttp.send(null);
	}
}
function getSignupContent(result,paramArray){
	var id=paramArray[0];
	var criteria=paramArray[1];
	var start=paramArray[2];
	var e=document.getElementById(id);
	if(e){
		e.innerHTML=result;
	}
	if(criteria != parseInt(document.getElementById('sortType').value) || start != parseInt(document.getElementById('start').value))
	{
		var ids = new Array();
		ids[0] = "nameASC";
		ids[1] = "nameDESC"
		ids[2] = "signupdateASC";
		ids[3] = "signupdateDESC";
		
		for (x in ids)
		{
			if(x!=criteria)
			{				
				if (x%2 == 0)
					imgSrc="images/sortascg.gif";
				else
					imgSrc="images/sortdescg.gif";
			}
			else
			{
				if (x%2 == 0)
					imgSrc="images/sortasc.gif";
				else
					imgSrc="images/sortdesc.gif";
			}
			
			document.getElementById(ids[x]).src=imgSrc;
		}
	}
}

function delService(serviceName,serviceCode,serviceType)
{
	if(confirm('Are you sure you want to delete '+serviceName+' ?'))
	{	
		var height = parseInt(document.body.offsetHeight);
		var height2 = parseInt(window.innerHeight);
		if(height2>height) height=height2;
		var e=document.getElementById('pleasewait');
		if(e){
			e.style.height = height;
			e.style.display='';
		}
		var url="ajax/fillsel.php?id=" + Math.random() + "&delService=" + serviceCode+ "&serviceType="+serviceType
		var myxmlHttp=newXMLHttpRequest();
		var handlerFunction = getReadyStateHandler(myxmlHttp,stateChanged_deleted,Array(serviceType,serviceName));
		myxmlHttp.onreadystatechange = handlerFunction;
		myxmlHttp.open("GET", url ,false);
		myxmlHttp.send(null);
	}
}

function evaluateJS(id){
	var e=document.getElementById(id);
	if(e){
		var js=e.getElementsByTagName("script");
		for(var i=0;i<js.length;i++){
			eval(js[i].innerHTML);
		}
	}
}

//==========================================================================================
//******************************************************************************************
//==========================================================================================

function displayBranchParent(branchTypeCode, id)
{
	idul = id;
	//alert(branchTypeCode);
	var url="ajax/fillsel.php?id=" + Math.random() + "&branchTypeCode=" + branchTypeCode
	xmlHttp=GetXmlHttpObject(stateChanged5)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}


//**********************************************
function populateSelMarkets(operationType, id, parentId)
{
	idul = id;
	parent = parentId;
	//alert(operationType);
	var url="ajax/fillsel.php?id=" + Math.random() + "&operationType=" + operationType + "&parentId=" + parentId
	if(operationType < 3)
		xmlHttp=GetXmlHttpObject(stateChanged6)
	else
	{
		document.getElementById('MarketsRow').style.display = '';
		xmlHttp=GetXmlHttpObject(stateChanged7)
	}
	
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	
}
//**********************************************
function populateHomeMarkets(operationType, id, parentId)
{

	idul = id;
	//alert(nearbyCityName);
	var url="ajax/fillsel.php?id=" + Math.random() + "&operationType=" + operationType + "&parentId=" + parentId
	xmlHttp=GetXmlHttpObject(stateChanged99)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)

}

function populateSpecialty(id)
{
	idul = id;
	//alert(nearbyCityName);
	var url="ajax/fillsel.php?id=" + Math.random() + "&specialty=spec"
	xmlHttp=GetXmlHttpObject(stateChanged98)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function emptySelect1(id)
{
	idul = id;
	//alert(nearbyCityName);
	var url="ajax/fillsel.php?id=" + Math.random() + "&empty=1"
	xmlHttp=GetXmlHttpObject(stateChanged97)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function emptySelect2(id)
{
	idul = id;
	//alert(nearbyCityName);
	var url="ajax/fillsel.php?id=" + Math.random() + "&empty=2"
	xmlHttp=GetXmlHttpObject(stateChanged96)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}


function emptySelect3(id)
{
	idul = id;
	//alert(nearbyCityName);
	var url="ajax/fillsel.php?id=" + Math.random() + "&empty=3"
	xmlHttp=GetXmlHttpObject(stateChanged)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


//**********************************************
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
	} 
} 
function stateChangedSignup() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert(idul+ ' se ajunge aici!: '+ xmlHttp.responseText);
		if(xmlHttp.responseText !='' && xmlHttp.responseText !=0)
		{
			if(document.getElementById('wait'))
			{
				document.getElementById('wait').style.display = "none";
			}
			if (document.getElementById(idul)) document.getElementById(idul).innerHTML=xmlHttp.responseText;
			
		}
			
		else
		{
			//alert("no res");
			if (document.getElementById('waitTd')) document.getElementById('waitTd').innerHTML = '<BR><b>No results were found with your search criteria.</b><BR><BR>';
		}
		if(document.getElementById('cautare'))
		{
			e.style.display = "none";
		}
		
	} 
} 

function stateChanged83() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
	if(idul){
		alert('The Product '+idul+' has been deleted!');
	}
	else{
		alert('The Product has been deleted!');
	}
		//if(document.getElementById(idul))
		//	document.getElementById(idul).innerHTML=xmlHttp.responseText;
		sortSignUpTable(document.getElementById('sortType').value, 'theTransfers');
	} 
} 

function stateChanged_resendlink() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById('testing').innerHTML=xmlHttp.responseText;
		//sortSignUpTable(document.getElementById('sortType').value, 'theTransfers');
		alert('The link has been sent!');
		var e=document.getElementById('pleasewait');
		if(e) e.style.display='none';
	} 
}
function stateChanged_sendIdandPass() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById('testing').innerHTML=xmlHttp.responseText;
		//sortSignUpTable(document.getElementById('sortType').value, 'theTransfers');
		alert('The Id and Password has been sent!');
		var e=document.getElementById('pleasewait');
		if(e) e.style.display='none';
	} 
}
function stateChanged_sendIdandPass() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById('testing').innerHTML=xmlHttp.responseText;
		//sortSignUpTable(document.getElementById('sortType').value, 'theTransfers');
		alert('The Id and Password has been sent!');
		var e=document.getElementById('pleasewait');
		if(e) e.style.display='none';
	} 
}

function stateChanged_deleted(result,param) 
{ 
	var serviceType=param[0];
	var serviceName=param[1];
	//document.getElementById('testing').innerHTML=xmlHttp.responseText;
	if(serviceName){
		alert('The Product '+serviceName+' has been deleted!');
	}
	else{
		alert('The Product has been deleted!');
	}
	var e=document.getElementById('pleasewait');
	if(e) e.style.display='none';
	if(serviceType==1){	
		mysortSignUpTable('theHotels',document.getElementById('sortType').value,0);
	}
	else 
	if(serviceType==2){
		myapartmentsortSignUpTable('theApartments',document.getElementById('sortType').value,0);
	}
} 
function stateChanged_hotelmakeLive() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById('testing').innerHTML=xmlHttp.responseText;
		//ide,sortCriteria,start,type,action,fid
		mysortSignUpTable('theHotels',0,0,document.getElementById('type').value,document.getElementById('action').value,document.getElementById('fid').value,0);
		var e=document.getElementById('pleasewait');
		if(e) e.style.display='none';
		document.getElementById('message').style.display='';
		document.getElementById('message').innerHTML=xmlHttp.responseText;
	} 
} 
function stateChanged_apartmentmakeLive() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById('testing').innerHTML=xmlHttp.responseText;
		//ide,sortCriteria,start,type,action,fid
		mysortSignUpTable('theApartments',0,0,document.getElementById('type').value,document.getElementById('action').value,document.getElementById('fid').value,0);
		var e=document.getElementById('pleasewait');
		if(e) e.style.display='none';
		document.getElementById('message').style.display='';
		document.getElementById('message').innerHTML=xmlHttp.responseText;
	} 
} 

function stateChanged_makeLive() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById('testing').innerHTML=xmlHttp.responseText;
		//ide,sortCriteria,start,type,action,fid
		alert('The Live Email has been sent !');		
		sortSignUpTable(document.getElementById('sortType').value, 'theTours', 'Tour');
		
		//var e=document.getElementById('pleasewait');
		//if(e) e.style.display='none';
		//document.getElementById('message').style.display='';
		//document.getElementById('message').innerHTML=xmlHttp.responseText;
	} 
}	

function stateChanged84() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById(idul).innerHTML=xmlHttp.responseText;
		//alert(xmlHttp.responseText);
		if(idul){
		alert('The Product '+idul+' has been deleted!');
	}
	else{
		alert('The Product has been deleted!');
	}
		sortSignUpTable(document.getElementById('sortType').value, 'theTours', 'Tour');
	} 
} 

function stateChanged_image() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert("response after Delete="+xmlHttp.responseText);		
	} 
} 

function stateChanged_verifySupplier()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var responseText = xmlHttp.responseText;
		
		if(responseText =='isanother')
		{
			document.getElementById('errorExisting').style.display ='';
			
			document.getElementById('NameOfSupplier').className = 'casute3error';
		}
		else
			document.getElementById('errorExisting').style.display ='none';
		
	}
	
}//end verify Supplier


function stateChanged_verifyCustomer()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var responseText = xmlHttp.responseText;
		
		if(responseText =='isanother')
		{
			//document.getElementById('errorExisting').style.display ='';
			document.getElementById('login').className = 'casute3error';
			alert("Please choose another Login Id because this id is already taken");
			document.getElementById("login").focus();	
		}
		else
			document.getElementById('errorExisting').style.display ='none';
		
	}
	
}//end verify Supplier





function stateChanged_payableRates()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		var response = xmlHttp.responseText;
		
		var pieces   = response.split("##");
		
		var nrRates   = pieces[0];
		var bookingNo = pieces[1];
		//var Currency  = pieces[2];
		var CustomerAmount  = pieces[2];
		var CustomerCurrency  = pieces[3];
		var thePenalty  = pieces[4];
		//alert(pieces[4]);
		var theRates  = pieces[5].split("@@@");
		
		var e=document.getElementById('pleasewait');
			if(e) e.style.display='none';
		
		if(CustomerAmount > 0)
		{
			for(k = 0; k < nrRates; k++)
			{
				var zaIdRate = "suppRate_"+bookingNo+"_"+(k+1);
				var zaIdCurrency = "currency_"+bookingNo+"_"+(k+1);
				var checkFree = "ffreeNight_"+bookingNo+"_"+(k+1);
				//alert(zaId + "-->"+ theRates[k]);
				if(document.getElementById(zaIdRate))
				{
					theNewData = theRates[k].split("^^");
					theRate = theNewData[0];
					theCurrency = theNewData[1];
					
					if(theRate >= 0 && !document.getElementById(checkFree).checked)
					document.getElementById(zaIdRate).value = theRate;
					else
					document.getElementById(zaIdRate).value = 0.00;
					
					selectCurrencyDay(bookingNo,(k+1),theCurrency);
					//select day currency
				}	
				
			}
		//set the penaltycharges as in yield	
		var nrPenaltiesOld = parseInt(document.getElementById('nr_penalties_'+bookingNo).value);
		var nrPenaltiesOldCopy = nrPenaltiesOld;
		
		//delete existing
		var delC = 1;
		
				for(peo = 1; peo <= nrPenaltiesOldCopy; peo++)
				{
					var theHoursId = 'selectHours_'+bookingNo+'_'+delC;
					if(document.getElementById(theHoursId))
					{
						deleteCancellationRow(bookingNo, delC,1);
					}
															
				}
					
		if(thePenalty != '')	
		{
			var thePenalties  = thePenalty.split("***");
			var pe = 0;
			
			//add new rules
			for(pe = 1; pe < thePenalties.length; pe++)
			{
				document.getElementById('addnewRule_'+bookingNo).click();
			}
			//select the proper values
			for(pe = 0; pe < thePenalties.length; pe++)
			{
				var cpenalty = thePenalties[pe].split("~~~");
				
				doSelectPenalty(bookingNo, pe, cpenalty[0], cpenalty[1]);				
			}
		}
		else
		{ //no yield defined
			document.getElementById('noPenaltyYield_'+bookingNo).style.display='';
		}
		
		
		
		//end penalty
			
		updateTotal(bookingNo);
		if(document.getElementById("MealCustomerAmount_"+bookingNo))
		{
			var customerMealAmount = parseFloat(document.getElementById("MealCustomerAmount_"+bookingNo).value);
					CustomerAmount2 = parseFloat(CustomerAmount) + customerMealAmount;
		}
			
		
		if(document.getElementById("totalNet_"+bookingNo))	
			document.getElementById("totalNet_"+bookingNo).value =  sprintf("%.2f",CustomerAmount);
		
		if(document.getElementById("totalNetMeals_"+bookingNo))	
			document.getElementById("totalNetMeals_"+bookingNo).value =  sprintf("%.2f",CustomerAmount2);		
			
		//selectCurrency(bookingNo,Currency);
		
		//alert("The payable rates are re-calculated based on the contracted rates for this Room type.");
		alert("The payable rates are re-calculated based on the contracted rates for this Room type.\n Please check Cancellation Policy and Charges area for validation.");
	
		document.getElementById("updatedRoomOrRate_"+bookingNo).value = 1;
		document.getElementById("warnUpdatedRoomOrRate_"+bookingNo).value = 1;
		}
		else
		{
		alert("There are no contracted rates for this room type and for this period.");
		if(document.getElementById("penaltyCharges1_1_"+bookingNo))
		{
			document.getElementById("penaltyCharges1_1_"+bookingNo).checked = true;
			document.getElementById("penaltyCharges1_"+bookingNo+"_percentage").style.display = 'none';
			document.getElementById("penaltyCharges_"+bookingNo+"_percentageSelect").value = 0;
		}	
		
		
		if(document.getElementById("nrDetails_"+bookingNo))
			var nrDaysRates = document.getElementById("nrDetails_"+bookingNo).value;
		else
			var nrDaysRates = 1;
			
		
		for(k = 0; k < nrDaysRates; k++)
			{
				var zaId = "suppRate_"+bookingNo+"_"+(k+1);
				//alert(zaId + "-->"+ theRates[k]);
				if(document.getElementById(zaId))
					document.getElementById(zaId).value = '';
				
			}
		updateTotal(bookingNo);	
		}
		var zaId = "suppRate_"+bookingNo+"_1";
		document.getElementById(zaId).focus();
		closeDivPopUp();
			
		
	}
	
}

// profile notes 



// profile notes 
function stateChanged_note() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		//alert("response after insert Note="+xmlHttp.responseText);
		
		var responseText = xmlHttp.responseText;
		var retVars = responseText.split("###");
		//empty the inputs 
		document.getElementById('noteSubject').value ='';
		document.getElementById('theNote').value ='';
		
		var notesTable = document.getElementById('notesTable');
		var spaceRow = notesTable.insertRow(notesTable.rows.length);
		
		spaceRow.setAttribute('align', 'center');
		spaceRow.setAttribute('id', 'note_'+retVars[4]);
		
		var spaceRowCell_0 = spaceRow.insertCell(0);
		var spaceRowCell_1 = spaceRow.insertCell(1);
		var spaceRowCell_2 = spaceRow.insertCell(2);
		var spaceRowCell_3 = spaceRow.insertCell(3);
		var spaceRowCell_4 = spaceRow.insertCell(4);
		
		//spaceRowCell_0.setAttribute('class', 'mytd');
		spaceRowCell_0.className = 'mytd';
		
		spaceRowCell_0.innerHTML = notesTable.rows.length-1;
		spaceRowCell_0.innerHTML = spaceRowCell_0.innerHTML+'.';
		
		//date and time
		//spaceRowCell_1.setAttribute('class', 'mytd');
		spaceRowCell_1.className = 'mytd';
		spaceRowCell_1.innerHTML = retVars[0];
		//user branch
		//spaceRowCell_2.setAttribute('class', 'mytd');
		spaceRowCell_2.className = 'mytd';
		spaceRowCell_2.innerHTML = retVars[1];
		
		//subject
		//spaceRowCell_3.setAttribute('class', 'mytd');
		spaceRowCell_3.className = 'mytd';
		spaceRowCell_3.innerHTML = retVars[2];
		
		//actions
		
		//spaceRowCell_4.setAttribute('class', 'mytd');
		spaceRowCell_4.className = 'mytd';
		spaceRowCell_4.setAttribute('nowrap', 'nowrap');
		spaceRowCell_4.innerHTML = retVars[3];
	
		//document.getElementById('mycontractArea').innerHTML=xmlHttp.responseText;
	} 
} 

function stateChanged_note_d() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		//alert("response after insert Note="+xmlHttp.responseText);
		
		var responseText = xmlHttp.responseText;
		var retVars = responseText.split("###");
		var notesTable = document.getElementById('notesTable');
		//var spaceRow = notesTable.insertRow(notesTable.rows.length);
		myId='note_'+retVars[0]
		var rowId = document.getElementById(myId).rowIndex;
		
		notesTable.tBodies[0].deleteRow(rowId);
		//renumerotam randurile
		nrRows = notesTable.tBodies[0].rows.length;
		if(nrRows >1)
		{
			for(i=1; i< nrRows; i++)
			{
				notesTable.tBodies[0].rows[i].cells[0].innerHTML = i+'.';
			}
		}
		else
		{//add no note
		var newrow = notesTable.insertRow(1);
			newrow.id = 'note_x';
		var mycell = newrow.insertCell(0);
			//mycell.setAttribute('colspan','5');
			mycell.colSpan = 5;
			mycell.innerHTML = '<div class="error">There are no notes.</div>'
			
		}
	} 
} 

function stateChanged_note_e() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
		//alert("response after insert Note="+xmlHttp.responseText);		
		var responseText = xmlHttp.responseText;
		var retVars = responseText.split("###");
		document.getElementById('editNote').value =1;
		document.getElementById('editId').value =retVars[0];
		document.getElementById('noteSubject').value =retVars[1];
		document.getElementById('theNote').value =retVars[2];		
	} 
}

function stateChanged_note_s() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
		//alert("response after insert Note="+xmlHttp.responseText);		
		var responseText = xmlHttp.responseText;
		
		var notesTable = document.getElementById('notesTable');
		var retVars = responseText.split("###");		
		retId='note_'+retVars[0]
		
		var rowId = document.getElementById(retId).rowIndex;
		notesTable.tBodies[0].rows[rowId].cells[3].innerHTML = retVars[1];
		
		document.getElementById('editNote').value =0;
		document.getElementById('editId').value =0;
		document.getElementById('saveStatus').innerHTML ='The information was saved with success.';
		document.getElementById('noteSubject').value ='';
		document.getElementById('theNote').value ='';		
	} 
}

//######################################################3
///supplier Docs
function stateChanged_editDoc()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
		//alert("response after insert Note="+xmlHttp.responseText);		
		var responseText = xmlHttp.responseText;
		var retVars = responseText.split("###");
		document.getElementById('editDocNote').value =1;
		document.getElementById('editDocId').value =retVars[0];
		document.getElementById('docSubject').value =retVars[1];
		document.getElementById('theDocNote').value =retVars[2];		
	} 
}

function stateChanged_delDoc() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		
		//alert("response after insert Note="+xmlHttp.responseText);
		
		var responseText = xmlHttp.responseText;
		var retVars = responseText.split("###");
		var notesTable = document.getElementById('DocTable');
		//var spaceRow = notesTable.insertRow(notesTable.rows.length);
		myId='doc_'+retVars[0]
		var rowId = document.getElementById(myId).rowIndex;
		
		notesTable.tBodies[0].deleteRow(rowId);
		//renumerotam randurile
		nrRows = notesTable.tBodies[0].rows.length;
		if(nrRows >1)
		{
			for(i=1; i< nrRows; i++)
			{
				notesTable.tBodies[0].rows[i].cells[0].innerHTML = i+'.';
			}
		}
		else
		{//add no note
		var newrow = notesTable.insertRow(1);
			newrow.id = 'doc_x';
		var mycell = newrow.insertCell(0);
			//mycell.setAttribute('colspan','5');
			mycell.colSpan = 6;
			mycell.innerHTML = '<div class="error">There is no Documentation uploaded.</div>'
			
		}
		document.getElementById('docSaveStatus').innerHTML ='The information was deleted successfully.';
	} 
} 

function stateChanged_saveDoc() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
		//alert("response after insert Note="+xmlHttp.responseText);		
		var responseText = xmlHttp.responseText;
		
		var notesTable = document.getElementById('DocTable');
		var retVars = responseText.split("###");		
		retId='doc_'+retVars[0]
		
		var rowId = document.getElementById(retId).rowIndex;
		notesTable.tBodies[0].rows[rowId].cells[3].innerHTML = retVars[1];
		
		document.getElementById('editDocNote').value =0;
		document.getElementById('editDocId').value =0;
		document.getElementById('docSaveStatus').innerHTML ='The information was saved with success.';
		document.getElementById('docSubject').value ='';
		document.getElementById('theDocNote').value ='';
		document.getElementById('saveDocButtonDiv').style.display ='none';
		document.getElementById('fileDoc').style.display ='';
	} 
}
//end supplier docs
//#############################################################
function stateChanged_contract() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert("response after generate contract="+xmlHttp.responseText);		
		document.getElementById('mycontractArea').innerHTML=xmlHttp.responseText;
	} 
} 


function stateChanged6() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		populateHomeMarkets(2,'HomeMarketDiv',0);
	} 
} 

function stateChanged99() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		populateSpecialty('SpecialtyTeritoryDiv');
	} 
} 

function stateChanged98() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		emptySelect1('SalesTeritoryDiv2');
	} 
} 

function stateChanged97() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		emptySelect2('HomeMarketDiv2');
	} 
} 

function stateChanged96() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		emptySelect3('SpecialtyTeritoryDiv2');
	} 
} 

function stateChanged7() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert(xmlHttp.responseText);
		
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		populateHomeMarkets(4,'HomeMarketDiv', parent);
	} 
} 



function stateChanged2() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		
		if(document.getElementById('stateCode'))
		{
			//alert(document.getElementById('selCityDiv'));
			//alert('0');
			if(document.getElementById('selCityDiv'))
				fillCities('0', 'selCityDiv', '', '');
		}
		else
		{
			//alert('1');
			//alert(document.getElementById('selCityDiv'));
			if(document.getElementById('selCityDiv'))
				fillCities(document.getElementById('countryCode').value, 'selCityDiv', '', '');
		}
		
	} 
} 

function MiscBranchChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('sourceTypeDiv').innerHTML=xmlHttp.responseText;
		MiscSourceType();
	}
} 

function MiscSourceTypeChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('miscStatusDiv').innerHTML=xmlHttp.responseText;
		MiscStatus();
	}
}

function MiscStatusChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('sourceMarketDiv').innerHTML=xmlHttp.responseText;
		MiscSourceMarket();
	}
} 

function MiscSourceMarketChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('serviceCityDiv').innerHTML=xmlHttp.responseText;
		MiscServiceCity();
	}
} 

function MiscServiceCityChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('customerTypeDiv').innerHTML=xmlHttp.responseText;
		MiscCustomerType();
	}
} 

function MiscCustomerTypeChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('customerCityDiv').innerHTML=xmlHttp.responseText;
		MiscCustomerCity();
	}
} 

function GroupsGetHotelsFromCityChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//document.getElementById('DestHotelCodeId').innerHTML=xmlHttp.responseText;
		eval(xmlHttp.responseText);
	}
} 

function stateChangedNrOrdine() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		
		if(document.getElementById('stateCode_' + nrOrd))
		{
			//alert(document.getElementById('selCityDiv'));
			//alert("|"+nrOrd+"|");
			//alert('0');
			if(document.getElementById('selCityDiv_' + nrOrd))
				fillCitiesNrOrdine('0', 'selCityDiv_' + nrOrd, nrOrd, '', '');
		}
		else
		{
			//alert('1');
			//alert("|"+nrOrd+"|");
			//alert(document.getElementById('selCityDiv_' + nrOrd));
			if(document.getElementById('selCityDiv_' + nrOrd))
				fillCitiesNrOrdine(document.getElementById('countryCode_' + nrOrd).value, 'selCityDiv_' + nrOrd, nrOrd, '', '');
		}
		
	} 
} 

function stateChanged22() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
		
		
		if(document.getElementById('stateCode'))
		{
			//alert(document.getElementById('selCityDiv'));
			//alert('0');
			if(document.getElementById('selCityDiv'))
				fillCities('0', 'selCityDiv', '', '');
		}
		else
		{
			//alert('1');
			//alert(document.getElementById('selCityDiv'));
			if(document.getElementById('selCityDiv'))
				fillCities(document.getElementById('countryCode').value, 'selCityDiv', 'fillLocations(this.value,\'selLocationDiv\')', '');
		}
		
	} 
} 


function stateChanged3() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById(idul).innerHTML=xmlHttp.responseText;
	
	if(document.getElementById('selLocationDiv'))	
		fillLocations(document.getElementById('selCity').value,'selLocationDiv')
	}
} 

function stateChanged4() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
		document.getElementById(idul).value=xmlHttp.responseText;
	} 
} 

function cityChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	
		//alert("cityChanged : |"+idul+"|");
		document.getElementById(idul).innerHTML=xmlHttp.responseText;
	} 
} 

function stateChanged5() 
{ 
	
	document.getElementById('MarketsRow').style.display = "none";
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert('-'+xmlHttp.responseText+'-');
		if(xmlHttp.responseText != '')
		{
			document.getElementById('branchParentRow').style.display="";
			if(xmlHttp.responseText == 'change')
			{
				document.getElementById(idul).style.display = "none";
				document.getElementById('explDiv').style.display= "";
/*
				document.getElementById('explDiv').setAttribute('style','');
				document.getElementById('alertRow').style.display = "";
				document.getElementById('MarketTable').style.display = "display:none";
*/
			}
			else
			{
				//alert('s-a intrat aici');
				var e=document.getElementById(idul);
				var j=0;
				var sel=0;
				document.getElementById('explDiv').style.display = "none";
				document.getElementById(idul).style.display = "";
				var data=xmlHttp.responseText;
				re = new RegExp("<option(.*?) value=\"(.*?)\"(.*?)>(.*?)</option>",'img');
				while(m=re.exec(data)){
					if(m[3]=='selected="selected"') sel=j;
					e[j++]=new Option(m[4],m[2]);
				}
				e.selectedIndex=sel;
				//alert('-'+xmlHttp.responseText+'-');

				//document.getElementById(idul).innerText = '<option value="caca">caca maca</option>';
				
				//document.getElementById(idul).innerHTML = xmlHttp.responseText;
				
				//alert('-'+idul+'-');
				/*
				document.getElementById('explDiv').setAttribute('style','display:none');
				document.getElementById(idul).setAttribute('style','');
				//document.getElementById(idul).innerHTML = xmlHttp.responseText;
				*/
			}
			
		}
		else
		{
			document.getElementById(idul).innerHTML = xmlHttp.responseText;
			document.getElementById('branchParentRow').style.display = "none";
			document.getElementById('MarketsRow').style.display = "";
			populateSelMarkets(1,'SalesTeritoryDiv',0);
			
		}
		
	} 
} 


//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


function formget(obj) {
      var getstr = "";
      if(!obj.childNodes.length) return '';
      for (var i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "text"||obj.childNodes[i].type == "hidden") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         else 
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         else{
         	getstr=getstr+formget(obj.childNodes[i]);
         }
      }
      return getstr;
 }
function getReadyStateHandler(req,responseXmlHandler,paramArray) {
return function () {
    // If the request's status is "complete"
    if (req.readyState == 4) {
      
      // Check that a successful server response was received
      if (req.status == 200) {
	if(paramArray[0]!= undefined && document.getElementById(paramArray[0])){
		var id2=document.getElementById(paramArray[0]);
		if(id2){
			if(id2.parentNode.innerHTML.match('loading5.gif')!=null){
				//var str=id2.parentNode.innerHTML.replace(/<img src='loading5.gif'>/,"");
				//id2.parentNode.innerHTML=str;
			}
		}
	}
        // Pass the XML payload of the response to the 
        // handler function
        responseXmlHandler(req.responseText,paramArray);

      } else {

        // An HTTP problem has occurred
        alert("HTTP error: "+req.status);
      }
      req=null;
    }
    else{
	if(paramArray[0]!= undefined && document.getElementById(paramArray[0])){
		var id2=document.getElementById(paramArray[0]);
		if(id2){
			if(id2.parentNode.innerHTML.match('loading5.gif')==null){
				//id2.parentNode.innerHTML=id2.parentNode.innerHTML+"<img src='loading5.gif'>";
			}
		}
	}
    }
  }
}
function getContent(result,paramArray){
	var id=paramArray[0];
	var hide=paramArray[1];
	var e=document.getElementById(id);
	if(e){
		e.innerHTML=result;
		evaluateJS(id);
	}
	var e1=document.getElementById("RoomTypeSubmit");
	if(e1&&!hide) e1.style.display='';
	var e1=document.getElementById("ApartmentSubmit");
	if(e1&&!hide) e1.style.display='';
	var e=document.getElementById('pleasewait');
	if(e) e.style.display='none';
	trimInputs();
}
function setidx(id,value){
	var e=document.getElementById(id);
	if(e){
		e.selectedIndex=value;
	}
}
function getContent2(result,paramArray){	
	var id=paramArray[0];
	var hotelCode=paramArray[1];
	var e=document.getElementById(id);
	var e2=document.getElementById('success');
	var e3=document.getElementById('errorr');
	var step=document.getElementById('step');
	result=result.replace(/^\s+|\s+$/g,'');
	if(parseInt(step.value)==2){
		var sel=document.getElementById('RoomTypes');
		var selidx=sel.selectedIndex;
	}
	if(e){
		if(result=='ok'){
			e.innerHTML=e2.innerHTML;
		}
		else{
			e.innerHTML=result;
			evaluateJS(id);
			var e1=document.getElementById("RoomTypeSubmit");
			if(e1) e1.style.display='';
		}
		if(parseInt(step.value)==2){
			var act='';
			//update roomtype
			act='setidx(\'RoomTypes\','+selidx+')';
			//returnOptions(hotelCode,'getroomtypes','RoomTypes','',act,'');	
		}
		
	}
}
function getContent3(result,paramArray){
	var id=paramArray[0];
	var apCode=paramArray[1];
	var e=document.getElementById(id);
	var e2=document.getElementById('success');
	var e3=document.getElementById('errorr');
	var step=document.getElementById('step');
	result=result.replace(/^\s+|\s+$/g,'');
	if(parseInt(step.value)==2){
		var sel=document.getElementById('Apartment');
		var selidx=sel.selectedIndex;
	}
	if(e){
		if(result=='ok'){
			e.innerHTML=e2.innerHTML;
		}
		else{
			e.innerHTML=result;
			evaluateJS(id);
			var e1=document.getElementById("ApartmentSubmit");
			if(e1) e1.style.display='';
		}
		if(parseInt(step.value)==2){
			var act='';
			//update roomtype
			act='setidx(\'Apartment\','+selidx+')';
			returnOptions(apCode,'getapartment','Apartment','',act,'');	
		}
		
	}
}
function myPostResult(result,paramArray){
	var id=paramArray[0];
	var e=document.getElementById(id);
	if(e){
		e.innerHTML=result;
	}
}

function myPopulateOption(result,paramArray){
	var id=paramArray[0];
	var id2=paramArray[1];
	var ehandler=paramArray[2];
	var nhandler=paramArray[3];
	var hideChoose=paramArray[4] == undefined?0:1;
	if(paramArray[5])
		var doSelect = paramArray[5];
		else
		var doSelect = 0;
	
	var elem=document.getElementById(id);
	if(elem){
		removeAllOptions(elem);
		var options=Array();
		var prop=Array();
		options=result.split(";");
		var len=options.length;
		var selected;
		if(len>1){
			if(!hideChoose) addOption(elem,"-- Choose One --",0,'');
			for(var i=0;i<len;i++){
				if(options[i].length>0){
					prop=options[i].split(",");
					if(prop.length>2&&prop[2]=='selected') selected='selected';
					else selected='';

					if(doSelect > 0 && prop[0] == doSelect) selected='selected';
					else selected='';
						
					addOption(elem,prop[1],prop[0],selected);
				}
			}
			if(id2.length>0&&document.getElementById(id2).style.display=='none'){
				document.getElementById(id2).style.display='';
			}
			if(ehandler&&ehandler.length>0){
				eval(""+ehandler+";");
			}
		}
		else{
			if(id2.length>0) document.getElementById(id2).style.display='none';
			if(nhandler&&nhandler.length>0){
				eval(""+nhandler+";");
			}
			addOption(elem,"No records found",0,'');
		}
	}
}
function myPopulateMarket(result,paramArray){
	var id=paramArray[0];
	var ehandler=paramArray[1];
	var nhandler=paramArray[2];
	var elem=document.getElementById(id);
	if(elem){
		removeAllOptions(elem);
		var options=Array();
		var prop=Array();
		options=result.split(";");
		var len=options.length;
		var selected;
		if(len>1){
			for(var i=0;i<len;i++){
				if(options[i].length>0){
					prop=options[i].split(",");
					if(prop.length>2&&prop[2]=='selected') selected='selected';
					else selected='';
					var color='';
					if(prop[0]=='delim0'||prop[0]=='delim1'||prop[0]=='delim2'){
						color='#FF0000';
						addOption(elem,prop[1],prop[0],selected,color);
					}
					else addOption(elem,prop[1],prop[0],selected);
				}
			}
			if(ehandler&&ehandler.length>0){
				eval(""+ehandler+";");
			}
		}
		else{
			if(nhandler&&nhandler.length>0){
				eval(""+nhandler+";");
			}
		}
	}
}

function removeAllOptions(from){
	if(!hasOptions(from)){return;}
	for(var i=(from.options.length-1);i>=0;i--){
		from.options[i] = null;
	}
	from.selectedIndex = -1;
}
function removeAllOptionsId(fromid,msg){
	var from=document.getElementById(fromid);
	if(!hasOptions(from)){return;}
	for(var i=(from.options.length-1);i>=0;i--){
		from.options[i] = null;
	}
	from.selectedIndex = -1;
	addOption(from,msg,0,'');
}
function hasOptions(obj){if(obj!=null && obj.options!=null){return true;}return false;}
function addOption(obj,text,value,selected,color){
	if(obj!=null && obj.options!=null){
		obj.options[obj.options.length] = new Option(text, value, false, selected);
		if(color!='undef'){
			obj.options[obj.options.length-1].style.color=color;
		}
	}
}

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

function GetXmlHttpObject(handler)
{ 

var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("Do not use Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler
return objXmlHttp
}
}
//new http request
function newXMLHttpRequest() {
  var xmlreq = null;
  if (window.XMLHttpRequest) {
    xmlreq = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e1) {
      try {
        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
      	
      }
    }
  }
  return xmlreq;
}


