﻿$(function() {
    
    var animatespeed = 2000;
    var sleep = 200;

    setTimeout(flashTowers, sleep);

    function flashTowers() {
        $('.cityscape').append('<div class="tower1 on"></div><div class="tower2 on"></div><div class="tower3 on"></div>');

        $('.cityscape .on:eq(0)').fadeIn(animatespeed, function() {
            setTimeout(flashTower2, sleep);
        });
    }

    function flashTower2() {
        $('.cityscape .on:eq(1)').fadeIn(animatespeed, function() {
            setTimeout(flashTower3, sleep);
        });
    }

    function flashTower3() {
        $('.cityscape .on:eq(2)').fadeIn(animatespeed, function() {
        });
    }
    

    //-- tooltip --//
    $('.tooltip .close').live('click', function() {
        $(this).parents('.tooltip').hide();
    });

    $('.tooltip .dontshow').live('click', function() {
        var rel = $(this).parents('.tooltip').attr('rel');

        //-- ajax call to store cookie --//
    });

    // -- quote switcher -- //

    var qf = new Array();
    function getQuotes() {
        var classes = document.styleSheets[2].rules || document.styleSheets[2].cssRules;
        var ql;
        
        for (i = 0; i < classes.length; i++) {

            ql = classes[i].selectorText;
            if (ql.substring(1, 9) == "bigquote") {
                qf.push(ql);
            }
        }
        //alert(qf.length);
    }
    getQuotes();
   // alert(qf.length);
    var r = Math.floor(Math.random() * qf.length + 1);
    var qclass = "bigquote" + r;
    $("#quoteswitch").addClass(qclass);
});
