	function PageHashReference(LinkID)
		{
		var el = document.getElementById(LinkID);
		var v = el.offsetTop + el.offsetHeight;
		window.scroll(0,parseFloat(v-50));
		//document.body.scrollTop = parseFloat(el.offsetTop-30);
		}

    function ShowHideDiv(el,objects,override,ParentID)
        {
        //Objects is a string array of element ID's
        for(i=0;i<objects.length;i++)
            {
            var e = document.getElementById(objects[i]);
            if (e!=null)
				{
				//This section for Checkboxes
				if (el.checked)
					{ e.style.display = 'block'; }
					else
					{ e.style.display = 'none'; }
	                
				//This section for RadioButtons
				if (override != null)
					{
					if (override == 1)
						{ e.style.display = 'block'; }
						else
						{ e.style.display = 'none'; }
					}
                }
            }
        }

	function GetFunctionParameter(txt)
		{
		var regExpSTR = "";
		var ie = document.all?true:false;
		if (!ie) { regExpSTR = '"[a-zA-Z0-9 "]+'; }
		else { regExpSTR = "'[a-zA-Z0-9 ']+"; }
		
		var re = new RegExp(regExpSTR);
		var m = re.exec(txt);
		var str = "";
		if (m == null)
			{ str = ""; }
		else
			{
				for (j=0;j<m.length;j++)
					str += m[j];
			}
		str = str.replace(/"/g,'');
		str = str.replace(/'/g,"");
		return str;
		}

    function setInputStyle()
        {
        var objInputs = document.getElementsByTagName("input");
	    for(var i=0;i<objInputs.length;i++)
	        if (objInputs[i].type == 'text')
				{
					try {
						var functionText = String(objInputs[i].onblur);
						functionText = functionText.replace(/[\r\n]+/g, "");
						if (functionText != 'undefined' && functionText != null)
							{
							var fp = GetFunctionParameter(functionText);
							if (fp != "") { inputAction(null,objInputs[i],fp,0); }
							}
						}
					catch(err)
						{ alert(err); }
		        }
		        
		var objInputs = document.getElementsByTagName("textarea");
	    for(var i=0;i<objInputs.length;i++)
	        if (objInputs[i].type == 'textarea')
				{
					try {
						var functionText = String(objInputs[i].onblur);
						functionText = functionText.replace(/[\r\n]+/g, "");
						if (functionText != 'undefined' && functionText != null)
							{
							var fp = GetFunctionParameter(functionText);
							if (fp != "") { inputAction(null,objInputs[i],fp,0); }
							}
						}
					catch(err)
						{ alert(err); }
		        }
		
        }
        
    function inputAction(e,el,text,direction)
        {
        var textValue = el.value;
            textValue = textValue.replace(/^\s*|\s*$/,"");
        if (el)
            {
            switch(direction)
                {
                case 1:
                    if (textValue == text)
                        { el.value = '';
                            el.className = SetInputNormal(el.className);
                             }
                        else
                        { el.select(); }
                    break;
                    
                case 0:
                    if (textValue == text)
                        { el.className = SetInputFaded(el.className);
							 }
                        else
                        { if (textValue == '')
                            { el.value = text;
                                el.className = SetInputFaded(el.className);
								}
                        }
                    break;
                    
                default:
                }
            }
        }

    function SetInputNormal(cn)
		{
		cn = cn.replace(/input/,'');
		cn = cn.replace(/fadedInput/,'');
		cn = 'input' + cn;
		return cn;
		}
		
	function SetInputFaded(cn)
		{
		cn = cn.replace(/input/,'');
		cn = cn.replace(/fadedInput/,'');
		cn = 'input fadedInput' + cn;
		return cn;
		}
		
	function QuestionSwitch(namingContainer,el)
		{
		var autoClick = true;
		if (el == null) { el = FindSelectedRadioButton(namingContainer); autoClick = false; }
		switch(el.value)
			{
				case "radTypeFlat":
				case "radTypeMaisonette":
					document.getElementById('propertyQuestions_row2').style.display = 'block';
					document.getElementById('propertyQuestions_row3').style.display = 'none';
					document.getElementById('propertyQuestions_row4').style.display = 'none';
					document.getElementById(namingContainer + '_rowPropertyFloors').style.display = 'none'
					if (autoClick) {document.getElementById(namingContainer + '_radBuildingTypePurposeBuilt').click();}
					break;
				
				case "radTypeHouse":
				case "radTypeBungalow":
					document.getElementById('propertyQuestions_row2').style.display = 'none';
					document.getElementById('propertyQuestions_row3').style.display = 'block';
					document.getElementById('propertyQuestions_row4').style.display = 'none';
					document.getElementById(namingContainer + '_rowPropertyFloors').style.display = 'none'
					if (autoClick) {document.getElementById(namingContainer + '_radBuildingTypeSemi').click();}
					break;
				
				case "radTypeCommercial":
					document.getElementById('propertyQuestions_row2').style.display = 'none';
					document.getElementById('propertyQuestions_row3').style.display = 'none';
					document.getElementById('propertyQuestions_row4').style.display = 'block';
					document.getElementById(namingContainer + '_rowPropertyFloors').style.display = 'block'
					if (autoClick) {document.getElementById(namingContainer + '_radBuildingClassPublicHouse').click();}
					break;
					
				default:
			}
		}
	function FindSelectedRadioButton(namingContainer)
		{	
		var id = new Array('_radTypeFlat','_radTypeHouse','_radTypeMaisonette','_radTypeBungalow','_radTypeCommercial');
		for (i = 0; i<id.length;i++)
			{
			var el = document.getElementById(namingContainer + id[i]);
			if (el.checked)
				{ return el; }
			}
		}         
		
	function FindAddressGoogle(Prefix,txtElement,TypeID)
		{
		var strSearch = '';
		var mrt = '';
		
		switch(TypeID)
			{
				case 4:
				case 5:
				case 6:
					mrt = 'yp'; break;
				default:
					mrt = '';
			}
		
		if (txtElement != null)
			{ strSearch = Prefix + txtElement.value; }
			else
			{ strSearch = Prefix; }
			
		var url = 'http://www.google.co.uk/maps?f=q&source=s_q&mrt=' + mrt + '&q=' + strSearch + '';
		window.open(url,'FindAddressGoogle','width=850,height=600,toolbar=no,location=no,status=no,menubar=no');
		}