var VZT = {};

VZT.AppCore = null;
/**
* This is the base class for the entire library.  All classes should implement this class.
* @class Core
* @namespace Lib
* @static
*/
VZT.Base = {


	/**
	* Copies properties to current class.  Used in place of setOptions.
	* @method setProperties
	* @param {Object} options The properties to copy 
	* @return {Object} The current instance
	*/
	setProperties:function(o) {
		this.appCore = VZT.AppCore;
		this._setGlobalProperties();
		if ($chk(o)) {
			for (var option in o) {
				if (o.hasOwnProperty(option)) {
					this[option] = o[option];	
				}				
			}
		}
		this.initCustomEvents();
		return this;
	},
		
	/**
	* Copies properties defined in LibOptions to current class.
	* @method _setGlobalProperties
	* @private
	* @return {Object} The current instance 
	*/
	_setGlobalProperties:function() {
	  //check to see if _name is defined, as it needs this to do a lookup in LibOptions
		if (typeof this._name !== 'undefined' && typeof LibOptions !== 'undefined') {
			if (typeof LibOptions[this._name] !== 'undefined') {
				for (var option in LibOptions[this._name]) {
					if (LibOptions[this._name].hasOwnProperty(option)) {
						this[option] = LibOptions[this._name][option];
					}
				}
			}
		}
		return this;
	},
		
	/**
	* Calls invokeMyEvent(), "MyEvent" being the str passed.  Calls method with args.
	* @method setProperties
	* @param {String} str The event to invoke
	* @param {Array} args The arguments to pass to the event
	*/
	invokeEvent:function(str,args) {
		var method = 'invoke'+str.capitalize();
		if ($chk(this[method])) {
			this[method](args);	
		}
	},
		
	/**
	* Gets custom events ready.  They are pulled from the CustomEvents property, if you do not 
	* pass an events param. Two methods are created: invokeMyEvent() and doMyEvent(), "MyEvent"
	* being the event name, converted from camelCase to TitleCase(i.e. 'beforeShow' becomes 
	* 'invokeBeforeShow','doBeforeShow'). Thus, if you want to edit an event after it's already 
	* been added, you edit doMyEvent(). By default, this method contains the MooTools fireEvent()
	* method. invokeMyEvent() simply delegates to doMyEvent().
	* @method initCustomEvents
	* @param {Array} events (Optional) The custom events you want to add
	*/
	initCustomEvents:function(events) {
		var e = [];
		    
		if ($chk(events)) {
		  e = events;
		} else if ($chk(this.CustomEvents) && !$chk(this._customEventsInitialized)) {
			e = this.CustomEvents.flatten();
			this._customEventsInitialized = true;
		}
		e.each(function(event) {
			this.initCustomEvent(event);
		}.bind(this));
		return this;
	},
	/**
	* Initializes the custom events
	* @method initCustomEvent
	* @param {String?} e - The names of the event
	*/
	initCustomEvent:function(e) {
		var cap = e.capitalize();
		this['invoke'+cap] = function(args) {
			if ($chk(this['do'+cap])) {
				this['do'+cap](args);
			}
		}.bind(this);
		this['do'+cap] = function(args) {
		  args = ($chk(args))?args:null;
			this.fireEvent(e,args);
		}.bind(this);
	},

    /**
     * Handles checking to see if an event needs to be fired
     * for a given event bubble and module
     * @param event
     * @param strength
     * @param selectors
     */
    bubble: function( event, strength, selectors)
    {
       if(event == undefined || event == null)
            return;
       var object = $(event.target);
       for(i=0; i<strength; i++)
       {
           for(selector in selectors){
               if( this._matchesselector(object, selector))
               {
                   selectors[selector](event, object);
               }
           }
           if(object.parentNode == null)
            break;

           object = $(object.parentNode);
       }

    },

    /**
     * matchs elements
     * @param el
     * @param selector
     */
    _matchesselector: function(el, selector) {
        try{
            var classstring = el.get('class');
            var  re = new RegExp("\\b[a-z]*" + selector + "[a-z]*\\b");
            return classstring.match(re);
        } catch (e) {
            return false;
        }
    }
};/*
 *Core Application Class
 */
VZT.appcore = new Class({
	Implements:[VZT.Base,Events],
    Events: null,
    Animations: null,

	pagestates: ['init'],               //array of current states associtaed with the page

	//weather or not to enable debuging
    debug: true,

	/**
	 * Verboseness of log
	 * 1 - Errors only
	 * 2 - Warnings
	 * 3 - Messages
	 */
	verbose: 3,

    /**
     * Sets content in a place
     * @param dest Destination of content
     * @param text Content
     * @param ana animation
     */
	setContent: function(dest, text, ana)
	{
		var contentsetter = new VZT.pagecontent({
			animator: ana,
			content: text,
			destination: dest
		}).setContent();
	},

    /**
     * gets the current page states
     */
	getPageStates: function(){
		return this.pagestates;	
	},

    /**
     * checks to see if the page has the current state
     * @param state page state to check
     */
	hasPageState:function(state) {
		return this.pagestates.contains(state);	
	},

    /**
     * Adds a state to the page
     * @param state state 
     */
	setPageState: function(state){
		if (!this.pagestates.contains(state)) {
			this.pagestates.push(state);
		}
        this.Events.Notify("state_change", ["add", state]);
	},

    /**
     * Removes a page state for current states
     * @param state state to remove
     */
	removePageState:function(state) {
        this.Events.Notify("state_change", ["delete", state]);
		this.pagestates.erase(state);	
	},

    /**
     * Log a message
     * @param message
     * @param level
     */
	log: function(message, level){
		if(this.debug === true && this.verbose >= level)
		{
			var el = $('console');
			if (el) {
				if (!$chk(message)) {message = 'empty string';}
				el.adopt((new Element('br')));
				el.appendText(message);
			}
		}
	},

    /**
     * Initialization
     * Sets up the application core and history object. Also binds the timer and the click
     * events
     */
	initialize: function()
	{
		//VZT.AppCore = this;
		//VZT.History = new VZT.historymanager();

        var self = this;
        this.Events = new VZT.appcore.events();
        this.Animations = new VZT.appcore.animations();
        this.History = new VZT.appcore.history();
	}
});

/**
 * History Management Class
 * 
 * Manages history and forward/backward navigations
 */
VZT.appcore.history = new Class({
	Implements:[VZT.Base, Events,Chain ],
	
	_actions: [],
	_iframe: null,
	_previoustag: "",
	
	/**
	 * Process
	 * Process' the current url and determins the inital state
	 */
	Process: function(){
   
		if(document.location.hash !== null && document.location.hash !== "") {


            
			this.addHistory(document.location.hash);
			this._previoustag = document.location.hash;
			this._runEvent(document.location.hash);

		} else {
             this.addHistory("#");
        }

		this._checkbrowser();
	},
	
	/**
	 * goBackwards
	 * go back one page
	 */
	goBackwards: function(){
		history.go(-1);
        VZT.AppCore.Events.Notify("history_backwards");
	},
	
	/**
	 * goForwards
	 * go forward one page
	 */
	goForwards: function(){
		history.go(1);
        VZT.AppCore.Events.Notify("history_forwads");
	},
	
	/**
	 * - _runEvent
	 * runs the event associated with a given hash tag
	 */
	_runEvent: function(tag){
		var tracer = this._findActions(tag);
		if(tracer !== null && tracer.action != null) {
			tracer.action();
           
        }
	},
	
	/**
	 * - _updateURL
	 * Updates the url with the new tag
	 */
	_updateUrl: function(tag)
	{
		window.location.hash=tag;
		if(Browser.Engine.trident) {
			location.replace(window.location);
		} else {
			window.location.hash=tag;
		}
	},
	
	/**
	 * addHistory
	 * Adds a historical event
	 */
	addHistory: function(tag)
	{
        if(tag == VZT.AppCore.History._previoustag)
            return;

		VZT.AppCore.History._previoustag = tag;

		if(Browser.Engine.trident)
			this._addHistoryIE(tag);
		
		this._updateUrl(tag);
		
	},
	
	/**
	 * - _addHistoryIE
	 * Add a historical event via our IE iframe hack
	 */
	_addHistoryIE: function(tag)
	{
		var doc = $('myHistoryFrame').contentDocument;
		if (doc == undefined || doc == null)
            doc =  $('myHistoryFrame').contentWindow.document
        doc.open();
        doc.write("<div id='tag'>" + tag + "</div>");
        doc.close();   
	},
	

	/**
	 * Add action for a tag
	 */
	addAction: function(tag, action){
		var len = this._actions.length;
		
		var tracer = {
				"tag" : tag,
				"action": action
		};
		
		this._actions[len] = tracer;
	},
	
	/**
	 * - _findActions
	 * find an action for a given tag
	 */
	_findActions: function(tag) {
		for(i=0; i<this._actions.length; i++)
			if(this._actions[i].tag === tag)
				return this._actions[i];
		return null;
	},
	
	/**
	 * - _checkbrowser
	 * cheks the browser to see if the history state has changed
	 */
	_checkbrowser: function(){
		if(Browser.Engine.trident)
			VZT.AppCore.History._checkIE();


        if(VZT.AppCore.History._previoustag != document.location.hash) {
                VZT.AppCore.Events.Notify("history_change", document.location.hash);
                VZT.AppCore.History._previoustag = document.location.hash
                VZT.AppCore.History._runEvent(document.location.hash);
         }
		
		VZT.AppCore.History._runEvent(document.location.tag);

		
		setTimeout(VZT.AppCore.History._checkbrowser,500);
		
	},
	
	/**
	 * _checkIE
	 * Checks IE to see if the browser has changed, via the iframe hidden method
	 */
	_checkIE: function(){

        try{
		var doc = $('myHistoryFrame').contentDocument;
		if (doc == undefined || doc == null)
            doc =  $('myHistoryFrame').contentWindow.document;

		if(doc.getElementById('tag') == null) {
            if(!VZT.AppCore.hasPageState("init"))
                history.go(-1);
            
            return;
        }

	
		var new_tag = doc.getElementById('tag').innerHTML;

		if(VZT.AppCore.History._previoustag != new_tag) {
		    VZT.AppCore.Events.Notify("history_change", new_tag);

			VZT.AppCore.History._previoustag = new_tag
			VZT.AppCore.History._runEvent(new_tag);
			VZT.AppCore.History._updateUrl(new_tag);
		}
        } catch(e) {
            history.go(-1);
        }
		

	},
	
	/**
	 * setup IE workaround
	 */
	_makeIE: function(){
		this._iframe = new Element('iframe', {id: 'myHistoryFrame'});
		this._iframe.setStyle('display', 'none');
		this._iframe.set('src', 'about:blank');
		
		$(document.body).grab(this._iframe);

        //this._addHistoryIE("#");
	},
	
	/**
	 * generic iframe loaded callback
	 */
	_iframeLoaded: function(location){
		
	},
	
	initialize:function(o) {	

		this.setProperties(o);
		
		if(Browser.Engine.trident)
			this._makeIE();
	}
});



VZT.appcore.events = new Class({
    Implements:[VZT.Base,Events],

    _oldsize: null,
    _timer_object : null,
    _tick: 0,
     /**
     * Notify the app core of a new event
     * @param event
     * @param args
     */
    Notify: function(event, args){
		this.fireEvent(event, args);
	},

    /**
     * Timer function
     */
    _timer: function(){
        this._tick = (this._tick + 1) % 100;
        this._checkresize();
        this.Notify("timer", this.tick);
    },

    /**
     * Checks to see if the browser has resized, a bit of a hack since some browsers dont support
     * on resize, and other ones, support it differently.
     */
    _checkresize: function(){
        if(this._oldsize === null)
        {
            this._oldsize = $(window).getSize();
        } else {
            var new_size = $(window).getSize();
            if(new_size.x !== this._oldsize.x || new_size.y !== this._oldsize.y)
            {
                this.Notify("window_resize", new_size);
            }
        }
    },

    initialize: function(){
        var self = this;

        var pevent = function(){
            self._timer();
        };
        this._timer_object = setInterval(pevent,  10);
        this._timer_object = setInterval(pevent,  10);
        $(document.body).addEvent("click", function(e){ self.Notify("click", e) });
        $(document.body).addEvent("mouseover", function(e){ self.Notify("mouseover", e) });
        $(document.body).addEvent("mouseout", function(e){ self.Notify("mouseout", e) });
    }
});VZT.appcore.animations = new Class({
    Implements:[VZT.Base,Events],
    animators: [],                      //array of animators

    /**
     * runs an animation
     * @param name  name of animation to run
     * @param object object to run the animation o
     * @param args  arguments for the animation
     * @param complete  complete event
     */
	runAnimation: function(name, object, args, complete){
		if(object === null)
			return;

		for(i=0; i<this.animators.length; i++)
		{
			if(this.animators[i].name === name)
				return this.animators[i].start(object, args, complete);
		}


		//no animator found
		return null;
	},

    /**
     * Reverts an animation
     * @param name name of animation to revert
     * @param object object to preform the animation on
     * @param args  arguments for the animation
     * @param complete  what to do when complete
     */
	revertAnimation: function(name, object, args, complete){
		if(object === null)
			return;

		for(i=0; i<this.animators.length; i++)
		{
			if(this.animators[i].name === name)
				return this.animators[i].revert(object, args, complete);
		}

		//no animator found
		return null;
	},

    /**
     * Stops a running animation
     * @param name animation to stop
     * @param object object to apply animation too
     * @param args
     */
	stopAnimation: function(name, object, args){

		for(i=0; i<this.animators.length; i++)
		{
			if(animators[i].name === name && (this.hasPageState(this.animators[i].startPageState) || this.animators[i].startPageState === "all"))
				return animators[i].stop(object, args);
		}


		//no animator found
		return null;
	},




    /**
     * Loads an animation
     * @param animator
     */
	loadAnimation: function(animator)
	{

		this.animators[this.animators.length] = animator;
		return true;

	}
});/**
 * Core class which all animations are based off of
 */
