function ValidateProjectEnquiryForm (form) { // Used in Give us your feedback page (pageid=5&ctype=bm)
  var fname = form.fullname.value;   
  //var country = form.country.value;   
	var phone = form.phone.value;
  var email = form.email.value;   
  var cal = form.cal.value;   

  if (!fname)	{
    alert("You must enter your full name.");
    return false;
	//} else if (!country) {
	//	alert("You must select your country.");
	//	return false;
	} else if ((!phone)&&(!email)) {
		alert("You must enter your phone number or your email address.");
		return false;
	} else if ((email)&&((email.indexOf('@') == -1) || (email.indexOf('.') == -1))) {
		alert("Wrong email format.");
		return false;
	} else if (cal != 5) {
		alert("Please calculate 2+3 correctly");
		return false;
	} else {
		return true;
	}
}
function ValidatePropertyEnquiryForm (form) { // Used in Give us your feedback page (pageid=5&ctype=bm)
  var fname = form.fullname.value;   
  var country = form.country.value;   
	var phone = form.phone.value;
  var email = form.email.value;   

  if (!fname)	{
    alert("You must enter your full name.");
    return false;
	} else if (!country) {
		alert("You must select your country.");
		return false;
	} else if ((!phone)&&(!email)) {
		alert("You must enter your phone number or your email address.");
		return false;
	} else if ((email)&&((email.indexOf('@') == -1) || (email.indexOf('.') == -1))) {
		alert("Wrong email format.");
		return false;
	} else {
		return true;
	}
}
function ValidateContactForm (form) { 
  var fname = form.fullname.value;   
  var email_phone = form.email_phone.value;   
  var cal = form.cal.value;   

  if (!fname)	{
    alert("You must enter your full name.");
    return false;
	} else if (!email_phone) {
		alert("You must enter your phone number or your email address.");
		return false;
	} else if (cal != 5) {
		alert("Please calculate 2+3 correctly ");
		return false;
	} else {
		return true;
	}
}

function ValidateCommentForm (form) {
  var firstname = form.firstname.value;
  var lastname = form.lastname.value;
  var company = form.company.value;  
  var email = form.email.value;   
  var ref_text = form.ref_text.value;   
  var cal = form.cal.value;   

  if (!firstname)	{
    alert("You must enter your first name.");
    return false;
	} else if (!lastname) {
		alert("You must enter your last name.");
		return false;
  } else if (!company) {
		alert("You must enter your company name.");
		return false;
	} else if (!email) {
		alert("You must enter your email address.");
		return false;
	} else if ((email)&&((email.indexOf('@') == -1) || (email.indexOf('.') == -1))) {
		alert("Wrong email format.");
		return false;
	} else if (!ref_text) {
		alert("You must enter your reference.");
		return false;
	} else if (cal != 5) {
		alert("Please calculate 2+3 correctly");
		return false;
	} else {
		return true;
	}
}

function ValidateMailingListRequestForm (form) { 
  var email = form.email.value;   

	if (!email) {
		alert("You must enter your email.");
		return false;
	} else if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1)) {
		alert("Wrong email format.");
		return false;
	} else {
		return true;
	}
}

function currencyConverter(sefUrlStatus) {
	fileLocation = '';
	if (sefUrlStatus!='Y') {
		fileLocation = '';
	} else {
		fileLocation = '/';
	}

	w_width = 810;
	w_height = 243;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',scrollbars=yes,resizable=yes';

	fparam = fileLocation+'tools/ucc/index.php';
  window.showCurrencyConverterWindow = open(fparam, 'showCurrencyConverterWindow', theWindowParam);
	setTimeout('if(showCurrencyConverterWindow&&!showCurrencyConverterWindow.closed)showCurrencyConverterWindow.focus()',100);
}

