﻿var popVis = false
var popMO = false
var tm = 1000
function mOverBrandpod()
{
    popMO = true 
    showBoxElements(true)   
}

function showBoxElements(bool)
{
    var ar= document.getElementById('blkArrow')
    //var tb = document.getElementById('titlebar')
    if(bool)
    {
       //tb.style.visibility  = ar.style.visibility = 'visible' 
       ar.style.visibility = 'visible' 
    }
    else
    {
        //tb.style.visibility  = ar.style.visibility = 'hidden' 
         ar.style.visibility = 'hidden'
    }
}

function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}

function mOutBrandpod()
{
    popMO = false   
    showBoxElements(false)
    setTimeout('closeme()',tm) 
}

function launchWS()
{
    window.open('http://www.haart.co.uk','clientlogin',"scrollbars=yes,status=no, resizable=yes,height=600px,width=800px,location=no,menubar=yes,toolbar=yes,top=5")  
}

function showWebsite(e)
{
    return
    var evObj
    clearTimeout()    
    setTimeout('closeme()',tm)
    if(popVis) return   
    else popVis = true
    if (window.event) 
    {
        e=event
        document.getElementById('wbR').style.left = (e.clientX + document.body.scrollLeft) -10
        document.getElementById('wbR').style.top = (e.clientY + document.body.scrollTop) - 150
    }
    else
    {
       document.getElementById('wbR').style.left = ((parseInt(e.pageX) + parseInt(window.pageXOffset)) - 10)+'px'
       document.getElementById('wbR').style.top = ((parseInt(e.pageY) + parseInt(window.pageYOffset)) - 150)+'px'
    }
    document.getElementById('wbR').style.display = 'block'
    popMO = true
}

function closeme()
{
   if(!popMO)
   {
        popVis = false
        document.getElementById('wbR').style.display = 'none'
   }
}

function hideWebSite(nm)
{
    return
    //document.getElementById('wbR').style.display = 'none'
    popMO = false;
    setTimeout('closeme()',tm)
}

function loadNav(pag,sub)
{
    injectToolBar()
    injectNavBar()
    selectMenu(pag,sub)
    expandToolbar(pag)
}

function selectMenu(pag,sub)
{
    //if(document.title=="SPICER)
   var ttl = document.title,obj
   if(sub&&sub!="")
   {
        obj = document.getElementById(sub)
        if(obj)obj.className = 'selected'
   }
   else
   {
        //if(pag=='aboutus'||pag=='divisions'||pag=='recruitment'||pag=='contactus'||pag=='home'||pag=='news')
        {
            obj = document.getElementById('itm'+pag)
            if(obj)obj.className = obj.className + ' selected'
        }
   }
}

var bk='black'
function switchBack()
{
   // alert(document.body.style.backgroundImage)
   // if(document.body.style.backgroundImage)
    if(bk=='color')
    {
        bk = 'black' 
        document.body.style.backgroundImage = "url(imgs/hq_bw.jpg)"
    }
    else
    {
        bk = 'color' 
        document.body.style.backgroundImage = "url(imgs/hq_clr.jpg)"
    }
}

function menu_click(e)
{
    if (window.event) e = window.event; 
    var srcEl = e.srcElement? e.srcElement : e.target; 
    var obj=srcEl.parentNode.parentNode.childNodes[1]
    if(obj.style.display=='none'||obj.style.display=='')
    {
        obj.style.display='block';
        srcEl.src=srcEl.src.replace('+','-')
    }
    else 
    {   
        srcEl.src=srcEl.src.replace('-','+')
        obj.style.display='none';
    }
    
    var parObj = obj.parentNode.parentNode 
    var parID = srcEl.parentNode.parentNode.id
    
    if(menuMode!="expanded"&&obj.style.display=='block')
    {
        //Close all menu's     
        //aboutus
        //divisions
        //recruitment
        //contactus
        if(parID!='aboutus')
        {          
            document.getElementById('aboutus').childNodes[1].style.display = 'none'
            document.getElementById('aboutus').childNodes[0].childNodes[0].src = 'imgs/orangesq+.png'
        }
      
        if(parID!='divisions')
        {
            document.getElementById('divisions').childNodes[1].style.display = 'none'
            document.getElementById('divisions').childNodes[0].childNodes[0].src = 'imgs/greensq+.png'
        }
        
        if(parID!='recruitment')
        {
            document.getElementById('recruitment').childNodes[1].style.display = 'none'
            document.getElementById('recruitment').childNodes[0].childNodes[0].src = 'imgs/lbluesq+.png'
        }
        
        if(parID!='contactus')
        {
            document.getElementById('contactus').childNodes[1].style.display = 'none'
            document.getElementById('contactus').childNodes[0].childNodes[0].src = 'imgs/yellowsq+.png'
        }
        
    } 
}