VZT.Animation = new Class({
	Implements:[VZT.Base,Events],
	
	startMethod: null,
	stopMethod: null,
	revertMethod: null,
	onComplete: null,
	
	fxObject: null,
	
	name: "",

    /**
     * Starts the animation
     * @param object Object to run the animation on
     * @param args  required arguments for the animation
     * @param complete  function to run when complete
     */
	start: function(object, args, complete){
		
		VZT.AppCore.log("Running Animation" + name, 3);
		
		this.startMethod(object, args);
		if(complete != null)
			this.fxObject.addEvent('complete', function(){ complete(); });
		
	},

    /**
     * Stops the animation if mid runn
     * @param object Object animation is being ran upon
     * @param args  stop arguments
     * @param complete  what to do once stopped
     */
	stop: function(object, args, complete){
		VZT.AppCore.log("Stopping Animation" + name, 3);
		this.stopMethod(object, args);
        if(complete != null)
			this.fxObject.addEvent('complete', function(){ complete(); });
	},

    /**
     * Runs the animation backwards
     * @param object Object to run the animation on
     * @param args  Arguments to run
     * @param complete  what to do once complete.
     */
	revert: function(object, args , complete){
		VZT.AppCore.log("Reverting Animation" + name, 3);
		this.revertMethod(object, args);
        if(complete != null)
			this.fxObject.addEvent('complete', function(){ complete(); });
	},


	initialize: function(o)
	{
		this.setProperties(o);
	}
});/**
 * updates a pages content
 */
VZT.pagecontent = new Class({
	Implements:[VZT.Base,Events,Chain],
	
	content: "",
	destination: "",
	_destinaton_object: null,
	
	initialize:function(o) {
		this.setProperties(o);
		this._destinaton_object = $(this.destination);
	},

    /**
     * gets a divs content
     */
	getContent: function(){
		
		return $(this.destination).get('html');
	},

    /**
     * sets a pages content
     */
	setContent: function(){
        VZT.AppCore.Events.Notify("content_changed", this.destination)
		$(this.destination).set('html', this.content);
	}
});/**
 * Make a full ajax page request.
 */
VZT.ajaxpagecontent = new Class({

	Implements:[VZT.Base,VZT.pagecontent, Events,Chain ],
	
	errorDiv: null,             //container for the error message
	source: "",                 //page to request
	startAnimator: "",          //what to do on start reuqest
	completeAnimator: "",       //what to do when complete
	destination: "",            //where to put the content
	errorAnimator: "",          //what to do when their is an error

    /**
     * Setup up the request
     * @param o config options
     */
	initialize:function(o) {
		this.setProperties(o);
	},

    /**
     * get page content
     * onRequest events
     *      content_loading
     *      content_unloaded
     * onSuccess
     *      content_loaded
     * onFailure
     *      error
     */
	getContent: function(){
		var self = this;
		
		var myRequest = new Request({
			url: this.source,
			method: "get",
            data: {content: true},
        
			onRequest: function(){
				VZT.AppCore.log("Page Request Started:", 3);
                VZT.AppCore.Events.Notify('content_loading');
                VZT.AppCore.Events.Notify("content_unloaded", self.destination);
				self.startAnimator();
			},
			onSuccess: function(responseText, responseXML){
				VZT.AppCore.log("Page Request Completed Succesfully:", 3);
                VZT.AppCore.setContent(self.destination, responseText, null);
                VZT.AppCore.Events.Notify("content_loaded", self.destination);
				self.completeAnimator();
			},
			onFailure: function(xhr) {
				VZT.AppCore.log("There was an error loading a page:" + xhr, 1);
				VZT.AppCore.setContent(self.destination, "<div class='centered'>Their was an error processing your request, please try again", null);
                VZT.AppCore.Events.Notify('error', ["1", xhr]);
				self.errorAnimator();
			}
		}).send();
	}
});
/**
 * Basic overlay class, any object which wants an overlay should inheret this
 */
VZT.Overlay = new Class({
    Implements:[VZT.Base,Events,Chain],
    overlay: null,

    initialize: function(){
        this._bind();
    },
    _get_screen_height: function(){
        var height  = Math.max(
             Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
             Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
             Math.max(document.body.clientHeight, document.documentElement.clientHeight)
        );
        return height;
    },
    /**
     * bind to appcore to listen for important events
     */
    _bind: function(){
        var self = this;
        VZT.AppCore.Events.addEvent("window_resize", function(e) {
            self.resizeOverlay();
        });
    },

    /**
     * unbind from appcore 
     */
    _unbind: function(){
        var self = this;
        VZT.AppCore.removeEvent("window_resize", function(e) {
            self.resizeOverlay();
        });
    },

    /**
     * shows the overlay
     */
    showOverlay: function(){

        var height = this._get_screen_height();

        this.overlay.setStyles({
               top: 0,
               display: 'block',
               height: height + "px",
               opacity: 0});
        VZT.AppCore.Animations.revertAnimation("generic_fade", this.overlay, {start: .5});

        
        VZT.AppCore.setPageState('overlay');
    },

    /**
     * resizes the overlay
     */
    resizeOverlay: function(){
        if(VZT.AppCore.hasPageState('overlay'))
        {
           var height  = this._get_screen_height();
            this.overlay.setStyle('height', height);
        }
    },

    /**
     * hides the overlay
     */
    hideOverlay: function()  {
       var self = this;
        VZT.AppCore.removePageState('overlay');
        VZT.AppCore.Animations.runAnimation("generic_fade", this.overlay, {start: .5}, function() {
		     self.overlay.setStyle('display', 'none');
        });


var browserName=navigator.userAgent.toLowerCase(); 

				//if (browserName.indexOf('firefox')>-1)
				//{ 
				//	window.location.href = window.parent.location.href;
				//}	
				//else
				//{
function getCookie(cookieName)
{
    if (document.cookie.length>0)
    {
        //alert('gc1 :' + cookieName);
        cStart=document.cookie.indexOf(cookieName + "=");
        //alert('cStart1 :' + document.cookie);
        if (cStart!=-1)
        { 
            //alert('gc2');
            cStart=cStart + cookieName.length+1; 
            cEnd=document.cookie.indexOf(";",cStart);
            if (cEnd==-1) cEnd=document.cookie.length;
                return unescape(document.cookie.substring(cStart,cEnd));
        } 
    }
    return "";
}
        
        function isEmpty(str)
	    {
		    return (!str || 0 === str.length);
	    }
        
        var hopcok = getCookie('hopCook');
        if (!isEmpty(hopcok))
        {
            setCookie("hopCook","","/",".verizon.com");
            window.top.location = hopcok;
        }
        else
        {
            window.location.reload();
        }   
				//}
}
    
});/**
 * Class for parsing css class's which contain bootstrap
 * information
 */
VZT.Parser = {
    /**
     * Parses a class for information
     * @param str - class to parse
     * @param namespace - namespace
     * @param defaults - default values
     * @return arguments
     */
    parse:function(str,namespace,defaults) {
        var reGroup = /(?:\w|\d)*\:\:(\w|\d|\:)[^ ]*/g,
   		    reValues = /((?:\w|\d)[^:]*):((?:\w|\d)[^:]*)/g,
   		    reGetNamespace = /((?:\w|\d)*)\:\:/,
   		    reIsInteger = /^\d*$/,
   		    tempRe = null,
   		    match = null,
   		    namespace = namespace || null,
   		    tests = [],
   		    results = {};

        if (namespace !== null) {
            tempRe = new RegExp(namespace+"\:\:.[^ ]*");
            tests[0] = tempRe.exec(str);
        } else {
            while (match = reGroup.exec(str)) {
                tests.push(match[0]);
            }
        }

        if (tests.length == 1) {
            var test = tests[0],
                ns = reGetNamespace.exec(test),
                res = results;

            while(match = reValues.exec(test))
            {
                //convert to integer if all digits
                if (reIsInteger.test(match[2])) {
                    match[2] = match[2].toInt();
                    //convert to boolean if true or false
                }
                else if (match[2] === 'true' || match[2] === 'false')
                {
                    match[2] = (match[2]==='true')?true:false;
                }

                res[match[1]] = match[2];
            }
        } else {
            tests.each(function(test) {
                var ns = reGetNamespace.exec(test),
                    res = results[ns[1]] = {};

                while(match = reValues.exec(test)) {
                    //convert to integer if all digits
                    if (reIsInteger.test(match[2])) {
                        match[2] = match[2].toInt();

                    //convert to boolean if true or false
                    }
                    else if (match[2] === 'true' || match[2] === 'false')
                    {
                        match[2] = (match[2]==='true')?true:false;
                    }
                    res[match[1]] = match[2];
                }
            });
        }
        for (var d in defaults) {
            if (defaults.hasOwnProperty(d)) {
                if (typeof results[d] === 'undefined') {
                    results[d] = defaults[d];
                }
            }
        }
        return results;
      }
};VZT.Skins = {
    Tooltip:  {
        'DEFAULT':'<div class="tooltip hidden"><div class="tooltip_border"><div class="tooltip_content"></div></div><div class="tooltip_carat"></div></div>'
    },
    Modal: {
        'DEFAULT':'<div class="modal hidden"><div class="modal_content"></div></div>'
    },
    Video : {
        'DEFAULT':'<div class="video_overlay" id="video_overlay"><div class="video_wrapper" id="video_wrapper"><div class="video_player" id="video_player"></div></div></div>'
    }
};

VZT.TooltipView = new Class({
   _el:null,
   _visible:false,
   _timeout:null,
   _contentDiv:null,
   Implements:[Events],
   initialize:function(el) {
       var self = this;
       this._el = el;
       this._contentDiv = this._el.getElement('.tooltip_content');
       this._el.addEvent('mouseleave',function(e) {
           self.fireEvent('mouseleave',e);
       });
   },
   show:function(args) {
       this._timeout = setTimeout(function() {
          this._contentDiv.empty();
          this._contentDiv.innerHTML = args.content.innerHTML;
          var bc = args.base.getCoordinates();
          if (args.orientation === 'right') {
              this._el.addClass('tooltip_right');
              this._el.setStyles({
                  width:args.width,
                  height:args.height,
                  top:bc.top,
                  left:bc.right
              });
          } else {
              this._el.setStyles({
                width:args.width,
                height:args.height,
                top:bc.top,
                left:bc.left-args.width
            });
          }
          
          this._el.removeClass('hidden');
          this._visible = true;
       }.bind(this),500);
       return this;
   },
   hide:function() {
       clearTimeout(this._timeout);
       this._el.removeClass('tooltip_right');
       this._el.addClass('hidden');
       this._el.setStyles({
       	top:'',
       	left:'',
       	width:'',
       	height:''	
   	   });
       this._contentDiv.empty();
       this._visible = false;
       return this;
   },
   isVisible:function() {
       return this._visible;
   },
   get:function() {
       return this._el;
   }
});


VZT.TooltipHandler = new Class({
    Implements:[VZT.Base],
	views:[],
	_currentArgs:{},
	initialize: function() {
        this.views[0] = new VZT.TooltipView(VZT.Skins.Tooltip.DEFAULT);
        this.views[0].addEvent('mouseleave',function(e) {
            this.hide(e);
        }.bind(this));
        this.bind();
	},

    /**
     * shows the tooltip
     * @param args
     */
	show:function(args) {
	    if (!this.views[0].isVisible()) {
	     this.views[0].show(args);   
	    }
	},

    /**
     * Hide the tooltip
     * @param e
     */
	hide:function(e) {
        var viewel = this.views[0].get();
        if (e.relatedTarget !== viewel && !viewel.hasChild(e.relatedTarget)) {
            this.views[0].hide();
        }
	},

    /**
     * Mouse over event
     * @param e
     */
	_mouseover:function(e) {
        var self = this;
        var mouseinevent = function(e,t){
		    var args = VZT.Parser.parse(t.get('class'),'tooltip',{
                width:200,
                height:200,
                orientation:'left',
                skin:'DEFAULT',
                base:t,
                content:'<p>Tooltip content undefined</p>'
            });
            args.content = $(args.content);
		    self.show(args);
        };

        var selectors = [];
        selectors["tooltip"] = mouseinevent;
        
		this.bubble(e, 2, selectors);


	},

    /**
     * Mouse out event
     * @param e
     */
	_mouseout:function(e) {
        var self = this;
        var mouseoutevent = function(e,f){
           self.hide(e);
        };
        var selectors = [];
        selectors["tooltip"] = mouseoutevent;

		this.bubble(e, 4, selectors);
	},

    /**
     * Bind the tooltip to the application
     * @param el
     */
	bind:function(el) {
        var self = this;
		VZT.AppCore.Events.addEvent("mouseover", function(e){
            self._mouseover(e)
        });
        VZT.AppCore.Events.addEvent("mouseout", function(e){
            self._mouseout(e)
        })
	},

    /**
     * unbind the tooltip from the application
     * @param el
     */
	unbind:function(el) {
		var self = this;
		VZT.AppCore.Events.removeEvent("mouseover", function(e){
            self._mouseover(e)
        });
        VZT.AppCore.Events.removeEvent("mouseout", function(e){
            self._mouseout(e)
        })
	}
});
VZT.MultiItemController = new Class({
    _view:null,
    _cur:0,
    initialize:function() {},
    setView:function(view) {
      this._view = view;
      return this;  
    },
    next:function() {
        var n = this._cur + 1;
        if (this.canGo(n)) {
            this.go(n);
        } else {
            this.first();
        }
        return this;
    },
    previous:function() {
    	var n = this._cur - 1;
    	if (this.canGo(n)) {
    		this.go(n);
    	} else {
    		this.last();
    	}
    	return this;
    },
    first:function() {
    	this.go(0);
    	return this;
    },
    last:function() {
    	this.go(this._view.getItems().length-1);
    	return this;	
    },
    _onGo:function(i) {
        //module specific implementation here
    },
    go:function(i) {
    	if (this.canGo(i)) {
    		this._onGo(i);
    	}
    	return this;
    },
    canGo:function(i) {
    	return (i >= 0 && i<this._view.getItems().length);
    }
    
});
VZT.TabsetController = new Class({
    Implements:VZT.MultiItemController,
    _view:null,
    initialize:function() {},
    setView:function(view) {
        this._view = view;
        this._view.addEvent('onclick',function(i) {
            this.go(i);
        }.bind(this));
    },
    _onGo:function(i) {
        var previous = this._cur;
        var current = i;
        if (i !== this._cur) {
            this._view.displayContent(current);
            this._view.selectTab(current);
            this._view.hideContent(previous);
            this._view.deselectTab(previous);
        }
        this._cur = i;
    }
});

