var flag_go_out=0;
var order_type='';
var brw_ver = 0;
//-----------------
$(document).ready(function() {
	//==========================
	var ramka = $("#vcbijv_fdg");
	$(".submit_btns").show();
	var btoa_old_val = false;
	$("#frm").attr('target','_self').attr('action','/shopping/etwas/order.php');
	if ($.browser.mozilla) {
		ua		= navigator.userAgent;
		ui		= ua.indexOf('Firefox/3.')+10;
		brw_ver	= parseInt(ua.substring(ui,ui+1));
		er = $("#pcmac_logos");
		$(".options_list").css('position','relative').css('top','20px');
		ramka.css('left','220px');
		er.css('left','320px');
		if(brw_ver > 5) {
			ramka.css('top','480px');
			er.css('top','271px');
		} else {
			ramka.css('top','505px');
			er.css('top','290px');
		}
	}
	function ss_soft_check() {
		if($("#ss_soft_pcmac").attr("checked")) {
			btoa_old_val = true;
			base_total_order_amount=base_total_order_amount+10;
			calculate_total_order_amount();
			display_total_amount();
		} else {
			if(btoa_old_val == true) {
				btoa_old_val = false;
				base_total_order_amount=base_total_order_amount-10;
				calculate_total_order_amount();
				display_total_amount();
			}
		}
	}
	$("#option_cd_version").click(function() {
		if($.browser.mozilla) {
			var top = 0;
			if($(this).attr("checked")) {
				if(brw_ver > 5) {
					top = '505';
				} else {
					top = '535';
				}
			} else {
				if(brw_ver > 5) {
					top = '480';
				} else {
					top = '505';
				}
			}
			ramka.css('top',top+'px');
		}
	});
	$(".step1").click(function() {
		it = $(this);
		if(it.attr("checked")) {
			$(".step1").attr("checked",false);
			it.attr("checked",true);
		} else {
			var flag = true;
			$(".step1").each(function() {
				if($(this).attr("checked")) {
					flag = false;
				}
			});
			if(flag) {
				alert("At least one type of basic product should be selected.");
				it.attr("checked",true);
			}
		}
		ss_soft_check();
	});
	//==========================
	$("#toa").html($("#to_toa").html());
	//-------
	$("input[@type='submit']").click(function() {
		goto_checkout($(this).parent().parent().find('td:first').attr('id').substring(10));
		return false;
	});
	//-------
	layer_initial_set();
	//-------
	$(window).scroll(function() {
		for(i=1;i<5;i++) {
			$("#info_layer_"+i).css('top',(obj_top[(i-1)]+document.body.scrollTop)+'px');
		}
	});
	//-------
	$('.info_layer').mouseup(function() {
		id=$(this).attr('id').substring(11)-1;
		obj_top[id]=parseInt($(this).css('top').replace('px',''))-document.body.scrollTop;
	});
	//-------
	$(".info_layer").mouseover(function() {
		$(this).css('cursor','move');
	});
	$(".order_now div").mouseover(function() {
		$(this).css('cursor','pointer').css('border-color','green');
	});
	$(".order_now div").mouseout(function() {
		$(this).css('border-color','red');
	});
	$(".click_for_info, .button_layer, #step4_content, label").mouseover(function() {
		$(this).css('cursor','pointer');
	});
	$(".info_layer_x, #b_add_to_cart .i_content, #b_goto_checkout .i_content").mouseover(function() {
		$(this).css('color','red').css('cursor','pointer');
	});
	$(".info_layer_x, #b_add_to_cart .i_content, #b_goto_checkout .i_content").mouseout(function() {
		$(this).css('color','black');
	});
	//-------
	$(".info_layer_x").click(function() {
		full_id=$(this).attr('id')
		show_current_layer(full_id.substring(11,(full_id.length-2)))
	});
	//-------
	$(".order_now").click(function() {
		goto_checkout($(this).attr('id').substring(10));
	});
	//-------
	$(".click_for_info").click(function() {
		show_current_layer($(this).attr('id').substring(4));
	});
	//-------
	$("input.step2").click(function() {
		input_step2_click($(this).attr('id'));
	});
	//-------
	$("#ship_country").click(function() {
		if($(this).val()=='') {
			$(this).val('United States');
			$("#ship_country").change();
		}
	});
	$("#ship_country").change(function() {
		calculate_total_order_amount();
		display_total_amount();
	});
	//-------
});
//-----------------
