
// -----------------------------------------------
// CHANGE THE HEADING
// -----------------------------------------------

function changeHeading(new_heading) {
  var heading = new Image();
  heading.src = "headings/" + new_heading + ".gif";
  top.topFrame.document.heading.src = heading.src;
} // end of function changeHeading(new_heading) 
// -----------------------------------------------
// CHECKS CONTACT FORM
// -----------------------------------------------
function check_form(form) {
   var msg = "";
   if (form.contact_name.value == "") msg = msg + "Name\n";
   if (form.email.value == "" && form.contact_no.value == "") msg = msg + "Your contact number or e-mail address\n";

   if (msg != "") {
      alert("Please enter all required information.\n\nYou have not entered the following:\n" + msg);
      return false;
   }
   return true;
} // end of function check_mv(form)

// -----------------------------------------------------
var zindex=100
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie4=document.all
var opr=navigator.userAgent.indexOf("Opera")

if (ie4 || ns6) 
  document.onclick=hidemenu

function dropit(e,whichone){
    curmenuID=ns6? document.getElementById(whichone).id : eval(whichone).id
    if (window.themenu&&themenu.id!=curmenuID)
    themenuStyle.visibility=ns4?"hide" : "hidden"

    themenu=ns6? document.getElementById(whichone): eval(whichone)
    themenuStyle=(ns6||ie4)? themenu.style : themenu

    themenuoffsetX=(ie4&&opr==-1)? document.body.scrollLeft : 0
    themenuoffsetY=(ie4&&opr==-1)? document.body.scrollTop : 0

    themenuStyle.left=ns6||ns4? e.pageX-e.layerX-130 : themenuoffsetX+event.clientX-event.offsetX-130
    themenuStyle.top=ns6||ns4? e.pageY-e.layerY : themenuoffsetY+event.clientY-event.offsetY

    hiddenconst=(ns6||ie4)? "hidden" : "hide"
    if (themenuStyle.visibility==hiddenconst){
    themenuStyle.visibility=(ns6||ie4)? "visible" : "show"
    themenuStyle.zIndex=zindex++
    }
    else
    hidemenu()
    return false
} // end of dropit

function hidemenu(){
    if ((ie4||ns6)&&window.themenu)
    themenuStyle.visibility="hidden"
    else if (ns4)
    themenu.visibility="hide"
}
// -----------------------------------------------------

function displayMap(house) {
    var curImg = top.mainFrame.display_main.document.map.src;


    var hImg= new Image();
    if (curImg.indexOf("blank.gif") != -1) {
    	hImg.src = "houses/" + house + "/map_bg.jpg";
    	top.mainFrame.display_main.document.map.src = hImg.src;
    } else {
    	hImg.src = "images/blank.gif";
    	top.mainFrame.display_main.document.map.src = hImg.src;
    }


} // end of displayMap

function hideMap(house) {
    var hImg= new Image();
    hImg.src = "images/blank.gif";
    top.mainFrame.display_main.document.map.src = hImg.src;
} // end of displayMap


function showMap(ev,whichone,imgName) {
    curmenuID=ns6? document.getElementById(whichone).id : eval(whichone).id;
    if (window.themenu&&themenu.id!=curmenuID)
    themenuStyle.visibility=ns4?"hide" : "hidden"
    themenu=ns6? document.getElementById(whichone): eval(whichone)
    themenuStyle=(ns6||ie4)? themenu.style : themenu

    // themenuoffsetX=(ie4&&opr==-1)? document.body.scrollLeft : 0
    // themenuoffsetY=(ie4&&opr==-1)? document.body.scrollTop : 0

    // themenuStyle.left=ns6||ns4? e.pageX-e.layerX : themenuoffsetX+event.clientX-event.offsetX
    // themenuStyle.top=ns6||ns4? e.pageY-e.layerY+19 : themenuoffsetY+event.clientY-event.offsetY+18

    hiddenconst=(ns6||ie4)? "hidden" : "hide"
    if (themenuStyle.visibility==hiddenconst) {
	themenuStyle.visibility=(ns6||ie4)? "visible" : "show"
	themenuStyle.zIndex=zindex++
	var map_name = "houses/"+imgName+"/map_bg.jpg";
	document["big_map"].src = map_name;;
    } else
	hidemenu()
    return false

	alert(document[imgName].src);
} // end of fucntion showmap


