var quirksMode = (top == self); 
if (!quirksMode) top.location.href = '/default.aspx';
var endPos;
var currentPos;
var accel = 0;
var timer;
var movediv = 0;

function driveOff() {
    movediv = document.getElementById('content');
    movediv.style.position = 'relative';
    endPos = parseInt(document.body.clientWidth) + 10;
    currentPos = parseInt(document.getElementById('van').style.marginLeft);
    timer = window.setInterval('moveVan();', 25);
}

function moveVan() {
    if (currentPos < endPos) {
        if (accel < 25) accel += 1;

        currentPos += accel; 
        document.getElementById('van').style.marginLeft = currentPos + 'px';
        
//        if (currentPos > 330) {
//            movediv.style.left = movediv.style.left + accel; 
//        }
    }
    else {
        window.clearInterval(timer);
        document.getElementById('van').style.display = 'none';
        currentPos = parseInt(movediv.style.left);
        timer = window.setInterval('hideContent();', 25);
    }
}

function hideContent() {
    if (currentPos < endPos) {
        if (accel < 100) accel += 10;

        currentPos += accel; 
        movediv.style.left = currentPos;
    }
    else {
        window.clearInterval(timer); movediv.style.display = 'none';
    }
}

function lookup() {
    if (cbCompanies.getSelectedItem()) {
        driveOff();
        return true
    } else {
        return false;
    }
}

function watermark() {
    if (this.style.color == 'silver') {
        this.value = ''; 
        this.style.color = 'black';
    };
    eval(this.id.substr(0, this.id.length - 6) + '.HandleFocus()');
}

function waterm() {
    if (this.style.color == 'silver' || this.value == 'Postcode') {
        this.value = '';
        this.style.color = 'black';
    };
}

if (document.getElementById('ctl00_C1_cbCompanies_Input')) {
    document.getElementById('ctl00_C1_cbCompanies_Input').onfocus = watermark;
    document.getElementById('ctl00_C1_cbCompanies_Input').style.color = 'silver';
    document.getElementById('ctl00_C1_cbCompanies_Input').setAttribute("autocomplete", "off");
}
if (document.getElementById('ctl00_C1_Categories_cbCategories_Input')) {
    document.getElementById('ctl00_C1_Categories_cbCategories_Input').value = 'Tradesman (e.g. Electrician)';
    document.getElementById('ctl00_C1_Categories_cbCategories_Input').onfocus = watermark;
    document.getElementById('ctl00_C1_Categories_cbCategories_Input').style.color = 'silver';
    document.getElementById('ctl00_C1_Categories_cbCategories_Input').setAttribute("autocomplete", "off");
}
if (document.getElementById('ctl00_C1_tbLocation')) {
    document.getElementById('ctl00_C1_tbLocation').style.color = 'silver';
    document.getElementById('ctl00_C1_tbLocation').onfocus = waterm;
    document.getElementById('ctl00_C1_tbLocation').setAttribute("autocomplete", "off");
}

function showSearches() {
    $('#fpSearches').fadeIn(); 
}
