﻿$(function() {
    $('.tower-details .toolbar .thumbs img').live('click', function() {
        $('.tower-details .toolbar .thumbs img').removeClass('on');
        $(this).addClass('on');

        $('.tower-details .hero img').show().attr('src', $(this).attr('src')); //looks to be how the tower image gets into the hero div. just not sure where the source is coming from.
        $('#TowerGoogleMap').addClass('hide').attr('rel', 'load');
    });

    $('#nav-google').live('click', function() {
        $('#TowerGoogleMap').parent().children().hide();
        $('#TowerGoogleMap').show();
        $(this).parent().find('li').removeClass('on');
        $(this).addClass('on');
        //frames["TowerGoogleFrame"].window.location.reload();
        if (window.frames.TowerGoogleFrame && window.frames.TowerGoogleFrame.GetGoogleMap) {
            window.frames.TowerGoogleFrame.GetGoogleMap();
        }
    });

    tabs();
			
});

function loadThumbs(){
  if ($('.tower-details .toolbar .thumbs img').length > 0)
  {
    $('.tower-details .toolbar .thumbs img:first').trigger('click');
  }
  else
  {
    $('.tower-details .toolbar .thumbs').hide();
    $('.tower-details .toolbar #nav_google').trigger('click');
    $('.tower-details .hero img').show(); 
    $(".hero img").attr("src", "../images/no_tower_photo.jpg"); // Add an image to show no available tower picture.
  }
}

function tabs() {
  //-- hide the maps --//
  $('#TowerGoogleMap, #TowerBingMap').hide();
  
  //-- tabs to change between details, google map, and bing map --//
  $('#nav-details').live('click',function() {
	$('#content-details').parent().children().hide();
	$('#content-details').show();
	$('.tower-details .hero img').show(); //make image come back any time someone clicks the details tab.
    $(this).parent().find('li').removeClass('on');
    $(this).addClass('on');
  });
 
  $('#nav-bing').live('click',function() {
	$('#TowerBingMap').parent().children().hide();
	$('#TowerBingMap').show();
    $(this).parent().find('li').removeClass('on');
    $(this).addClass('on');
    //frames["TowerBingFrame"].window.location.reload();
    if (window.frames.TowerBingFrame && window.frames.TowerBingFrame.GetBingMap) {
        window.frames.TowerBingFrame.GetBingMap();
    }
   
  });
}

// Cut In Canister interaction.
var winsize = $(window).width();
var tdPosition;

$("a[id*='CutInCanister']").live('click', function() {

    if ($("#towermodal").length) {
        tdPosition = $("#towermodal").position();
        $("#towermodal").animate({ left: '-2000px' }, 700);
    } else {
        tdPosition = $(".tower-details").position();
        $(".tower-details").animate({ left: '-2300px' }, 700);
    }
    $("#Cutcontent").css('display', 'inline-block');

});

$(".Cutback").live('click', function() {

    if ($("#towermodal").length) {
        $("#towermodal").animate({ left: tdPosition.left }, 700);
    } else {
        $(".tower-details").animate({ left: tdPosition.left }, 700);
    }
    setTimeout("$('#Cutcontent').css('display', 'none')", 1000);

});