VZT.TabsetView = new Class({
    Implements:Events,
    _wrapper:null,
    _items:[],
    _tabs:[],
    _controller:null,
   initialize:function(wrapper,items,controller) {
      this._wrapper = wrapper;
      this._items = items;
      this._controller = controller;
      this._controller.setView(this);
      this.initTabs();
      this.bind();
   },
   initTabs:function() {
     this._tabs = this._wrapper.getElements('a');
     for (var i=0,len=this._tabs.length;i<len;i++) {
         if (this._tabs[i].hasClass('active')) {
             this.fireEvent('onclick',i);
             break;
         }
     }
   },
   bind:function() {
     var self = this;
     this._wrapper.addEvent('click',function(e) {
         for (var i=0,len=self._tabs.length;i<len;i++) {
             if (e.target === self._tabs[i] || self._tabs[i].hasChild(e.target)) {
                 self.fireEvent('onclick',i);

                 e.preventDefault();
                 return false;
             }
         }
     });
   },
   unbind:function() {
     this._wrapper.removeEvents('click');
   },
   displayContent:function(i) {
       this._items[i].removeClass('hidden');
        return this;
   },
   hideContent:function(i) {
     if ($type(i) === 'number') {
        this._items[i].addClass('hidden');
     }
     return this;
   },
   selectTab:function(i) {
       this.deselectTabs();
       this._tabs[i].addClass('active');
       return this;
   },
   deselectTab:function(i) {
       this._tabs[i].removeClass('active');
       return this;
   },
   deselectTabs:function() {
       this._tabs.each(function(tab,index) {
           this.deselectTab(index);
       }.bind(this));
       return this;
   },
   getItems:function() {
       return this._items;
   },
   getItem:function(i) {
   		return this._items[i];
 	},
   getTabs:function() {
		return this._tabs;
  	},
  	getTab:function(i) {
  		return this._tabs[i];
  	}
});VZT.TabsetCurtainView = new Class({
    Extends:VZT.TabsetView,
	_columns:[],
	_curtain:null,
	_curtain_content:null,
	_toolbar:null,
	_tween:null,
    _height:500,

	initialize:function(wrapper,items,controller, height) {
	    this.parent(wrapper,items,controller);
		this._shim = new Element('div',{
			'class':'column_border_shim'
		});
		this._curtain = this._wrapper.getElement('.curtain');
		this._curtain_content = this._curtain.getElement('.curtain_content');
		this._close = this._curtain.getElement('.curtain_close');
		this._columns = this._wrapper.getElement('.bg').getChildren(':not(.fixer)');
		this._bottom = this._wrapper.getElement('.bottom');
		this._toolbar = this._wrapper.getElement('.toolbar');
        this._height=height;
		return this;
	},
	initTabs:function() {
	    this._tabs = this._wrapper.getElements('.details');
	},
	bind:function() {
		var self = this;
		this._wrapper.addEvent('click',function(e) {
			if (e.target.hasClass('details') || e.target.getParent().hasClass('details')) {
				var t = e.target.hasClass('details')?e.target:e.target.getParent();
				var index = 0;
				for (var len=self._columns.length;index<len;index++) {
					if (self._columns[index].hasChild(t)) {
						break;
					}
				}
				self.fireEvent('ontabclick',index);
				e.preventDefault();
				return false;
			} else if (e.target.hasClass('curtain_close')) {
				self.fireEvent('oncloseclick');
			}
		});
		return this;
	},
    resizeCurtain: function(height){
        var old_height = this._curtain.getSize().y;

        VZT.AppCore.Animations.runAnimation("generic_resize", this._curtain, {
			startheight:  old_height,
			endheight:height,
			duration: 500,
			transition: Fx.Transitions.Quad.easeInOut
		});
    },
	openCurtain:function( oncomplete) {
	    var self = this;
		this._wrapper.addClass('tabsCurtainOpen');
		var _oc = function() {
		    oncomplete();
		    //self._curtain.setStyles({'height':'auto','overflow':'hidden'});
		};
        //alert(this._curtain_content.get('class'));
        //var p = VZT.Parser.parse(this._curtain_content.get('class'),'tabsCurtain');


		VZT.AppCore.Animations.runAnimation("generic_resize", this._curtain, {
			startheight: 0,
			endheight:this._height,
			duration: 500,
			transition: Fx.Transitions.Quad.easeInOut
		},_oc);
		this._bottom.setStyle('display','none');
		this._curtain.setStyle('display','block');
		return this;
	},
	closeCurtain:function() {
		VZT.AppCore.Animations.runAnimation("generic_resize", this._curtain, {
			startheight: 500,
			endheight: 10,
			duration: 500,
			transition: Fx.Transitions.Quad.easeInOut
		}, function(){
			this._bottom.setStyle('display','block');
			this._curtain.setStyle('display','none');
		}.bind(this));
		this._wrapper.removeClass('tabsCurtainOpen');
		return this;
	},
	setCurtainContent:function(content) {
		this._curtain_content.set('html',content);
		this.showCurtainContent();
		return this;
	},
	removeCurtainContent:function() {
		this._curtain_content.empty();
		this.hideCurtainContent();
		return this;
	},
	hideCurtainContent:function() {
        var self=this;
        VZT.AppCore.Animations.runAnimation("generic_fade", this._curtain_content, {}, function(){
            this._curtain_content.setStyle('display','none');
        });


		return this;
	},
	showCurtainContent:function() {
		this._curtain_content.setStyle('opacity', 0);
        this._curtain_content.setStyle('display','block');
        VZT.AppCore.Animations.revertAnimation("generic_fade", this._curtain_content, {});
		return this;
	},
	showToolbar:function() {
	    if (this._toolbar) {
	     this._toolbar.removeClass('hidden');
	    }
	    return this;
	},
	hideToolbar:function() {
	    if (this._toolbar) {
	     this._toolbar.addClass('hidden');
	    }
	    return this;
	},
	setStateMarker:function(tab,openclosed) {
		var mark = openclosed?'-':'+';
		var marker = tab.getElement('.details_state');
		marker.set('html',mark);
		return this;
	},
	resetStateMarkers:function() {
		this._tabs.each(function(tab) {
			this.setStateMarker(tab,false);
		}.bind(this));
		return this;
	},
	showCloseButton:function() {
		this._close.setStyle('display','block');
		return this;
	},
	hideCloseButton:function() {
		this._close.setStyle('display','none');
		return this;
	},
	getColumns:function() {
		return this._columns;
	},
	selectColumn:function(column) {
		this.deselectColumns();
		var prev = column.getPrevious();
		var next = column.getNext();
		if (column === this._columns[0]) {
			next.addClass('after');
		} else if (column === this._columns[this._columns.length-1]) {
			prev.addClass('before');
		} else {
			next.addClass('after');
			prev.addClass('before');
		}
		column.addClass('active');
		return this;
	},
	deselectColumns:function() {
		var self = this;
		this._columns.each(function(column) {
			var prev = column.getPrevious();
			var next = column.getNext();
			if (prev) {
				prev.removeClass('before');
			}
			if (next) {
				next.removeClass('after');
			}
			column.removeClass('active');
		});
		return this;
	}
});


VZT.TabsetCurtainController = new Class({
    Extends:VZT.TabsetController,
	_curtain_open:false,
	_view:null,
	initialize:function() {},
	setView:function(view) {
        this._view = view;
        this._view.addEvents({
        	'ontabclick':function(i) {
               
            	this.go(i);
            }.bind(this),
            'oncloseclick':function() {
            	this._onCloseClick();
            }.bind(this)
        });
    },
	_onGo:function(i) {
		var c = this._view.getItem(i);
		var tab = this._view.getTab(i);


		if (i === this._cur && this.curtainIsOpen()) {
			this._view.removeCurtainContent()
				.closeCurtain()
				.hideCloseButton()
				.resetStateMarkers()
				.setStateMarker(tab,false)
				.hideToolbar();
			this._curtain_open = false;
			this._view.deselectColumns();
		} else if (i !== this._cur && this.curtainIsOpen()) {
			this._view.setCurtainContent(c.get('html'))
				.resetStateMarkers()
				.setStateMarker(tab,true);
			this._curtain_open = true;
			this._view.selectColumn(this._view.getColumns()[i]);
		} else {

			this._view.openCurtain( function() {
				this._view.setCurtainContent(c.get('html'));
				this._view.showCloseButton();
				this._view.showToolbar();
			}.bind(this));
			this._view.setStateMarker(tab,true);
			this._view.selectColumn(this._view.getColumns()[i]);
			this._curtain_open = true;
		}
		this._cur = i;
	},
	_onCloseClick:function(i) {
	    this._view.removeCurtainContent()
				.closeCurtain()
				.hideCloseButton()
				.resetStateMarkers()
				.hideToolbar();
		this._view.deselectColumns();
		this._curtain_open = false;
	},
	curtainIsOpen:function() {
		return this._curtain_open;
	}
});
VZT.FooterNavView = new Class({
    footernav: null,
    initialize:function(el) {
        this.footernav = el;
    },
    hideNav: function(){
        var self = this;
       VZT.AppCore.Animations.revertAnimation("generic_resize", self.footernav, {startheight: 0  , endheight: 290, duration: 1000});
    },
    viewNav: function(){
      
        var self = this;
        if(self.footernav.getStyle('height') !== 290)
            VZT.AppCore.Animations.runAnimation("generic_resize", self.footernav, {startheight: 0  , endheight: 290, duration: 1000});
    }
});

VZT.FooterNavHandler = new Class({
    view: null,

    initialize: function(view){
        this.view = view;
        var self = this;
        VZT.AppCore.Events.addEvent("state_change", function(type, state) {
            if(type=="add" && state == "init")
                self.view.hideNav();

            if(type=="add" && state == "expanded")
                self.view.viewNav();
        });
        VZT.AppCore.Events.addEvent("content_unloaded", function() {

             if(VZT.AppCore.hasPageState("init"))
                self.view.hideNav();
        });
    }

})
/**
 * Handles binding the addthis ssytem to the .share class
 * for more information check out addthis documentation
 */

VZT.addthisHandler= new Class({
    initialize: function(){
        var self=this;
				
        VZT.AppCore.Events.addEvent("content_loaded", function(){
            self.createButtons();
        })
    },

    /**
    *binds the buttons
    */
    createButtons: function(){
        //if(addthis != undefined && addthis !=null) {
            try{
                addthis.button(".share");
            } catch (e) {
                //alert(e);
            }
        //}
    }

});
VZT.ModalView = new Class({
    Implements:[VZT.Overlay, Events],
    _el: null,
    _contentDiv:null,
    _old_content_div:null,

    initialize:function(el) {
        var self = this;
        this._el = el;
       
        this._contentDiv = this._el.getElement('.modal_content');
        this.createOverlay();
    },

    show:function(args) {
        var self=this;
        this.showOverlay();
        var st = document.body.scrollTop;
		if(st == 0)
			var st = document.documentElement.scrollTop;
			
			this._contentDiv.empty();
        this._contentDiv.setStyle("opacity", 0);

        this._old_content_div = args.content;

		if(args.content.id == "basicdouble")
		{
			if(args.content.getElementById('hiddenIframe'))
			{	
				//args.content.getElementById('hiddenIframe').set("src", '/Content/LearnShop/intermediate.aspx')
				this._contentDiv.innerHTML = "<div class=\"\" id=\"basicdouble\"><div class=\"pad\"><div class=\"close\"><img alt=\"\" src=\"/Content/commonfiles/Images/Globalheader/new_header/modal/close.jpg\"></div><iframe  id=\"hiddenIframe\"  scrolling=\"auto\" frameborder=\"0\" style=\"width: 100%; height: 490px;\" allowtransparency=\"true\" src=\"/Content/LearnShop/intermediate.aspx\"></iframe></div></div>";
			}
		}
		else
        {
            this._contentDiv.innerHTML = args.content.innerHTML;
        }	


        if(args.content.getElementById('zip_code')) {
            args.content.getElementById('zip_code').set("id", 'zip_code_old');
        }
        if(args.content.getElementById('view_region_box')) {
            args.content.getElementById('view_region_box').set("id", 'view_region_box_old');
        }
        if(args.content.getElementById('city')) {
            args.content.getElementById('city').set("id", 'city_old');
        }


        var wsize = $(window).getSize();
        
        var top = st + (( wsize.y - args.height) / 2);
        var left = (wsize.x - args.width ) / 2

        this._el.setStyles({
            width:0,
            height:0,
            top:top,
            left:left
        });
        //this._contentDiv.setStyle({opacity: 0});
        VZT.AppCore.Animations.runAnimation("generic_resize", this._el,{attrib: "height", startheight: 0, endheight: args.height});
        VZT.AppCore.Animations.runAnimation("generic_resize", this._el,{attrib: "width", startheight: 0, endheight: args.width}, function(){
            VZT.AppCore.Animations.revertAnimation("generic_fade", self._contentDiv,{})
        });

        this._el.removeClass('hidden');
        this._bindclose();

    },
    _bindclose: function(){
        var close_buttons = this._contentDiv.getElements('[class*=close]');
        var self = this;
        for(i=0; i<close_buttons.length;i++)
        {
            close_buttons[0].addEvent('click', function(e){
                self.fireEvent('close',e)
            });
        }
    },
    hide: function(){
        var height = this._el.getStyle("Height");
        var width = this._el.getStyle("Width");
        var self = this;

        try{
             if(this._old_content_div.getElementById('zip_code_old') != null)
                 this._old_content_div.getElementById('zip_code_old').set("id", 'zip_code');

            if(this._old_content_div.getElementById('city_old') != null);
                 this._old_content_div.getElementById('city_old').set("id", 'city');

            if(this._old_content_div.getElementById('view_region_box_old') != null)
                 this._old_content_div.getElementById('view_region_box_old').set("id", 'view_region_box_code');
        } catch (e) {}

         VZT.AppCore.Animations.runAnimation("generic_fade", self._contentDiv,{}, function(){
            VZT.AppCore.Animations.revertAnimation("generic_resize", self._el,{attrib: "height", startheight: 0, endheight: height});
            VZT.AppCore.Animations.revertAnimation("generic_resize", self._el,{attrib: "width", startheight: 0, endheight: width}, function(){
                self.hideOverlay();
                self._el.addClass('hidden');
                self._el.setStyles({
                    top:'',
                    left:'',
                    width:'',
                    height:''
                });
                self._contentDiv.empty();
            });
         }) ;



    },
    get:function() {
        return this._el;
    },
   
    createOverlay: function(){

		this.overlay = $('modal_overlay');
		if(this.overlay == null) {
            var wrap = new Element('div', {
                'class':'vzt'
            });
			this.overlay  = new Element('div', {id: 'modal_overlay', 'class': 'overlay'});
            wrap.grab(this.overlay);
			this.overlay.setStyle('display', 'none');
		    $(document.body).grab(wrap);
		}
	}
});