// -----------------------------------------------
// Check to see if the browser is DHTML-compatible
// -----------------------------------------------
function checkDHTML() {
  if ((parseInt(navigator.appVersion)>=4) &&
     ((navigator.appName!="Netscape" &&
       navigator.appVersion.indexOf("X11") == -1) ||
      (navigator.appName!="Microsoft Internet Explorer" &&
       navigator.appVersion.indexOf("Macintosh") == -1)))
    { return 1 }
  else
    { document.location="nodhtml.htm"; return 0 }
}


// -----------------------------------------------
//  FUNCTION TO CHECK NAVIGATOR NAME AND VERSION
// -----------------------------------------------

function check_nav()  {  
	var navVer = parseInt(navigator.appVersion);
	var navName = navigator.appName;
	
	if (navName == "Microsoft Internet Explorer")  {
		if (navVer >= 4)
			setTimeout("window.location = 'national.html'",5000);
		else  {
			alert("Please use 4.x or a higher version of Microsoft Internet Explorer\nClick logo to enter National Homes");
			setTimeout("window.location = 'national.html'",5000);
			}  // end of if statement
	} else if (navName == "Netscape")  {
		if (navVer >= 4)
			setTimeout("window.location = 'national.html'",5000);
		else  {
			alert("Please use 4.x or a higher version of Netscape Communicator\nClick logo to enter National Homes");
			setTimeout("window.location = 'national.html'",5000);
			} // end of else statement
	} else	{
		alert("It is recommended that you use Netscape Communicator or MS Internet Explorer to view pages");
		setTimeout("window.location = 'national.html'",5000);
		} // end of big if statement
					
	}// end of function check_nav	

// -----------------------------------------------
// RANDOM NUMBER GENERATOR
// -----------------------------------------------

function rand(max) {
//  dummy = new Date();
//  rand_num = dummy.getTime();
//  rand_num = ((rand_num % 4648653) * 399498) + 1;
	
	var randnum = Math.random();
	var randomselect = Math.round((max-1)*randnum)+1;
	return randomselect;

} // end of function rand


// -----------------------------------------------
// FUNCTION FOR INITIALIZING ARRAYS
// -----------------------------------------------

function initArray() {
	this.length = initArray.arguments.length;
	for (var i=0; i < this.length; i++)
		this[i] = initArray.arguments[i];
} // end of function initArray
	


// -----------------------------------------------
// FUNCTIONS FOR SLIDES - HOME.HTML
// -----------------------------------------------

function check()  {
	// alert("CHECK");
	animate = !animate;
	if(animate)
		slides(0);
	}  //end of function check


function slides(counter) {
	var houselist = new initArray("house13","australis","capel","centro","chenin","constellationII","crestwood","grange","grove","lakewood","lodge","rushton","stirling","verona");
	if (animate && document.images)  {
		document.picture.src = "houses/"+houselist[counter]+"/house_sm2.jpg";
		if (counter < 13)
			counter++;
		else if (counter == 13)
			counter = 0;
		setTimeout("slides("+counter+");",2000);
	} // end of if statement
}  // end of function slides
		
// -----------------------------------------------

