/**
* Eduweb, http://eduweb.pl
* Copyright (c)2009, CSD
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright       		Grzegorz Rog
* @backenddeveloper		_
* @frontedndeveloper		Krzysztof Safjanowski
* @license         		http://www.opensource.org/licenses/mit-license.php The MIT License
*/

/*
* jQuery v1.3.2
*/

$(window).load(function() {
    /*
    * lava lamp
    */
    if ($('#menu > .container > ul > li.current').length > 0) {
        $('#menu ul').currentPosition(
		{
		    fx: "backout",
		    speed: 400,
		    current: true
		});
    }
    else {
        $('#menu ul').currentPosition(
		{
		    fx: "backout",
		    speed: 400,
		    current: false
		});
    }
});

$(function() {
    /*
    * menu i submenu
    */
    if ($('#menu > .container > ul > li > a.active').length > 0) {
        $('#submenu > .container > ul').replaceWith($('#menu > .container > ul > li > a.active').next().clone());

        /* ??? */
        $('#menu, #submenu').hover(function() {
            $(this).addClass('eHover');
        }, function() {
            $(this).removeClass('eHover');
        });

        window.setInterval(function() {
            if ($('#menu').hasClass('eHover') || $('#submenu').hasClass('eHover')) {
            }
            else {
                $('#menu > .container > ul > li').removeClass('current');
                $('#menu > .container > ul > li > a').removeClass('active');
                $('#menu > .container > ul > li > a.tmpActive').addClass('active').parent().addClass('current');
                $('#menu > .container > ul > li > a.active').trigger('mouseover');
                $('#submenu > .container > ul').replaceWith($('#menu > .container > ul > li > a.active').next().clone());
            }
        }, 2000);
    }
    else {
        $('#submenu .container').append('<ul><li><a href="#"><span>&nbsp;</span></a></li></ul>');
    }

    $('#menu > .container > ul > li > a').hover(function(e) {
        e.preventDefault();
        $('#menu > .container > ul > li').removeClass('current');

        if ($(this).hasClass('active')) {
        }
        else {
            $('#menu > .container > ul > li > a').removeClass('active');
            $(this).addClass('active');
            $('#submenu > .container > ul').replaceWith(($(this).next().clone()).fadeIn());
        }
    });

    /*
    * efekt toggle dla listy kursow
    */
    $('#main-courses li div.header').click(function(e) {
        e.preventDefault();
        $(this).next().slideToggle('slow');
        $(this).parent().toggleClass('details');
    }).next().hide();

    /* rozwiniecie pierwszej pozycji menu */
    $('#main-courses li').removeClass('details').find('div.header').next().hide();
    $('#main-courses li:first').addClass('details').find('div.header').next().show();

    /*
    * proces zamowienia
    */
    $('#main-order-buy-packets-details, #main-order-choice-version-dvd-details, #main-order-choice-version-on-line-details, .main-order-choice-version-address-invoice').hide();

    /* zebra */
    $('#main-order-buy-packets-details tr:even').addClass('even');



    $('#main-order-buy-packets').click(function(e) {

        var value = $('#main-order-buy-packets-details').is(":visible");

        if (value) {
            $('#main-order-buy-packets-details').hide();

        } else {
            $('#main-order-buy-packets-details').show();
        }
    });

    /* wersja on-line */
    $('#main-order-choice-version-on-line').click(function(e) {
        if (isOnlineAvailable()) {
            e.preventDefault();
            $(this).removeClass('disable');
            $('#main-order-choice-version-dvd').addClass('disable');
            $('#main-order-choice-version-dvd-details, #main-order-choice-version-on-line-details, .main-order-choice-version-address-invoice').hide();
            $('#main-order-choice-version-dvd-details').hide();
            $('#main-order-choice-version .box .price').hide('slow');
            $('#main-order-choice-version-on-line-details').slideDown();
        }
    });
    

    /* dane do faktury */
	$( '#main-order-choice-version-address-invoice-check input' ).click( function()
	{
		$('.main-order-choice-version-address-invoice' ).toggle('slow');
	});
	$( '#main-order-choice-version-address-invoice-dvd-check input' ).click( function()
	{
		$( '.main-order-choice-version-address-invoice-dvd' ).toggle('slow');
	});

    $('.main-order-login-panel').hide();
    
    //ukryj zmodyfikowane ceny zakupu dla dvd
    $('.main-order-choice-version-promotion-for-dvd-base').show();
    $('.main-order-choice-version-promotion-for-dvd-with-support').hide();
    $('.main-order-choice-version-promotion-for-dvd-with-case').hide();
    $('.main-order-choice-version-promotion-for-dvd-with-support-case').hide();
    
    //ukryj zmodyfikowane ceny zakupu dla online
    $('.main-order-choice-version-promotion-for-online-with-support').hide();

   
    /*zmiana cena wraz z supportem dla ver online*/
    $('.main-order-choice-version-promotion-for-online').click(function(e) {

        var value = $('.main-order-choice-version-promotion-for-online-with-support').is(":visible");

        if (value) {
            $('.main-order-choice-version-promotion-for-online-with-support').hide();
            $('.main-order-choice-version-promotion-for-online-no-support').show();
        } else {
            $('.main-order-choice-version-promotion-for-online-with-support').show();
            $('.main-order-choice-version-promotion-for-online-no-support').hide();
        }
    });


    /* show hide box */
    $('.main-order-is-old-client').click(function(e) {
        $('.main-order-login-panel').show();
    });

    $('.main-order-is-new-client').click(function(e) {
        $('.main-order-login-panel').hide();
    });  
   
    
    /* wybor pakietow */
    $('#main-order-choise-packets table tbody tr:even,').addClass('even');

    /* wybor kursow */
    $('#main-order-choise-courses table tbody tr:even,').addClass('even');

    /*
    * Moje Eduweb
    */
    $('#main-private-support-messages li:even').addClass('even');

    /*
    * Fancybox
    */
    $('a.iframe1024').fancybox(
	{
	    'zoomOpacity': true,
	    'zoomSpeedIn': 500,
	    'zoomSpeedOut': 500,
	    'overlayShow': true,
	    'frameWidth': 800,
	    'frameHeight': 645,
	    'hideOnContentClick': false
	});
    $('a.iframe1280').fancybox(
	{
	    'zoomOpacity': true,
	    'zoomSpeedIn': 500,
	    'zoomSpeedOut': 500,
	    'overlayShow': true,
	    'frameWidth': 1055,
	    'frameHeight': 840,
	    'hideOnContentClick': false
	});

    /*
    * focus i blur na elementarz formularza
    */
    var sSidebarNewsletterEmail = $('#sidebar-newsletter-email').val();
    var sFooterPropositionEmail = $('#footer-proposition-email').val();
    var sFooterPropositionMessage = $('#footer-proposition-message').val();

    // :focus
    $('#sidebar-newsletter-email').focus(function() {
        if (($(this).val()) == sSidebarNewsletterEmail) {
            $(this).val('');
        }
    });

    $('#footer-proposition-email').focus(function() {
        if (($(this).val()) == sFooterPropositionEmail) {
            $(this).val('');
        }
    });

    $('#footer-proposition-message').focus(function() {
        if (($(this).val()) == sFooterPropositionMessage) {
            $(this).val('');
        }
    });

    // :blur
    $('#sidebar-newsletter-email').blur(function() {
        if (($(this).val()) == sSidebarNewsletterEmail || ($(this).val()) == '') {
            $(this).val(sSidebarNewsletterEmail);
        }
    });

    $('#footer-proposition-email').blur(function() {
        if (($(this).val()) == sFooterPropositionEmail || ($(this).val()) == '') {
            $(this).val(sFooterPropositionEmail);
        }
    });

    $('#footer-proposition-message').blur(function() {
        if (($(this).val()) == sFooterPropositionMessage || ($(this).val()) == '') {
            $(this).val(sFooterPropositionMessage);
        }
    });
	});

/*
* SWFObject v2.1
*/

/*
var flashvars = {};
var params = {
wmode: "opaque",
menu: "false" 
};
var attributes = {};

swfobject.embedSWF("swf/brands.swf", "brands-container", "959", "400", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
*/
