﻿
/*
Cross browser Marquee script- (c) Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

//Specify the marquee's width (in pixels)
var marqueewidth="220px"
//Specify the marquee's height
var marqueeheight="15px"
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=2
//configure background color:
var marqueebgcolor="#ffed51"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1

//Specify the marquee's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent='<nobr>View the Extreme Home Makeover Trailer! View the Extreme Home Makeover Trailer! View the Extreme Home Makeover Trailer! View the Extreme Home Makeover Trailer! View the Extreme Home Makeover Trailer! View the Extreme Home Makeover Trailer! View the Extreme Home Makeover Trailer!</nobr>'


////NO NEED TO EDIT BELOW THIS LINE////////////
marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed) //slow speed down by 1 for NS
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px;">'+marqueecontent+'</span>')
var actualwidth=''
var cross_marquee, ns_marquee

function populate(){
if (iedom){
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
//cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
cross_marquee.style.left=20 + "px"
cross_marquee.innerHTML=marqueecontent
actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
}
else if (document.layers){
ns_marquee=document.ns_marquee.document.ns_marquee2
ns_marquee.left=20
ns_marquee.document.write(marqueecontent)
ns_marquee.document.close()
actualwidth=ns_marquee.document.width
}
lefttime=setInterval("scrollmarquee()",20)
}
window.onload=populate

function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+20))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
else
cross_marquee.style.left=20+"px"

}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+20))
ns_marquee.left-=copyspeed
else
ns_marquee.left=parseInt(marqueewidth)+20
}
}

// browser detection
var w3c=(document.getElementById)?true:false;
var ns4=(document.layers)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;

// DHTML functions
var DHTML = (document.getElementById || document.all || document.layers);

function lightup(imgName)
 {
   if (document.images)
    {
      imgOn=eval(imgName + "_on.src");
      document[imgName].src= imgOn;
    }
 }

function turnoff(imgName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + "_off.src");
      document[imgName].src= imgOff;
    }
 }

function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	} else
	if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else
	if (document.layers) {
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}

// return document object by id;
function getobject(obj){
if (document.getElementById)
	return document.getElementById(obj)
else if (document.all)
	return document.all[obj]
}

// set obj class style
function setStyle(obj, className) {		
	if(getobject(obj).className != className) {
	getobject(obj).className = className;
	}
}

/// popup window function
function popup(URL,w,h) {

day = new Date();
id = day.getTime();

var width = w;
var height = h;

var left = ((screen.width-width)/2);
var top = ((screen.height-height)/2);

eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + '');");
}

/// popup window function with name
function wpopup(URL,n,w,h) {

day = new Date();

var name = n;
var width = w;
var height = h;

var left = ((screen.width-width)/2);
var top = ((screen.height-height)/2);

var features = 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;

//eval("page" + name + " = window.open(URL, '" + name + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + '');");
    
var popWin = window.open(URL, name, features);
popWin.focus();

}

/// popup window function with name and no scrollbars
function wpopup2(URL,n,w,h) {

var day = new Date();

var name = n;
var width = w;
var height = h;

var left = 50;
var top = 20;


var features = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;

//eval("page" + name + " = window.open(URL, '" + name + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + '');");
    
window.open(URL, name, features);
//popWin.focus();


}

function popWindow(url, name, features) 
{
    var host = location.hostname;
	window.top.name = "opener";
	var popupWin = window.open( url, name, features );
	
	if ( popupWin && popupWin.opener ) {
		if ( openerUrl )
		{
			popupWin.opener.location = openerUrl;
			popupWin.focus();
		}
	}
}


function enable_other()
{
	if (document.getElementById('clubs_other_check').checked)
	{
		document.getElementById('clubs_other').disabled = false;
		document.getElementById('clubs_other').focus();
	}
	else
	{
		document.getElementById('clubs_other').disabled = true;
		document.getElementById('clubs_other').value = "";
	}
}


/////
///onKeyPress="return numbersonly(this, event)";
/////

function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;
	if (window.event){
		key = window.event.keyCode;
	}else if (e){
		key = e.which;
	}else{
		return true;
	}
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ){
		return true;
	}else if ((("+1234567890").indexOf(keychar) > -1)){
		return true;
	}else if (dec && (keychar == ".")){
		myfield.form.elements[dec].focus();
		return false;
	}else{
		return false;
	}
}

///// onKeyUp="numTyped(this.value,p3,'3')"
/// jump phone number fields
function numTyped(current, next,maxlen) {
  var len = current.length;
  if (len==maxlen) {
    next.focus();
  }
}

//// form validation

/// form validation starts here

var new_fieldname = ""

//this is the onclick that calls this function
//
// onClick="return check(form,form.elements.length)"
//


function checkEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{
		return (true)
	}
	else
	{
		return (false)
	}
}

/*

function check(form,x)

{

	var message = ""
	var more_message = new Array //(4)
	var showmsg = "no"
	var doItNow = "yes"

	var required = new Array (12)

	if (doItNow == "yes") 	{

			var i = 0;

						
						if (count_checkboxes('clubs[]') >= 0 && count_checkboxes('clubs[]') < 3)
							{more_message [i++] = "\nPlease Select at least 3 choices from the activities section"}
						else if (count_checkboxes('clubs[]') > 3)
							{more_message [i++] = "\nPlease Only Select 3 choices from the activities section"}
						
						if (document.getElementById('clubs_other_check').checked && form.clubs_other.value == "")
						{
							more_message [i++] = "\nPlease enter what your other club is";	
						}
						/// end construct messgaes
						if (more_message != "") {

								if (message == "") {message = more_message}

									else

									{message = message + "\n" + more_message}

				        }

						if (message > "")

								{showmsg = "yes"}																

						if (showmsg == "yes")

			{
				alert("The following form field(s) were incomplete or incorrect:\n\n" + message + "\n\n Please complete or correct the form and submit again.")
				return false;
			}
			else
			{ 
				form.submit()
				return true;
			}

		}

}
*/