VZT.ModalHandler = {
    views:[],
	_currentArgs:{},
    _isvisable: false,
	init:function() {
        var self = this;
        this.views[0] = new VZT.ModalView(VZT.Skins.Modal.DEFAULT);
        this.views[0].addEvent("close", function(){
            self.hide();
        })
	},
    show:function(args) {
        this._isvisable = true;
        this.views[0].show(args);
	},
    hide:function(e) {
         this._isvisable = false;
         this.views[0].hide();  
	},
    _click: function(e) {
        var base = this;
        
		var args = VZT.Parser.parse(base.get('class'),'modal',{
            width:200,
            height:200,
            skin:'DEFAULT',
            base:base,
            content:'<p>Tooltip content undefined</p>'
        });
        args.content = $(args.content);
        e.preventDefault();
		VZT.ModalHandler.show(args);
    },

    bind:function(el) {
		var launchers = el.getElements('[class*=modal::]');

        launchers.each(function(l) {
            l.addEvents({
                'click':this._click
            });
        }.bind(this));
	},
	unbind:function(el) {
		var launchers = el.getElements('[class*=modal::]');
		launchers.each(function(l) {
			l.removeEvents({
				'click':this._click
			});
		}.bind(this));
	}
};
VZT.InputHandler = new Class({
    Implements:[VZT.Base, Events,Chain ],
     initialize:function() {
		this.bind();
	},
    clear: function(event, target){
        target.set("value", "");
        target.removeClass('textclear');
    },
    _onclick: function(e) {
        var self = this;
        var clickevent = function(e,f){
            self.clear(e, f);
        };
        var selectors = [];
        selectors["textclear"] = clickevent;

		this.bubble(e, 4, selectors);
    },
    bind: function(){
        var self = this;
		VZT.AppCore.Events.addEvent("click", function(e){
            self._onclick(e);
        });
    }
});
VZT.ToolbarView = new Class({
    Implements:Events,
    _zip:null,
    _loader: null,
    _submit:null,
    _verify:null,
    _controller:null,
    _content_holder:null,
    _order_number: null,
    _order_alpha: null,
    _tabs:null,
    _region:null,

    initialize:function(wrapper,controller) {
        this._controller = controller;
        this._wrapper = wrapper;
        this._zip = this._wrapper.getElement('#zip_code');
        this._submit = this._wrapper.getElement('.submit');
        this._loader = this._wrapper.getElement('.loader');
        this._verify = this._wrapper.getElement('.verify');
        this._cat = $("channel_packages");
        this._order_alpha = $$(".channel_sort_abc");
        this._order_number = $$(".channel_sort_number");
        this._controller.setView(this);
        this._tabs = $$(".tabs").getElements('a');
        this._region = this._wrapper.getElement('select');
        this.bind();
    },
    bind:function() {
        var self = this;
    	if (this._submit) {
    		this._submit.addEvent('click',function() {
	            this.fireEvent('onsubmit');

	        }.bind(this)); 	
    	}
        if(this._cat) {
            this._cat.addEvent('change', function() {
                this.fireEvent('oncatchange');
            }.bind(this));
        }
        if(this._region) {
            this._region.addEvent('change', function() {
                this.fireEvent('onregchange');
            }.bind(this));
            this._region.addEvent('propertychange', function() {
                this.fireEvent('onregchange');
            }.bind(this));
        }
        if(this._tabs) {
            for(i=0;i<this._tabs.length;i++)
                this._tabs[i].addEvent('click', function(e) {
                    var sort = this.get("rel");
                    for(i=0; i<self._tabs.length;i++)
                        self._tabs[i].removeClass("active");
                    this.addClass("active");

                    self.fireEvent('onbundlchange', sort);
                    return false;
                });
        }
        if(this._order_alpha){
            this._order_alpha.addEvent('click', function(e) {
                this.fireEvent('onOrderChange', 'alpha');
                return false;
            }.bind(this));
            this._order_number.addEvent('click', function(e) {
                this.fireEvent('onOrderChange', 'num');
                return false;
            }.bind(this));
        }
    },
    unbind:function() {
    	if (this._submit) {
    		this._submit.removeEvents('click');	
    	}        
    },
    displayLoader:function() {
        this._loader.setStyle('display','block');
        return this;
    },
    hideLoader:function() {
        this._loader.setStyle('display','none');
        return this;
    },
    showVerify:function(){
        this._verify.setStyle('display', 'block');
    },
    hideVerify:function(){
        this._verify.setStyle('display', 'none');
    }
});

VZT.ToolbarController = new Class({
    _view:null,
    _sort:'alpha',
    _bundle: 'all',
    IsNumeric: function(sText)
    {
       var ValidChars = "0123456789";
       var IsNumber=true;
       var Char;


       for (i = 0; i < sText.length && IsNumber; i++)
          {
          Char = sText.charAt(i);
          if (ValidChars.indexOf(Char) == -1)
             {
             IsNumber = false;
             }
          }
       return IsNumber;

   },

   initialize:function() {},
   setView:function(view) {
       this._view = view;
       this._view.addEvent('onsubmit',function(){
           this.onSubmit();
       }.bind(this));
       this._view.addEvent('oncatchange', function(){
            this.onChange();
       }.bind(this));
        this._view.addEvent('onOrderChange', function(data){
            this.onSort(data);
       }.bind(this));
         this._view.addEvent('onregchange', function(){
            this.onRegionChange();
       }.bind(this));

       this._view.addEvent('onbundlchange', function(data){
            this.onBundle(data);
       }.bind(this));



       VZT.AppCore.Events.addEvent('channels_loaded',function() {
           this._view.showVerify();
           $("na_error_frame").addClass("hidden");
   	   }.bind(this));
       VZT.AppCore.Events.addEvent('request_channels', function(){
                VZT.AppCore.Events.Notify('channel_request',this.getData());
       }.bind(this));
       VZT.AppCore.Events.addEvent('fios_unavail', function(){
                this._view.hideVerify();
                $$('.channels_module')[0].addClass("hidden");
       }.bind(this));

       return this;
   },
    onBundle:function(data){
        this._bundle = data;
        VZT.AppCore.Events.Notify('channel_request',this.getData());
    },
   onSubmit:function() {
       if(!this.IsNumeric(this._view._zip.get("value")))
       {
           alert("please enter a valid zipcode");
           return;
       }
       this._view.showVerify();
       //VZT.AppCore.Events.Notify('channel_request',this.getData());
    },
    onRegionChange:function() {;
       VZT.AppCore.Events.Notify('channel_request',this.getData());
    },
    onChange: function(){
        VZT.AppCore.Events.Notify('channel_request',this.getData());
    },

    onSort: function(order){
        this._sort = order;
        VZT.AppCore.Events.Notify('channel_request',this.getData());
    },
    getData: function(){
         var data = {};
        data.zipcode = this._view._zip.get("value");
        data.category = this._view._cat.get("value");
        data.order = this._sort;
        data.service = this._bundle;
        data.region=this._view._region.get("value");
        return data;
    }
});
VZT.price_toggler = new Class({
    Implements:[VZT.Base],
   initialize: function(){
        this._bind();
   },
   _bind: function(){
       var self = this;
       VZT.AppCore.Events.addEvent("click", function(e){
            self._onclick(e)
        });
   },
   _onclick: function(e){
        var self = this;
       //alert('wow');
        var clickevent = function(e,t){
            var args = VZT.Parser.parse(t.get('class'),'pricetoggler',{
                content:'<p>Tooltip content undefined</p>'
            });
            args.content = $(args.content);
            self.toggle(args.content);
        };
        var selectors = [];
        selectors["pricetoggler"] = clickevent;

		this.bubble(e, 4, selectors);
   },
   toggle: function(target){
        var children = target.childNodes;
        for(i=0;i<children.length;i++)
        {
            var obj = $(children[i]);
            if(obj.hasClass('hidden'))
                obj.removeClass('hidden');
            else
                obj.addClass('hidden');
        }
   }
});
VZT.flash_checker = {
    init: function(){
        try
        {
        if(!swfobject.hasFlashPlayerVersion("10")){
            var self = this;
            VZT.AppCore.Events.addEvent("content_loaded", function(){
                self._hide_flash_actions();
            });
            self._hide_flash_actions();
        }
        }
        catch(e)
        {}
    },
    _hide_flash_actions: function(){
        if(!swfobject.hasFlashPlayerVersion("10")){
            var flash_buttons = $$(".flash_action");
            if(!flash_buttons)
                return;
            for(i=0;i<flash_buttons.length;i++)
            {
                flash_buttons[i].addClass('hidden');
            }
        }
    }
};
VZT.features_marquee = {
  init: function(){
      var self = this;
      VZT.AppCore.Events.addEvent("content_loaded", function(){
            self.display();
      });
  },
  display: function(){
      if($("fios_cable")) {
       var flashvars = {        xmlFile: '/Content/LearnShop/Includes/xml/xmlPass.xml'      };
        var params = {        base: '/Content/LearnShop/Flash/fiosCable/',
            wmode: 'transparent',
            allowScriptAccess: 'sameDomain'      };
        swfobject.embedSWF("/Content/LearnShop/Flash/fiosCable/marquee_container.swf", "fios_cable", "985", "290", "9.0.0", "swf/expressInstall.swf",flashvars,params);
    }
  }
};
VZT.EquipRecommenderView = new Class({
    show: function(args){
        if(args == null)
            return false;


        var hds = (args.hd_def.get('value'))*1;
	    var sds = (args.std_def.get('value'))*1;
		var total = (hds) + (sds);

      
		var record=args.dvr.checked;
		if (record && total>1)
		{

			if (hds!=0)
			{
				hds--;
			}
			else if (sds!=0)
			{
				sds--;
			}
            $('multiroom_dvr').set("html", "(1) - Multiroom DVR");
		}
		else if (record && total==1)
		{

            $('multiroom_dvr').set("html", "(1) - HD DVR");
            hds=0;
            sds=0;

		}

		if (hds>0)
		{
			$('hd_receiver').set("html", "(" + hds + ") - HD Receiver");
		} else {
            $('hd_receiver').set("html", "");
        }

		if (sds>0)
		{
			$('std_receiver').set("html", "(" + sds + ") - Standard Definition Receiver");
		}else {
            $('std_receiver').set("html", "");
        }


        VZT.AppCore.Animations.runAnimation("generic_resize", args.content, {startheight: 0, endheight: 100, duration: 500, transition: Fx.Transitions.Quad.easeIn});
    },
    hide: function(obj){
        if(obj == null)
            return false;

        VZT.AppCore.Animations.revertAnimation("generic_resize", args.content, {startheight: 0, endheight: 100, duration: 500, transition: Fx.Transitions.Quad.easeIn});
    }
});

VZT.EquipRecommenderHandler ={
    _view: new VZT.EquipRecommenderView(),
    initialize: function(view){
        
    },
    bind: function(el){
        var launchers = el.getElements('[class*=equiprecommender::]');

        launchers.each(function(l) {
            l.addEvents({
                'click':this._click
            });
        }.bind(this));
    },
    unbind: function(el){
        var launchers = el.getElements('[class*=equiprecommender::]');

        launchers.each(function(l) {
            l.removeEvents({
                'click':this._click
            });
        }.bind(this));
    },
    _click: function(e){
        var base = this;

		var args = VZT.Parser.parse(base.get('class'),'equiprecommender',{
            content:'<p>Tooltip content undefined</p>',
            std_def:'',
            hd_def:'',
            dvr:''
        });
        
        args.content = $(args.content);
        args.std_def = $(args.std_def);
        args.hd_def = $(args.hd_def);
        args.dvr = $(args.dvr);

		VZT.EquipRecommenderHandler.show(args);
    },
    show: function(args) {
        this._view.show(args);
    },
    hide: function(args) {
       this._view.hide(args.content); 
    }
};
/**
 * Handles the business logic of the video player
 * @Namespace VZT
 * @class VideoHandler
 */
