/**
 * This file is part of the sinersis proyect.
 * (c) 2010 RADMAS S.L. Rad(+) Technologies
 * (c) 2010 SINERSIS ESTRATEGIAS DE DISTRIBUCIÓN, S.A.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package     : sinersis
 * @author      : Daniel Gonzalez <daniel.gonzalez@radmas.com>
 */

$(document).ready(function() {

    /* shadowbox */
    Shadowbox.init({
        handleOversize: 'drag',
        modal: true
    });
    if ($('#flash').length > 0){
        var so = new SWFObject('../../swf/header.swf', 'flash', '990', '230', '10', '#ffffff');
        so.write('flash');
    }
    $('#send').click(function(){
        $('#form').submit();
        return false;
    });
    $('#send2').click(function(){
        $('#form2').submit();
        return false;
    });
    $('.onchange_submit').change(function(){
        $('#form').submit();
        return false;
    });
    $('#form').keypress(function(event) {
        if (event.which == '13') {
            $('#form').submit();
            return false;
        }
    });
    $('.false').click(function(){
        return false;
    });    
    $('#searchword').blur(function(){
        if($(this).val() == '' ){
            $(this).val('buscar producto');
        }
    });
    $('#searchword').focus(function(){
        if($(this).val() == 'buscar producto' ){
            $(this).val('');
        }
    });
    $('#nav li').hover(
        function () {
            $('ul', this).slideDown(0);

        },  
        function () {
            $('ul', this).slideUp(0);
        });
    $('.accordion ul').hide();
    $('.accordion p').click(function(){
        $(this).next('ul').slideToggle('slow')
        .siblings('ul:visible').slideUp('slow');
        $(this).toggleClass('active');
        $(this).siblings('p').removeClass('active');
    });
    $('#subtipo_id').change(function(){
        var location = document.location.href;
        location = location.replace(/\&fsubtype=[0-9]+/g, '');
        if ($(this).val() && ($(this).val()  != '0')){
            document.location.href = location + '&fsubtype=' + $(this).val();
        }
        else{
            document.location.href = location;
        }
        return false;
    });    
    $('.data li:even').addClass('two');    
    $('.change_image').click(function(){
        $('#list_images li').removeClass('active');
        $(this).parent().addClass('active');
        $('#target_image').attr('src', $(this).attr('href'));
        return false;
    });
});