/// functions for form validation script

function count_checkboxes(element_name)
{ 
	box_checked = 0;
	with (document.form) { 
		for (var i=0; i < elements.length; i++) { 
			if (elements[i].name == element_name)
				if (  elements[i].checked )
				{ 
						box_checked += 1;
				}
		}
	}
	return box_checked;
}
 
function chkAll(frm, arr, mark) {
  for (i = 0; i <= frm.elements.length; i++) {
   try{
     if(frm.elements[i].name == arr) {
       frm.elements[i].checked = mark;
     }
   } catch(er) {}
  }
}

function switchImage(frontorback,imgID,imgSRC){
	if (document.getElementById){
		document.getElementById(imgID).src = imgSRC;
		estateidfront = imgID + "front";
		estateidrear = imgID + "rear";
		if(frontorback=="front"){
			document.getElementById(estateidfront).style.fontWeight="bold";
			document.getElementById(estateidrear).style.fontWeight="normal";
			}else{
			document.getElementById(estateidrear).style.fontWeight="bold";
			document.getElementById(estateidfront).style.fontWeight="normal";
			}
		}
		
		if(imgID=="summerhill"){
				if(imgSRC=="../media/images/estateproperties/SummerhillFrontRendering.jpg"){
				document.getElementById('summerhillrendering').innerHTML = "<a href=\"javascript:wpopup('renderingspop.php?neighborhood=gables2','renderingspop',650,560)\"><img src=\"" + imgSRC + "\" id=\"summerhill\" /></a>";
				}else{
				document.getElementById('summerhillrendering').innerHTML = "<a href=\"javascript:wpopup('renderingspop.php?neighborhood=gables1','renderingspop',650,560)\"><img src=\"" + imgSRC + "\" id=\"summerhill\" /></a>";
				}
		}
}