﻿var xPos;
var yPos;
var twidth=200;
var twidthDesc=400;
var theightDesc=500;

var ThumbRotate;
var Timeouts = new Array;

//////////////////////////////////////////////////////////
//////////         Stage Map Display           ///////////
//////////////////////////////////////////////////////////



function SwitchMap() {
    var imagediv = document.getElementById("FullImage");
    var imagesrc = document.getElementById("FullImgSrc");
    var popuplabel = document.getElementById("ImgSwitchLabel");

    if (imagesrc.src.indexOf("SatMaps")>-1) {
        //We currently have SatMap displayed so switch to OSMap
        imagesrc.src = imagesrc.src.replace("SatMaps", "OSMaps");
        popuplabel.innerHTML = "Switch to Satellite Map";
    } else {
        //We currently have OSMap displayed so switch to SatMap
        imagesrc.src = imagesrc.src.replace("OSMaps", "SatMaps");
        popuplabel.innerHTML = "Switch to Road Map";
    }
    
    imagediv.style.height=imagesrc.offsetHeight + 'px';
}

//////////////////////////////////////////////////////////
///////////        Thumbnail Rotation          ///////////
//////////////////////////////////////////////////////////

function RotateRoadMap(obj, imgpath) {
    ThumbRotate = true;
    RotateThumbnails(obj.id, imgpath);
}

function RotateThumbnails(ThumbTagID, ImgPath) {
  	var ThumbTag = document.getElementById(ThumbTagID);
  	var TimeoutID;
  	var nextpath;
  	
  	if (ImgPath.indexOf("SatMaps")>-1) {
  	   nextpath = ImgPath.replace("SatMaps", "OSMaps");
       ThumbTag.src = nextpath;
    } else {
       nextpath = ImgPath.replace("OSMaps", "SatMaps");
       ThumbTag.src = nextpath;
    }

    if (ThumbRotate) {
       TimeoutID = window.setTimeout("RotateThumbnails('" + ThumbTagID + "', '" + nextpath + "')", 700);
       ThumbTag.name = TimeoutID;
  	}
}

function StopThumbRotation(obj, ImgPath) {
    ThumbRotate = false;
    
    //Reset Thumb to Sat Map for consistency
    var ThumbTag = document.getElementById(obj.id);
    
    if (ThumbTag.src.indexOf("OSMaps")>-1) {
       ThumbTag.src = ImgPath.replace("OSMaps", "SatMaps");
    }    
    
    window.clearTimeout(obj.name)
}
