$(function(){

	//alert("S");
	var test_code='';
	var test_id= (Date.now())+(Math.floor(100000 + Math.random() * 900000));
	alert(test_id);
	var test_type='free';
	

	var full_name='';
	var gender='';
	var country='';
	var city='' ;
	var stay_country='';
	var stay_city='' ;
	
	var country_text='';
	var city_text='' ;
	var stay_country_text='';
	var stay_city_text='' ;
	
	var birth_date='';
	var birth_time='';
	var email='';
	var mobile='';
	var gray_1='';
	var gray_2='';
	var gray_3='';
	var gray_4='';
	var gray_5='';
	var colors1_1='';
	var colors1_2='';
	var colors1_3='';
	var colors1_4='';
	var colors1_5='';
	var colors1_6='';
	var colors1_7='';
	var colors1_8='';
	var colors2_1='';
	var colors2_2='';
	var colors2_3='';
	var colors2_4='';
	var colors2_5='';
	var colors2_6='';
	var colors2_7='';
	var colors2_8='';	
	
	var colors_sort1 ='';
	var colors_sort2 ='';
	var colors_sort3 ='';
	var colors_sort4 ='';
	
	
	var shape_1='';
	var shape_2='';
	var shape_3='';
	var shape_4='';
	var shape_5='';
	var shape_6='';	
	var shape_7='';	
	var basic_colors_1=0;
	var basic_colors_2=0;
	var basic_colors_3=0;
	var basic_colors_4=0;
	var basic_colors_sort_0=0;
	var basic_colors_sort_1=0;
	var basic_colors_sort_2=0;
	var basic_colors_sort_3=0;
	var blue_1=0;
	var blue_2=0;
	var blue_3=0;
	var blue_4=0;
	var blue_sort_0=0;
	var blue_sort_1=0;
	var blue_sort_2=0;
	var blue_sort_3=0;
	var green_1=0;
	var green_2=0;
	var green_3=0;
	var green_4=0;
	var green_sort_0=0;
	var green_sort_1=0;
	var green_sort_2=0;
	var green_sort_3=0;
	var red_1=0;
	var red_2=0;
	var red_3=0;
	var red_4=0;
	var red_sort_0=0;
	var red_sort_1=0;
	var red_sort_2=0;
	var red_sort_3=0;
	var yellow_1=0;
	var yellow_2=0;
	var yellow_3=0;
	var yellow_4=0;
	var yellow_sort_0=0;
	var yellow_sort_1=0;
	var yellow_sort_2=0;
	var yellow_sort_3=0;

	var type='';
	var end_test=0;
	var most_color=0;
	var most_color2=0;
	
	var plus_plus='';
	var plus='';
	var plus_minus='';
	var minus_minus='';
	
	var basic_colors_collect='';
	var blue_collect='';
	var green_collect='';		
	var red_collect='';	
	var yellow_collect='';	
	var basic_colors_collect_style='';
	var blue_collect_style='';
	var green_collect_style='';		
	var red_collect_style='';	
	var yellow_collect_style='';	
	
	var shape_style1='';
	var shape_style2='';
	
	var basic_colors_collect_reverse='';
	var blue_collect_reverse='';
	var green_collect_reverse='';		
	var red_collect_reverse='';	
	var yellow_collect_reverse='';	
	var basic_colors_collect_reverse_style='';
	var blue_collect_reverse_style='';
	var green_collect_reverse_style='';		
	var red_collect_reverse_style='';	
	var yellow_collect_reverse_style='';
	
	var un_regular=0;
	var un_regular_basic=0;
	var un_regular_blue=0;
	var un_regular_green=0;
	var un_regular_red=0;
	var un_regular_yellow=0;
			
	var client_opinion_val=0;
	var opinion_id=0;
	var basic_colors_repeat=0;
	var blue_repeat=0;
	var green_repeat=0;
	var red_repeat=0;
	var yellow_repeat=0;
	

	var basic_colors_row=1;
	var blue_row=1;
	var green_row=1;
	var red_row=1;
	var yellow_row=1;
	
	

	
	

$(document).on('click', '#message_btn', function(event){
	//alert("S");
	$("#message_container").hide();
});

$(document).on('click', '#voucher_button_free', function(event){
	$("#voucher_container").remove();
	test_type='free';
	//alert(test_type);
});


$(document).on('click', '#voucher_button', function(event){
	test_code=$("#voucher").val();
	//alert("test_code="+test_code);
	alert(website_url);
	$.ajax({
		url: website_url+"/ajax_check_voucher.php",
		data:{
			"voucher":$("#voucher").val()
			},
		method: "POST"
	}).done(function( data ) {
			alert(data);
			if(data=='limit'){
			$("#message_title").html("لقد وصلت للحد الاقصى من المحاولات");
			$("#message_container").show();
			
		}else if(data=='not found'){
			
			$("#message_title").html("الكود غير صحيح");
			$("#message_container").show();
			
		}else if (data=='done'){
			$("#voucher_container").remove();
			test_type='paied';
		}
		});
});


	
	
	$('#close_instruction_view').click(function(){
		$("#instruction_view").hide();
	});
	
	$("#instruction_link").click(function(){
		$("#instruction_view").show();		
		
	});
	
	$("#about_link").click(function(){
		$(".fourth_btn").click();		
		
	});

	
	
	
	
	function show_message(message_value){
		
			$('#message_background').show(0);
			$('#message').html('<p>'+message_value+'</p>');
			$('#message_box').fadeIn(200);
	}
	
	$("#message_btn").click(function(){
		$('#message_background').hide(0);
		$('#message_box').fadeOut(200);
	});

	
	///////////////////////    sort answers function    //////////////////////



	function basic_colors_sort_unregular(type) {
		
		basic_colors_sort_0='';
		basic_colors_sort_1='';
		basic_colors_sort_2='';		
		basic_colors_sort_3='';	
		

		
		if (basic_colors_1==0){
			basic_colors_sort_0=basic_colors_sort_0+','+'1';
		} if (basic_colors_2==0){
			basic_colors_sort_0=basic_colors_sort_0+','+'2';
		} if (basic_colors_3==0){
			basic_colors_sort_0=basic_colors_sort_0+','+'3';
		} if (basic_colors_4==0){
			basic_colors_sort_0=basic_colors_sort_0+','+'4';
		}

		if (basic_colors_1==1){
			basic_colors_sort_1=basic_colors_sort_1+','+'1';
		} if (basic_colors_2==1){
			basic_colors_sort_1=basic_colors_sort_1+','+'2';
		} if (basic_colors_3==1){
			basic_colors_sort_1=basic_colors_sort_1+','+'3';
		} if (basic_colors_4==1){
			basic_colors_sort_1=basic_colors_sort_1+','+'4';
		}

		if (basic_colors_1==2){
			basic_colors_sort_2=basic_colors_sort_2+','+'1';
		} if (basic_colors_2==2){
			basic_colors_sort_2=basic_colors_sort_2+','+'2';
		} if (basic_colors_3==2){
			basic_colors_sort_2=basic_colors_sort_2+','+'3';
		} if (basic_colors_4==2){
			basic_colors_sort_2=basic_colors_sort_2+','+'4';
		}

		if (basic_colors_1==3){
			basic_colors_sort_3=basic_colors_sort_3+','+'1';
		} if (basic_colors_2==3){
			basic_colors_sort_3=basic_colors_sort_3+','+'2';
		} if (basic_colors_3==3){
			basic_colors_sort_3=basic_colors_sort_3+','+'3';
		} if (basic_colors_4==3){
			basic_colors_sort_3=basic_colors_sort_3+','+'4';
		}	
	
		basic_colors_sort_0 = basic_colors_sort_0.substring(1);
		basic_colors_sort_1 = basic_colors_sort_1.substring(1);
		basic_colors_sort_2 = basic_colors_sort_2.substring(1);
		basic_colors_sort_3 = basic_colors_sort_3.substring(1);
		
	}





function blue_sort_unregular(type) {
		
		blue_sort_0='';
		blue_sort_1='';
		blue_sort_2='';		
		blue_sort_3='';	
		

		
		if (blue_1==0){
			blue_sort_0=blue_sort_0+','+'1';
		} if (blue_2==0){
			blue_sort_0=blue_sort_0+','+'2';
		} if (blue_3==0){
			blue_sort_0=blue_sort_0+','+'3';
		} if (blue_4==0){
			blue_sort_0=blue_sort_0+','+'4';
		}

		if (blue_1==1){
			blue_sort_1=blue_sort_1+','+'1';
		} if (blue_2==1){
			blue_sort_1=blue_sort_1+','+'2';
		} if (blue_3==1){
			blue_sort_1=blue_sort_1+','+'3';
		} if (blue_4==1){
			blue_sort_1=blue_sort_1+','+'4';
		}

		if (blue_1==2){
			blue_sort_2=blue_sort_2+','+'1';
		} if (blue_2==2){
			blue_sort_2=blue_sort_2+','+'2';
		} if (blue_3==2){
			blue_sort_2=blue_sort_2+','+'3';
		} if (blue_4==2){
			blue_sort_2=blue_sort_2+','+'4';
		}

		if (blue_1==3){
			blue_sort_3=blue_sort_3+','+'1';
		} if (blue_2==3){
			blue_sort_3=blue_sort_3+','+'2';
		} if (blue_3==3){
			blue_sort_3=blue_sort_3+','+'3';
		} if (blue_4==3){
			blue_sort_3=blue_sort_3+','+'4';
		}	
	
		blue_sort_0 = blue_sort_0.substring(1);
		blue_sort_1 = blue_sort_1.substring(1);
		blue_sort_2 = blue_sort_2.substring(1);
		blue_sort_3 = blue_sort_3.substring(1);
		
	}



	function green_sort_unregular(type) {
		
		green_sort_0='';
		green_sort_1='';
		green_sort_2='';		
		green_sort_3='';	
		

		
		if (green_1==0){
			green_sort_0=green_sort_0+','+'1';
		} if (green_2==0){
			green_sort_0=green_sort_0+','+'2';
		} if (green_3==0){
			green_sort_0=green_sort_0+','+'3';
		} if (green_4==0){
			green_sort_0=green_sort_0+','+'4';
		}

		if (green_1==1){
			green_sort_1=green_sort_1+','+'1';
		} if (green_2==1){
			green_sort_1=green_sort_1+','+'2';
		} if (green_3==1){
			green_sort_1=green_sort_1+','+'3';
		} if (green_4==1){
			green_sort_1=green_sort_1+','+'4';
		}

		if (green_1==2){
			green_sort_2=green_sort_2+','+'1';
		} if (green_2==2){
			green_sort_2=green_sort_2+','+'2';
		} if (green_3==2){
			green_sort_2=green_sort_2+','+'3';
		} if (green_4==2){
			green_sort_2=green_sort_2+','+'4';
		}

		if (green_1==3){
			green_sort_3=green_sort_3+','+'1';
		} if (green_2==3){
			green_sort_3=green_sort_3+','+'2';
		} if (green_3==3){
			green_sort_3=green_sort_3+','+'3';
		} if (green_4==3){
			green_sort_3=green_sort_3+','+'4';
		}	
	
		green_sort_0 = green_sort_0.substring(1);
		green_sort_1 = green_sort_1.substring(1);
		green_sort_2 = green_sort_2.substring(1);
		green_sort_3 = green_sort_3.substring(1);
		
	}



	function red_sort_unregular(type) {
		
		red_sort_0='';
		red_sort_1='';
		red_sort_2='';		
		red_sort_3='';	
		

		
		if (red_1==0){
			red_sort_0=red_sort_0+','+'1';
		} if (red_2==0){
			red_sort_0=red_sort_0+','+'2';
		} if (red_3==0){
			red_sort_0=red_sort_0+','+'3';
		} if (red_4==0){
			red_sort_0=red_sort_0+','+'4';
		}

		if (red_1==1){
			red_sort_1=red_sort_1+','+'1';
		} if (red_2==1){
			red_sort_1=red_sort_1+','+'2';
		} if (red_3==1){
			red_sort_1=red_sort_1+','+'3';
		} if (red_4==1){
			red_sort_1=red_sort_1+','+'4';
		}

		if (red_1==2){
			red_sort_2=red_sort_2+','+'1';
		} if (red_2==2){
			red_sort_2=red_sort_2+','+'2';
		} if (red_3==2){
			red_sort_2=red_sort_2+','+'3';
		} if (red_4==2){
			red_sort_2=red_sort_2+','+'4';
		}

		if (red_1==3){
			red_sort_3=red_sort_3+','+'1';
		} if (red_2==3){
			red_sort_3=red_sort_3+','+'2';
		} if (red_3==3){
			red_sort_3=red_sort_3+','+'3';
		} if (red_4==3){
			red_sort_3=red_sort_3+','+'4';
		}	
	
		red_sort_0 = red_sort_0.substring(1);
		red_sort_1 = red_sort_1.substring(1);
		red_sort_2 = red_sort_2.substring(1);
		red_sort_3 = red_sort_3.substring(1);
		
	}



	function yellow_sort_unregular(type) {
		
		yellow_sort_0='';
		yellow_sort_1='';
		yellow_sort_2='';		
		yellow_sort_3='';	
		

		
		if (yellow_1==0){
			yellow_sort_0=yellow_sort_0+','+'1';
		} if (yellow_2==0){
			yellow_sort_0=yellow_sort_0+','+'2';
		} if (yellow_3==0){
			yellow_sort_0=yellow_sort_0+','+'3';
		} if (yellow_4==0){
			yellow_sort_0=yellow_sort_0+','+'4';
		}

		if (yellow_1==1){
			yellow_sort_1=yellow_sort_1+','+'1';
		} if (yellow_2==1){
			yellow_sort_1=yellow_sort_1+','+'2';
		} if (yellow_3==1){
			yellow_sort_1=yellow_sort_1+','+'3';
		} if (yellow_4==1){
			yellow_sort_1=yellow_sort_1+','+'4';
		}

		if (yellow_1==2){
			yellow_sort_2=yellow_sort_2+','+'1';
		} if (yellow_2==2){
			yellow_sort_2=yellow_sort_2+','+'2';
		} if (yellow_3==2){
			yellow_sort_2=yellow_sort_2+','+'3';
		} if (yellow_4==2){
			yellow_sort_2=yellow_sort_2+','+'4';
		}

		if (yellow_1==3){
			yellow_sort_3=yellow_sort_3+','+'1';
		} if (yellow_2==3){
			yellow_sort_3=yellow_sort_3+','+'2';
		} if (yellow_3==3){
			yellow_sort_3=yellow_sort_3+','+'3';
		} if (yellow_4==3){
			yellow_sort_3=yellow_sort_3+','+'4';
		}	
	
		yellow_sort_0 = yellow_sort_0.substring(1);
		yellow_sort_1 = yellow_sort_1.substring(1);
		yellow_sort_2 = yellow_sort_2.substring(1);
		yellow_sort_3 = yellow_sort_3.substring(1);
		
	}





	function basic_colors_sort(type) {
		if (basic_colors_1==0){
			basic_colors_sort_0=1;
		}else if (basic_colors_2==0){
			basic_colors_sort_0=2;
		}else if (basic_colors_3==0){
			basic_colors_sort_0=3;
		}else if (basic_colors_4==0){
			basic_colors_sort_0=4;
		}

		if (basic_colors_1==1){
			basic_colors_sort_1=1;
		}else if (basic_colors_2==1){
			basic_colors_sort_1=2;
		}else if (basic_colors_3==1){
			basic_colors_sort_1=3;
		}else if (basic_colors_4==1){
			basic_colors_sort_1=4;
		}

		if (basic_colors_1==2){
			basic_colors_sort_2=1;
		}else if (basic_colors_2==2){
			basic_colors_sort_2=2;
		}else if (basic_colors_3==2){
			basic_colors_sort_2=3;
		}else if (basic_colors_4==2){
			basic_colors_sort_2=4;
		}

		if (basic_colors_1==3){
			basic_colors_sort_3=1;
		}else if (basic_colors_2==3){
			basic_colors_sort_3=2;
		}else if (basic_colors_3==3){
			basic_colors_sort_3=3;
		}else if (basic_colors_4==3){
			basic_colors_sort_3=4;
		}
	}
	
	
	function blue_sort(type) {
		if (blue_1==0){
			blue_sort_0=1;
		}else if (blue_2==0){
			blue_sort_0=2;
		}else if (blue_3==0){
			blue_sort_0=3;
		}else if (blue_4==0){
			blue_sort_0=4;
		}

		if (blue_1==1){
			blue_sort_1=1;
		}else if (blue_2==1){
			blue_sort_1=2;
		}else if (blue_3==1){
			blue_sort_1=3;
		}else if (blue_4==1){
			blue_sort_1=4;
		}

		if (blue_1==2){
			blue_sort_2=1;
		}else if (blue_2==2){
			blue_sort_2=2;
		}else if (blue_3==2){
			blue_sort_2=3;
		}else if (blue_4==2){
			blue_sort_2=4;
		}

		if (blue_1==3){
			blue_sort_3=1;
		}else if (blue_2==3){
			blue_sort_3=2;
		}else if (blue_3==3){
			blue_sort_3=3;
		}else if (blue_4==3){
			blue_sort_3=4;
		}
	}


	function green_sort(type) {
		if (green_1==0){
			green_sort_0=1;
		}else if (green_2==0){
			green_sort_0=2;
		}else if (green_3==0){
			green_sort_0=3;
		}else if (green_4==0){
			green_sort_0=4;
		}

		if (green_1==1){
			green_sort_1=1;
		}else if (green_2==1){
			green_sort_1=2;
		}else if (green_3==1){
			green_sort_1=3;
		}else if (green_4==1){
			green_sort_1=4;
		}

		if (green_1==2){
			green_sort_2=1;
		}else if (green_2==2){
			green_sort_2=2;
		}else if (green_3==2){
			green_sort_2=3;
		}else if (green_4==2){
			green_sort_2=4;
		}

		if (green_1==3){
			green_sort_3=1;
		}else if (green_2==3){
			green_sort_3=2;
		}else if (green_3==3){
			green_sort_3=3;
		}else if (green_4==3){
			green_sort_3=4;
		}
	}

	function red_sort(type) {
		if (red_1==0){
			red_sort_0=1;
		}else if (red_2==0){
			red_sort_0=2;
		}else if (red_3==0){
			red_sort_0=3;
		}else if (red_4==0){
			red_sort_0=4;
		}

		if (red_1==1){
			red_sort_1=1;
		}else if (red_2==1){
			red_sort_1=2;
		}else if (red_3==1){
			red_sort_1=3;
		}else if (red_4==1){
			red_sort_1=4;
		}

		if (red_1==2){
			red_sort_2=1;
		}else if (red_2==2){
			red_sort_2=2;
		}else if (red_3==2){
			red_sort_2=3;
		}else if (red_4==2){
			red_sort_2=4;
		}

		if (red_1==3){
			red_sort_3=1;
		}else if (red_2==3){
			red_sort_3=2;
		}else if (red_3==3){
			red_sort_3=3;
		}else if (red_4==3){
			red_sort_3=4;
		}
	}


	function yellow_sort(type) {
		if (yellow_1==0){
			yellow_sort_0=1;
		}else if (yellow_2==0){
			yellow_sort_0=2;
		}else if (yellow_3==0){
			yellow_sort_0=3;
		}else if (yellow_4==0){
			yellow_sort_0=4;
		}

		if (yellow_1==1){
			yellow_sort_1=1;
		}else if (yellow_2==1){
			yellow_sort_1=2;
		}else if (yellow_3==1){
			yellow_sort_1=3;
		}else if (yellow_4==1){
			yellow_sort_1=4;
		}

		if (yellow_1==2){
			yellow_sort_2=1;
		}else if (yellow_2==2){
			yellow_sort_2=2;
		}else if (yellow_3==2){
			yellow_sort_2=3;
		}else if (yellow_4==2){
			yellow_sort_2=4;
		}

		if (yellow_1==3){
			yellow_sort_3=1;
		}else if (yellow_2==3){
			yellow_sort_3=2;
		}else if (yellow_3==3){
			yellow_sort_3=3;
		}else if (yellow_4==3){
			yellow_sort_3=4;
		}
	}	
	




	$("#test_start_btn").click(function(){
		
		$(".second_btn").click();
		
	});

	$(".personal_btn").click(function(){
		
		full_name=$('#full_name').val();
		gender=$('#gender').val();
		
		country=$('#country').val();
		city=$('#city').val();
		stay_country=$('#stay_country').val();
		stay_city=$('#stay_city').val();
		
		country_text=$( "#country option:selected" ).text();
		city_text=$( "#city option:selected" ).text();
		stay_country_text=$( "#stay_country option:selected" ).text();
		stay_city_text=$( "#stay_city option:selected" ).text();
		
		
		
		mobile=$('#mobile').val();
		email=$('#email').val();
		birth_date=$('#birth_date').val();
		birth_time=$('#birth_time').val();		
	});	

	$(document).on('click', '.contact_us', function(event){
		
		$('.fourth_btn').click();
	});	
	
		$(".personal_btn_2").click(function(){
		
		full_name=$('#full_name').val();
		gender=$('#gender').val();
		country=$('#country').val();
		city=$('#city').val();
		stay_country=$('#stay_country').val();
		stay_city=$('#stay_city').val();
		
		country_text=$( "#country option:selected" ).text();
		city_text=$( "#city option:selected" ).text();
		stay_country_text=$( "#stay_country option:selected" ).text();
		stay_city_text=$( "#stay_city option:selected" ).text();
		
		
		mobile=$('#mobile').val();
		email=$('#email').val();
		birth_date=$('#birth_date').val();
		birth_time=$('#birth_time').val();		
	});	
	
	
	
	$('.gray').click(function(){
		
		if(gray_1==''){
			
			gray_1=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');

		}else if(gray_2==''){
			
			gray_2=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
			
		}else if(gray_3==''){
			
			gray_3=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
			
		}else if(gray_4==''){
			
			gray_4=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
		}
		else if(gray_5==''){
			gray_5=$(this).attr("num");
			$(this).css('visibility','hidden');
			
			$("#gray_container").hide();
			$("#colors1_container").css('display','table');
			
			//show_message('أختار لونك المفضل من بين تلك الالون');		
			
			}
		
	});



	$('.colors1').click(function(){

		if(colors1_1==''){
			
			colors1_1=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
			
		}else if(colors1_2==''){
			
			colors1_2=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
			
		}else if(colors1_3==''){
			
			colors1_3=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
			
		}else if(colors1_4==''){
			
			colors1_4=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
			
		}else if(colors1_5==''){
			
			colors1_5=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('اختار اكثر لون غير مفضل من بين تلك الالوان');
			
		}else if(colors1_6==''){
			
			colors1_6=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('اختار اكثر لون غير مفضل من بين تلك الالوان');
			
		}else if(colors1_7==''){
			
			colors1_7=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('اختار اكثر لون غير مفضل من بين تلك الالوان');
						
		}else if(colors1_8==''){
			colors1_8=$(this).attr("num");
			$(this).css('visibility','hidden');
			
			//alert(colors1_1);
			//alert(colors1_2);
			//alert(colors1_3);
			//alert(colors1_4);
			//alert(colors1_5);
			//alert(colors1_6);
			//alert(colors1_7);
			//alert(colors1_8);		
			
			//show_message('قم باختيار الشكل المفضل لديك من بين هؤلاء الاشكال');
			$("#colors1_container").hide();
			$("#shape_container").css('display','table');
			
			
			
		}


		

	});




	$('.shape').click(function(){
		
		if(shape_1==''){
			
			shape_1=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('قم باختيار الشكل المفضل لديك من بين هؤلاء الاشكال');

		}else if(shape_2==''){
			
			shape_2=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('قم باختيار الشكل المفضل لديك من بين هؤلاء الاشكال');
			
		}else if(shape_3==''){
			
			shape_3=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('قم باختيار الشكل المفضل لديك من بين هؤلاء الاشكال');

		}else if(shape_4==''){
			
			shape_4=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('قم باختيار الشكل المفضل لديك من بين هؤلاء الاشكال');			

		}else if(shape_5==''){
			
			shape_5=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('قم باختيار الشكل المفضل لديك من بين هؤلاء الاشكال');

		}else if(shape_6==''){
			
			shape_6=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('قم باختيار الشكل المفضل لديك من بين هؤلاء الاشكال');

		}else if(shape_7==''){
			
			shape_7=$(this).attr("num");
			$(this).css('visibility','hidden');

			$("#shape_container").hide();
			$("#basic_colors_container").css('display','table');
			//show_message('قم باختيار اللون المفضل من بين اللونين');
		}
		
	});


	$('.basic_colors').click(function(){
		
		if($(this).attr('num')==1){
			basic_colors_1++;
		}else if($(this).attr('num')==2){
			basic_colors_2++;
		}else if($(this).attr('num')==3){
			basic_colors_3++;
		}else if($(this).attr('num')==4){
			basic_colors_4++;
		}

		
		if(basic_colors_row<6){
			
			$(this).parent().css('display','none');
			$(this).parent().next('.slim_row').css('display','flex');
			basic_colors_row++;

			
		}else{
			
			if(basic_colors_1==basic_colors_2 || basic_colors_1==basic_colors_3 || basic_colors_1==basic_colors_4 || basic_colors_2==basic_colors_3 || basic_colors_2==basic_colors_4 || basic_colors_3==basic_colors_4 ){
				
				if(basic_colors_repeat==0){
					
					basic_colors_1=0;
					basic_colors_2=0;
					basic_colors_3=0;
					basic_colors_4=0;
					basic_colors_row=1;
					$(".slim_row:first-child").show();
					$(".slim_row:last-child").hide();
					//alert("اعادة الامتحان");
					basic_colors_repeat=1;
					
					
				}else{
					
					un_regular=1;
					un_regular_basic=1;
					$("#basic_colors_container").hide();
					$("#blue_container").css('display','table');
				
				}
				basic_colors_sort_unregular();
				
			}else{
				
				//alert(basic_colors_1);
				
				basic_colors_sort();
	
				//alert(basic_colors_sort_1);
				
				$("#basic_colors_container").hide();
				$("#blue_container").css('display','table');
			
			}
		}
		
	});




	$('.blue').click(function(){
		
		if($(this).attr('num')==1){
			blue_1++;
		}else if($(this).attr('num')==2){
			blue_2++;
		}else if($(this).attr('num')==3){
			blue_3++;
		}else if($(this).attr('num')==4){
			blue_4++;
		}

		
		if(blue_row<6){
			
			$(this).parent().css('display','none');
			$(this).parent().next('.slim_row').css('display','flex');
			blue_row++;

			
		}else{
			
			
			if(blue_1==blue_2 || blue_1==blue_3 || blue_1==blue_4 || blue_2==blue_3 || blue_2==blue_4 || blue_3==blue_4 ){
				
				if(blue_repeat==0){
					
					blue_1=0;
					blue_2=0;
					blue_3=0;
					blue_4=0;
					blue_row=1;
					$(".slim_row:first-child").show();
					$(".slim_row:last-child").hide();
					//alert("اعادة الامتحان");
					blue_repeat=1;
					
					
				}else{
					
					un_regular=1;
					un_regular_blue=1;
					$("#blue_container").hide();
					$("#green_container").css('display','table');
				
				}
				blue_sort_unregular();
			}else{
					
				blue_sort();
				$("#blue_container").hide();
				$("#green_container").css('display','table');				

			}
				
			
			

		}
		
	});


	$('.green').click(function(){
		
		if($(this).attr('num')==1){
			green_1++;
		}else if($(this).attr('num')==2){
			green_2++;
		}else if($(this).attr('num')==3){
			green_3++;
		}else if($(this).attr('num')==4){
			green_4++;
		}

		
		if(green_row<6){
			
			$(this).parent().css('display','none');
			$(this).parent().next('.slim_row').css('display','flex');
			green_row++;

			
		}else{if(green_1==green_2 || green_1==green_3 || green_1==green_4 || green_2==green_3 || green_2==green_4 || green_3==green_4 ){
				
				if(green_repeat==0){
					
					green_1=0;
					green_2=0;
					green_3=0;
					green_4=0;
					green_row=1;
					$(".slim_row:first-child").show();
					$(".slim_row:last-child").hide();
					//alert("اعادة الامتحان");
					green_repeat=1;
					
					
				}else{
					
					un_regular=1;
					un_regular_green=1;
					$("#green_container").hide();
					$("#red_container").css('display','table');
				
				}
				
				green_sort_unregular();
			}else{
				
				green_sort();
				$("#green_container").hide();
				$("#red_container").css('display','table');
			
			
			}
		}
		
	});




	$('.red').click(function(){
		
		if($(this).attr('num')==1){
			red_1++;
		}else if($(this).attr('num')==2){
			red_2++;
		}else if($(this).attr('num')==3){
			red_3++;
		}else if($(this).attr('num')==4){
			red_4++;
		}

		
		if(red_row<6){
			
			$(this).parent().css('display','none');
			$(this).parent().next('.slim_row').css('display','flex');
			red_row++;

			
		}else{
			
			if(red_1==red_2 || red_1==red_3 || red_1==red_4 || red_2==red_3 || red_2==red_4 || red_3==red_4 ){
				
				if(red_repeat==0){
					
					red_1=0;
					red_2=0;
					red_3=0;
					red_4=0;
					red_row=1;
					$(".slim_row:first-child").show();
					$(".slim_row:last-child").hide();
					//alert("اعادة الامتحان");
					red_repeat=1;
					
					
				}else{
					
					un_regular=1;
					un_regular_red=1;
					$("#red_container").hide();
					$("#yellow_container").css('display','table');
				
				}
				
				red_sort_unregular();
			}else{
			
				red_sort();
				$("#red_container").hide();
				$("#yellow_container").css('display','table');
			
			}
		}
		
	});



	$('.yellow').click(function(){
		
		if($(this).attr('num')==1){
			yellow_1++;
		}else if($(this).attr('num')==2){
			yellow_2++;
		}else if($(this).attr('num')==3){
			yellow_3++;
		}else if($(this).attr('num')==4){
			yellow_4++;
		}

		
		if(yellow_row<6){
			
			$(this).parent().css('display','none');
			$(this).parent().next('.slim_row').css('display','flex');
			yellow_row++;

			
		}else{
			
			if(yellow_1==yellow_2 || yellow_1==yellow_3 || yellow_1==yellow_4 || yellow_2==yellow_3 || yellow_2==yellow_4 || yellow_3==yellow_4 ){
				
				if(yellow_repeat==0){
					
					yellow_1=0;
					yellow_2=0;
					yellow_3=0;
					yellow_4=0;
					yellow_row=1;
					$(".slim_row:first-child").show();
					$(".slim_row:last-child").hide();
					//alert("اعادة الامتحان");
					yellow_repeat=1;
					
					
				}else{
					
					un_regular=1;
					un_regular_yellow=1;
					$("#yellow_container").hide();
					$("#colors2_container").css('display','table');
				
				}
				yellow_sort_unregular();
			}else{
				
				
				yellow_sort();
				$("#yellow_container").hide();
				$("#colors2_container").css('display','table');
			
				//show_message('أختار لونك المفضل من بين تلك الالون');
			
			}
		}
		
	});




	$('.colors2').click(function(){

		if(colors2_1==''){
			
			colors2_1=$(this).attr("num");
			most_color=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
						
		}else if(colors2_2==''){
			
			colors2_2=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
						
		}else if(colors2_3==''){
			
			colors2_3=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
						
		}else if(colors2_4==''){
			
			colors2_4=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('أختار لونك المفضل من بين تلك الالون');
						
		}else if(colors2_5==''){
			
			colors2_5=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('اختار اكثر لون غير مفضل من بين تلك الالوان');
			
		}else if(colors2_6==''){
			
			colors2_6=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('اختار اكثر لون غير مفضل من بين تلك الالوان');		
			
		}else if(colors2_7==''){
			
			colors2_7=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('اختار اكثر لون غير مفضل من بين تلك الالوان');
			
		}else if(colors2_8==''){
			
			colors2_8=$(this).attr("num");
			$(this).css('visibility','hidden');
			//show_message('اختار اللون الذى تفضل ان تراه بجوار لونك المفضل');
			
			//alert(most_color);
			//$( ".most_color[num='"+most_color+"']" ).css("animation","mymove 0.5s infinite");
			//$( ".most_color[num='"+most_color+"']" ).addClass("most_color_selected");
			$( ".most_color[num='"+most_color+"']" ).css("border","solid 6px #AAA200");
			
			$("#most_color_container").css('display','table');
			$("#colors2_container").hide();
			
			
		}
	});		
	
	
	
	
			
			
	
		
		
		
		
		$('.most_color').on('click',function(){	
		
			if(most_color == $(this).attr("num")){
			
			alert('لا يمكنك اختيار هذا اللون  .. اختار اكثر لون تفضل ان تراه بجواره');
			
			}else{
				
				most_color2=$(this).attr("num");
				$(this).css('visibility','hidden');
				$("#most_color_container").hide();
				$("#user_details_2_container").css('display','table');
				
			}
		});
		
	$('#show_result').on('click',function(){		
		//alert(most_color);
		//alert($(this).attr("num"));
		//alert(err_2);
		if(err_2==1){
			
			//alert('ادخل الفورم');
			
		}else{
			

						
				
			//alert(colors2_1);
			//alert(colors2_2);
			//alert(colors2_3);
			//alert(colors2_4);
			//alert(colors2_5);
			//alert(colors2_6);
			//alert(colors2_7);
			//alert(colors2_8);		
			end_test=1;
			//alert("تم الانتهاء من الاختبار");
			
			$("#form2").hide();
			//$("#final_container").css('display','table');
			$("#voucher_container").css('display','table');
			
						
			variables='<table>';
			variables+='<tr><td>full_name</td><td>'+full_name+'</td></tr>';
			variables+='<tr><td>gender</td><td>'+gender+'</td></tr>';
			variables+='<tr><td>country</td><td>'+country+'</td></tr>';
			variables+='<tr><td>city</td><td>'+city+'</td></tr>';
			variables+='<tr><td>stay_country</td><td>'+stay_country+'</td></tr>';
			variables+='<tr><td>stay_city</td><td>'+stay_city+'</td></tr>';
			variables+='<tr><td>birth_date</td><td>'+birth_date+'</td></tr>';
			variables+='<tr><td>birth_hour</td><td>'+birth_time+'</td></tr>';
			variables+='<tr><td>email</td><td>'+email+'</td></tr>';
			variables+='<tr><td>mobile</td><td>'+mobile+'</td></tr>';
			variables+='<tr><td>gray_1</td><td>'+gray_1+'</td></tr>';
			variables+='<tr><td>gray_2</td><td>'+gray_2+'</td></tr>';
			variables+='<tr><td>gray_3</td><td>'+gray_3+'</td></tr>';
			variables+='<tr><td>gray_4</td><td>'+gray_4+'</td></tr>';
			variables+='<tr><td>gray_5</td><td>'+gray_5+'</td></tr>';
			variables+='<tr><td>colors1_1</td><td>'+colors1_1+'</td></tr>';
			variables+='<tr><td>colors1_2</td><td>'+colors1_2+'</td></tr>';
			variables+='<tr><td>colors1_3</td><td>'+colors1_3+'</td></tr>';
			variables+='<tr><td>colors1_4</td><td>'+colors1_4+'</td></tr>';
			variables+='<tr><td>colors1_5</td><td>'+colors1_5+'</td></tr>';
			variables+='<tr><td>colors1_6</td><td>'+colors1_6+'</td></tr>';
			variables+='<tr><td>colors1_7</td><td>'+colors1_7+'</td></tr>';
			variables+='<tr><td>colors1_8</td><td>'+colors1_8+'</td></tr>';
			variables+='<tr><td>colors2_1</td><td>'+colors2_1+'</td></tr>';
			variables+='<tr><td>colors2_2</td><td>'+colors2_2+'</td></tr>';
			variables+='<tr><td>colors2_3</td><td>'+colors2_3+'</td></tr>';
			variables+='<tr><td>colors2_4</td><td>'+colors2_4+'</td></tr>';
			variables+='<tr><td>colors2_5</td><td>'+colors2_5+'</td></tr>';
			variables+='<tr><td>colors2_6</td><td>'+colors2_6+'</td></tr>';
			variables+='<tr><td>colors2_7</td><td>'+colors2_7+'</td></tr>';
			variables+='<tr><td>colors2_8</td><td>'+colors2_8+'</td></tr>';
			variables+='<tr><td>shape_1</td><td>'+shape_1+'</td></tr>';
			variables+='<tr><td>shape_2</td><td>'+shape_2+'</td></tr>';
			variables+='<tr><td>shape_3</td><td>'+shape_3+'</td></tr>';
			variables+='<tr><td>shape_4</td><td>'+shape_4+'</td></tr>';
			variables+='<tr><td>shape_5</td><td>'+shape_5+'</td></tr>';
			variables+='<tr><td>shape_6</td><td>'+shape_6+'</td></tr>';	
			variables+='<tr><td>shape_6</td><td>'+shape_7+'</td></tr>';	
			variables+='<tr><td>basic_colors_1</td><td>'+basic_colors_1+'</td></tr>';
			variables+='<tr><td>basic_colors_2</td><td>'+basic_colors_2+'</td></tr>';
			variables+='<tr><td>basic_colors_3</td><td>'+basic_colors_3+'</td></tr>';
			variables+='<tr><td>basic_colors_4</td><td>'+basic_colors_4+'</td></tr>';
			variables+='<tr><td>blue_1</td><td>'+blue_1+'</td></tr>';
			variables+='<tr><td>blue_2</td><td>'+blue_2+'</td></tr>';
			variables+='<tr><td>blue_3</td><td>'+blue_3+'</td></tr>';
			variables+='<tr><td>blue_4</td><td>'+blue_4+'</td></tr>';
			variables+='<tr><td>green_1</td><td>'+green_1+'</td></tr>';
			variables+='<tr><td>green_2</td><td>'+green_2+'</td></tr>';
			variables+='<tr><td>green_3</td><td>'+green_3+'</td></tr>';
			variables+='<tr><td>green_4</td><td>'+green_4+'</td></tr>';
			variables+='<tr><td>red_1</td><td>'+red_1+'</td></tr>';
			variables+='<tr><td>red_2</td><td>'+red_2+'</td></tr>';
			variables+='<tr><td>red_3</td><td>'+red_3+'</td></tr>';
			variables+='<tr><td>red_4</td><td>'+red_4+'</td></tr>';
			variables+='<tr><td>yellow_1</td><td>'+yellow_1+'</td></tr>';
			variables+='<tr><td>yellow_2</td><td>'+yellow_2+'</td></tr>';
			variables+='<tr><td>yellow_3</td><td>'+yellow_3+'</td></tr>';
			variables+='<tr><td>yellow_4</td><td>'+yellow_4+'</td></tr>';
			variables+='</table>';
			
			//alert(variables);
			report="<div style='padding:10px;background:#fff;'>";
			report+="<table style='margin-top:60px;border-bottom:solid 1px #ddd'>";

			report+="<tr>";
			report+="<td>الاسم : "+full_name+"</td>";
	
			report+="</tr>";

		

			report+="</table>";

			report+="<br>";

			report+="<table style='direction:ltr'>";
			report+="<tr>";
			report+="<td colspan='3'> </td>";
			report+="<td class='cell_top'>1</td>";
			report+="<td class='cell_top'>2</td>";
			report+="<td class='cell_top'>3</td>";
			report+="<td class='cell_top'>4</td>";
			report+="<td class='cell_top'>5</td>";
			report+="<td class='cell_top'>6</td>";
			report+="<td class='cell_top'>7</td>";
			report+="<td class='cell_top'>8</td>";
			report+="</tr>";
			report+="<tr >";
			report+="<td colspan='3' style='text-align:left'>اختبار الرمادى </td>";
			report+="<td class='cell_right'>"+gray_1+"</td>";
			report+="<td class='cell'>"+gray_2+"</td>";
			report+="<td class='cell'>"+gray_3+"</td>";
			report+="<td class='cell'>"+gray_4+"</td>";
			report+="<td class='cell'>"+gray_5+"</td>";
			report+="<td class='cell_no'> </td>";
			report+="<td class='cell_no'> </td>";
			report+="<td class='cell_no'> </td>";
			report+="</tr>";
			
			report+="<tr style='margin:0px;height:10px' >";
			report+="<td style='padding:0px;font-size:10px' colspan='3' style='text-align:left'> </td>";
			report+="<td style='padding:0px;font-size:10px;border:solid 1px #333' colspan='2' class='cell'>1,2,4</td>";
			report+="<td style='padding:0px;border:0px;font-size:10px' colspan='2' class='cell'></td>";
			report+="<td style='padding:0px;font-size:10px;border:solid 1px #333' colspan='1' class='cell'>0,1,3</td>";
			report+="</tr>";
			
			report+="<tr style='height:10px'></tr>";

			report+="<tr >";
			report+="<td colspan='3' style='text-align:left'>اختبار 8 الوان</td>";
			report+="<td class='cell_right'>"+colors1_1+"</td>";
			report+="<td class='cell'>"+colors1_2+"</td>";
			report+="<td class='cell'>"+colors1_3+"</td>";
			report+="<td class='cell'>"+colors1_4+"</td>";
			report+="<td class='cell'>"+colors1_5+"</td>";
			report+="<td class='cell'>"+colors1_6+"</td>";
			report+="<td class='cell'>"+colors1_7+"</td>";
			report+="<td class='cell'>"+colors1_8+"</td>";
			report+="</tr>";
			
			
			report+="<tr style='margin:0px;height:10px' >";
			report+="<td style='padding:0px;font-size:10px;' colspan='3' style='text-align:left'> </td>";
			report+="<td style='padding:0px;font-size:10px;border:solid 1px #333' colspan='2' class='cell'>0,6,7</td>";
			report+="<td style='padding:0px;border:0px;font-size:10px' colspan='3' class='cell'></td>";
			report+="<td style='padding:0px;font-size:10px;border:solid 1px #333' colspan='3' class='cell'>1,2,3,4</td>";
			report+="</tr>";

			report+="<tr style='height:10px'></tr>";

			report+="<tr>";
			report+="<td colspan='1' style='text-align:left'>اختبار 8 الوان</td>";
			report+="<td class='cell_right'>"+most_color2+"</td>";
			report+="<td class='cell_no'></td>";
			report+="<td class='cell_right'>"+colors2_1+"</td>";
			report+="<td class='cell'>"+colors2_2+"</td>";
			report+="<td class='cell'>"+colors2_3+"</td>";
			report+="<td class='cell'>"+colors2_4+"</td>";
			report+="<td class='cell'>"+colors2_5+"</td>";
			report+="<td class='cell'>"+colors2_6+"</td>";
			report+="<td class='cell'>"+colors2_7+"</td>";
			report+="<td class='cell'>"+colors2_8+"</td>";
			report+="</tr>";
			
			report+="<tr style='height:10px'></tr>";

			if(colors2_1==1 || colors2_1==2 || colors2_1==3 || colors2_1==4){
				if(colors_sort1==''){
					colors_sort1=colors2_1;
				}else if(colors_sort2==''){
					colors_sort2=colors2_1;
				}else if(colors_sort3==''){
					colors_sort3=colors2_1;
				}else if(colors_sort4==''){
					colors_sort4=colors2_1;
				}
			}
			
			if(colors2_2==1 || colors2_2==2 || colors2_2==3 || colors2_2==4){
				if(colors_sort1==''){
					colors_sort1=colors2_2;
				}else if(colors_sort2==''){
					colors_sort2=colors2_2;
				}else if(colors_sort3==''){
					colors_sort3=colors2_2;
				}else if(colors_sort4==''){
					colors_sort4=colors2_2;
				}
			}
			
			if(colors2_3==1 || colors2_3==2 || colors2_3==3 || colors2_3==4){
				if(colors_sort1==''){
					colors_sort1=colors2_3;
				}else if(colors_sort2==''){
					colors_sort2=colors2_3;
				}else if(colors_sort3==''){
					colors_sort3=colors2_3;
				}else if(colors_sort4==''){
					colors_sort4=colors2_3;
				}
			}
			
			if(colors2_4==1 || colors2_4==2 || colors2_4==3 || colors2_4==4){
				if(colors_sort1==''){
					colors_sort1=colors2_4;
				}else if(colors_sort2==''){
					colors_sort2=colors2_4;
				}else if(colors_sort3==''){
					colors_sort3=colors2_4;
				}else if(colors_sort4==''){
					colors_sort4=colors2_4;
				}
			}
			
			if(colors2_5==1 || colors2_5==2 || colors2_5==3 || colors2_5==4){
				if(colors_sort1==''){
					colors_sort1=colors2_5;
				}else if(colors_sort2==''){
					colors_sort2=colors2_5;
				}else if(colors_sort3==''){
					colors_sort3=colors2_5;
				}else if(colors_sort4==''){
					colors_sort4=colors2_5;
				}
			}
			
			if(colors2_6==1 || colors2_6==2 || colors2_6==3 || colors2_6==4){
				if(colors_sort1==''){
					colors_sort1=colors2_6;
				}else if(colors_sort2==''){
					colors_sort2=colors2_6;
				}else if(colors_sort3==''){
					colors_sort3=colors2_6;
				}else if(colors_sort4==''){
					colors_sort4=colors2_6;
				}
			}
			
			if(colors2_7==1 || colors2_7==2 || colors2_7==3 || colors2_7==4){
				if(colors_sort1==''){
					colors_sort1=colors2_7;
				}else if(colors_sort2==''){
					colors_sort2=colors2_7;
				}else if(colors_sort3==''){
					colors_sort3=colors2_7;
				}else if(colors_sort4==''){
					colors_sort4=colors2_7;
				}
			}
			
			
			if(colors2_8==1 || colors2_8==2 || colors2_8==3 || colors2_8==4){
				if(colors_sort1==''){
					colors_sort1=colors2_8;
				}else if(colors_sort2==''){
					colors_sort2=colors2_8;
				}else if(colors_sort3==''){
					colors_sort3=colors2_8;
				}else if(colors_sort4==''){
					colors_sort4=colors2_8;
				}
			}
			
			report+="<tr>";
			report+="<td colspan='3' style='text-align:left'>الترتيب</td>";
			report+="<td class='cell_right'>"+colors_sort1+"</td>";
			report+="<td class='cell'>"+colors_sort2+"</td>";
			report+="<td class='cell'>"+colors_sort3+"</td>";
			report+="<td class='cell'>"+colors_sort4+"</td>";
			report+="<td class='cell_no'></td>";
			report+="<td class='cell_no'></td>";
			report+="<td class='cell_no'></td>";
			report+="<td class='cell_no'></td>";
			report+="</tr>";			

			report+="<tr style='height:10px'></tr>";
			
			report+="<tr>";
			report+="<td colspan='3' style='text-align:left'>الاشكال</td>";
			report+="<td class='cell_right' style='"+ shape_style1 +"'>"+shape_1+"</td>";
			report+="<td class='cell' style='"+ shape_style1 +"'>"+shape_2+"</td>";
			report+="<td class='cell'>"+shape_3+"</td>";
			report+="<td class='cell'>"+shape_4+"</td>";
			report+="<td class='cell'>"+shape_5+"</td>";
			report+="<td class='cell' style='"+ shape_style2 +"'>"+shape_6+"</td>";
			report+="<td class='cell' style='"+ shape_style2 +"'>"+shape_7+"</td>";
			report+="<td class='cell_no'></td>";
			report+="</tr>";
			
			report+="<tr style='height:10px'></tr>";
			
			report+="</table>";

			report+="<hr>";
			report+="<table style='direction:ltr;border-collapse: collapse;'>";



			report+="<tr style='height:30px;'>";
			report+="<td colspan='2' style='padding:0'> </td>";
			report+="<td colspan='4' class='cell_top' style='padding:0'>ترتيب المدخلات</td>";
			report+="<td colspan='1' class='cell_top' style='padding:0'></td>";
			report+="<td colspan='4' class='cell_top' style='padding:0'>عدد مرات الادخال</td>";
			

			report+="</tr>";
			report+="<tr>";
			report+="<td style='padding:0' colspan='2'> </td>";

			
			report+="<td style='padding:0' class='cell_top'>|||</td>";
			report+="<td style='padding:0' class='cell_top'>||</td>";
			report+="<td style='padding:0' class='cell_top'>|</td>";
			report+="<td style='padding:0' class='cell_top'>0</td>";

			report+="<td style='padding:0' class='cell_top'></td>";

			report+="<td style='padding:0' class='cell_top'>1</td>";
			report+="<td style='padding:0' class='cell_top'>2</td>";
			report+="<td style='padding:0' class='cell_top'>3</td>";
			report+="<td style='padding:0' class='cell_top'>4</td>";			

			report+="</tr>";

			report+="<tr style='height:10px'></tr>";



			report+="<tr style='"+ basic_colors_collect_style + ";" + basic_colors_collect_reverse_style + "'>";
			report+="<td colspan='2' style='text-align:left;border-right:1px solid #333'>الالوان الاساسية</td>";

			
			report+="<td class='cell_right'>"+basic_colors_sort_3+"</td>";
			report+="<td class='cell'>"+basic_colors_sort_2+"</td>";
			report+="<td class='cell'>"+basic_colors_sort_1+"</td>";
			report+="<td class='cell'>"+basic_colors_sort_0+"</td>";
			
			report+="<td class='cell_no'> </td>";


			report+="<td class=' cell_right'>"+basic_colors_1+"</td>";
			report+="<td class='cell'>"+basic_colors_2+"</td>";
			report+="<td class='cell'>"+basic_colors_3+"</td>";
			report+="<td class='cell'>"+basic_colors_4+"</td>";
			
			
			report+="</tr>";

			report+="<tr style='height:10px'><td colspan='11' style='border-bottom:solid 2px #333;padding:5px;'></td></tr>";
			report+="<tr style='height:10px'></tr>";
			report+="<tr style='"+ blue_collect_style + ";" + blue_collect_reverse_style + "'>";
			report+="<td colspan='2' style='text-align:left;border-right:1px solid #333'> العلاقات والانتماء</td>";

			report+="<td class='cell_right'>"+blue_sort_3+"</td>";
			report+="<td class='cell'>"+blue_sort_2+"</td>";
			report+="<td class='cell'>"+blue_sort_1+"</td>";
			
			if(blue_sort_0 != 1){
				
				if(blue_sort_0 == 3){
					report+="<td class='cell red_shadow'>"+blue_sort_0+"</td>";
				}else{
					report+="<td class='cell'>"+blue_sort_0+"</td>";
				}
			
			}else{
			report+="<td class='cell yellow_shadow'>"+blue_sort_0+"</td>";
			}
			
			report+="<td class='cell_no'> </td>";
			
			report+="<td class=' cell_right'>"+blue_1+"</td>";
			report+="<td class='cell'>"+blue_2+"</td>";
			report+="<td class='cell'>"+blue_3+"</td>";
			report+="<td class='cell'>"+blue_4+"</td>";
			report+="</tr>";


			report+="<tr style='height:10px'></tr>";
			
			
			report+="<tr style='"+ green_collect_style + ";" + green_collect_reverse_style + "'>";
			report+="<td colspan='2' style='text-align:left;border-right:1px solid #333'> معرفة الذات</td>";

			
			report+="<td class='cell_right cell_top_bottom_right'>"+green_sort_3+"</td>";
			report+="<td class='cell cell_top_bottom'>"+green_sort_2+"</td>";
			report+="<td class='cell cell_top_bottom'>"+green_sort_1+"</td>";
			
			if(green_sort_0 != 2){
				if(green_sort_0 == 3){
					report+="<td class='cell red_shadow'>"+green_sort_0+"</td>";
				}else{
					report+="<td class='cell'>"+green_sort_0+"</td>";
				}
			}else{
			report+="<td class='cell yellow_shadow'>"+green_sort_0+"</td>";
			}
			
			report+="<td class='cell_no'> </td>";
			
			report+="<td class='cell_right cell_top_bottom_right '>"+green_1+"</td>";
			report+="<td class='cell cell_top_bottom'>"+green_2+"</td>";
			report+="<td class='cell cell_top_bottom'>"+green_3+"</td>";
			report+="<td class='cell cell_top_bottom_left'>"+green_4+"</td>";

			report+="</tr>";

			report+="<tr style='height:10px'></tr>";

			report+="<tr style='"+ red_collect_style + ";" + red_collect_reverse_style + "'>";
			report+="<td colspan='2' style='text-align:left;border-right:1px solid #333' > العمل والانجازات</td>";

			report+="<td class='cell_right'>"+red_sort_3+"</td>";
			report+="<td class='cell'>"+red_sort_2+"</td>";
			report+="<td class='cell'>"+red_sort_1+"</td>";
			
			if(red_sort_0 != 3){
				if(red_sort_0 == 3){
					report+="<td class='cell red_shadow'>"+red_sort_0+"</td>";
				}else{
					report+="<td class='cell'>"+red_sort_0+"</td>";
				}
			}else{
			report+="<td class='cell yellow_shadow'>"+red_sort_0+"</td>";
			}
			

			
			report+="<td class='cell_no'> </td>";

			
			report+="<td class='cell_right'>"+red_1+"</td>";
			report+="<td class='cell'>"+red_2+"</td>";
			report+="<td class='cell'>"+red_3+"</td>";
			report+="<td class='cell'>"+red_4+"</td>";
			report+="</tr>";

			report+="<tr style='height:10px'></tr>";

			report+="<tr style='"+ yellow_collect_style + ";" + yellow_collect_reverse_style + "'>";
			report+="<td colspan='2' style='text-align:left;border-right:1px solid #333' > المستقبل والتوقعات</td>";


			report+="<td class='cell_right'>"+yellow_sort_3+"</td>";
			report+="<td class='cell'>"+yellow_sort_2+"</td>";
			report+="<td class='cell'>"+yellow_sort_1+"</td>";
			
			if(yellow_sort_0 != 4){
				if(yellow_sort_0 == 3){
					report+="<td class='cell red_shadow'>"+yellow_sort_0+"</td>";
				}else{
					report+="<td class='cell'>"+yellow_sort_0+"</td>";
				}
				
			}else{
			report+="<td class='cell yellow_shadow'>"+yellow_sort_0+"</td>";
			}
			
			report+="<td class='cell_no'></td>";
			
			report+="<td class='cell_right'>"+yellow_1+" </td>";
			report+="<td class='cell'>"+yellow_2+"</td>";
			report+="<td class='cell'>"+yellow_3+"</td>";
			report+="<td class='cell'>"+yellow_4+"</td>";
			
			

			report+="</tr>";
			
			
			
			report+="<tr>";
			report+="<td colspan='2' style='text-align:left' > </td>";

			report+="<td colspan='4' style='border:0px;padding:10px 0px' class='cell'>";
			
			report+="<table style='border-collapse:collapse;width:100%'>";
			report+="<tr>";
			
			
			
			if(yellow_sort_3==green_sort_3 && yellow_sort_3==red_sort_3 && yellow_sort_3==blue_sort_3){
				plus_plus=yellow_sort_3;
			}
			
			if(yellow_sort_2==green_sort_2){
				plus=yellow_sort_2;
			}else if(yellow_sort_2==blue_sort_2){
				plus=yellow_sort_2;
			}else if(yellow_sort_2==red_sort_2){
				plus=yellow_sort_2;
			}else if(green_sort_2==red_sort_2){
				plus=green_sort_2;
			}else if(blue_sort_2==red_sort_2){				
				plus=blue_sort_2;
			}else if(green_sort_2==blue_sort_2){
				plus=green_sort_2;
			}	


			if(yellow_sort_1==green_sort_1){
				plus_minus=yellow_sort_1;
			}else if(yellow_sort_1==blue_sort_1){
				plus_minus=yellow_sort_1;
			}else if(yellow_sort_1==red_sort_1){
				plus_minus=yellow_sort_1;
			}else if(green_sort_1==red_sort_1){
				plus_minus=green_sort_1;
			}else if(blue_sort_1==red_sort_1){				
				plus_minus=blue_sort_1;
			}else if(green_sort_1==blue_sort_1){
				plus_minus=green_sort_1;
			}	

			if(yellow_sort_0==green_sort_0){
				minus_minus=yellow_sort_0;
			}else if(yellow_sort_0==blue_sort_0){
				minus_minus=yellow_sort_0;
			}else if(yellow_sort_0==red_sort_0){
				minus_minus=yellow_sort_0;
			}else if(green_sort_0==red_sort_0){
				minus_minus=green_sort_0;
			}else if(blue_sort_0==red_sort_0){				
				minus_minus=blue_sort_0;
			}else if(green_sort_0==blue_sort_0){
				minus_minus=green_sort_0;
			}			


			
			
			report+="<td class='cell_right' rowspan='2'>"+"++"+ plus_plus +" </td>";
			report+="<td class='cell' >"+"+"+ plus + " </td>";
			report+="<td class='cell' >"+"+-"+ plus_minus +" </td>";
			report+="<td class='cell' rowspan='2'>"+"--"+ minus_minus+" </td>";

			report+="</tr>";
			
			report+="<tr>";			
			report+="<td class='cell' colspan='2'>Column</td>";
			report+="</tr>";

			
			report+="</table>";
			report+="</td>";

			
			report+="<td class='cell_no'></td>";
			
			report+="<td colspan='4' style='border:0px' class='cell'></td>";

	
			report+="</tr>";
			
			
			


			report+="</table></div>";









		
			
		loading_page='ajax_basic_colors_answers.php';
		alert("test_code="+test_code);
		if(test_type=='paied'){
			
				loading_page='ajax_all_colors_answers.php';
			//alert("All");
			
		}
		

				$.post(website_url+"/ajax_add_test.php",
					{
						'full_name':full_name,
						'gender':gender,
						'birth_date':birth_date,
						'birth_time':birth_time,
						'email':email,
						'mobile':mobile,
						'country':country,
						'city':city,
						'stay_country':stay_country,
						'stay_city':stay_city,						
						'gray_1':gray_1,
						'gray_2':gray_2,
						'gray_3':gray_3,
						'gray_4':gray_4,
						'gray_5':gray_5,
						'colors1_1':colors1_1,
						'colors1_2':colors1_2,
						'colors1_3':colors1_3,
						'colors1_4':colors1_4,
						'colors1_5':colors1_5,
						'colors1_6':colors1_6,
						'colors1_7':colors1_7,
						'colors1_8':colors1_8,
						'colors2_1':colors2_1,
						'colors2_2':colors2_2,
						'colors2_3':colors2_3,
						'colors2_4':colors2_4,
						'colors2_5':colors2_5,
						'colors2_6':colors2_6,
						'colors2_7':colors2_7,
						'colors2_8':colors2_8,
						'shape_1':shape_1,
						'shape_2':shape_2,
						'shape_3':shape_3,
						'shape_4':shape_4,
						'shape_5':shape_5,
						'shape_6':shape_6,
						'shape_7':shape_7,
						'basic_colors_1':basic_colors_1,
						'basic_colors_2':basic_colors_2,
						'basic_colors_3':basic_colors_3,
						'basic_colors_4':basic_colors_4,
						'blue_1':blue_1,
						'blue_2':blue_2,
						'blue_3':blue_3,
						'blue_4':blue_4,
						'green_1':green_1,
						'green_2':green_2,
						'green_3':green_3,
						'green_4':green_4,
						'red_1':red_1,
						'red_2':red_2,
						'red_3':red_3,
						'red_4':red_4,
						'yellow_1':yellow_1,
						'yellow_2':yellow_2,
						'yellow_3':yellow_3,
						'yellow_4':yellow_4,
						'report':report,
						'un_regular':un_regular,
						'test_type':test_type,
						'pdf_id':test_id
					},
					function(data,status){
					//alert(data);
						
						opinion_id=data;
						
						//if(data=='done'){
						//$(".sp-modal_content").css('display','table');
						//$(".offcanvas-overlay").addClass('active');	
						//}

					}).success(function(data){
							alert("success"+data);
						
						
						
								
						if(un_regular==1){
							//if(test_code!='biospace1234'){
								//$('#result_table').append(report);
								
								basic_colors_sort_value=basic_colors_sort_0+''+basic_colors_sort_1+''+basic_colors_sort_2+''+basic_colors_sort_3;
								
								//alert(basic_colors_sort_value);
								alert("text_id"+test_id);
								$('#result_ignostic').load(website_url+'/'+loading_page,
								{
								
								'value':basic_colors_sort_value,
								'test_id':test_id,
								'test_code':test_code
								
								},function(){

									alert($("#pdf_report").html());	
									alert("success");
									
											
										//generate_table_pdf_file
											$.post(website_url+"/tcpdf/tpdf/generate.php",
												{
													'full_name':full_name,
													'gender':gender,
													'birth_date':birth_date,
													'birth_time':birth_time,
													'email':email,
													'mobile':mobile,
													'country':country,
													'city':city,
													'stay_country':stay_country,
													'stay_city':stay_city,						
													'gray_1':gray_1,
													'gray_2':gray_2,
													'gray_3':gray_3,
													'gray_4':gray_4,
													'gray_5':gray_5,
													'most_color2':most_color2,
													'colors1_1':colors1_1,
													'colors1_2':colors1_2,
													'colors1_3':colors1_3,
													'colors1_4':colors1_4,
													'colors1_5':colors1_5,
													'colors1_6':colors1_6,
													'colors1_7':colors1_7,
													'colors1_8':colors1_8,
													'colors2_1':colors2_1,
													'colors2_2':colors2_2,
													'colors2_3':colors2_3,
													'colors2_4':colors2_4,
													'colors2_5':colors2_5,
													'colors2_6':colors2_6,
													'colors2_7':colors2_7,
													'colors2_8':colors2_8,
													'colors_sort_1':colors_sort1,
													'colors_sort_2':colors_sort2,
													'colors_sort_3':colors_sort3,
													'colors_sort_4':colors_sort4,
													'shape_1':shape_1,
													'shape_2':shape_2,
													'shape_3':shape_3,
													'shape_4':shape_4,
													'shape_5':shape_5,
													'shape_6':shape_6,
													'shape_7':shape_7,
													'basic_colors_1':basic_colors_sort_0,
													'basic_colors_2':basic_colors_sort_1,
													'basic_colors_3':basic_colors_sort_2,
													'basic_colors_4':basic_colors_sort_3,
													'blue_1':blue_sort_0,
													'blue_2':blue_sort_1,
													'blue_3':blue_sort_2,
													'blue_4':blue_sort_3,
													'green_1':green_sort_0,
													'green_2':green_sort_1,
													'green_3':green_sort_2,
													'green_4':green_sort_3,
													'red_1':red_sort_0,
													'red_2':red_sort_1,
													'red_3':red_sort_2,
													'red_4':red_sort_3,
													'yellow_1':yellow_sort_0,
													'yellow_2':yellow_sort_1,
													'yellow_3':yellow_sort_2,
													'yellow_4':yellow_sort_3,
													'plus_plus':plus_plus,
													'plus':plus,
													'plus_minus':plus_minus,
													'minus_minus':minus_minus,
													'report':report,
													'un_regular':un_regular,
													'test_type':test_type,
													'customer_name':'<div class="ignostic_title" >الاسم : '+full_name+'</div><br/><br/>',
													'test_id':test_id
													
												
													
											},function(data){
												alert(data);
											});			


											if(test_type=='paied'){
												//generate diagmostic pdf file
												$.post(website_url+"/tcpdf/tpdf/generate_dig.php",
												{
													'full_name':full_name,
													'report':$("#pdf_report").html(),
													'test_id':test_id
													
												
													
											},function(data){
												alert(data);
											});	
											
											}else if (test_type=='free'){
												
												//generate diagmostic free pdf file
												$.post(website_url+"/tcpdf/tpdf/generate_dig_free.php",
												{
													'full_name':full_name,
													'report':$("#pdf_report").html(),
													'test_id':test_id
													
												
														
												},function(data){
													alert(data);
												});	
											}

											
								
								}).success(function(data){
									
																		
										
							
							
								});

								
								$("#end_test").click(function(){
									window.scrollTo(0,0);
									
									basic_colors_sort_value=basic_colors_sort_0+''+basic_colors_sort_1+''+basic_colors_sort_2+''+basic_colors_sort_3;
								
									//alert(basic_colors_sort_value);
									$('#result_ignostic').load(website_url+'/'+loading_page,
									{
									
									'value':basic_colors_sort_value
									
									},function(){	
									
									});								
								
									
								});
								
								
						
						
						
							//}
						}else{
							$('#result_ignostic').html("");
							$('#result_ignostic').append('<div style="background: #fff;margin: 20px;padding-bottom: 10px;"><div class="ignostic_title">أخبار مؤسفة</div><div class="ignostic_body">تعانى من بعض المشكلات .. رجاء التواصل مع المركز</div>		<button id="contact_us" style="height:60px;width:150px;font-size:20px;display:block;margin:30px auto auto auto;" type="submit" name="submit" class="contact_us btn btn-danger btn-success" menu_open="1"> تواصل معنا <span style="margin-right:7px;" class="glyphicon glyphicon-send"></span></button></div>');
							
							}

	
						
					});
					
					
					
		}
	
	
		$('.third_btn').click();	

	});
	

	$(document).on('click', '#download_report', function(event){
			alert($("#pdf_report").html());
			alert(test_id);
		
		$.post(website_url+"/tcpdf/tpdf/generate.php",
			{
				
				'report':'<div class="ignostic_title" >الاسم : '+full_name+'</div><br/><br/>'+$("#pdf_report").html(),
				
				'test_id':test_id
			}).success(function(data){
				
				pdfurl='http://biospace-eg.com/lucher/pdfs/LucherTest-'+test_id+'.pdf';
				alert(pdfurl);
				//window.location.href = pdfurl;
				
				window.open(
				  pdfurl,
				  '_blank' // <- This is what makes it open in a new window.
				);


						
			});
	});

		
	$("#end_test").on('click',function(){
		

	});	



	
	


current_slide_num=1;
$(".slide_btn").click(function(){
	
	if($(this).attr('num')==3 && end_test==0){
		alert('لابد من انهاء الاختبار أولا لعرض النتيجة ');
		return false;
	}
	
	$(".slide_btn").removeClass('active');
	$(this).addClass('active');
	
	btn_slide_num=$(this).attr('num');
	
	if(btn_slide_num>current_slide_num){
		$(".mobile_slide"+btn_slide_num).css("left","0vw");
		$(".mobile_slide"+current_slide_num).css("left","-100vw");
		current_slide_num=btn_slide_num;
		
	}else if(btn_slide_num<current_slide_num){
		
		$(".mobile_slide"+btn_slide_num).css("left","0vw");
		$(".mobile_slide"+current_slide_num).css("left","100vw");
		current_slide_num=btn_slide_num;
		
	}
	


	
	
});


	$(document).on('click', '.client_opinion_val', function(event){


	//alert($(this).val());
	client_opinion_val=$(this).attr('value');
	//alert(client_opinion_val);
	$(".client_opinion_val").css({'background':'#fff','color':'var(--black)'});	
	$(this).css({'background':'#c288bd','color':'#fff'});
	 

});


	
	$(document).on('click', '.client_opinion_btn', function(event){
	
	if(client_opinion_val==0){
		
		alert ("قم باختيار مدى توافق التقييم مع شخصيتك");
	}else{
		
		//alert(website_url);
		$.post(website_url+"/ajax_add_opinion.php",
			{

				'id':test_id,
				'opinion_table':'basic_colors',
				'opinion_num':$(this).attr('value'),
				'opinion':client_opinion_val,
				
			},function(data){
						
				alert(data);
				$(".opinion_block").fadeOut();
				
				client_opinion_val=0;
				
				
						
			});
				
				if($(".client_opinion_btn").attr("last")!='last'){
					
					$(this).parents('.basic_colors_ignostic').hide();
					$(this).parents('.basic_colors_ignostic').next().show();
					
					$("#result_slide").animate({ scrollTop: 0 }, "slow");
					
				}else{
					
					$(this).parents('.basic_colors_ignostic').hide();
					$("#download_dig").show();
					
				}
	}
	
	
});






});