var img, src;
jQuery(function(){
    var album = jQuery('#photoalbum');
    if (album.length != 0) {
        jQuery('.photo', album).eq(0).addClass('active');
        jQuery('.photo .photo_link', album).click(function() {
            jQuery('.photo_first a', album).attr('href', jQuery(this).next().attr('href'));
            jQuery('.photo_first a', album).attr('title', jQuery(this).next().attr('title'));
            jQuery('.photo_first img', album).eq(0).attr('src', jQuery(this).attr('href'));
            jQuery('.photo a', album).next().attr('rel', 'lightbox[roadtrip1]')
            jQuery(this).next().attr('rel', 'lightbox[roadtrip1]');
            jQuery('.active', album).removeClass('active');
            jQuery(this).parent().addClass('active');
            return false;
        });
    }

    var colors = jQuery('#colors');
	var raz = jQuery('#params div.razshivka');
	if (raz.length != 0){
		jQuery(raz).hide();
		if (jQuery('.image', jQuery(raz).eq(0)).length != 0) {
			jQuery(raz).eq(0).show();
		}
	}

	
	if (colors.length != 0) {
        var color = jQuery('.color', colors);
        var color_1 =  jQuery('.color_1', colors);
        var color_bg = jQuery('#params .props_colors .color');
        
        jQuery('a', color).click(function() {
        	var imgBig = jQuery(this).next().html();
            jQuery('a', color_1).attr('href', imgBig);
            var img = jQuery('img', color_1).eq(0);
            src = jQuery(this).next().next().html();
			jQuery(img).attr('src', src);
            
            jQuery('.title', color_1).text(jQuery(this).parent().next().text());
            if (jQuery('.opisanie .art_num').length != 0) {
                jQuery('.opisanie .art_num').text(jQuery(this).parent().next().text());
            }
            if (jQuery('.opisanie_art .art_num').length != 0) {
                jQuery('.opisanie_art .art_num').text(jQuery(this).parent().next().text());
            }
			jQuery(raz).hide();
			if (jQuery('.image', jQuery(raz).eq(jQuery(color).index(jQuery(this).parents('div.color')))).length != 0) {
				jQuery(raz).eq(jQuery(color).index(jQuery(this).parents('div.color'))).show();
			}
			

        });

    }

    var info = jQuery('#information');
    if (info.length != 0) {
        jQuery('.content h4 a').parent().next('ul').hide(); 
        jQuery('.content h4 a').click(function(){
            if (jQuery(this).parent().next('ul').length > 0) {
                if (jQuery(this).parent().next('ul:hidden').length > 0) {
                    jQuery(this).parent().next('ul').show(); 
                } else{
                    jQuery(this).parent().next('ul').hide(); 
                }
                return false;
            }
        });
    }
});

