File: D:/web/coventrydemolition/inc-multiple-logo-footer.asp
<!-- (SS,16/9/15) for logo changes, adapted from previous background changer -->
<script>
$(document).keypress(function(e){
//alert(e.which);
// key p or b
if (e.which == 112 || e.which == 98) {
previous_logo();
event.preventDefault();
logo_timer = false;
}
// key n
else if (e.which == 110) {
next_logo();
event.preventDefault();
logo_timer = false;
}
// key t for timer
else if (e.which == 116) {
logo_timer = !logo_timer;
if (logo_timer)
{
start_logo_timer();
}
change_logo(); // also updates the caption
event.preventDefault();
}
});
var current_logo = 0; // moved to top to allow default to be set using logo query string value
var logo_timer = false;
function start_logo_timer()
{
setTimeout(next_logo_timer, 5000);
}
function next_logo_timer()
{
if (logo_timer) {
if (current_logo >= max_logo()) current_logo = -1; // wrap around
next_logo();
start_logo_timer();
}
}
function next_logo()
{
if (current_logo < max_logo()) {
current_logo = current_logo + 1;
change_logo();
}
//else alert("No more");
}
function previous_logo()
{
if (current_logo > 0) {
current_logo = current_logo - 1;
change_logo();
}
//else alert("No more");
}
function max_logo()
{
return logos.length - 1;
}
function change_logo()
{
// if outside min or max then set to within limit
current_logo = Math.max(0, current_logo);
current_logo = Math.min(max_logo(), current_logo);
// set in cookie to pass back to server to allow all pages to have the latest logo
document.cookie = "logo=" + current_logo.toString();
$("#logo-main").attr("src", "/logos/" + logos[current_logo]);
$(".logo-info").html("Logo file name: " + logos[current_logo])
if (logo_timer)
$(".logo-info").html('*' + $(".logo-info").text());
}
// on page load, set the default logo
$(document).ready(function() {
if (default_logo!= 0) {
current_logo = default_logo;
change_logo();
}
});
</script>