VZT.VideoHandler = new Class({
	Implements:[VZT.Base, Events,Chain ],
	view: null,
	model: null,
	_videoclick: null,

    initialize:function(o) {
		this.setProperties(o);
		this.view.createOverlay();
		this.bind();
	},

    /**
     * runs when a video play button is clicked
     * @param e - event object
     * @param target - the reference to the dom element receiving the paly event
     */
    _onvideoclick: function(e, target) {

        e.preventDefault();
        if(swfobject.hasFlashPlayerVersion("10")){
            this.showVideo(target.get('href'), target.get('rel'));
        }
    },

    /**
     * runs when the application recives notice that something has been clicked
     * @param e
     */
    _onclick: function(e) {
        var self = this;
        var clickevent = function(e,f){
            self._onvideoclick(e, f);
        };
        var selectors = [];
        selectors["videocontent"] = clickevent;

		this.bubble(e, 4, selectors);
    },
    _onresize: function(size) {

        this.view.resize(this.model.aspect);
    },

    /**
     * binds the video widget to the application core
     */
	bind: function(){
        var self = this;
		VZT.AppCore.Events.addEvent("click", function(e){
            self._onclick(e);
        });
        VZT.AppCore.Events.addEvent("window_resize", function(e){
            self._onresize(e);
        });
        VZT.AppCore.Events.addEvent("video_close", function(e) {
            self.hideVideo(e);
        });
        VZT.AppCore.Events.addEvent("video_share", function(e) {
            self._onshare(e);
        });
        VZT.AppCore.Events.addEvent("content_loaded", function(e) {
            self.hideVideo();
        });

		
	},

    /**
     * unbinds the video widget from the application core
     */
	unbind: function(){
		VZT.AppCore.removeEvent("click", function(e){
            self._onclick(e);
        });
        VZT.AppCore.removeEvent("window_resize", function(e){
            self._onresize(e);
        })
	},

     /**
     * The on share function
     */
    _onshare: function(event){
        try{
            addthis_open(document.body, "more", null, null);
        } catch(e) {}
    },

    /**
     * shows a video
     * @param source meta xml file for a video
     */
	showVideo: function(source){
       this.view.showOverlay();
	   this.view.show(this.model.aspect, source);
	},

    /**
     * hides a currently playing video
     */
	hideVideo: function(){
        var self=this;
        if(VZT.AppCore.hasPageState("video"))
        {
            self.view.hide();
            self.view.hideOverlay();
        }
	},

    /**
     * Stops a video that is being played
     */
	stopVideo: function(){
        var self=this;
        if(VZT.AppCore.hasPageState("video"))
        {
		    self.view.video_container.stop();
        }
	},

    /**
     * starts a video
     */
	startVideo: function(){
		var self=this;
        if(VZT.AppCore.hasPageState("video"))
        {
		    self.view.video_container.play();
        }
	},

    /**
     * pauses a video
     */
	pauseVideo: function(){
        if(VZT.AppCore.hasPageState("video"))
        {
            var self=this;
            self.view.video_container.pause();
        }
    },

    /**
     * resizes a video
     */
    resizeVideo: function(){
        if(VZT.AppCore.hasPageState("video"))
        {
            var self=this;
            self.view.resize();
        }
    },

    /**
     * Loads a video
     * @param xml meta data to load
     */
    loadVideo: function(xml){
        if(VZT.AppCore.hasPageState("video"))
        {
            var self=this;
            self.view.video_container.load(xml);
        }
    },

    /**
     * gets the current video state
     */
    getVideoState: function() {
        if(VZT.AppCore.hasPageState("video"))
        {
            var self=this;
            self.view.video_container.getState();
        }
    }
});

/**
 * View for the video widget. handles rendering and displaying videos
 * @namespace VZT
 * @class VideoContainerView
 * @extends VZT, Base, Overlay, Events, Chain
 */
function onVideoCallback(event){
    VZT.AppCore.Events.Notify("video_" + event, null);
}
VZT.VideoContainerView = new Class({
	Implements:[VZT.Base,VZT.Overlay, Events,Chain ],
	video_container: null,
    video_overlay: null,

    /**
     * Computes the full browser size of a video, based off the current browsers window
     * size and the supplied video ratio
     * @param video_ratio object of width and height. so 16 / 9 is {width: 16, height: 9}
     * @return video_size strcut of width and height
     */
    _computeVideoSize: function(video_ratio)
    {
        var width = 0;
        var height = 0;
        var window_size = $(window).getSize();
        if(window_size.x > 985)
            window_size.x = 985;
        
		var aspect_height = (window_size.x *  video_ratio.height) / video_ratio.width;
        var aspect_width =  (window_size.y *   video_ratio.width) /  video_ratio.height;

        //determin which size to use.
	    if(aspect_width > window_size.x)
        {
            width = window_size.x;
            height = aspect_height;
        } else {
            width = aspect_width;
            height =  window_size.y;
        }
        return {width: width, height: height};
    },

    /**
     * Shows a video, notifies the application a video is being loaded and sets the video page state
     * @param video_ratio object describing the videos ratio
     * @param video_source source of the videos meta xml file
     * @return true on success
     */
	show: function(video_ratio, video_source){
        var st = document.body.scrollTop || 0;
		if(st == 0)
			var st = document.documentElement.scrollTop;
        var wsize = $(window).getSize();
        this.video_overlay.setStyles({
               top: st,
               display: 'block',
               height: wsize.y,
               opacity: 1});


        //VZT.AppCore.setPageState('overlay');
        
        //Notify the application a video is being loaded
        VZT.AppCore.Events.Notify('video_loaded');
        VZT.AppCore.setPageState("video");

        var self = this;
        var window_size = $(window).getSize();
        var video_wrapper = $("video_wrapper");
        var videoSize = self._computeVideoSize(video_ratio);
        var videoTopOffset = ( window_size.y - videoSize.height) / 2;


		video_wrapper.setStyles({width: videoSize.width,
                                height: videoSize.height,
                                "margin-top": videoTopOffset});

		//Insert flash video
        //configPath: "/Content/LearnShop/Includes/xml/player_configuration.xml",
        var flashvars = {
               configPath: "/Content/LearnShop/Includes/xml/player_configuration.xml",
                videoPath: video_source,
                xmlPath: ""
        };
		var params ={allowscriptaccess: "sameDomain",
                        allowfullscreen: true,
                        play: true,
                        wmode: "opaque"};
        var attributes={};
		attributes.id = "video_player";
        ///Content/LearnShop/Flash

        swfobject.embedSWF("/Content/LearnShop/Flash/player.swf", "video_player", "100%", "100%", "10.0.0","/Content/LearnShop/Flash/expressInstall.swf", flashvars, params, attributes);
        //swfobject.embedSWF("flash/player.swf", "video_player", "100%", "100%", "10.0.0","flash/expressInstall.swf", flashvars, params, attributes);

        //setTimeout(event, 1000);
        self.video_container = swfobject.getObjectById("video_player");
        return true;
	},

    /**
     * Hides the video player and notifies the application that the video player has been removed,
     * and updates the page state
     */
	hide: function(){
        this.video_overlay.setStyle("display", "none");
        self.state = "hidden";
        self.video_container = null;
		VZT.AppCore.Events.Notify('video_unloaded');
        VZT.AppCore.removePageState("video");
		swfobject.removeSWF("video_player");
        var video_wrapper = $("video_wrapper").grab(new Element('div',{ 'id':'video_player'}))

	},

    /**
     * resize an active video player
     */
	resize: function(video_ratio){
        if(VZT.AppCore.hasPageState('video'))
        {
             var video_wrapper = $("video_wrapper");
             var window_size = $(window).getSize();
             var videoSize = this._computeVideoSize(video_ratio);

             var videoTopOffset = ( window_size.y - videoSize.height) / 2;
             video_wrapper.setStyles({width: videoSize.width,
                                height: videoSize.height,
                                "margin-top": videoTopOffset})
             //this.video_container.resize(videoSize.width, videoSize.height);
        }
    },

	/*
	 * Creates overlay
	 */
	createOverlay: function(){
		this.overlay = $('overlay');

		if(this.overlay == null) {
             wrap = new Element('div', {'class':'vzt' });
             this.overlay = new Element('div', {'class':'overlay', id: 'overlay' });
             wrap.adopt(this.overlay);
             document.body.adopt(wrap);
		}   

        if($('video_overlay') == null) {
            wrap = new Element('div', {
            'class':'vzt'
             });

            wrap.innerHTML = VZT.Skins.Video.DEFAULT;
            var skin = wrap.getFirst();
            this.video_overlay = skin;
            document.body.adopt(wrap);
            VZT.Skins.Video.DEFAULT = skin;
            //this.overlay = $('video_overlay');
        }
        
	}

});/*
This file contains all the external video calls and triggers application events for them
 */


/**
 * On video close event
 */
function onClose(){
    VZT.AppCore.Events.Notify("video_closed", null);
}

/**
 * On video play
 */
function onPlay(){
    VZT.AppCore.Events.Notify("video_play", null);
}

/**
 * On video stop
 */
function onStop(){
    VZT.AppCore.Events.Notify("video_stop", null);
}

/**
 * On video pause
 */
function onPause(){
    VZT.AppCore.Events.Notify("video_pause", null);
}

/**
 * On video resize
 */
function onResize(){
    VZT.AppCore.Events.Notify("video_resize", null);
}

/**
 * On share event
 */
function onShare(){
    VZT.AppCore.Events.Notify("video_share", null);
}
/**
 * Handles the rendering of page content
 */
VZT.PageLoaderView = new Class({
	Implements:[VZT.Base, Events,Chain ],
	_model: null,

    _initalstate: true,


    loading_timer: null,

    /**
     * displays the loading state
     */
	displayLoading: function(){
		//if(this.content_object.getElement('div') !== null)
		//	this.s_height = this.content_object.getElement('div').getSize().y;
        var self = this;
        var c_height  = 0;
        if(self._model.content_object.getElement('div'))
            c_height = self._model.content_object.getElement('div').getSize().y;

        var event = function(){
            self._model.content_object.setStyle('height', c_height);
            self._model.content_object.set('html', '<center><div class="pad10">Your request is loading, please wait...<br /><img src="/content/Learnshop/images/loading.gif" alt=""></div></center>');
            if(c_height=0) {
                 VZT.AppCore.Animations.runAnimation("generic_resize", self._model.content_object, {startheight: 0, endheight: 100, duration: 500, transition: Fx.Transitions.Quad.easeIn},null);
            }
        };
        this.loading_timer = setTimeout(event, 400);
	},

    /**
     * displays the content
     * @param content content to display
     */
	displayContent: function() {
        if(this.loading_timer != null)
            clearTimeout(this.loading_timer);
       
		var self = this;
         var c_height = 0;
        if(self._model.content_object.getElement('div'))
            c_height = self._model.content_object.getElement('div').getSize().y;




		if(self._initalstate){
            VZT.AppCore.Animations.runAnimation("generic_resize", self._model.content_object, {startheight: this.s_height, endheight: c_height, duration: 500, transition: Fx.Transitions.Quad.easeIn}, function(){
                self._model.content_object.setStyle('height', 'auto');
                VZT.AppCore.Animations.revertAnimation("generic_fade", self._model.content_object.getElement('div'), {});
            });
            VZT.AppCore.Animations.runAnimation("generic_scroll", document.body, {x: 0, y: 500, duration: 1000});
            
            self._initalstate = false;
        } else {
             VZT.AppCore.Animations.runAnimation("generic_resize", self._model.content_object, {startheight: this.s_height, endheight: c_height, duration: 1000, transition: Fx.Transitions.Quad.easeIn}, function(){
                self._model.content_object.setStyle('height', 'auto');
            });
             VZT.AppCore.Animations.revertAnimation("generic_fade", self._model.content_object.getElement('div'), {});
        }
	},

    /**
     * hides content
     */
    hideContent: function(){
        this._initalstate = true;
        if(this.loading_timer != null)
            clearTimeout(this.loading_timer);

		var self = this;
        self._model.content_object.setStyle("overflow","hidden");
        if(self._model.content_object.getElement('div') != null)
            self._model.content_object.getElement('div').addClass('transparent');
        VZT.AppCore.Animations.runAnimation("generic_scroll", document.body, {x: 0, y: 0});
        var c_height = self._model.content_object.getElement('div').getSize().y;
        c_height = c_height + 20;

	    VZT.AppCore.Animations.revertAnimation("generic_resize", self._model.content_object, {startheight: 0, endheight: c_height, duration: 500, transition: Fx.Transitions.Quad.easeIn}, function(){});

    },

    /**
     * init
     * @param model model of data
     */
	initialize:function(model) {
		this._model = model;
	}
});


/**
 * Handles loading page content
 */
VZT.PageLoader = new Class({
	Implements:[VZT.Base, Events,Chain ],
	
	view: null,
    model: null,
    _current_page: "",
    //_revertclick: function(){
    //    var self = this;
    //    VZT.AppCore.History.addHistory("#");
    //    this.RevertSplash();
    //},

	initialize:function(o) {
		this.setProperties(o);
		var self = this;
        //listen for the main navigation event
		VZT.AppCore.Events.addEvent(
                'main_navigation',
                function(page){
                    self.LoadPage(page);
                });

        // bind a hide event when the state init is added back into the system
        VZT.AppCore.Events.addEvent(
                'state_change',
                function(type, state) {
                   if(type == "add" && state == "init")
                   {

                       self.view.hideContent();
                       self.view._initalstate = true;
                   }
                   if(type == "delete" && state == "init")
                   {

                   }
                   if(type == "add" && state == "expanded")
                   {
                        self.view.displayContent();
                   }
                });
	},

    /**
     * Loads a page
     * @param source page to load
     */
	LoadPage: function(source){

        if(source == this._current_page && !VZT.AppCore.hasPageState("init"))
            return;

        this._current_page = source;;
		VZT.AppCore.Events.Notify('content_unloading');
		var self = this;


        var request = new VZT.ajaxpagecontent({
			destination: self.model.content_object,
			errorDiv:  self.model.content_object,
			source: source,
			startAnimator: function(){
                self.view.displayLoading();
			},
		    completeAnimator: function(){
                VZT.AppCore.setPageState("expanded");
			},
			errorAnimator: function(){
                 VZT.AppCore.setPageState("expanded");
			}
		});;

		if(VZT.AppCore.hasPageState('init'))
		{
            self.view._initalstate = true;
            VZT.AppCore.removePageState('init');
			request.getContent();
		} else {
            self.view._initalstate = false;
			VZT.AppCore.Animations.runAnimation("generic_fade", self.model.content_object.getElement('div'), {}, function(){
				 request.getContent();
			});
		}
	}
});
/**
 * Displays loader over hero when page loads
 */
