	/*<![CDATA[*/
/*
	function IEHoverPseudo() {

		var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
		
		for (var i=0; i<navItems.length; i++) {
			if(navItems[i].className == "menuparent") {
				navItems[i].onmouseover=function() { this.className += " over"; }
				navItems[i].onmouseout=function() { this.className = "menuparent"; }
			}
		}

	}
	window.onload = IEHoverPseudo;
	window.onLoad=preloadNavImages();
*/
	/*]]>*/

function changestyle(objRow,className) {
	document.getElementById(objRow).className=className;
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document.getElementById(changeImages.arguments[i]).src = changeImages.arguments[i+1];
		}
	}
}

function flowOver(name) {
	changestyle("flow_"+name,"flow_"+name+"_fish");
}

function flowOff(name) {
	changestyle("flow_"+name,"flow_"+name);
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function preloadNavImages() {
	if (document.images) {
		nav_01_plan = newImage("/elements/images/flow/flow_01_plan_fish.jpg");
		nav_02_approve = newImage("/elements/images/flow/flow_02_approve_fish.jpg");
		nav_03_design = newImage("/elements/images/flow/flow_03_design_fish.jpg");
		nav_04_approve = newImage("/elements/images/flow/flow_04_approve_fish.jpg");
		nav_05_build = newImage("/elements/images/flow/flow_05_build_fish.jpg");
		nav_06_approve = newImage("/elements/images/flow/flow_06_approve_fish.jpg");
		nav_07_host = newImage("/elements/images/flow/flow_07_host_fish.jpg");
	}
}

var hasDom=true;

function disguise() {
    var ary=disguise.arguments;
    for(a=0;a<ary.length;a++) {
        var name=ary[a];
        if (hasDom) {
            var lyrStyle=document.getElementById("lyr_"+name).style;
            lyrStyle.display="none";
        }
    }
}

function reveal() {
	var ary=reveal.arguments;
    for(a=0;a<ary.length;a++) {
		var name=ary[a];
        if (hasDom) {
			var lyrStyle=document.getElementById("lyr_"+name).style;
			lyrStyle.display="block";
        }

    }
}

function printPage() {
	if(window.print) {
		window.print();
	} else {
		if(agt.indexOf("mac") != -1) {
			alert("To print this page press Command-P.");
		} else {
			alert("To print this page press Control-P.");
		}
	}
}

var preloadFlag = true;

	var set_name
	
	function show(name) {
		if ( set_name ) {
			disguise(set_name)
		}
		reveal(name)
		set_name=name
	}

	function hide(name) {
		disguise(name)
		set_name=null
	}

function updateBasket(id) {
	var qty = 0
	qty = document.getElementById('first_item_quantity_'+id).value
	
	updateBasketCore(id, qty);
}

function updateBasketCore(id, qty){
	
	
	//var searchstring=document.getElementById('search').value;
	var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = '/shopping_basket_contents.php?id='+id+'&qty='+qty; //This is the path to the file we just finished making *
	    xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
	    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById('shopping_basket').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function removeItem(item) 
{
	//get the current quantity
	qty = document.getElementById(item).value;
	//decrease the quantity by 1 if not already 0
	qty -= 1;	
	//change the select box and hidden input
	document.getElementById(item).value = qty;
	document.getElementById('changeQuantities').value = 'changeQuantities';
	//submit the form using update basket
	document.go_shopping.submit();
}


function changeShopCategory(categoryID)
{
	//alert(categoryID);
	//put the cat id into the form
	document.shop_items.selected_category.value = categoryID;
	
	//alert("Element:"+document.getElementById('selected_category').value);
	
	//submit the form
	document.getElementById('shop_items').submit();
}

function doSubmit(command)
{
	document.getElementById('action').name = command;
	document.getElementById('action').value = command;
	//alert(document.getElementById('action').name);
	document.getElementById('shop_items').submit();
}



function setVisible(obj)
{
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
    if (screen.width > '1024') {
    obj.style.left = "46%";
    } else  {
    obj.style.left = "43%";
    }
}

function checkRadioButton(afield)
{
	buttonvalue = "";
	len = afield.length;

	for (i = 0; i <len; i++) {
		if (afield[i].checked) {
			buttonvalue = afield[i].value
		}
	}
	
	if (buttonvalue == "") {
		document.getElementById('ctl'+afield[0].name).style.visibility = 'visible';
	}
	else {
		document.getElementById('ctl'+afield[0].name).style.visibility = 'hidden';
	}
}

function checkInput(afield)
{	output = "";
	if (afield.value.length == 0) {
		// Check if this is how website found text box.
		if (afield.name == 'howWebsiteFoundSpecify') {
			if (document.getElementById('website_found_id').value == 2) {
				document.getElementById('ctl'+afield.name).style.visibility = 'hidden';
			}
			else {
				document.getElementById('ctl'+afield.name).style.visibility = 'visible';
				output = '<li>Please specify how you found this website</li>';
			}
		}
		else {
			document.getElementById('ctl'+afield.name).style.visibility = 'visible';
			// If interestRate field then have to set display to none to maintain correct spacing
			if (afield.name == 'interestRate') {
				document.getElementById('ctl'+afield.name).style.display = 'block';
			}
			
			switch (afield.name) {
				case 'firstName': output = "<li>'First Name' is a required field</li>"; break;
				case 'lastName' : output = "<li>'Last Name' is a required field</li>"; break;
				case 'yourName': output = "<li>'Your Name' is a required field</li>"; break;
				case 'emailAd' : output = "<li>'Email Address' is a required field</li>"; break;
				case 'phoneNo' : output = "<li>'Telephone' is a required field</li>"; break;
				case 'phoneNum' : output = "<li>'Phone Number' is a required field</li>"; break;
				case 'comments' : output = "<li>'Message' is a required field</li>"; break;
				case 'myAge' : output = "<p>You must select your age.</p>"; break;
				case 'propertyValue' : output = "required"; break;
			}
		}
	}
	else {
		if (afield.name == 'emailAd') {
			// Need to check that address is valid
			re = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{2,})+$/;
			// Regular expression used in original ASF website.
			//re = /^([a-zA-Z0-9_\\-\\.\']+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$/;
			if (re.test(afield.value)) {
				document.getElementById('ctl'+afield.name).style.visibility = 'hidden';
			}
			else {
				document.getElementById('ctl'+afield.name).style.visibility = 'visible';
			}
		}
		else {
			document.getElementById('ctl'+afield.name).style.visibility = 'hidden';
			// If interestRate field then have to set display to none to maintain correct spacing
			if (afield.name == 'interestRate') {
				document.getElementById('ctl'+afield.name).style.display = 'none';
			}
			if (afield.name == 'propertyValue') {
				minValue = 150000;
				maxValue = 9999999999999;
				if ((afield.value < minValue) || isNaN(afield.value)) {
					output = 'range';
					document.getElementById('ctl'+afield.name+'1').style.visibility = 'visible';
				}
				else if (afield.value > maxValue) {
					output = 'range_high';
					document.getElementById('ctl'+afield.name+'2').style.visibility = 'visible';
				}
				else {
					document.getElementById('ctl'+afield.name+'1').style.visibility = 'hidden';
				}
			}
		}
	}
	return output;
}

function validateInputs(fname,lname,emailAd,phoneNo,msg)
{
	var output = "";
	output = checkInput(fname);
	output += checkInput(lname);
	output += checkInput(emailAd);
	output += checkInput(phoneNo);
	output += checkInput(msg);

	if (output.length > 0) {
		output = '<ul>' + output;
		output += '</ul>';
	}
	return output;

}

function validateFeedbackInputs(name,emailAd,phoneNo,websiteFound) 
{
	var output = "";
	output = checkInput(name);
	output += checkInput(emailAd);
	output += checkInput(phoneNo);
	output += checkInput(websiteFound);
	if (output.length > 0) {
		output = '<ul>' + output;
		output += '</ul>';
	}
	return output;
}


