﻿var totalSlides = 5;
var currentSlide = 0;
var timer;
var sliding = true;

function swapContent(slideNumber){
Stop();
Rotate(slideNumber);}

function Rotate(slideNumber){
currentSlide = slideNumber;
for(var i = 1; i <= totalSlides; i++){
  var content = document.getElementById("rotatorDiv" + i);
  var button = document.getElementById("rotatorButton" + i);
  if(i == slideNumber){
    content.style.visibility = "visible";
    content.style.display = "block";
    button.src = "http://images.intellicast.com/App_Themes/Silver/Images/btn_" + i + "_r.gif";}
  else{
    content.style.visibility = "hidden";
    content.style.display = "none";
    button.src = "http://images.intellicast.com/App_Themes/Silver/Images/btn_" + i + ".gif";}}}

function ToggleTimer(){if(sliding){Stop();}else{ Start();}}
function Start(){
sliding = true;
NextSlide();
var button = document.getElementById("contentPlayer");
button.src = "http://images.intellicast.com/App_Themes/Silver/Images/btn_pause.gif";
timer = setTimeout("Start()", 8000);}

function Stop(){
sliding = false;
var button = document.getElementById("contentPlayer");
button.src = "http://images.intellicast.com/App_Themes/Silver/Images/btn_play.gif";
clearTimeout(timer);
timer = 0;}

function NextSlide(){
if(currentSlide == totalSlides){currentSlide = 0;}
Rotate(currentSlide + 1);}

function PreviousSlide(){
if (currentSlide == 1){currentSlide = (totalSlides + 1);}
Rotate(currentSlide - 1);
Stop();}

function swapTab(tab){
if (tab == 1) {
$("#cities").css("display", "none");
$("#alerts").css("display", "block");
$("#cityTab").css("background", "url(http://images.intellicast.com/App_Images/tab_cities.gif)");
$("#alertTab").css("background", "url(http://images.intellicast.com/App_Images/tab_watchwarning_1.gif)");
$("#cityTab").mouseover(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_cities_r.gif)"; });
$("#cityTab").mouseout(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_cities.gif)"; });
$("#alertTab").mouseover(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_watchwarning_1.gif)"; });
$("#alertTab").mouseout(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_watchwarning_1.gif)"; });
}
else if (tab == 0) {
$("#cities").css("display", "block");
$("#alerts").css("display", "none");
$("#cityTab").css("background", "url(http://images.intellicast.com/App_Images/tab_cities_1.gif)");
$("#alertTab").css("background", "url(http://images.intellicast.com/App_Images/tab_watchwarning.gif)");
$("#cityTab").mouseover(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_cities_1.gif)"; });
$("#cityTab").mouseout(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_cities_1.gif)"; });
$("#alertTab").mouseover(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_watchwarning_r.gif)"; });
$("#alertTab").mouseout(function() { this.style.background = "url(http://images.intellicast.com/App_Images/tab_watchwarning.gif)"; });}}

if (document.images) {
cityOff = new Image();
cityOff.src = "http://images.intellicast.com/App_Images/tab_cities.gif";
cityHover = new Image();
cityHover.src = "http://images.intellicast.com/App_Images/tab_cities_r.gif";
cityOn = new Image();
cityOn.src = "http://images.intellicast.com/App_Images/tab_cities_1.gif";
wwOff = new Image();
wwOff.src = "http://images.intellicast.com/App_Images/tab_watchwarning.gif";
wwHover = new Image();
wwHover.src = "http://images.intellicast.com/App_Images/tab_watchwarning_r.gif";
wwOn = new Image();
wwOn.src = "http://images.intellicast.com/App_Images/tab_watchwarning_1.gif";}

function homeSwipe(state){
var text = "Enter City, State, Country, Zip or Airport";
if (state == 'on' && $("#homeSearchBox").val() == text) {
  $("#homeSearchBox").val("");
  $("#homeSearchBox").css("font-size", "11px");
  $("#homeSearchBox").css("color", "#454545");}
else if ($("#homeSearchBox").val() == ""){
  $("#homeSearchBox").val(text);
  $("#homeSearchBox").css("font-size", "10px");
  $("#homeSearchBox").css("color", "#999");}}

function homeEnter() {
if (event.keyCode == 13) {
  event.cancelBubble = true;
  event.returnValue = false;
  search($('#homeSearchBox').val());}}