function showMap() {
	w_width = 640;
	w_height = 400;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=no';

	fparam = 'showmap.html';
  window.showMapWindow = open(fparam, 'showMapWindow', theWindowParam);
	setTimeout('if(showMapWindow&&!showMapWindow.closed)showMapWindow.focus()',100);
}
function showContact() {
	w_width = 640;
	w_height = 400;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=no';

	fparam = 'showcontact.html';
  window.showContactWindow = open(fparam, 'showContactWindow', theWindowParam);
	setTimeout('if(showContactWindow&&!showContactWindow.closed)showContactWindow.focus()',100);
}
function printPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 800;
	w_height = 600;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=yes,scrollbars=yes';

	fparam = 'print.php'+lochref;
  window.showPrintWindow = open(fparam, 'showPrintWindow', theWindowParam);
	setTimeout('if(showPrintWindow&&!showPrintWindow.closed)showPrintWindow.focus()',100);
}
function emailPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 460;
	w_height = 360;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=yes,scrollbars=no';

	fparam = 'tools/emailpage/index.php'+lochref;
  window.showEmailWindow = open(fparam, 'showEmailWindow', theWindowParam);
	setTimeout('if(showEmailWindow&&!showEmailWindow.closed)showEmailWindow.focus()',100);
}
function popupWindow (theWindow, theParam) {

//	newLeft = screen.width
//	newTop = screen.height
	switch (theWindow)
	{
		case 'newmenu':
			window.open('menuform.php?'+theParam, 'NewMenu', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,width=500,height=500,left=50,top=50');
		break
		case 'editmenu':
			window.open('menuform.php?'+theParam, 'EditMenu', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,width=500,height=500,left=50,top=50');
		break
		default:
			return;
	}
}
function changeLangAlert(theLang) {
	alert('The '+theLang+' language is not published yet. Please check back soon.');
}
function changeLang(theLang, theQueryString) {
  lochref = '';
	// Check if already lang parameter is sent
	if (theQueryString.match('lang=') != null) {
		langPos = theQueryString.indexOf('lang=');
		theQueryString = theQueryString.substring(0,(langPos-1))+theQueryString.substring((langPos-1)+8);
	}
	// Check all parameters that 'index.php' files handles
	if (theQueryString != '') {
		lochref = 'index.php?'+theQueryString+'&lang='+theLang;
	} else {
		lochref = 'index.php?lang='+theLang;
	}
	location = lochref;
}
function goToSearch(theform) {
  var theSearchQuery = theform.searchquery.value;
	
  lochref = 'index.php?pageaction=search&searchquery=' + theSearchQuery;
	
	location = lochref;
}
function goToSitemap() {

  lochref = 'index.php?pageaction=sitemap';

	location = lochref;
}
function SwapButtonImage(theImageName, theCase) {
	document.getElementById(theImageName).src = "layout/images/" + theImageName + "_" + theCase + "_btn.gif";
}


//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function MM_MouseOverAndOut(theMMId, theCase) {

	if (theCase == '1') {
		document.getElementById("mm_l1_"+theMMId).style.backgroundColor = '#8D8C91';
	} else if (theCase == '2') {
		document.getElementById("mm_l1_"+theMMId).style.backgroundColor = '#F18F18';
	}
}

/* functions for template ws_mm_projects_25 */

function projects_25_showGalleryWindow(theId, theLang, theType) {
	if ((theType == 'Photo')||(theType == 'Map')) {
		w_width = 700;
		w_height = 650;
	} else if (theType == 'Video') {
		w_width = 700;
		w_height = 650;
	}
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=yes,scrollbars=yes';

	fparam = 'templates/ws_mm_projects_25/showgallery.php?pageid=' + theId+'&lang=' + theLang +'&type='+ theType;
  window.showPhoto2Window = open(fparam, 'showPhoto2Window', theWindowParam);
	setTimeout('if(showPhoto2Window&&!showPhoto2Window.closed)showPhoto2Window.focus()',100);
}
function projects_25_showPhoto(theId, theLang) {
	w_width = 820;
	w_height = 620;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=yes,scrollbars=yes';

	fparam = 'templates/ws_mm_projects_25/showphoto.php?pageid=' + theId + '&lang=' + theLang;
  window.showPhotoWindow = open(fparam, 'showPhotoWindow', theWindowParam);
	setTimeout('if(showPhotoWindow&&!showPhotoWindow.closed)showPhotoWindow.focus()',100);
}
function projects_25_ShowPhotoSrc(theId, theFile, theDescId, theDesc, theGalType) {

	if (document.getElementById) {
		var c = document.getElementById(theId);
		if (c.style.display != "block") {
			c.innerHTML = '<img src="' + theFile + '">';
		} else {
			c.innerHTML = '<img src="../../layout/images/transparent.gif">';
			c.style.display="none";
		}
	}
	document.getElementById(theId).alt = theDesc;
	document.getElementById(theDescId).value = theDesc;
}
/* functions for template ws_mm_estates_45 */

function estates_45_showPhoto(theOwnId, thePhotoId, theLang) {
	w_width = 820;
	w_height = 620;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=yes,scrollbars=yes';

	fparam = 'templates/ws_mm_estates_45/showphoto.php?pageid=' + theOwnId + '&lang='+theLang+'&photo_id='+thePhotoId;
  window.showPhotoWindow = open(fparam, 'showPhotoWindow', theWindowParam);
	setTimeout('if(showPhotoWindow&&!showPhotoWindow.closed)showPhotoWindow.focus()',100);
}

function estates_45_showEnquiry(theId, theLang) {
	w_width = 550;
	w_height = 630;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=yes,scrollbars=yes';

	fparam = 'templates/ws_mm_estates_45/showenquiry.php?pageid=' + theId + '&lang='+theLang;
  window.showPhotoWindow = open(fparam, 'showPhotoWindow', theWindowParam);
	setTimeout('if(showPhotoWindow&&!showPhotoWindow.closed)showPhotoWindow.focus()',100);
}

function DisplayMortgageCalculator() {

 var BlockCurrentStatus = document.getElementById("MortgageCalculator").style.display;
 if (BlockCurrentStatus == 'block') {
 	document.getElementById("MortgageCalculator").style.display = 'none';
 } else if (BlockCurrentStatus == 'none') {
 	document.getElementById("MortgageCalculator").style.display = 'block';
 }
}
// functions for Mortgage Calculator
function checkForZero(field) {
	if (field.value == 0 || field.value.length == 0) {
		alert ("This field can't be 0!");
		field.focus(); }
	else
		calculatePayment(field.form);
}

function cmdCalc_Click(form) {
	if (form.price.value == 0 || form.price.value.length == 0) {
			alert ("The Price field can't be 0!");
			form.price.focus(); }
	else if (form.ir.value == 0 || form.ir.value.length == 0) {
			alert ("The Interest Rate field can't be 0!");
			form.ir.focus(); }
	else if (form.term.value == 0 || form.term.value.length == 0) {
			alert ("The Term field can't be 0!");
			form.term.focus(); }
	else
			calculatePayment(form);
}

function calculatePayment(form) {
	princ = form.price.value - form.dp.value;
	intRate = (form.ir.value/100) / 12;
	months = form.term.value * 12;
	form.pmt.value = Math.floor((princ*intRate)/(1-Math.pow(1+intRate,(-1*months)))*100)/100;
	form.principle.value = princ;
	form.payments.value = months;
}

