﻿function loadLinks() {
        var arrLinks = new Array();
        var arrText = new Array();
        arrLinks[0]="boats-for-sale-up-to-£10,000";
        arrText[0]="Boats Under £10k";
        arrLinks[1]="boats-for-sale-£10,000-to-£20,000";
        arrText[1]="Boats £10k - £20k";
        arrLinks[2]="boats-for-sale-£20,000-plus";
        arrText[2]="Boats Over £20k";
        
        var k = 3;
        if(document.getElementById('ctl00_ctl00_MainBody_HdnNarrowCount').value >> 0) {
            arrLinks[k]="narrow-boats-for-sale";
            arrText[k]="Narrow Boats";
            k++;
        }
        if(document.getElementById('ctl00_ctl00_MainBody_HdnSailingCount').value >> 0) {
            arrLinks[k]="sailing-boats-for-sale";
            arrText[k]="Sailing Boats";
            k++;
        }
        if(document.getElementById('ctl00_ctl00_MainBody_HdnDinghyCount').value >> 0) {
            arrLinks[k]="dinghies-for-sale";
            arrText[k]="Dinghies";
        }
        
        
        var leftNav = document.getElementById('leftNav');
        var p2 = document.getElementById('pInfo');
        var p1 = document.createElement('p');
        p1.setAttribute('class','subTitle');
        p1.innerHTML = "Browse By Price";
        var ul = document.createElement('ul');

        for(i=0;i<arrText.length;i++)
        {     
            var a = document.createElement('a');
            a.setAttribute('href','/boat-sales/' + arrLinks[i] + '.html');
            a.innerHTML = '<b>- ' + arrText[i] + '</b>';
            var li = document.createElement('li');
            li.appendChild(a);
            ul.appendChild(li);
        }
        leftNav.insertBefore(p1,p2);
        leftNav.insertBefore(ul,p2);
    }
    
    function loadSearch()
    {
        var leftNav = document.getElementById('leftNav');
        var p4 = document.getElementById('pBrwsMake');
        
        var p3 = document.createElement('p');
        p3.setAttribute('id', 'pSearch');
        p3.setAttribute('class','subTitle');
        p3.innerHTML = 'Search For Boats';
        
        var inputText = document.createElement('input');
        inputText.setAttribute('id','tbSearch');
        inputText.setAttribute('class','searchBox');
        inputText.setAttribute('onKeyDown','if(event.keyCode==13){document.getElementById("searchButton").click();return false;}else{return true};');
        inputText.setAttribute('type','text');
        inputText.setAttribute('onblur','if(this.value==\'\'){this.value=\'Enter search term...\'};');
        inputText.setAttribute('onclick','this.value=\'\';');
        inputText.setAttribute('value','Enter search term...');
        
        var inputButton = document.createElement('input');
        inputButton.setAttribute('id','searchButton');
        inputButton.setAttribute('class','searchButton');
        inputButton.setAttribute('type','button');
        inputButton.setAttribute('value','Go');
        inputButton.setAttribute('onclick','location.href="/boat-sales/boat-search?q="+document.getElementById("tbSearch").value;');
        
        
        var linkAdv = document.createElement('a');
        linkAdv.setAttribute('class','searchAdvanced');
        linkAdv.setAttribute('href','/boat-sales/boat-search?mode=adv');
        linkAdv.innerHTML = '- Advanced Search...';
        
        
        leftNav.insertBefore(p3,p4);
        leftNav.insertBefore(inputText,p4);
        leftNav.insertBefore(inputButton,p4);
        leftNav.insertBefore(linkAdv,p4);
    }

    var kl=0;

    function flashWmk()
    {
	if(kl==0)
	{
	    document.getElementById('ctl00_ctl00_MainBody_MainBody_DivModelImgMainWatermark').style.backgroundColor = 'white';
	    document.getElementById('ctl00_ctl00_MainBody_MainBody_DivModelImgMainWatermark').style.color = 'red';
	    kl=1;
	}
	else
	{
	    document.getElementById('ctl00_ctl00_MainBody_MainBody_DivModelImgMainWatermark').style.backgroundColor = 'red';
	    document.getElementById('ctl00_ctl00_MainBody_MainBody_DivModelImgMainWatermark').style.color = 'white';
	    kl=0;
	}
    }
