/*


   Click_and_design Tools v1.0
   Copyright 2011 Whiteflame www.whiteflame.eu


*/

jQuery(document).ready(function(){



			var options = {
			  //target: "#header  > *",
			  success: function() {
			  
					if(!jQuery("body").find("#TB_overlay").is("div"))  {/* если фон уже добавлен не добавляем повторно */
					
					   if(!jQuery.browser.msie) /* если браузер не ИЕ фоном будет div */

					   jQuery("body").append("<div id='TB_overlay'></div>");

					   else /* иначе добавляем iframe */

					   jQuery("body").append("<div id='TB_overlay'><iframe scrolling='no' frameborder='0' style='position: absolute; top: 0; left: 0; width: 100%; height: 100%; filter:alpha(opacity=0)'></iframe></div>");

					} else {
						$("#TB_overlay").show();
					}
			  
			  
			  
					jQuery('#header').load('/shopping_cart/ #header > *');
					jQuery('#cart_info').show();	
					setTimeout(function() {
						jQuery('#cart_info').hide();
						jQuery('#TB_overlay').hide();
							}, 3000);
			  }
			};
			jQuery("#linenForm").ajaxForm(options);
			//$("[name = multiple_products_cart_quantity]").ajaxForm(options);
			//$("[name = cart_quantity]").ajaxForm(options);


 
});


function Class_69 () {

    this.categories_id = 110;
    this.style = 'nostyle';
    this.design = 'nodesign';
    this.bodycolor = 'nobodycolor';
    this.pipingcolor = 'nopipingcolor';
	
    this.set_category = set_category;       
    this.set_style = set_style;       
    this.set_design = set_design;       
    this.set_bodycolor = set_bodycolor;       
    this.set_pipingcolor = set_pipingcolor;       
    this.load_default = load_default;       
    this.change_style = change_style;       
    this.change_design = change_design;       
    this.change_bodycolor = change_bodycolor;       
    this.change_pipingcolor = change_pipingcolor;       
    this.change_final_image = change_final_image;       

}

function set_category(categories_id) {
    this.categories_id = categories_id;
}

function set_style(style) {
    this.style = style.replace(" ", "_");
}

function set_design(design) {
    this.design = design.replace(" ", "_");
}

function set_bodycolor(bodycolor) {
    this.bodycolor = bodycolor.replace(" ", "_");
}

function set_pipingcolor(pipingcolor) {
    this.pipingcolor = pipingcolor.replace(" ", "_");
}

function load_default() {

	$('.style69').hide();
	$('.design69').hide();
	$('.bodycolor69').hide();
	$('.pipingcolor69').hide();

	$('#style69_'+this.categories_id).show();
	$('#design69_'+this.categories_id).show();
	$('#bodycolor69_'+this.categories_id).show();
	$('#pipingcolor69_'+this.categories_id).show();

}

function change_style (name, styles_id, final_title, options_id) {
	
	//var categories_id = 110;
	$('#style_final').html('<div class="final-duvet-style"><div style="float: left;">1. '+final_title+'</div><div style="text-align: right;" id="final-duvet-style">'+name+'</div></div>');
	$('.item_style_title').removeAttr('style');
	$('#style_'+name).attr('style', 'color:#872D20;');
	$('#design69_'+this.categories_id).load('/index.php?ajax=click_and_design&action=change_style&categories_id='+this.categories_id+'&styles_id='+styles_id);
	$('#69products_form').load(
	  '/index.php?main_page=index&cPath=69&styles_id='+styles_id+' #69products_form > *',
	  {
		categories_id: this.categories_id
	  },
	  set_69style_attributes (options_id, styles_id)
	);
	$('#bodycolor69_'+this.categories_id).text('');
	$('#pipingcolor69_'+this.categories_id).text('');
	$('#design_final').html('');
	$('#bodycolor_final').html('');
	$('#acolor_final').html('');
	
	this.set_style(name);
	this.design = 'nodesign';
    this.bodycolor = 'nobodycolor';
    this.pipingcolor = 'nopipingcolor';
	
	this.change_final_image();

}

