var message="";
/////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false");

//-----------------------------------------------------------
var popUpWin=0;
function popUpWindow(strFile)
{
var left,top;
left=(screen.width/2)-300;
top=(screen.height/2)-225;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open("floor_plan.php?pic="+strFile, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=600,height=550,left='+left+',top='+top);
}

var popUpWin=0;
function FloorimgpopWindow(strFile)
{
var left,top;
left=(screen.width/2)-325;
top=(screen.height/2)-225;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open("floor_plan.php?pic="+strFile, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=650,height=550,left='+left+',top='+top);
}

var newWin=0;
function Location()
{
	//alert("ok");
var ht = screen.height; 
var wdth = screen.width; 
var newWidth = 775; 
var newHeight = 550; 
var lft = (wdth / 2) - (newWidth / 2); 
var tp = (ht / 2) - (newHeight / 2);
  if(newWin)
  {
    if(!newWin.closed) newWin.close();
  }
  newWin = open("pop.htm","newWin", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=" + lft + ",top=" + tp + ",width=" + newWidth + ",height=" + newHeight);
}

var UnitePlanWindow=0;
function popUpUnitePlan(width, height, strType){
var strFile="";
var strPopType=strPopType=document.form1.unit_ID.value;
strPopType=strPopType.charAt(4);
var strImgType="";

	if(strType=="plan"){
		strImgType="plan";
		strFile="FloorPlanes/"+document.form1.unit_ID.value+".jpg";
	}else if(strType=="location"){
		strImgType="location";
		strFile=document.form1.unit_ID.value;
		strFile="LocationPlan/" + strFile.charAt(0)+strFile.charAt(4);
		var type=document.form1.unit_plan.value;
		if(type=="ii"){
			strFile=strFile+"-ii.jpg";	
		}else{
			strFile=strFile+"-i.jpg";	
		}
	}
//alert(strFile);
if((strPopType=="1") || (strPopType=="3") || (strPopType=="5")){
	height+=40;	
}
var left,top;
left=(screen.width/2)-(width/2);
top=(screen.height/2)-(height/2);
  if(UnitePlanWindow)
  {
    if(!UnitePlanWindow.closed) UnitePlanWindow.close();
  }
  UnitePlanWindow = open("floor_plan.php?imgType="+strImgType+"&type="+strPopType+"&pic="+strFile, 'UnitePlanWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top);
  //location_plan.php
}

var popUpOption=0;
function popUpOptionWindow()
{

var strFile="";
var UniteType=document.form1.unit_ID.value;
var FloorNo=0;
UniteType = UniteType.charAt(1)+UniteType.charAt(2);
FloorNo=Number(UniteType);
//alert("Floor No is : "+FloorNo);
var Tower=document.form1.unit_ID.value;
Tower=Tower.charAt(0);
if(Tower=="A"){
	if(FloorNo==42){
		strFile="A10";
	}else if((FloorNo>=6) && (FloorNo<=20)){
		strFile=document.form1.unit_ID.value;
		strFile=strFile.charAt(4);
		if((strFile=="3")||strFile=="4"){
			strFile="A3";
		}else{
			strFile="A1";
		}
	}else if((FloorNo>=21) && (FloorNo<=24)){
		strFile="A6";
	}else if(FloorNo==25){
		strFile="A7";
	}else if((FloorNo>=26) && (FloorNo<=41)){
		strFile="A6";
	}
}else if(Tower=="B"){
	if(FloorNo==38){
		UniteType=document.form1.unit_ID.value;
		UniteType=UniteType.charAt(4);
		//alert(UniteType);
		if(UniteType=="1")
			strFile="B13";
		else
			strFile="B15";
	}else if((FloorNo>=6) && (FloorNo<=20)){
		//alert("Floor 6-7");
		strFile=document.form1.unit_ID.value;
		strFile=strFile.charAt(4);
		//alert(strFile);
		if((strFile=="1")||strFile=="2"){
			strFile="B1";
		}else if((strFile=="3")||strFile=="4"){
			strFile="B3";
		}else if((strFile=="5")||strFile=="6"){
			strFile="B5";	
		}
		
	}else if((FloorNo>=21) && (FloorNo<=22)){
		strFile=document.form1.unit_ID.value;
		strFile=strFile.charAt(4);
		//alert(strFile);
		if(strFile=="1"){
			strFile="B7";
		}else{
			strFile="B8";	
		}
	}else if(FloorNo==23){
		strFile=document.form1.unit_ID.value;
		strFile=strFile.charAt(4);
		if(strFile=="1"){
			strFile="B10";
		}else{
			strFile="B11";	
		}
	}else if((FloorNo>=24) && (FloorNo<=37)){
		strFile=document.form1.unit_ID.value;
		strFile=strFile.charAt(4);
		//alert(strFile);
		if(strFile=="1"){
			strFile="B7";
		}else{
			strFile="B8";	
		}
	}
}
//alert(strFile);

var left,top;
left=(screen.width/2)-300;
top=(screen.height/2)-325;
  if(popUpOption)
  {
    if(!popUpOption.closed) popUpOption.close();
  }
  popUpOption = open("options.php?unit="+strFile, 'popUpOption', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=600,height=650,left='+left+',top='+top);
}

var popUpPrice=0;
function popUpPriceWindow(strAppType){

var strFile=strAppType;
//alert(strFile);
var left,top;
left=(screen.width/2)-350;
top=(screen.height/2)-250;
  if(popUpPrice)
  {
    if(!popUpPrice.closed) popUpPrice.close();
  }
  popUpPrice = open("price_list.php?unit="+strFile, 'popUpPrice', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=700,height=550,left='+left+',top='+top);
}
//---------------- ******** Form validation functions ********* ----------------

// ---- Email validation
var testresults
function checkemail(){
	var str=document.form1.txtEmail.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
		testresults=false;
	else{
		alert("Please input a valid email address!");
		testresults=true;
	}
	return (testresults);
}
// --- End Email validation


function checkForm(){
	//alert("ela");
	var err=false;
	
	if(document.form1.txtName.value == ""){err=true;}
	else if(document.form1.txtCountry.value == ""){err=true;}
	else if(document.form1.txtEmail.value == ""){err=true;}
	else if(document.form1.txtTel.value == ""){err=true;}
	else if(document.form1.txtMessage.value == ""){err=true;}
   // document.form1.txtReserve.value=rType;

	if(!err){
		if(checkemail()){
			return false;
		}
		else{
			return true;
		}
	}
	else{
		alert("* marked fields are required.");	
		return false;
		
	} 
}


function FADwin(O,popwin) {
	var ht = screen.height; 
	var wdth = screen.width; 
	var newWidth = 500; 
	var newHeight = 550; 
	var lft = (wdth / 2) - (newWidth / 2); 
	var tp = (ht / 2) - (newHeight / 2);
	
	
window.open("FAD.php?cap="+O+"","popwin","toolbar=no,location=self,directories=no,status=no, menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no left=" + lft + ",top=" + tp + ",width=" + newWidth + ",height=" + newHeight);
}
