/*
 * Copyright 2000-2008 namics ag. All rights reserved.
 */
/**
 * TV.Basic class.
 *
 * @author Remo Brunschwiler, namics ag
 */
TV.Basic = function(){
    this.bindBasicEvents();
};

/* ==========================================================
 * Binds the hide and show event to the genre chooser
 * ==========================================================
 */
TV.Basic.prototype.chooseGenres = function(){
    TV.$('#genre_toggle').toggle(function(){
        TV.$(this).removeClass('passive').addClass('active');
        TV.$('#genre_hidden').show();
    }, function(){
        TV.$(this).removeClass('active').addClass('passive');
        TV.$('#genre_hidden').hide();
    });
};

/* ==========================================================
 * Set search action
 * ==========================================================
 */
TV.Basic.prototype.setSearchAction = function() {
	TV.$('.hr_search_options input').click(function() {
		var $form = TV.$(TV.$(this).parents('form')[0]);
		if (TV.$(this).val() == 'sf_all') {
			$form.attr('action', 'http://www.suche.sf.tv/');
		}
		else {
			$form.attr('action', 'http://www.tvprogramm.sf.tv/q/');
			$form.find('.hr_search').attr('name', 'query');
		}
	});
};

/* ==========================================================
 * Trigger login lightbox
 * ==========================================================
 */
TV.Basic.prototype.triggerLogin = function() {
	TV.$('.login').click(function() {

        // trigger the login with the YMC jQuery version
		var $login = jQuery('.sflogin-button_out');

        $login.trigger('click');

        if($login.length > 0) {
            return false;
        }
	});
};


/* ==========================================================
 * Binds the events
 * ==========================================================
 */
TV.Basic.prototype.bindBasicEvents = function(){
    var that = this;
    TV.$(document).ready(function(){
        that.chooseGenres();
		that.setSearchAction();
        that.triggerLogin();
	});
};