function injectNavBar()
{
    var iStr =''
    iStr +='<div style="width:38px;"><a target="mbsold" title="Visit Must Be Sold" href="http://www.mustbesold.com/"><div id="mbsold"></div></a></div>'
    iStr +='<div style="width:35px;"><a target="chainfree" title="Visit Chainfree" href="http://www.chainfree.com/"><div id="chainfree"></div></a></div>'
    iStr +='<div style="width:58px;"><a target="valu" title="Visit Valunation" href="http://www.valunation.co.uk/"><div id="valu"></div></a></div>'
    iStr +='<div style="width:65px;"><a target="justm" title="Visit Just Mortgages" href="http://www.haybrookmortgages.com/"><div id="jmort"></div></a></div>'
    iStr +='<div style="width:89px;"><a target="shNewHomes" title="Visit Spicerhaart Land and New Homes" href="http://www.spicerhaartlandandnewhomes.co.uk/"><div id="newHomes"></div></a></div>'
    iStr +='<div style="width:96px;"><a target="Direct" title="Visit Mortgages Direct" href="http://www.haart.co.uk/mortgages.aspx"><div id="mDirect"></div></a></div>'
    iStr +='<div style="width:36px;"><a target="iSOLD" title="Visit iSOLD" href="http://www.isold.com/"><div id="isold"></div></a></div>'
    iStr +='<div style="width:51px;"><a target="Fine" title="Visit Fine" href="http://www.fine.co.uk/"><div id="fine"></div></a></div>'
    iStr +='<div style="width:84px;"><a target="FJlord" title="Visit Felicity J Lord" href="http://www.fjlord.co.uk/"><div id="fjl"></div></a></div>'
    iStr +='<div style="width:52px;"><a target="Haybrook" title="Visit Haybrook" href="http://www.haybrook.com/"><div id="haybrook"></div></a></div>'
    iStr +='<div style="width:49px;"><a target="McColl" title="Visit Spicer McColl" href="http://www.spicer.co.uk/"><div id="spicer"></div></a></div>'
    iStr +='<div style="width:54px;"><a target="Darlows" title="Visit Darlows" href="http://www.darlows.co.uk/"><div id="darlows"></div></a></div>'
    iStr +=' <div style="width:50px;"><a target="haart" title="Visit Haart Estate Agents" href="http://www.haart.co.uk/"><div onmouseout=hideWebSite("haart") onmouseover="showWebsite(event)" id="haart"></div></a></div>'
    iStr +='<div style="margin-left:-2px;width:86px;"><a target="shCorp" title="Visit Spicerhaart Corporate Sales" href="http://corpsales.spicerhaart.co.uk/"><div id="shCorp"></div></a></div>'
    iStr +='<div class="legal">&copy; 2011 Spicerhaart Group Ltd. Registered in England No.04081664</div>'
    document.getElementById('btmBar').innerHTML = iStr
}