function change_design (name, design_id, final_title, options_id) {
	var categories_id = this.categories_id;
	$('#design_final').html('<div class="final-duvet-style"><div style="float: left;">2. '+final_title+'</div><div style="text-align: right;" id="final-duvet-design">'+name+'</div></div>');
	//$('#final-duvet-design').text(name);
	$('.item_design_title').removeAttr('style');
	$('#design_'+name).attr('style', 'color:#872D20;');
	$('#bodycolor69_'+categories_id).load('/index.php?ajax=click_and_design&action=change_design&categories_id='+categories_id+'&design_id='+design_id);
	$('#pipingcolor69_'+categories_id).load('/index.php?ajax=click_and_design&action=change_bodycolor&categories_id='+categories_id+'&design_id='+design_id);
	//$('#pipingcolor69').load('/index.php?ajax=click_and_design&action=change_bodycolor');
	//set_69attributes (379, 1, 7);
	$('#bodycolor_final').html('');
	$('#acolor_final').html('');
	set_69design_attributes(options_id, design_id);
	this.set_design(name);
    this.bodycolor = 'nobodycolor';
    this.pipingcolor = 'nopipingcolor';
	this.change_final_image();
	//$('.item_bodycolor_title').removeAttr('style');
	//$('.item_pipingcolor_title').removeAttr('style');
}

function change_bodycolor (color, design_id, bodycolor_id, hex_color, final_title, options_id) {
	var categories_id = this.categories_id;
	$('#bodycolor_final').html('<div class="final-duvet-style"><div style="float: left;">3. '+final_title+'</div><div style="text-align: right; padding-right:15px;" id="final-duvet-bodycolor">'+color+'</div><div class="final-color-hex" id="final-duvet-bodycolor-hex">&nbsp;</div></div>');
	
	//$('#final-duvet-bodycolor').text(color);
	$('.item_bodycolor_title').removeAttr('style');
	//$('.item_pipingcolor_title').removeAttr('style');
	$('#final-duvet-bodycolor-hex').attr('style', 'background-color:'+hex_color+';');
	color = color.replace(/\s/, '_');
	$('#bodycolor_'+color).attr('style', 'color:#872D20;');
	$('#pipingcolor69_'+categories_id).load('/index.php?ajax=click_and_design&action=change_bodycolor&categories_id=110&design_id='+design_id+'&bodycolor_id='+bodycolor_id);
	$('#acolor_final').html('');
	this.set_bodycolor(color);
    this.pipingcolor = 'nopipingcolor';
	this.change_final_image();
	set_69bodycolor_attributes(options_id, bodycolor_id);
}

function change_pipingcolor (bodycolors_id, color, hex_color, final_title, options_id) {
	var categories_id = this.categories_id;
	$('#acolor_final').html('<div class="final-duvet-style"><div style="float: left;">4. '+final_title+'</div><div style="text-align: right; padding-right:15px;" id="final-duvet-pipingcolor">'+color+'</div><div class="final-color-hex" id="final-duvet-pipingcolor-hex">&nbsp;</div></div>');
	//$('#final-duvet-pipingcolor').text(color);
	$('.item_pipingcolor_title').removeAttr('style');
	$('#final-duvet-pipingcolor-hex').attr('style', 'background-color:'+hex_color+';');
	color = color.replace(/\s/, '_');
	$('#pipingcolor_'+color).attr('style', 'color:#872D20;');
	if (this.bodycolor == 'nobodycolor') this.set_bodycolor('White');
	this.set_pipingcolor(color);
	this.change_final_image();
	set_69acolor_attributes(options_id, bodycolors_id);
}

function change_final_image() {

	final_image1 = 'background-image: url(/images/click_and_design/110/final/'+this.style+'-'+this.design+'-'+this.bodycolor+'-'+this.pipingcolor+'.gif)';

	$('#final_image').attr('style', final_image1);

}