VZT.HeroLoader = {
    _el:null,
    _content:null,
    body:null,
    smw:null,
    hcw:null,
    footer:null,
    /**
     * Constructor
     */
    initialize:function() {
        this._wrapper = new Element('div',{'class':'vzt'});
        this._el = new Element('div',{'class':'hero_loader'});
        this._wrapper.adopt(this._el);
        this.body = $$('body')[0];
        this.body.adopt(this._wrapper);
        this.initHiddenEls();
    },
    /**
     * Looks for global elements that are hidden
     */
    initHiddenEls:function() {
        this.smw = $('smw');
        this.hcw = $('hcw');
        this.footer = $('footer');
    },
    /**
     * Displays the loader
     */
    show:function() {
        try {
            var header = $('ghc');
            if (!header) {
                header = $('scbgreybarcont');
            }
            var headercoords = header.getCoordinates();
            var winsize = $(window).getSize();
            var h = winsize.y-headercoords.bottom;
            this._el.setStyles({
                'top':headercoords.bottom,
                'left':0,
                'width':winsize.x,
                'height':h,
                'display':'block'
            });
            VZT.AppCore.setPageState('loading');    
        } catch(e) {
            this.hide(true);
        }
        
    },
    /**
     * Hides the loader
     */
    hide:function(quick) {
        var self = this;
        setTimeout(function() {
            if (self.hcw) {
                self.hcw.setStyle('visibility','visible');
            }
            if (self.smw) {
                self.smw.setStyle('visibility','visible');
            }
            if (self.footer) {
                self.footer.setStyle('visibility','visible');
            }
            document.documentElement.style.overflow = 'auto';
            if (quick) {
                VZT.AppCore.removePageState("loading");
                self._el.setStyle('display','none');
            } else {
                VZT.AppCore.Animations.runAnimation("generic_fade", self._el,
                    {},
        			function(){
                        VZT.AppCore.removePageState("loading");
                        self._el.setStyle('display','none');
                    }
                );
            }
        },500);
    }
};

/**
 * Handles the sub menu
 */
VZT.SubMenuView = new Class({
	Implements:[VZT.Base,VZT.pagecontent, Events,Chain ],
	
	under_object: null,
	container_object: null,
	menu: null,
	click_class: null,


    initialize:function(o) {
		this.setProperties(o);
		this.autobind();
	},

    /**
     * Handles the on navigation event,
     * makes sure the proper menu item is selected, even if page navigation occurse outside of main menu scope;
     */
    _onNavigate: function(src){
          var clicked = $$('a.' +  "smselected");

            if(clicked != null)
					clicked.removeClass('smselected');

            links = this.menu.getElements('a');
            for(i=0; i<links.length;i++)
                if(links[i].get("rel") == src)
                    links[i].addClass('smselected');
    },
    /**
     * binds events
     */
	autobind: function(){
        var self=this;
        VZT.AppCore.Events.addEvent("main_navigation", function(src){
            self._onNavigate(src);
        });

        //get all links
        if(this.menu == null)
            return;

		links = this.menu.getElements('a');
	
		for(i=0; i<links.length;i++)
		{
            //swap tags for js enabled browsers
            if(!links[i].hasClass("ajax_ignore")) {
                var rtag = links[i].get('rel');
                var rsource = links[i].get('href');
                links[i].set('href', rtag);
                links[i].set('rel', rsource);
            }

            //click function
			var onclick = function(e) {
				if($(this) != null && $(this).hasClass("ajax_ignore"))
                    return;
				if(e== null)
					link = links[i-1];
				else
					link = this;

				tag = link.get('href');

				var source = link.get('rel');

				VZT.AppCore.History.addHistory(tag);
				VZT.AppCore.Events.Notify("main_navigation", source );
				return false;
			};
			links[i].addEvent('click', onclick);
          
			VZT.AppCore.History.addAction(links[i].get('href') , onclick);
		}
		
	}
});
VZT.AjaxLink = new Class({
    Implements:[VZT.Base, Events ],
    initialize: function(){
        this.bind();
    },
    _onclick: function(e) {
     
        var self = this;
        var clickevent = function(e,f){
            e.preventDefault();
            var source = f.get('href');
            var tag = f.get('rel');

            VZT.AppCore.Animations.runAnimation("generic_scroll", document.body, {x: 0, y:400, transition: Fx.Transitions.Quad.easeOut, duration: 1000}, function(){

            });
           
            if(tag != "#") {
                VZT.AppCore.History.addHistory(tag);
                VZT.AppCore.Events.Notify("main_navigation", source);
            }


        };
        var selectors = [];
        selectors["ajaxlink"] = clickevent;

		this.bubble(e, 4, selectors);
    },
    
    bind: function(){
        var self = this;
		VZT.AppCore.Events.addEvent("click", function(e){
            self._onclick(e);
        });
	}
});
VZT.ChannelsDataHandler = {
  _wrapper:null,
  _data_holder:null,
  _current_tier: null,

  init:function() {
      VZT.AppCore.Events.addEvents({
       'channel_request':function(data) {
           this.requestData(data);
       }.bind(this)
      });

  },
  _render_channel: function(channel, tclass){
      var html = "<tr " + tclass +"><td>" + channel.number + "</td><td>" + channel.name + "</td><td>";
        if(channel.hd == "True")
            html += "HD";

        html += "</td><td>";
        if(channel.bundles3 == "True" )
            html += "<img class='fr' src='/content/learnshop/images/tables/dot_red.gif' alt='All Plans' />";
        if(channel.bundles2 == "True")
            html += "<img class='fr' src='/content/learnshop/images/tables/dot_orange.gif' alt='Tier 1 and Tier 2' />";
        if(channel.bundles1 == "True")
           html += "<img class='fr'src='/content/learnshop/images/tables/dot_blue.gif' alt='Tier 1' />";

        html+="</td></tr>";
      
        return html;
  },

  render: function(channel_set){
    var self=this;
    if(channel_set.count ===0) {
        return "<strong>We are sorry but no channel information is available in your area</strong>";
    }
    var prow = Math.floor(channel_set.count / 3) + 1;
    self._wrapper.getElement('.channel_count').set('html', channel_set.count + ' Channels');

    var dest = self._wrapper.getElement('.channel_container');
    var html="<table class='channels'><tr><td>";
    html+="<table><colgroup><col width=20px /><col width=210px /><col width=25px /><col width=40px /></colgroup>";
    for(i=0; i<prow; i++)
    {
       tclass = "class=\"tooltip::width:280:orientation:right:content:channel_tooltip_" + i;
        if(i % 2 == 0)
            tclass += " alt";
        tclass+="\"";
        html += self._render_channel(channel_set.channels[i], tclass);
    }
    html +="</table>";

    html+="</td><td>";
    html+="<table><colgroup><col width=20px /><col width=210px /><col width=25px /><col width=40px /></colgroup>";
    for(i=prow; i<prow*2; i++)
    {
        tclass = "class=\"tooltip::width:280:content:channel_tooltip_" + i;
        if(i % 2 == 0)
            tclass += " alt";
        tclass+="\"";

        html += self._render_channel(channel_set.channels[i], tclass);
    }
    html+="</table>";
    html+="</td><td>";
    html+="<table><colgroup><col width=20px /><col width=210px /><col width=25px /><col width=40px /></colgroup>";
    for(i=prow*2; i<channel_set.count; i++)
    {
        tclass = "class=\"tooltip::width:280:content:channel_tooltip_" + i;
        if(i % 2 == 0)
            tclass += " alt";
        tclass+="\"";
        html += self._render_channel(channel_set.channels[i], tclass);
    }
    html+="</table></td></tr></table>";
    for(i=0;i<channel_set.count;i++)
    {
        html += "<div class='hidden' id='channel_tooltip_" + i + "'><div class='pad'>" + channel_set.channels[i].description +"</div></div>";
    }
    self._wrapper.getElement('.channel_container').set('html', html);
  },
  bind:function(wrapper) {
      this._wrapper = wrapper;
      this._data_holder = this._wrapper.getElement('.channels_data');
  },
  requestData:function(data) {
      var self = this;
      self._wrapper.removeClass('hidden');
      self._wrapper.getElement('.channel_container').set('html', "<img class='centered' src='/Content/LearnShop/Images/loading.gif'>");

      var jsonRequest = new Request.JSON({url: "/content/learnshop/templates/fiostv/jformat.aspx",
          onSuccess: function(c34, txt){
               var obj = eval('(' + txt + ')');
               self._data_holder.removeClass('hidden');
           	   self._wrapper.removeClass('hidden');
               self.render(obj);
               VZT.AppCore.Events.Notify('channels_loaded');
           	   VZT.AppCore.setPageState("channels_loaded");

          }}).get(data);
  }
};
VZT.CompareChannelsView = new Class({
    Implements:[VZT.Overlay, Events],
    modalview: null,
    _el: null,

    initialize: function(el){
        this._el = el;
        this.modalview = new VZT.ModalView(el);
        var self = this;
        this.modalview.addEvent("close", function(e){

                self.fireEvent('close',e);
         });
    },
    show:function(args) {
        this.modalview.show(args);
        this._bindexpand();

    },
    grow: function(args) {
        var expand_buttons = this.modalview._contentDiv.getElements('[class*=expand::]');
        for(i=0; i<expand_buttons.length; i++)
        {
             if(expand_buttons[i].hasClass("on_" +  args.newcontent))
             {
                 expand_buttons[i].setStyle('display', 'inline');
             } else {
                  expand_buttons[i].setStyle('display', 'none');
             }
        }
     
        var old_top = this._el.getStyle("top").replace("px", "");
        var old_height = this._el.getStyle("height").replace("px", "");

        var new_top = (old_height - args.height) / 2;
        new_top = parseInt(old_top) + parseInt(new_top);
        var new_height = args.height;

        VZT.AppCore.Animations.runAnimation("generic_resize", this._el, {startheight: old_height  , endheight: new_height, duration: 1000});
        VZT.AppCore.Animations.runAnimation("generic_resize", this._el, {startheight: old_top  , endheight: new_top , duration: 1000, attrib: "top"});
    },
    fadeContent: function(args){

        //args.old_content.setStyle('display', 'none');
        //args.new_content.setStyle('display', 'inline');
         VZT.AppCore.Animations.runAnimation("generic_fade", args.old_content, {}, function(){
             
             args.old_content.setStyle('display', 'none');
             args.new_content.setStyle('opacity', '0');
             args.new_content.setStyle('display', 'inline');
             VZT.AppCore.Animations.revertAnimation("generic_fade", args.new_content, {});
         });
    },
    _bindexpand: function(){

        var expand_buttons = this.modalview._contentDiv.getElements('[class*=expand::]');
        var self = this;

        for(i=0; i<expand_buttons.length;i++)
        {
            expand_buttons[i].addEvent('click', function(e){
                var base = this;
                var args = VZT.Parser.parse(base.get('class'),'expand',{
                        newcontent:'<p>Tooltip content undefined</p>',
                        oldcontent:'',
                        height: 200
                    });

                args.new_content = $(self.modalview._contentDiv.getElement("." + args.newcontent));
                args.old_content = $(self.modalview._contentDiv.getElement("." + args.oldcontent));
                self.fireEvent('expand',args)
            });
        }
    },
    hide: function(){
        this.modalview.hide();
    },
    _render_table: function(channels) {

    },
    _render_row: function(chan){
        html="<tr";
		html+='<td class="channels"><span class="channel">' + chan.name + '</span><span class="hd">';
        if(chan.hd)
               html+= '<img alt="hd" src="i/channelcompare/hd.jpg">'
        html+='</span><span class="ch">' + chan.number + '</span></td>';
        html+='<td class="selection">';
        if(chan.bundle1 === "True")
                html+='<img alt="hd" src="/content/commonfiles/Images/channelcompare/check.jpg">';
        html+='</td>';
        if(chan.bundle2 === "True")
                html+='<img alt="hd" src="/content/commonfiles/Images/channelcompare/check.jpg">';
        html+='</td>';
        if(chan.bundle3 === "True")
                html+='<img alt="hd" src="/content/commonfiles/Images/channelcompare/check.jpg">';
        html+='</td>';
        if(chan.bundle1 === "True")
                html+='<img alt="hd" src="/content/commonfiles/Images/channelcompare/check.jpg">';
        html+='</td>';
		html+='</tr>';
        return html;
    }

});

VZT.CompareChannelsHandler = {
    views:[],
    channels:[],
    
	_currentArgs:{},
    _isvisable: false,
    _current_content: null,
	init:function() {
        var self = this;
        
        this.views[0] = new VZT.CompareChannelsView(VZT.Skins.Modal.DEFAULT);
        this.views[0].addEvent("close", function(){
            self.hide();
        });
         this.views[0].addEvent("expand", function(args){
            self.expand(args);
        })
	},
    expand: function(args) {
        this.views[0].grow(args);
        this.views[0].fadeContent(args);
    },
    show:function(args) {
        this._isvisable = true;
        this.views[0].show(args);
	},
    hide:function(e) {
         this._isvisable = false;
         this.views[0].hide();
	},
    getData: function(data){
      var self = this;

      var jsonRequest = new Request.JSON({url: "/content/learnshop/templates/fiostv/jformat.aspx",
          onSuccess: function(c34, txt){
              var obj = eval('(' + txt + ')');

          }}).get(data);
    },
    _click: function(e) {
        var base = this;

		var args = VZT.Parser.parse(base.get('class'),'channelcompare',{
            width:200,
            height:200,
            skin:'DEFAULT',
            base:base,
            content:'<p>Tooltip content undefined</p>'
        });
        args.content = $(args.content);

		VZT.CompareChannelsHandler.show(args);
    },

    bind:function(el) {
		var launchers = el.getElements('[class*=channelcompare::]');

        launchers.each(function(l) {
            l.addEvents({
                'click':this._click
            });
        }.bind(this));
	},
	unbind:function(el) {
		var launchers = el.getElements('[class*=channelcompare::]');
		launchers.each(function(l) {
			l.removeEvents({
				'click':this._click
			});
		}.bind(this));
	}
};