function injectToolBar()
{
    var iStr =''
    iStr += '<div class="menu"><div class="menuHeader"><img alt="purplebox" src="imgs/purpleBox.jpg" class="navbox" /><a title="Spicerhaart Home Page" href="default.aspx"><div id="itmhome" class="purple">HOME</div></a></div></div>'
    iStr += '<div id="aboutus" class="menu"><div class="menuHeader"><img onclick="menu_click(event)" alt="Expand/Contract The Menu" src="imgs/orangesq+.png" class="navbox" /><a title="Spicerhaart About Us" href="spicerhaart-aboutUs.aspx"><div id="itmaboutus" class="orange">ABOUT SPICERHAART</div></a></div>'
    iStr += "<div class='menuItems orange'>"
    iStr+="<div><a id='board' href='spicerhaart-board.aspx'>The Board</a></div>"
    iStr+="<div><a id='executive' href='spicerhaart-executive.aspx'>Executive Team</a></div>"
    //iStr+="<div><a id='structure' href='spicerhaart-organisational-structure.aspx'>Organisational Structure</a></div>"
    iStr+="<div><a id='ho' href='spicerhaart-head-office.aspx'>Head Office</a></div>"
    iStr+="<div><a id='contact' href='spicerhaart-contact-centre.aspx'>Contact Centre</a></div>"
    iStr+="<div><a id='charity' href='spicerhaart-charity-support.aspx'>Charity Support</a></div>"
    iStr+="<div><a id='awards' href='spicerhaart-awards-page.aspx'>Awards Page</a></div>"
    iStr += '</div></div>'
    
    iStr += '<div id="divisions" class="menu"><div class="menuHeader"><img onclick="menu_click(event)" alt="greenbox" src="imgs/greensq+.png" class="navbox" /><a href="spicerhaart-divisions.aspx" title="Spicerhaart Divisions"><div id="itmdivisions" class="green">DIVISIONS</div></a></div>'
    iStr += "<div class='menuItems green'>"
    iStr+="<div><a id='estate' href='Spicerhaart-Estate-Agents.aspx'>Estate Agency</a></div>"
    iStr+="<div><a id='sold' href='Spicerhaart-iSold.aspx'>iSold.com</a></div>"
    iStr+="<div><a id='fin' href='Spicerhaart-Fine.aspx'>Fine</a></div>"
    iStr+="<div><a id='letting' href='Spicerhaart-Letting.aspx'>Residential Lettings</a></div>"
    iStr+="<div><a id='services' href='Spicerhaart-Financial-Services.aspx'>Financial Services</a></div>"
    iStr+="<div><a id='legal' href='Spicerhaart-Legal-Services.aspx'>Legal Services</a></div>"
    iStr+="<div><a id='val' href='Spicerhaart-Valunation.aspx'>Valunation</a></div>"
    iStr+="<div><a id='land' href='Spicerhaart-Land-And-NewHomes.aspx'>Land & New Homes</a></div>"
    iStr+="<div><a id='priority' href='Spicerhaart-Priority-Network-Club.aspx'>The Priority Network Club</a></div>"
    iStr+="<div><a id='corp' href='Spicerhaart-Corporate-Sales.aspx'>Corporate Sales</a></div>"
    iStr+="<div><a  id='mbs' href='Spicerhaart-MustBeSold.aspx'>MustBeSold.com</a></div>"
    iStr+="<div><a id='cf' href='Spicerhaart-ChainFree.aspx'>ChainFree.com</a></div>"
    iStr += '</div></div>'
    
    iStr += '<div class="menu"><div class="menuHeader"><img alt="bluebox" src="imgs/blue-sq.jpg" class="navbox" /><a title="Spicerhaart Property News" href="spicerhaart-news.aspx"><div id="itmnews" class="blue">NEWS</div></a></div></div>'
	
	iStr += '<div class="menu"><div class="menuHeader"><img alt="bluebox" src="imgs/blue-sq.jpg" class="navbox" /><a title="Spicerhaart Recruitment" href="spicerhaart-recruitment.aspx"><div id="itmrecruitment" class="blue">RECRUITMENT</div></a></div></div>'
	
   // iStr += '<div id="recruitment" class="menu"><div class="menuHeader"><img onclick="menu_click(event)" alt="lightbluebox" src="imgs/lbluesq+.png" class="navbox" /><a title="Spicerhaart Recruitment" href="spicerhaart-recruitment.aspx"><div id="itmrecruitment" class="lblu">RECRUITMENT</div></a></div>'
   // iStr += "<div class='menuItems lblue'>"
   // iStr +="<div><a id='vacancies' title='Current Vacancies' href='Spicerhaart-vacancies.aspx'>Current Vacancies</a></div>"
  //  iStr +="<div><a id='graduate' title='Lettings Graduate Scheme' href='spicerhaart-lettings-graduate-scheme.aspx'>Lettings Graduate Scheme</a></div>"
  //  iStr += '</div></div>'
    
    iStr += '<div id="contactus" class="menu"><div class="menuHeader"><img onclick="menu_click(event)" alt="yellowbox" src="imgs/yellowsq+.png" class="navbox" /><a title="Contact Spicerhaart" href="spicerhaart-contactUs.aspx"><div class="yellow" id="itmcontactus">CONTACT US</div></a></div>'
    iStr += "<div class='menuItems yellow'>"
    iStr +="<div><a id='enquiryform' title='Spicerhaart Enquiry Form' href='spicerhaart-enquiryForm.aspx'>Enquiry Form</a></div>"
    iStr +="<div><a id='directions' title='Directions to Spicerhaart Head Office' href='spicerhaart-directions.aspx'>Directions to Head Office</a></div>"
    iStr += '</div></div>'
    
    document.getElementById('navToolBar').innerHTML = iStr
  
}