function click_slide(imgName) {


//	var imgSrc = document[imgName].src;
	var imgSrc = parent.topFrame.document[imgName].src;

	var houseno = imgSrc.indexOf("house");

	var hsStr = imgSrc.substring(houseno,imgSrc.length);
	var hsno = hsStr.indexOf("/");
	
	hsStr = hsStr.substring(hsno+1,hsStr.length);
	hsno = hsStr.indexOf("/");
	hsStr = hsStr.substring(0,hsno);
	

	var house = "houses/" + hsStr + "/house.html";
	parent.mainFrame.location.href = house;
//	parent.mainFrame.document.write(house+"    "+location.src);

} // end of click_slide()



// -----------------------------------------------
// CHANGES IMAGES ACCORDING TO MOUSE MOVEMENT
// -----------------------------------------------
function ImgOn(imgName) {
	if (document.images)  {
    	 var onImg= new Image();
    	 onImg.src = "menus/" + imgName + "_on.gif";
	 document[imgName].src = onImg.src;
	} 
} // end of ImgOn


function ImgOff(imgName) {
	if (document.images)  {
    	 var offImg= new Image();
    	 offImg.src = "menus/" + imgName + ".gif";
	 document[imgName].src = offImg.src;
	} 
} // end of ImgOff


// -----------------------------------------------
// FUNCTION TYPES MESSAGE IN STATUS BAR
// -----------------------------------------------

function StatusMesg(message) {
	lng = 60;
	txt_str = message;
	txt_lth = 1;
	dm_base=0;
	displayMsg();
} // end of function StatusMsg
	
function displayMsg() {
	
	if (txt_str.charAt(txt_lth) == "~")  {		
		dm_base = txt_lth + 1;
		window.status = " ";
	} else {
		var temp = lng;
		while (temp >= 0)  {
		   blank1 = "";
		   for (i=0;i<temp;i++)
			blank1 = blank1 + " ";
  		   window.status = txt_str.substring(0,txt_lth-1) + blank1 + txt_str.substring(txt_lth-1,txt_lth);	
		   temp = temp - 1;
		} // end of while statement
	}  // end of if .. else
	
	if (++txt_lth <= txt_str.length) {
		var cmd = "displayMsg()";
		setTimeout(cmd,rand(500)+1);
	} 
} // end of function displayMsg

// -----------------------------------------------
//    COOKIE FUNCTIONS
// -----------------------------------------------

function setCookie(name,value)  {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name+"="+escape(value) +
		((expires == null) ? " " : (";expires="+expires.toGMTString())) +
		((path == null) ? " " : (";path="+path)) + 
		((domain == null) ? " " : (";domain="+domain)) +
		((secure == true) ? ";secure" : " ");
	}  // end of function setCookie

function getCookie(name) {
	var arg = name+"=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)  {
		var j=i+alen;
		if (document.cookie.substring(i,j) == arg)
			return getCookieVal(j);
		i = document.cookie.indexOf(" ",i)+1;
		if (i == 0)
			break;
		}  // end of while statement
	return null;
	}  // end of function getCookie


// -----------------------------------------------
// FUNTION TO HANDLE SOUND FILES
// -----------------------------------------------

function play(song)  {
//	play_win = window.open(song,"","toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,copyhistory=no,width=200,height=30");
	var NSsound = navigator.plugins && navigator.plugins["LiveAudio"];
	var IEsound = navigator.plugins && document.all;
	var audioEnabled = NSsound || IEsound;

	var navName = navigator.appName;
	if (navName == "Microsoft Internet Explorer")
		document.write("<EMBED SRC=song WIDTH=144 HEIGHT=55>");
	else if (navName == "Netscape")
		document.write("<EMBED SRC=song WIDTH=144 HEIGHT=55>");
} // end of function song


// ---------------------------------------------------
// RANDOMLY CHANGE IMAGE ACCOURDING TO MOUSE MOVEMENT
// ---------------------------------------------------

function changeImg(imgName) {
        if (document.images) {
          var rno = rand(24)+1;
          var newImg = new Image();
          newImg.src = "random/pic"+rno+".jpg";
          document[imgName].src = eval('newImg.src');
        } // end of ImgOn
} // end of changeImg

