﻿function setAction( strActionName, strActionValue, strConfirm ) {
    var bConfirm;


    //  Request confirmation if necessary.
    if ( strConfirm != null ) {
        bConfirm = confirm( strConfirm );
    } else {
        bConfirm = true;
    }
    
    if ( bConfirm == true ) {

        //  Set the action.
        document.getElementById( "action_name" ).value = strActionName;
        document.getElementById( "action_value" ).value = strActionValue;

        //  Submit the form.
        document.getElementById( "aspnetForm" ).submit();
    }
}

function enlargeSample( strSample ) {

    //  Open new window.
    var objWinbdow = window.open( "/Enlarge-Image.aspx?filename=samples/" + strSample + "-large.jpg", "image", "status=0, toolbar=0, menubar=0, directories=0, resizable=0, scrollbars=0, height=440, width=440" );
    objWinbdow.focus();
}

function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}


//Colour swatches.

function showSwatch(strImageURL, strSwatchName, strSwatchCode) {
    var objSwatchImage = document.getElementById("swatchimage");
    var objSwatchName = document.getElementById("swatchname");
    var objSwatchCode = document.getElementById("swatchcode");

    objSwatchImage.src = "/media/images/swatches/" + strImageURL;
    objSwatchName.innerHTML = strSwatchName;
    objSwatchCode.innerHTML = strSwatchCode;
}




//---------------------------------------------------------------------------






var currentImage = 1;
var serviceImageTime = 5000;
//var whiteImageTime = 0;


function nextImage() {
    var objAnimationImage = document.getElementById( "imgAnimation" );
    var objAnimationLink = document.getElementById( "lnkAnimation" );

    //  Set image timings.
    if ( currentImage == 1 ) { 
        objAnimationImage.src = "/media/images/animation/neighbours-sol.jpg";
        objAnimationLink.href = "/sectors/domestic.aspx"
        setTimeout( "nextImage()", serviceImageTime ); 
    } else if ( currentImage == 2 ) {      
        objAnimationImage.src = "/media/images/animation/school-sol.jpg";
        objAnimationLink.href = "/sectors/schools.aspx"
        setTimeout( "nextImage()", serviceImageTime );
    } else if ( currentImage == 3 ) {       
        objAnimationImage.src = "/media/images/animation/housing-sol2.jpg";
        objAnimationLink.href = "/sectors/acoustic-consultants.aspx"
        setTimeout( "nextImage()", serviceImageTime );
        
        //  Reset current image.
        currentImage = 0;
    }
    
    //  Increae image counter.
    currentImage = currentImage + 1;
}