var menuMode;
function expandToolbar(pag)
{   
   var obj=document.getElementById(pag)
   if(obj)
   {    
        obj.childNodes[1].style.display = 'block'
        obj.childNodes[0].childNodes[0].src = obj.childNodes[0].childNodes[0].src.substring(0,obj.childNodes[0].childNodes[0].src.indexOf('.png')-1) + '-.png'   
   }
   if(window.document.body.clientHeight < 820)
   {
        menuMode="collasped"
   }
   else
   {    
        menuMode="expanded" 
        document.getElementById('aboutus').childNodes[1].style.display = 'block'
        document.getElementById('aboutus').childNodes[0].childNodes[0].src = 'imgs/orangesq-.png'
        document.getElementById('divisions').childNodes[1].style.display = 'block'
        document.getElementById('divisions').childNodes[0].childNodes[0].src = 'imgs/greensq-.png'
        document.getElementById('recruitment').childNodes[1].style.display = 'block'
        document.getElementById('recruitment').childNodes[0].childNodes[0].src = 'imgs/lbluesq-.png'
        document.getElementById('contactus').childNodes[1].style.display = 'block'
        document.getElementById('contactus').childNodes[0].childNodes[0].src = 'imgs/yellowsq-.png'
   }  
   
}

function processDetailsA()
{
    var str='';
    if(checkFormA())
    {
        str=document.getElementById('nameA').value
        str+='^'+document.getElementById('companyA').value
        str+='^'+document.getElementById('telephoneA').value
        str+='^'+document.getElementById('emailA').value
        str+='^'+document.getElementById('messageA').value
        document.getElementById('sendA').disabled = true;
        window.RS.Execute("default.aspx",
                                "rs_processDetails",
                                    str,
                                      cb_processDetailsA,
                                            errorCallback)
    }
    else 
    {
        alert(errMsg)
        aObj.focus();
    }
}

function validateEmail(val)
{  
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
    return emailPattern.test(val);  
} 

var errMsg=''
var aObj = null
function checkFormA()
{   
    errMsg=''
    aObj = null
    if(document.getElementById('nameA').value=='')
    {
        errMsg='Please complete the name field'
        aObj = document.getElementById('nameA')
    }
    if(document.getElementById('companyA').value=='')
    {
        if(errMsg=='')
        {
            errMsg='Please complete the company field'
            aObj = document.getElementById('companyA')
        }
        else
        {
            errMsg+='\r\nPlease complete the company field'
        }
    }
    
    if(document.getElementById('telephoneA').value=='')
    {
        if(errMsg=='')
        {
            errMsg='Please complete the telephone field'
            aObj = document.getElementById('telephoneA')
        }
        else
        {
            errMsg+='\r\nPlease complete the telephone field'
        }
    }
    else
    {
            if(document.getElementById('telephoneA').value.substring(0,2)=='08')
            {
                if(document.getElementById('telephoneA').value.length < 9)
                {
                    if(errMsg=='')
                    {
                        errMsg='Telephone Number is not correct'
                        aObj = document.getElementById('telephoneA')
                    }
                    else
                    {
                        errMsg+='\r\nTelephone Number is not correct'
                    }
                }
            }
            else if(!checkUKTelephone(document.getElementById('telephoneA').value))
            { 
                 if(errMsg=='')
                {
                    errMsg='Telephone Number is not correct'
                    aObj = document.getElementById('telephoneA')
                }
                else
                {
                    errMsg+='\r\nTelephone Number is not correct'
                }
            }
    
    }
    
    if(document.getElementById('emailA').value.replace(/ /g,'')=='')
    {
        if(errMsg=='')
        {
            errMsg='Please complete the email field'
            aObj = document.getElementById('emailA')
        }
        else
        {
            errMsg+='\r\nPlease complete the email field'
        }
    }
    else
    {
        if(!validateEmail(document.getElementById('emailA').value))
        {
            if(errMsg=='')
            {
                errMsg='Please provide a valid email address'
                aObj = document.getElementById('emailA')
            }
            else
            {
                errMsg+='\r\nPlease provide a valid email address'
            }
        }
    }
    
    if(document.getElementById('messageA').value=='')
    { 
        if(errMsg=='')
        {
            errMsg='Please complete the message field'
            aObj = document.getElementById('messageA')
        }
        else
        {
            errMsg+='\r\nPlease complete the message field'
        }
    }
    
    if(errMsg!='')return false
    else return true;
}

function cb_processDetailsA(rs)
{
   if(rs=="Success")
   {
        document.getElementById('tblA').style.display = 'none'
        document.getElementById('sendA').style.display = 'none'
        document.getElementById('successA').style.display = 'block'
   }
}

function errorCallback(result)
{
    alert("An error occurred while processing the form : " + result);
}



document.write('<script type="text/javascript" language="JavaScript" src="js/jstelnumbers.js"></script><script type="text/javascript" language="JavaScript" src="js/rs.js"></script>');

var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19305448-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