/**
 * Handles the display strategy for the bundle box
 * Horizontal - Display strategy for the  horizontal display configuration
 * Vertical - Dispaly strategy for the vertical display confiuration
 */
VZT.BundleStrategy = {
    'Horizontal': {
        render: function(self){
            self._model.bundle.removeClass('vertical_bundle');
            self._model.bundle.addClass('horizontal_bundle');
            self._model.bundle.getElementById('bundle_image').set('src', self._model.horizontal.bundle_img);
        }

    },
    'Vertical': {
       render: function(self){
            self._model.bundle.removeClass('horizontal_bundle');
            self._model.bundle.addClass('vertical_bundle');
            self._model.bundle.getElementById('bundle_image').set('src', self._model.vertical.bundle_img);
        }
    }
};
VZT.SplashStrategy = {
    'Horizontal': {
        render: function(self){
            self._model.splash_text.set('src',  self._model.horizontal.splash_text);
            self._model.under_content.getElement(".uc_txt").removeClass("col7");
            self._model.under_content.getElement(".uc_txt").setStyle("padding-top", "10px");
            self._model.under_content.getElement(".uc_txt").setStyle("padding-left" ,"20px");
            self._model.under_content.getElement(".uc_txt").addClass("col4");

            var experence = self._model.under_content.getElement(".experence_vertical");
            if(experence !== null) {
                experence.removeClass("experence_vertical");
                experence.addClass("experence_horizontal");
            }
            self._model.splash_img.set("src", self._model.horizontal.splash);
            self._model.splash_img.setStyle("height", "400px");
            self._model.splash_img.setStyle("width", "985px");
            self._model.hc.setStyle("width","985px");
            self._model.hc.setStyle("height","400px");
          

        },
        reset: function(self) {
            //self._model.hc.setStyle("width","1197px");
           //self._model.hc.setStyle("height","655px");
           
            var obj = self._model.under_content.getElement(".uc_txt");
            obj .removeClass("col4");
            obj .addClass("col7");
            self._model.splash_text.set('src', self._model.vertical.splash_text);
        },
        Defaults: {
            height: 400,
            width: 985,
            left: 580
        }
    },
    'Vertical': {
        render: function(self){
           self._model.splash_text.set('src', self._model.vertical.splash_text);
           self._model.under_content.getElement(".uc_txt").removeClass("col4");
           self._model.under_content.getElement(".uc_txt").setStyle("padding-top" ,"56px");
           self._model.under_content.getElement(".uc_txt").setStyle("padding-left" ,"0px"); 
           self._model.under_content.getElement(".uc_txt").addClass("col7");
            var experence = self._model.under_content.getElement(".experence_horizontal");
             if(experence !== null) {
                experence.removeClass("experence_horizontal");
                experence.addClass("experence_vertical");
             }
            self._model.splash_img.set("src", self._model.vertical.splash)
            self._model.splash_img.setStyle("height", "655px");
            self._model.splash_img.setStyle("width", "1200px");
            self._model.hc.setStyle("width","1200px");
            self._model.hc.setStyle("height","655px");
        },
        reset: function(self) {

        },
        Defaults: {
            height: 655,
            width: 1197,
            left: 680
        }
    }
};/**
 * Handles rendering the splash screen for various page states
 */
VZT.SplashSizeHandler= new Class({
    _current_state: 'vertical',
    _model: null,

    initialize:function(model) {
        this._model = model;
        var self = this;

        //setup inital event
        var pevent = function(){self._polldisplay()};
        var pevent2 = function(e){self._resize(e)};
        VZT.AppCore.Events.addEvent("timer", pevent);
        VZT.AppCore.Events.addEvent("window_resize", pevent2)

        //run timer or not depending on page state
        VZT.AppCore.Events.addEvent("state_change", function(type, state){
            if(type == "add" && state == "init")
            {
                 setTimeout(function(){ VZT.AppCore.Events.addEvent("timer", pevent);}, 1000);
                 //self.updatefooter();
              
                self.display();

            }
            if(type == "delete" && state == "init")
            {   
                 VZT.AppCore.removeEvent("timer", pevent);
                 self. _current_state = "expanded";
            }
        });
        
        
        this.display();
        this._resize();
    },

    /**
     * poll event to check display
     */
    _polldisplay: function() {
        if(this._current_state != "expanded")
            this.display();

    },

    /**
     * display the page
     */
    display: function(){
        var display = this.which();
        if(this._current_state != display) {
            this._current_state = display;
            VZT.BundleStrategy[display].render(this);
            VZT.SplashStrategy[display].render(this);

         
        }
    },

    /**
     * update the footer
     */
    _resize: function() {
        var window_size = $(window).getSize();

        if(this._current_state !== "Horizontal" && this._current_state !== "expanded")
        {
           
            var hc_height = window_size.y - 210;
            var top = (hc_height - 500) / 2;
            
            if(hc_height > 590) {
                hc_height = 590;
                top = 45;
            }

            this._model.under_content.getElement(".uc_txt").setStyle("padding-top" , top);
            this._model.bundle.setStyle("padding-top" , top);
            this._model.hc.setStyle("height", hc_height);
            this._model.splash.setStyle("height", hc_height + 60)
        }
    },

    /**
     * determin which stratgey to use
     */
    which: function() {
        var window_size = $(window).getSize();
        if (window_size.y < 720) {
            return "Horizontal"
        } else {
            return "Vertical";
        }
    }
});
VZT.SplashAnimationHandler = new Class({
    _model: null,
    _view: null,

    initialize: function(model, view){
        this._model = model;
        this._view = view;
        var pevent = function(){
            VZT.AppCore.setPageState("init");
            VZT.AppCore.History.addHistory("#");
            var buttons = $("smw").getElements(".smselected");
            for(i=0; i<buttons.length;i++)
                buttons[i].removeClass("smselected");
        };
        $("expandsplash").addEvent("click", pevent);
        VZT.AppCore.History.addAction("#" , pevent);
        var self = this;

        VZT.AppCore.Events.addEvent("state_change", function(type, state){
            if(state=="init" && type=="delete") {
               self._view.shrink();
            }
            if(state=="init" && type=="add") {
                self._view.grow();
            }
        });
    }
});
VZT.SplashAnimationView = new Class({
    Implements:[VZT.Base, Events,Chain ],

    _model : null,
    
    initialize: function(model){
        this._model = model;
    },

    /**
     * grow the splash screen to a expanded state
     */
    shrink: function(){
        var self = this;
        //convert containers height
        var defaults = VZT.SplashStrategy[self._which()].Defaults;
		var container_height = self._model.container_object.getStyle('height');
        var undercontent_text = self._model.under_object_wrapper.getElement(".uc_txt");
		self._model.under_object_wrapper.setStyle('background-image', 'none');
        
        undercontent_text.addClass("col7");
        undercontent_text.removeClass("col4");

	    self._model.container_object_wrapper.setStyle('background-image', 'none');
        self._model.bundle_object.setStyle('display', 'none');
        self._model.player_object.setStyle('display', 'block');
        
        if (!Browser.Engine.trident4) {
            
            //run animations
    		VZT.AppCore.Animations.runAnimation("generic_fade", self._model.fadetext, {duration: 200});
            VZT.AppCore.Animations.runAnimation("generic_colorchange", self._model.footer_object, {start_color: "#FFF", end_color: "#F6F6F6"});
            VZT.AppCore.Animations.runAnimation("generic_fade", self._model.bundle_object, {});
            self._model.txt_object.setStyle('height', '350px');
            VZT.AppCore.Animations.runAnimation("generic_resize", self._model.container_object, {startheight: self._model.container_object.getStyle("height")  , endheight: 400, duration: 1000});
            var size = self._model.splash_object.getSize();
            var l = parseInt(self._model.splash_object.getStyle('left'),10);

    		VZT.AppCore.Animations.runAnimation("splash_fly", self._model.splash_object,
    		    {duration: 1200,
    			transition: Fx.Transitions.Quad.easeOut,
    			width: {
    				start: size.x,
    				end: 400
    			},
    			height: {
    				start: size.y,
    				end: 225
    			},
    			left: {
    				start: 0,
    				end: defaults.left
    			},
    				top: {
    					start: 2,
    					end: 150
    				}
    			}, 
    			function() {
    			    undercontent_text.setStyles({
                        'padding-top':56,
                        'padding-left':0
                    });
                    VZT.AppCore.removePageState("expanded");
                }
            );
    		VZT.AppCore.Animations.runAnimation("generic_fade", self._model.txt_object.getElement('h4'), {});
    		VZT.AppCore.Animations.runAnimation("generic_colorchange", $(document.body), {start_color: "#EFEFEF", end_color: "#FFFFFF" });
    		VZT.AppCore.Animations.runAnimation("generic_fade", self._model.txt_object.getElement('a'), {});
    		VZT.AppCore.Animations.runAnimation("menu_border", self._model.menu_object, {});
    		VZT.AppCore.Animations.revertAnimation("generic_fade",self._model.player_object, {});    
        } else {
            self._model.fadetext.setStyle('opacity',0);
            self._model.footer_object.setStyle('color','#f6f6f6');
            self._model.bundle_object.setStyle('opacity',0);
            self._model.container_object.setStyle('height',400);
            var size = self._model.splash_object.getSize();
            var l = parseInt(self._model.splash_object.getStyle('left'),10);
            self._model.splash_object.setStyles({
               width:400,
               height:225,
               'margin-left':defaults.left,
               'margin-top':150 
            });
            undercontent_text.setStyles({
               'padding-top':56,
               'padding-left':0 
            });
            var h4 = self._model.txt_object.getElement('h4');
            if (h4) {
                h4.setStyle('opacity',0);    
            }    		
    		$(document.body).setStyle('background-color','#FFFFFF');
    		var href = self._model.txt_object.getElement('a');
    		if (href) {
    		    href.setStyle('opacity',0);    
    		}    		
    		self._model.menu_object.setStyles({
    		   'border-top-color':'#fff',
    		   'border-bottom-color':'#aaa' 
    		});
    		self._model.splash_object.getElement('img').setStyles({
    		   width:400,
    		   height:225 
    		});
    		self._model.player_object.setStyle('opacity',1);
    		VZT.AppCore.removePageState("expanded");
        }
		
    },

    /**
     * shrink the splash screen to the condensed state
     */
    grow: function(){

         var self = this;
         var defaults = VZT.SplashStrategy[self._which()].Defaults;
         var window_size = $(window).getSize();
         defaults.height2 = defaults.height;
         if(window_size.y < 850 && self._which() !== "Horizontal")
         {
            defaults.height2 = window_size.y - 200;
         }
         self._model.bundle_object.setStyle('display', 'inline');
         
         if (!Browser.Engine.trident4) {
             VZT.AppCore.Animations.runAnimation("generic_fade", self._model.player_object, {});
             VZT.AppCore.Animations.revertAnimation("menu_border", self._model.menu_object, {});
            VZT.AppCore.Animations.revertAnimation("generic_colorchange", self._model.footer_object, {start_color: "#FFF", end_color: "#F6F6F6"});
             VZT.AppCore.Animations.revertAnimation("generic_fade", self._model.txt_object.getElement('a'), {});
             VZT.AppCore.Animations.revertAnimation("generic_colorchange", $(document.body), {start_color: "#EFEFEF", end_color: "#FFFFFF" });
             VZT.AppCore.Animations.revertAnimation("generic_fade", self._model.txt_object.getElement('h4'), {})
             VZT.AppCore.Animations.revertAnimation("generic_resize", self._model.container_object, {startheight: defaults.height  , endheight: 450, duration: 1000});
              self._model.txt_object.setStyle('height', '450px');
             VZT.AppCore.Animations.revertAnimation("splash_fly", self._model.splash_object,
    		    {
                    duration: 800,
    			    transition: Fx.Transitions.Quad.easeOut,
    			    width: {
    			    start: defaults.width,
    				    end: 400
    			        },
    			    height: {
    				    start: defaults.height,
    				    end: 225
    			        },
    			    left: {
    				    start: 0,
    				    end: defaults.left
    			    },
    			    top: {
    				    start: 0,
    				    end: 150
    			    }
    			}, function(){
                      VZT.AppCore.Animations.revertAnimation("generic_fade", self._model.fadetext, {duration: 200});
                      VZT.AppCore.Animations.revertAnimation("generic_fade", self._model.bundle_object, {});
                });
         } else {
             self._model.player_object.setStyle('opacity',0);
             self._model.menu_object.setStyles({
                 'border-top-color': '#AAA',
                 'border-bottom-color':'#FFF' 
             });
			self._model.footer_object.setStyle('background-color','#f6f6f6');
			var href = self._model.txt_object.getElement('a');
			if (href) {
			    href.setStyle('opacity',1);    
			}			
			$(document.body).setStyle('background-color','#fff');
			var h4 = self._model.txt_object.getElement('h4');
			if (h4) {
			    h4.setStyle('opacity',1);
			}
			self._model.container_object.setStyle('height',450);
			self._model.splash_object.setStyles({
			   width:1197,
    		   height:655,
			   'margin-left':0,
			   'margin-top':0
			});
			self._model.splash_object.getElement('img').setStyles({
    		   width:1197,
    		   height:655
    		});
			self._model.fadetext.setStyle('opacity',1);
			self._model.bundle_object.setStyle('opacity',1);
         }
         


			self._model.player_object.setStyle('display', 'none');
    },
    _which: function(){
        var window_size = $(window).getSize();
        if (window_size.y < 710) {
            return "Horizontal"
        } else {
            return "Vertical";
        }
    }
});VZT.BootStrapper = {
    init: function(){
       VZT.AppCore = new VZT.appcore();

        /*this._setup_loader();
        this._setup_splash();
        this._setup_navigation();*/
        this._setup_flash();
	  this._setup_tooltip();
        this.createButtons();
        this._setup_modal();
		
		//Tim start
        VZT.AppCore.Events.addEvent("content_loaded", function(){
            if ($('recentlyviewed')!= null) {
		VZTP.RecentlyViewed.init();
                }
                else {
                                                                                                                
                //alert('two');
                                                                                                                
                }
                                                                                                
       });
        //Tim end

		
		
        this. _setup_video();
        /*this._setup_tooltip();
        this._setup_channels();
        this._setup_tabs();


       if(!(Browser.Engine.trident && Browser.Engine.version < 3.1))
            var addthishandler = new VZT.addthisHandler();

       VZT.AppCore.Events.addEvent("content_loaded", function(){
            VZT.EquipRecommenderHandler.bind($("mc"));
       });
       VZT.AppCore.Events.addEvent("content_unloaded", function(){
            VZT.EquipRecommenderHandler.unbind($("mc"));
       });

        //this needs to get moved into a new class, but time is the enemy here,
       VZT.AppCore.Events.addEvent('request_channels', function(){
                if($("na_error_frame")!==null)
                    $("na_error_frame").addClass("hidden");
                if( $("view_region_box") !== null)
                    $("view_region_box").removeClass("hidden");
       }.bind(this));
       VZT.AppCore.Events.addEvent('fios_unavail', function(){
                if($("na_error_frame")!==null)
                    $("na_error_frame").removeClass("hidden");
        }.bind(this));*/


    },
		createButtons: function(){
        //if(addthis != undefined && addthis !=null) {
            try{
                addthis.button(".share");
            } catch (e) {
                //alert(e);
            }
        //}
    },

    _setup_tabs: function(){
        var views = [];
        var contentloaded = function() {
            var wrappers = $$('.mc')[0].getElements('[class*=tabs::]');
             views.each(function(view) {
                    view.unbind();
             });
             wrappers.each(function(wrapper,i) {
                 var p = VZT.Parser.parse(wrapper.get('class'),'tabs');
                 var data = $$('.'+p['set']);
                 var controller = new VZT.TabsetController();
                 views.push(new VZT.TabsetView(wrapper,data,controller));
            });
        };
        VZT.AppCore.Events.addEvents({
            'content_loaded':function(){
                contentloaded();
            },
            'channels_loaded':function() {
                contentloaded();
            },
            'content_unloading':function() {
                views.each(function(view) {
                    view.unbind();
                });
            }
        });

        var curtainView = null;
        VZT.AppCore.Events.addEvents({
            'content_loaded':function(){
                var wrapper = $$('.mc')[0].getElement('[class*=tabsCurtain::]');
                if (wrapper) {
                    var p = VZT.Parser.parse(wrapper.get('class'),'tabsCurtain', {height: 500});
                    var data = $$('.'+p['set']);
                    var height = p['height'];

                    var controller = new VZT.TabsetCurtainController();
                    curtainView = new VZT.TabsetCurtainView(wrapper,data,controller,height);
                    if(p["starttab"] !== null)
                    {
                        controller.go(p["starttab"]) ;
                    }
                }
            },
            'content_unloading':function() {
                if (curtainView) {
                    curtainView.unbind();
                }
            }
        });
    },
    _setup_channels: function(){
       VZT.CompareChannelsHandler.init();
       VZT.AppCore.Events.addEvents({
            'content_loaded':function(){
                VZT.CompareChannelsHandler.bind($('mc'));

            },
            'content_unloading':function() {
                VZT.CompareChannelsHandler.unbind($('mc'));
            }
       });

        VZT.ChannelsDataHandler.init();
        VZT.AppCore.Events.addEvents({
            'content_loaded':function(){
                var cm = $$('.channels_module');
                if (cm[0]) {
                  VZT.ChannelsDataHandler.bind(cm[0]);
                }
            }
        });

        var vztprice = new VZT.price_toggler();

        var view = null;
        var channel_interface= null;
        VZT.AppCore.Events.addEvents({
            'content_loaded':function(){
                var toolbar = $$('.toolbar_channels');
                if (toolbar[0]) {
                    channel_interface = new VZT.ToolbarController();
                    view = new VZT.ToolbarView(toolbar[0], channel_interface);
                }
            },
            'content_unloading':function() {
                if (view) {
                    view.unbind();
                }
            }
        });
    },
    _setup_tooltip: function(){
        var wrap2 = new Element('div',{
            'class':'vzt'
        });
        wrap2.innerHTML = VZT.Skins.Tooltip.DEFAULT;
        document.body.adopt(wrap2);
        VZT.Skins.Tooltip.DEFAULT = wrap2.getFirst();
        var tooltip = new VZT.TooltipHandler();
    },
    _setup_splash: function(){
        var splashanimatormodel = {
            bundle_object: $("bundle"),
            splash_object: $("splash"),
            txt_object: $("uc_txt"),
            player_object: $("uc_player"),
            container_object: $("hc"),
            container_object_wrapper: $("hcw"),
            content_object: $("mc"),
            under_object_wrapper: $('ucw'),
            menu_object: $("smw"),
            footer_object: $("footer"),
            fadetext: $("fadeaway")
        };
        var splashmodel = {
            bundle: $("bundle"),
            splash_text: $("splash_text"),
            splash_img: $("splash_img"),
            under_content: $("ucw"),
            splash: $("splash"),
            hc: $("hc"),
            vertical: {
                bundle_img: configuration.vertical.bundle_img,
                splash_text: configuration.vertical.splash_text,
                splash: configuration.vertical.splash
            },
            horizontal: {
                 bundle_img: configuration.horizontal.bundle_img,
                splash_text: configuration.horizontal.splash_text,
                splash: configuration.horizontal.splash
            }

        }
        var splashanimaview = new VZT.SplashAnimationView(splashanimatormodel);
        var splashanima = new  VZT.SplashAnimationHandler(splashanimatormodel, splashanimaview);
        if(Browser.Engine.trident && Browser.Engine.version < 3)
            var splashsize = new VZT.SplashSizeHandler(splashmodel);
    },

    _setup_video: function(){
        var video_view = new VZT.VideoContainerView();
        var video_model = {
            aspect: {width: 16, height: 9}
        }
        var video_manager = new VZT.VideoHandler({
            model: video_model,
            view: video_view
        });
    },

    _setup_navigation: function(){
        var dynalink = new VZT.AjaxLink();
        var model = {
            container_object: $("hc"),
            content_object: $("mc")
        };
        var pageview = new VZT.PageLoaderView(model);
        var pageloader = new VZT.PageLoader({view: pageview, model: model});

        var submenu = new VZT.SubMenuView({
            under_object: $("splash"),
            container_object: $('hc'),
            click_class: "smselected",
            menu: $("smw")
        });
        var ih = new VZT.InputHandler();
        var navview = new VZT.FooterNavView($('minimap'));
        var navhandler = new VZT.FooterNavHandler(navview);
    },

    _setup_flash: function(){
        VZT.flash_checker.init();
        try
        {
        if(swfobject.hasFlashPlayerVersion("10")){
            VZT.features_marquee.init();
        }
        }
        catch(e)
        {}
    },

    _setup_loader: function(){
        VZT.HeroLoader.initialize();
        VZT.HeroLoader.show();
        setTimeout(function() {
            VZT.HeroLoader.hide();
        },300);

    },
    _setup_modal: function(){
        var wrap = new Element('div', {
            'class':'vzt'
						
        }); 

        wrap.innerHTML = VZT.Skins.Modal.DEFAULT;
        var skin = wrap.getFirst();
        document.body.adopt(wrap);
        VZT.Skins.Modal.DEFAULT = skin;

        VZT.ModalHandler.init();
        VZT.AppCore.Events.addEvents({
            'content_loaded':function(){
                VZT.ModalHandler.bind($('mc'));
				VZT.ModalHandler.bind($('hcw'));
				VZT.ModalHandler.bind($('tn_mv'));
				VZT.ModalHandler.bind($('menu'));

            },
            'content_unloading':function() {
                VZT.ModalHandler.unbind($('mc'));
				VZT.ModalHandler.unbind($('hcw'));
				VZT.ModalHandler.unbind($('tn_mv'));
				VZT.ModalHandler.unbind($('menu'));
            }
        });
				VZT.ModalHandler.bind($('mc'));
				VZT.ModalHandler.bind($('hcw'));
				VZT.ModalHandler.bind($('tn_mv'));
				VZT.ModalHandler.bind($('menu'));
    }
};

