
var good;
function checkEmailAddress(field) {
// the following expression must be all on one line...
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}else{
alert('Please enter a valid e-mail address.');
field.focus();
field.select();
good = false;
   }
}

function emptyfield(ffield){
alert("\nPlease enter: " + ffield + " ...\t\t\t\n");
		}
// code for checking form input
 function checkform(){
var empty = "";
	if( document.contact.Name.value==""){
 			empty = "Name";
			}
if( document.contact.Email.value==""){
			empty = empty + " -Email";
			}
 if (empty != ""){
emptyfield(empty);
return false;
 }else{
checkEmailAddress(document.contact.Email)
return good;
}
}

buttonanimation = document.images

if(buttonanimation){
 buttonOn = new Image()   
 buttonOn.src = "./images/onarrow.gif"

 buttonOff = new Image()   
 buttonOff.src = "./images/offarrow.gif"

 shortbuttonOn = new Image()   
 shortbuttonOn.src = "./images/shortonarrow.gif" 

 shortbuttonOff = new Image()   
 shortbuttonOff.src = "./images/shortoffarrow.gif"

}

function outBut(whichbut){
if(whichbut == "floorplanon" || whichbut == "virtualon"){
return
}
if(buttonanimation){

if(whichbut == "rentalapp"){
document.images[whichbut].src = shortbuttonOff.src 
}else{

document.images[whichbut].src = buttonOff.src 

}
}
}

function overBut(whichbut){
if(whichbut == "floorplanon" || whichbut == "virtualon"){
return
}
if(buttonanimation){

if(whichbut == "rentalapp"){
document.images[whichbut].src = shortbuttonOn.src 
}else{
document.images[whichbut].src = buttonOn.src 
}


}
}

function docjslib_getImageWidth(imgID) {

 return eval(imgID).width;


}

function docjslib_getImageHeight(imgID) {
  return eval(imgID).height;
}

function docjslib_getImageXfromLeft(imgID) {
  if (ns4) return eval(imgID).x
  else return docjslib_getRealLeft(imgID);

}

function docjslib_getImageYfromTop(imgID) {
  if (ns4) return eval(imgID).y
  else return docjslib_getRealTop(imgID);
}

function docjslib_getRealLeft(imgElem) {
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

function docjslib_getRealTop(imgElem) {
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function docjslib_setElementTop(id, elementTop) {
  if (NS4) eval(id).top = elementTop
  else eval(id).style.top = elementTop;
}

function docjslib_setElementLeft(id, elementLeft) {
  if (NS4) eval(id).left = elementLeft
  else eval(id).style.left = elementLeft;
}

function docjslib_setElementWidth(id, elementWidth) {
  if (NS4) eval(id).width = elementWidth
  else eval(id).style.width = elementWidth;
}

function docjslib_setElementHeight(id, elementHeight) {
  if (NS4) eval(id).height = elementHeight
  else eval(id).style.height = elementHeight;
}



var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

linkset[0]='<table cellpadding="0" cellspacing="0" class="tableskin">'
linkset[0]+='<tr><td><div class="menuitems"><a href="http://www.rusticvillageapartments.com/1bedroomfloorplan.html">1 Bedroom</a></div></td></tr>'
linkset[0]+='<tr><td><div class="menuitems"><a href="http://www.rusticvillageapartments.com/2bedroomfloorplan.html">2 Bedroom</a></div></td></tr>'
linkset[0]+='<tr><td><div class="menuitems"><a href="http://www.rusticvillageapartments.com/floorplandetails.html">Interior Detail</a></div></td></tr>'
linkset[0] +='</table>'
linkset[1]='<table cellpadding="0" cellspacing="0" class="tableskin">'
linkset[1]+='<tr><td><div class="menuitems"><a href="http://viewer.inviewtours.com/AAA8B639-911C-4DFC-A5BA-92F99DABD31D" target="_blank">360° Interior Detail</a></div></td></tr>'
linkset[1]+='<tr><td><div class="menuitems"><a href="http://www.rusticvillageapartments.com/virtualtour.html">Property Tour</a></div></td></tr>'
linkset[1]+='<tr><td><div class="menuitems"><a href="http://www.rusticvillageapartments.com/virtualtour2.html">Property Tour 2</a></div></td></tr>'
linkset[1] +='</table>'
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers

function showmenu(im1, e,which){

if (!document.all&&!document.getElementById&&!document.layers)
return

var butoffset = 137;

overBut(im1);

clearhidemenu()

menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj

if (ie4||ns6)
menuobj.innerHTML=which
else{
menuobj.document.write('<layer name=gui bgColor=#FFFFCC width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>')
menuobj.document.close()
}

menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width
menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height

menuobj.thestyle.visibility="visible"

menuobj.thestyle.left = docjslib_getImageXfromLeft(document.images[im1]) + butoffset + "px";

menuobj.thestyle.top = docjslib_getImageYfromTop(document.images[im1]) + "px";

return false

}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){

if (window.menuobj)
menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"


}

function dynamichide(e){
if (ie4&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(but){

if (ie4||ns6||ns4)
delayhide=setTimeout("hidemenu()",100)

outBut(but)

}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

function highlightmenu(e,state){
if (document.all)
source_el=event.srcElement
else if (document.getElementById)
source_el=e.target
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}
else{
while(source_el.id!="popmenu"){
source_el=document.getElementById? source_el.parentNode : source_el.parentElement
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}
}
}
}

if (ie4||ns6)
document.onclick=hidemenu