// JavaScript Document
currentDir = currentDirectory();

URLparams = location.href.split("?");
if (URLparams.length > 1) {
	var newLoc = newLoc+"?"+URLparams[1];
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
	alert("MM_showHideLayers - i: "+i+"  v: "+v);
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 goPage(tp, subTp) {
	//The flash menu calls this with 3-letter topic and subtopic codes
	//These codes origianlly matched the file names, but to improve search engine response
	//files were re-named with actual words, and code added here to cross reference to them
	if(subTp == "") {subTp = "index";}
	//alert("goPage0 - currentDir: "+currentDir+",  tp: "+tp+",  subTp: \""+subTp+"\"");
	//cross reference 3 letter codes to full directory and page names
	var topicCodes = ["condos","amenities","dev","own","tra","contact","index"];
	var topics = ["condos","amenities","development_team","owning_in_mexico","travel_maps","contact","index"];
	var subtopics = [["site_plan","floor_plans","custom_features","resources","aerial_photo","flo_andalucia","flo_barcelona","flo_castilla","flo_dali","flo_estero"],
	["beach","pool_area","restaurants","recreation","conveniences","overview"],
	["team","developer_vilcor","legal_aguilera_lindsey","architect_moran_architects","construction_the_beck_group","interiors_est_est","title_stewart_title","eng_izquierdo_DIIN_nolte_engineering"],
	["faq_mexican_property","articles"],
	["area_map","history_features","information_local","activites_local","driving_directions"],
	["contact_us"],
	["index"]];
	
	//Search through topicCodes array to find index number for this topic 
	for (var topIdx = 0; topIdx<topicCodes.length; topIdx++) {
		if (tp == topicCodes[topIdx]) {break;}
	}
	var top = topics[topIdx]; //full topic name
	
	var subTopArrayBuff = subtopics[topIdx]; //subtopic array for this topic
	subTp = subTp.substring(1,subTp.length); //trim leading underscore from subtopic code
	
	//Search through subtopic array for match with first 3 letters
	for (var subTopIdx = 0; subTopIdx<subTopArrayBuff.length; subTopIdx++) {
		var subTopBuff = subTopArrayBuff[subTopIdx];
		//alert("subTp: "+subTp+" subTopBuff: "+subTopBuff);
		if (subTopBuff.indexOf(subTp)==0) {break;}
	}
	subTop = subTopBuff;
	//alert("top: "+top+",  subTop: "+subTop);

	if (topics.join().indexOf(currentDir)<0) {
		var locationBuff = top+"/"+subTop+".php";
	//alert("goPage1 - locationBuff: "+locationBuff);
	} else if (top == "index") {
		var locationBuff = "../"+subTop+".php";
	//alert("goPage2 - locationBuff: "+locationBuff);
	} else if (top == currentDir) {
		var locationBuff = subTop+".php";
	//alert("goPage3 - locationBuff: "+locationBuff);
	} else if (topics.join().indexOf(currentDir)>=0 && top != currentDir) {
		var locationBuff = "../"+top+"/"+subTop+".php";
	//alert("goPage4 - locationBuff: "+locationBuff);
	}
	//alert("goPage5 - currentDir: "+currentDir+",  top: "+top+",  subTop: "+subTop+",  locationBuff: "+locationBuff);
	if (URLparams.length > 1) {
		var locationBuff = locationBuff+"?"+URLparams[1];
	}
	window.location = locationBuff;
}

function drawFlashNav(top, subTop) {
	//Inserts the Flash object block with parameters 
	//called wherever you want the menu to draw. 
	//top tells which topic label to go to in the flash
	//subTop tells which sub-topic label to go to in the flash
	if (top =="index" || top == "") {
		var swif = "global/gui/topnav.swf";
	} else {
		var swif = "../global/gui/topnav.swf";
	}
	//var swif = "global/gui/topnav.swf"
	var bkClr = "#D0E0D3"
	var objBuff = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"750\" height=\"219\">\n";
  objBuff = objBuff + "<param name=\"movie\" value=\""+swif+"?topic="+top+"&subTopic="+subTop+"\">\n";
  objBuff = objBuff + "<param name=\"quality\" value=\"high\">\n";
	objBuff = objBuff + "<param name=\"BGCOLOR\" value=\""+bkClr+"\">\n";
	objBuff = objBuff + "<param name=\"wmode\" value=\"transparent\">\n";
  objBuff = objBuff + "<embed src=\""+swif+"?topic="+top+"&subTopic="+subTop+"\" width=\"750\" height=\"219\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" bgcolor=\""+bkClr+"\" wmode=\"transparent\"></embed>\n";
  objBuff = objBuff + "</object>";
	//alert(objBuff);
	
	document.write(objBuff);
}

function drawFlashContent(top, subTop, w, h) {
	//Inserts the Flash object block with parameters 
	//called wherever you want the menu to draw. 
	//top tells which topic label to go to in the flash
	//subTop tells which sub-topic label to go to in the flash
	//alert("w: "+w+"   h: "+h);
	if (w == "" || w == undefined) {
		w=750;
		h=440;
	}
	if (top =="index" || top == "") {
		var swif = "assets/"+top+subTop+".swf";
	} else {
		var swif = "../assets/"+top+subTop+".swf";
	}
	//var swif = "assets/"+top+subTop+".swf"
	var bkClr = "#D0E0D3"
	var objBuff = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+w+"\" height=\""+h+"\">\n";
  objBuff = objBuff + "<param name=\"movie\" value=\""+swif+"?topic="+top+"&subTopic="+subTop+"\">\n";
  objBuff = objBuff + "<param name=\"quality\" value=\"high\">\n";
	objBuff = objBuff + "<param name=\"BGCOLOR\" value=\""+bkClr+"\">\n";
	objBuff = objBuff + "<param name=\"wmode\" value=\"transparent\">\n";
  objBuff = objBuff + "<embed src=\""+swif+"?topic="+top+"&subTopic="+subTop+"\" width=\""+w+"\" height=\""+h+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" bgcolor=\""+bkClr+"\" wmode=\"transparent\"></embed>\n";
  objBuff = objBuff + "</object>";
	//alert("drawFlashcontent -  objbuff: "+objBuff);
	
	document.write(objBuff);
}

function currentDirectory() {
	//alert("currentDirectory() - window.location: "+window.location);
	var dirsBuff = String(window.location);
	//var dirsBuff = "arf/woof/bark/yip";
	var dirsBuffArray = dirsBuff.split("/");
	//alert("currentDirectory() - window.location: "+window.location+"  **current directory: "+dirsBuffArray[dirsBuffArray.length - 2]);
	return dirsBuffArray[dirsBuffArray.length - 2];
}

function layerObscure() {
	//keeps spider content layer from showing without letting spider know
	var buff1 = "visibility";
	var buff2 = "hidden";
	document.write(buff1+":"+buff2);
}

function showContactForm(lvl,butnLoc) {
	var URLparams = location.href.split("?");
	if (lvl==undefined) {
		var newLoc = "../infoForm.php";
	} else if (lvl == 0) {
		var newLoc = "infoForm.php";
	} else if (lvl == 1) {
		var newLoc = "../infoForm.php";
	} else if (lvl == 2) {
		var newLoc = "../../infoForm.php";
	}
	if (URLparams.length > 1) {
		var newLoc = newLoc+"?"+URLparams[1];
		if (butnLoc !=undefined) {
			var newLoc = newLoc+"&butnLoc="+butnLoc;
		}
	} else {
		if (butnLoc !=undefined) {
			var newLoc = newLoc+"?butnLoc="+butnLoc;
		}
	}
	displayWindow(newLoc,"logWin",550,500,"toolbar=no,location=no,directories=no,status=no,scrollbars=no,scrolling=no,resizable=yes,copyhistory=no");
}
function displayWindow(theURL,winName,width,height,features) { //v3.1
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + features + '');
}