﻿/**
 * @author Ron
 */
var q = 1;
var questions = new Array(
		'I bring my creativity with me to every meeting and use it in every interaction. It is truly a part of who I am.',
		'Before beginning a project that requires creativity, I always understand clearly what I am trying to accomplish.',
		'I am comfortable sharing my opinion and taking risks at work.',
		'I rarely run out of sources of creativity. I have many sources of inspiration at my disposal.',
		'My colleagues and I feel as though we have too many breakthrough ideas as opposed to not enough.',
		'In my team, the best idea wins, not the person with the fanciest title.',
		'I feel I have a large supply of creativity inside me.',
		'I regularly challenge and question the status quo.',
		'I routinely dowarm-up exercises to prepare to unleashmy best thinking.',
		'When faced with a creative challenge, I usually can get started quickly and easily.',
		'Brainstorming sessions are frequent, fun, focused, and productive at my company.',
		'We have a system for sorting out the best ideas from the not-as-good ones.',
		'Where I work, creativity is for everyone . . . not just something those ‘‘art’’ people do.',
		'I often find myself wondering about possibilities and wondering why some things don’t currently exist.',
		'When working on new ideas, I leave my normal surroundings and find a physical environment that enables my creativity.',
		'I feel confident enough to tackle any creative challenge, big or small.',
		'When my teamand I work to develop new ideas, we usemany different and powerful techniques to uncover our best thinking.',
		'I feel that our system for measuring ideas and creativity is sufficient.',
		'Creativity is valued, nurtured, and rewarded in my organization.',
		'I rarely accept things as they are, and often question authority.',
		'As I create new things, I rarely edit as I go.',
		'I have an abundance of techniques for spurring my best thinking.',
		'I have a vivid imagination and often come up with ‘‘wacky’’ ideas.',
		'Once I have a good idea, I usually test it before bringing it to the world.',
		'Creativity, original thought, and imagination are some of my top personal and professional priorities.',
		'I am highly aware of my surroundings and environment.',
		'I feel comfortable taking risks and contributing my most innovative ideas with no fear of embarrassment or retribution.',
		'I regularly use metaphors and analogies.',
		'We have a good system in place to generate creative ideas for any type of challenge.',
		'When we generate good ideas, there is always a clear next step for putting them into action.'
	);
var result = new Array();
result['all'] = 0;
result['a'] = new Array();
result['a']['sum'] = 0;
result['a']['quest'] = [1,7,13,19,25];
result['b'] = new Array();
result['b']['sum'] = 0;
result['b']['quest'] = [2,8,14,20,26];
result['c'] = new Array();
result['c']['sum'] = 0;
result['c']['quest'] = [3,9,15,21,27];
result['d'] = new Array();
result['d']['sum'] = 0;
result['d']['quest'] = [4,10,16,22,28];
result['e'] = new Array();
result['e']['sum'] = 0;
result['e']['quest'] = [5,11,17,23,29];
result['f'] = new Array();
result['f']['sum'] = 0;
result['f']['quest'] = [6,12,18,24,30];

jQuery(document).ready(function(){
	jQuery('#test').click(function(){
		jQuery('body').append(
			'<div class="popup popup-question"><a onclick="closePopup();" class="close" href="#">Close</a><div class="indent" id="quest">'+
			'</div></div>'
		);
		loadQuestion(themeDir);
	});
	
});

function loadQuestion(path){
	jQuery.ajax({
		type: "GET",
		url: path+"/test/q.html",
		success: function(data){
			jQuery('.popup .indent').html(data);
			jQuery('#quest h3').before('<span class="pages">'+q+' of 30</span>');
			jQuery('#quest h3').html(questions[q-1]);
			jQuery('.popup .indent').append('<a href="#" class="button" onclick="getAnswer()"><img src="'+themeDir+'/images/button-next.png" alt="" /></a>');
			jQuery('.popup').toggle();
			q++;
		}
	});
}

function getAnswer(){
	if( ! jQuery("#testquest input:checked").val() ){
		alert('Please select the answer! ');
	} else {
		var value = parseInt( jQuery("#testquest input:checked").val() );
		result['all'] = result['all'] + value;
		if( jQuery.inArray(q-1, result['a']['quest']) >= 0 ){
			result['a']['sum'] = result['a']['sum'] + value;
			alert
		}
		if( jQuery.inArray(q, result['b']['quest']) >= 0 ){
			result['b']['sum'] = result['b']['sum'] + value;
		}
		if( jQuery.inArray(q, result['c']['quest']) >= 0 ){
			result['c']['sum'] = result['c']['sum'] + value;
		}
		if( jQuery.inArray(q, result['d']['quest']) >= 0 ){
			result['d']['sum'] = result['d']['sum'] + value;
		}
		if( jQuery.inArray(q, result['e']['quest']) >= 0 ){
			result['e']['sum'] = result['e']['sum'] + value;
		}
		if( jQuery.inArray(q, result['f']['quest']) >= 0 ){
			result['f']['sum'] = result['f']['sum'] + value;
		}
		if(q <= 30){
			jQuery('#quest .pages').html(q+' of 30');
			jQuery('#quest h3').html(questions[q-1]);
		} else {
			loadResult(result, themeDir);
		}
		q++;
		jQuery("#testquest input:checked").removeAttr('checked');
	}
	return false;
}