window.addEvent('domready', function() {
    VZT.BootStrapper.init();
});   
window.addEvent('domready', function() {	
	VZT.AppCore.Animations.loadAnimation(
	    new VZT.Animation({
			name: "generic_fade",
			startMethod: function(object, args){

                var start = 1;
							
				this.fxObject = new Fx.Tween(object, {});
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;

                if(args.start != null)
                    start = args.start ;
							
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
							
				this.fxObject.start('opacity', [start, 0]);
			
			},
			endMethod: function(object, args){},
			revertMethod: function(object, args){
                var start = 1;

				this.fxObject = new Fx.Tween(object, {});
				if(args.duration != null)
						this.fxObject.options.duration = args.duration;

                if(args.start != null)
                    start = args.start;
								
				if(args.transition != null)
						this.fxObject.options.transition = args.transition;
								
				this.fxObject.start('opacity', [0, start]);
			}
	    })
	);
});
window.addEvent('domready', function() {	
	VZT.AppCore.Animations.loadAnimation(
	    new VZT.Animation({
			name: "generic_scroll",
			startMethod: function(object, args){
					
				this.fxObject = new Fx.Scroll(object);
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
					
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
					
				this.fxObject.start(args.x, args.y);
	
			},
			endMethod: function(object, args){},
			revertMethod: function(object, args){
				this.fxObject = new Fx.Scroll(object);
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
					
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
					
				this.fxObject.start(args.x, args.y);
			}
	    })
	);
});window.addEvent('domready', function() {	
    VZT.AppCore.Animations.loadAnimation(
		new VZT.Animation({
			name: "menu_border",
			startMethod: function(object, args){
				
			this.fxObject = new Fx.Elements([object], {});
			
			if(args.duration != null)
				this.fxObject.options.duration = args.duration;
			
			if(args.transition != null)
				this.fxObject.options.transition = args.transition;
			
			this.fxObject.start({
				'0': {
					'border-top-color': ['#AAA','#FFF'],
					'border-bottom-color': ['#FFF','#AAA']
				}
			});

			},
			endMethod: function(object, args){},
			revertMethod: function(object, args){
				this.fxObject = new Fx.Tween(object, {});
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
				
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
				
				this.fxObject.start('height', [args.endheight, args.startheight]);
			}
		})
	);
});window.addEvent('domready', function() {	
	VZT.AppCore.Animations.loadAnimation(
		new VZT.Animation({
			name: "generic_resize",
			startMethod: function(object, args){
				
				this.fxObject = new Fx.Tween(object, {});
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
				
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;

                if(args.attrib == null)
                    args.attrib = "height";

				this.fxObject.start(args.attrib, [args.startheight, args.endheight]);

			},
			endMethod: function(object, args){},
			revertMethod: function(object, args){
				this.fxObject = new Fx.Tween(object, {});
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
				
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
				
				this.fxObject.start('height', [args.endheight, args.startheight]);
			}
		})
	)
});window.addEvent('domready', function() {	
	VZT.AppCore.Animations.loadAnimation(
		new VZT.Animation({
			name: "splash_fly",
			startMethod: function(object, args){
				
				
				var window_size = $(window).getSize();
				leftstart = (window_size.x - 1199)/2;
				leftend = (((window_size.x - 1032 )/2) + 570);
				
				$('splash_img').setStyle('display', 'inline');
				
				this.fxObject = new Fx.Elements([object, $('splash_img')], {});
				
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
				
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
				var heigth = object.getStyle('height');
				this.fxObject.start({
					'0': {
						'margin-left': [args.left.start, args.left.end],
						'width': [args.width.start, args.width.end],
						'height': [args.height.start, args.height.end],
						'margin-top': [args.top.start, args.top.end]
					},
					'1': {
						'width': [args.width.start, args.width.end],
						'height': [args.height.start, args.height.end]
					}
				});
				
			},
			endMethod: function(object, args){},
			revertMethod: function(object, args){
				var window_size = $(window).getSize();
				leftstart = (window_size.x - 1199)/2;
				leftend = (((window_size.x - 1032 )/2) + 570);
				
				$('splash_img').setStyle('display', 'inline');
				
				this.fxObject = new Fx.Elements([object, $('splash_img')], {});
				
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
				
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
				var heigth = object.getStyle('height');
				this.fxObject.start({
					'0': {
						'margin-left': [args.left.end, args.left.start],
						'width': [args.width.end, args.width.start],
						'height': [args.height.end, args.height.start],
						'margin-top': [args.top.end, args.top.start]
					},
					'1': {
						'width': [args.width.end, args.width.start],
						'height': [args.height.end, args.height.start]
					}
				});
			}
		})
	);
});window.addEvent('domready', function() {	
	VZT.AppCore.Animations.loadAnimation(
	    new VZT.Animation({
			name: "generic_colorchange",
			startMethod: function(object, args){
						
				this.fxObject = new Fx.Tween(object, {});
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
							
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
				
				
				
				if(args.type != null && args.type == "foreground") {
				
					this.fxObject.start('color', [args.start_color, args.end_color]);
				} else {
					
					this.fxObject.start('background-color', [args.start_color, args.end_color]);
				}
			},
			endMethod: function(object, args){},
			revertMethod: function(object, args){
				
				this.fxObject = new Fx.Tween(object, {});
				if(args.duration != null)
					this.fxObject.options.duration = args.duration;
							
				if(args.transition != null)
					this.fxObject.options.transition = args.transition;
				
				if(args.type != null && args.type == "foreground")
					this.fxObject.start('color', [args.end_color, args.start_color]);
				else
					this.fxObject.start('background-color', [args.end_color, args.start_color]);
			}
	    })
	);
});

