function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function openpopup(url, width, height) {
	var param = "scrollbars=1,height=" + height + ",width=" + width;
	newwindow=window.open(url,'name',param);
	if (window.focus) {newwindow.focus()}
	return false;
}

function openhelppopup(id, lang) {
	var url = "../showhint.php?id=" + id + "&lang=" + lang;
	return openpopup(url, 400, 200);
}

function calenderDateClicked(formId, day, month, year) {
	dayWithLeads = day;
	monthWithLeads = month;
	if(day<10)		dayWithLeads = "0"+day;
	if(month<10)	monthWithLeads = "0"+month;

	compareString = year +"-"+ monthWithLeads +"-"+ dayWithLeads;
	reservedString = document.getElementById("month"+formId).value;
	reserved = reservedString.split(",");

	selectedDayIsReserved = false;
	for (i=0; i<reserved.length; i++) {
		if (reserved[i]==compareString) {
			selectedDayIsReserved = true;
			break;
		}
	}

	newString = "";
	if (selectedDayIsReserved) {
		document.getElementById("day"+formId+"_"+day).setAttribute("class", "cal-free");
		document.getElementById("day"+formId+"_"+day).className = "cal-free";	// for IE
		for (i=0; i<reserved.length; i++) {
			if (reserved[i]!=compareString) {
				newString += "," + reserved[i];
			}
		}
	} else {
		document.getElementById("day"+formId+"_"+day).setAttribute("class", "cal-reserved");
		document.getElementById("day"+formId+"_"+day).className = "cal-reserved";	// for IE
		newString = document.getElementById("month"+formId).value;
		newString += "," + compareString;
	}
	
	if (newString.substr(0,1)==",")
		newString = newString.substr(1);
	
	document.getElementById("month"+formId).value = newString;
}


function toggleAdvancedSearch() {
	obj = document.getElementById("advancedsearch");
	if (document.getElementById("advancedSearchOn").value==1)
		hideAdvancedSearch();
	else
		revealAdvancedSearch();
}

function revealAdvancedSearch() {
	obj = document.getElementById("advancedsearch");
	obj.setAttribute("class", "revealed-field");
	obj.className = "revealed-field";	// for IE
	document.getElementById("advancedSearchOn").value=1;
}
function hideAdvancedSearch() {
	obj = document.getElementById("advancedsearch");
	obj.setAttribute("class", "hidden-field");
	obj.className = "hidden-field";	// for IE
	document.getElementById("advancedSearchOn").value=0;
}

function showSearchRegion() {
	obj = document.getElementById("searchRegionDiv");
	obj.setAttribute("class", "revealed-field");
	obj.className = "revealed-field";	// for IE
}
function hideSearchRegion() {
	obj = document.getElementById("searchRegionDiv");
	obj.setAttribute("class", "hidden-field");
	obj.className = "hidden-field";	// for IE
}


// Add new apartment, page 2 - other info fields
function showAddApartmentLanguageField(lang) {
	var langs = new Array("spa", "fre", "ita", "swe", "fin", "ger", "eng");

	for (i=0; i<langs.length; i++) {
		inputObj = document.getElementById("add_otherinfo"+lang);
		inputCurObj = document.getElementById("add_otherinfo"+langs[i]);
		txtCurObj = document.getElementById("link-"+langs[i]);
		if (inputObj==inputCurObj) {
			inputCurObj.setAttribute("class", "revealed-field");
			inputCurObj.className = "revealed-field";	// for IE
			txtCurObj.setAttribute("class", "selected-inputbox-text");
			txtCurObj.className = "selected-inputbox-text";	// for IE
		} else {
			inputCurObj.setAttribute("class", "hidden-field");
			inputCurObj.className = "hidden-field";	// for IE
			txtCurObj.setAttribute("class", "nonselected-inputbox-text");
			txtCurObj.className = "nonselected-inputbox-text";	// for IE
		}
	}

}


function changePropertyLocationFromFlash(args) {
	document.getElementById("add_loc_euro").value=args;
}
function changePropertyCountryLocationFromFlash(args) {
	document.getElementById("add_loc_country").value=args;
}