function loadResult(res, path){
	var text = new Array();
	if( res['all'] <= 84 )
		text['all'] = 'You are in the creativity danger zone. This score should serve as a loud wake-up call to you and your organization; it should signal that something must be changed or you will run into significant problems moving forward. You are a lost creative soul and need to immediately reconnect with your imagination. Your organization is holding you back, and you need to become a change agent to reshape your company or find a new one. Although this information may be alarming, don’t get too discouraged. You are about to go through a transformational change by putting the Disciplined Dreaming process to work. You will immediately enjoy a boost in your creativity and have a lot of fun in the process. It will push you outside your comfort zone, so please remember that that’s the only place where real growth happens.';
	if( res['all'] >= 85 && res['all'] <= 109 )
		text['all'] = 'Unfortunately, you are in the same situation as nearly 60 percent of the business population. You probably have great creative abilities, but they are being significantly restricted most of the time. You are probably frustrated with the bureaucracy of your organization or have a number of limiting beliefs that are holding you back from expressing your true creative abilities. You may tell yourself such stories as ‘‘I’m not creative’’ or ‘‘I can’t share by ideas because people will laugh at me.’’ Your creativity muscles need to be dusted off and given a rigorous workout. The good news is that you will see immediate and tremendous growth by using the Disciplined Dreaming system. You are about to unlock creativity you didn’t even know you had, and will enjoy an exciting new way of approaching the world.';
	if( res['all'] >= 110 && res['all'] <= 129 )
		text['all'] = 'Certainly not bad, but you have a lot of room for improvement. This score indicates that you are doing many things right, but also have some significant barriers that are getting in theway of your creativity. You may be in an organization that is inhibiting your creativity and holding you back. This score range should alert you that you have a lot of creative potential butmay not be using it effectively. You will grow tremendously by putting the Disciplined Dreaming process to work for the benefit of your company and yourself.';
	if( res['all'] >= 130 )
		text['all'] = 'You are in amuch better spot thanmost, as this score puts you in the top 10 percent of creative individuals and companies. You are connected to your creative self and are in an organization that supports it. This score also means that you are well situated to continue to grow your creative capacity and are on your way to reaching your full potential. The techniques and concepts you will learn in this book will be instrumental in helping you further grow';
	text[0] = 'Excellent';
	text[1] = 'Above average';
	text[2] = 'Average';
	text[3] = 'Below average';
	jQuery.ajax({
		type: "GET",
		url: path+"/test/result.html",
		success: function(data){
			jQuery('.popup .indent').html(data);
			jQuery('.popup').removeClass('popup-question');
			jQuery('p.all').html(text['all']);
			if( res['a']['sum'] >=22 ){
				jQuery('td.a').html(text[0]);
			}
			if( res['a']['sum'] >=19 && res['a']['sum'] <=21 ){
				jQuery('td.a').html(text[1]);
			}
			if( res['a']['sum'] >=17 && res['a']['sum'] <=19 ){
				jQuery('td.a').html(text[2]);
			}
			if( res['a']['sum'] <= 16 ){
				jQuery('td.a').html(text[3]);
			}
				
			if( res['b']['sum'] >=22 )
				jQuery('td.b').html(text[0]);
			if( res['b']['sum'] >=19 && res['b']['sum'] <=21 )
				jQuery('td.b').html(text[1]);
			if( res['b']['sum'] >=17 && res['b']['sum'] <=19 )
				jQuery('td.b').html(text[2]);
			if( res['b']['sum'] <= 16 )
				jQuery('td.b').html(text[3]);
				
			if( res['c']['sum'] >=22 )
				jQuery('td.c').html(text[0]);
			if( res['c']['sum'] >=19 && res['c']['sum'] <=21 )
				jQuery('td.c').html(text[1]);
			if( res['c']['sum'] >=17 && res['c']['sum'] <=19 )
				jQuery('td.c').html(text[2]);
			if( res['c']['sum'] <= 16 )
				jQuery('td.c').html(text[3]);
				
			if( res['d']['sum'] >=22 )
				jQuery('td.d').html(text[0]);
			if( res['d']['sum'] >=19 && res['d']['sum'] <=21 )
				jQuery('td.d').html(text[1]);
			if( res['d']['sum'] >=17 && res['d']['sum'] <=19 )
				jQuery('td.d').html(text[2]);
			if( res['d']['sum'] <= 16 )
				jQuery('td.d').html(text[3]);
				
			if( res['e']['sum'] >=22 )
				jQuery('td.e').html(text[0]);
			if( res['e']['sum'] >=19 && res['e']['sum'] <=21 )
				jQuery('td.e').html(text[1]);
			if( res['e']['sum'] >=17 && res['e']['sum'] <=19 )
				jQuery('td.e').html(text[2]);
			if( res['e']['sum'] <= 16 )
				jQuery('td.e').html(text[3]);
				
			if( res['f']['sum'] >=22 )
				jQuery('td.f').html(text[0]);
			if( res['f']['sum'] >=19 && res['f']['sum'] <=21 )
				jQuery('td.f').html(text[1]);
			if( res['f']['sum'] >=17 && res['f']['sum'] <=19 )
				jQuery('td.f').html(text[2]);
			if( res['f']['sum'] <= 16 )
				jQuery('td.f').html(text[3]);
		}
	});
	
}

function closePopup(){
	jQuery('.popup').remove();
	q = 1;
	result['all'] = 0;
	result['a']['sum'] = 0;
	result['b']['sum'] = 0;
	result['c']['sum'] = 0;
	result['d']['sum'] = 0;
	result['e']['sum'] = 0;
	result['f']['sum'] = 0;
	return false;
}
