﻿// JScript File

var intCount;
var intCancel;

function GenerateBounce()
{
    var backgroundDIV = document.createElement("div");
    backgroundDIV.className = "bounceBackground";
    
    var containerDIV = document.createElement("div");
    containerDIV.className = "bounceContainer";
    containerDIV.setAttribute("id","bounceContainer");
    
    var ramblersWorldwideLogoDIV = document.createElement("div");
    ramblersWorldwideLogoDIV.className = "bounceRamblersWorldwideLogo";
    
    var countrywideLogoDIV = document.createElement("div");
    countrywideLogoDIV.className = "bounceCountrywideLogo";
    
    var titleDIV = document.createElement("div");
    titleDIV.className = "bounceTitle";
    
    var titleText = "Great British Walking Breaks & Holidays";
    titleDIV.innerHTML = titleText;
    
    var precisDIV = document.createElement("div");
    precisDIV.className = "bouncePrecis";
    
    var precisText = "Countrywide Holidays is the UK arm of Ramblers Worldwide Holidays. ";
    precisText += "Offering a fantastic range of short breaks in some on the most scenic parts of Britain, ";
    precisText += "the Countrywide Holidays website will now open for you to explore the ";
    precisText += "further delights of our walking holiday programme.";
    
    precisDIV.innerHTML = precisText;
    
    var loadingDIV = document.createElement("div");
    loadingDIV.className = "bounceLoadingLogo";
    
    
    var imgCancel = new Image();
    imgCancel.src = "/images/countrywide_bounce/cancel.jpg";
    imgCancel.alt = "Cancel";
    imgCancel.border = 0;
    imgCancel.width = 75;
    imgCancel.height = 25;
    
    var lnkCancel = document.createElement("a");
    lnkCancel.className = "bounceLink";
    lnkCancel.onclick =  new Function( "RemoveBouncePopup();" );
    
    lnkCancel.appendChild( imgCancel );
    
    var cancelPageDIV = document.createElement("div");
    cancelPageDIV.className = "bounceCancelPage";
    cancelPageDIV.appendChild( lnkCancel );
    
    var openPageDIV = document.createElement("div");
    openPageDIV.className = "bounceOpenPage";
    
    var lnkOpen = document.createElement("a");
    lnkOpen.className = "bounceLink";
    lnkOpen.href = "http://www.countrywidewalking.com";
   
    var imgOpen = new Image();
    imgOpen.src = "/images/countrywide_bounce/button.jpg";
    imgOpen.alt = "Open";
    imgOpen.border=0;
    imgOpen.width=146;
    imgOpen.height=25;
    
    lnkOpen.appendChild( imgOpen );
    
    openPageDIV.appendChild( lnkOpen );
    
    var openNewPageDefaultDIV = document.createElement("div");
    openNewPageDefaultDIV.className = "bounceOpenPageFontDefault";
    openNewPageDefaultDIV.innerHTML = "Opening in ";
    
    var openNewPageBoldDIV = document.createElement("div");
    openNewPageBoldDIV.className = "bounceOpenPageFontBold";
    openNewPageBoldDIV.setAttribute("id","lblTimer");
    
    // Add to Container DIV
    containerDIV.appendChild( ramblersWorldwideLogoDIV );
    containerDIV.appendChild( countrywideLogoDIV );
    containerDIV.appendChild( titleDIV );
    containerDIV.appendChild( precisDIV );
    containerDIV.appendChild( loadingDIV );
    containerDIV.appendChild( openNewPageDefaultDIV );
    containerDIV.appendChild( openNewPageBoldDIV );
    containerDIV.appendChild( cancelPageDIV );
    containerDIV.appendChild( openPageDIV );
    
    
    
  //  backgroundDIV.appendChild( containerDIV );
    
    document.forms[0].appendChild( backgroundDIV );
    document.forms[0].appendChild( containerDIV );
    
}

function displayTimer()
{
    var strText = intCount + " seconds";
    
    var lblTimerDIV = document.getElementById("lblTimer");
    
    lblTimerDIV.innerHTML = strText;
}


function Countdown()
{
    if( intCancel == 0 )
    {
 	    intCount--;
 	    displayTimer(); 
	    if ( intCount > 0 )
	    {
 		    Id = window.setTimeout("Countdown()",1000); 
	    } 
	    else
	    {
	        this.RemoveBouncePopup();
		    window.location = "http://www.countrywidewalking.com";
	    }
	}
}	

function GenerateBouncePopup()
{
    this.intCount = 16;
    this.intCancel = 0;
    this.GenerateBounce();
    this.Countdown();
}

function RemoveBouncePopup()
{
    intCancel = 1;
    var containterDIV = document.getElementById("bounceContainer");
    document.forms[0].removeChild( containterDIV );
}