// var alertTimerId = 0;
var photos=new Array()
var photoslink=new Array()
var photoslinknewwindow=new Array()
var which=0
var user_answers=new Array()

//user answers - clear them out
user_answers[0]=""
user_answers[1]=""
user_answers[2]=""
user_answers[3]=""
user_answers[4]=""
user_answers[5]=""
user_answers[6]=""
user_answers[7]=""
user_answers[8]=""
user_answers[9]=""

//define images. You can have as many as you want:
photos[0]="game_seed_1.jpg"
photos[1]="game_seed_2.jpg"
photos[2]="game_seed_3.jpg"
photos[3]="game_seed_4.jpg"
photos[4]="game_seed_5.jpg"
photos[5]="game_seed_6.jpg"
photos[6]="game_seed_7.jpg"
photos[7]="game_seed_8.jpg"
photos[8]="game_seed_9.jpg"
photos[9]="game_seed_10.jpg"

//Specify whether images should be linked or not (1=linked)
var linkornot=0

//Set corresponding URLs for above images. Define ONLY if variable linkornot equals "1"
photoslink[0]=""
photoslink[1]=""
photoslink[2]=""
photoslink[3]=""
photoslink[4]=""
photoslink[5]=""
photoslink[6]=""
photoslink[7]=""
photoslink[8]=""
photoslink[9]=""

//Set corresponding new window targets = 0 = no, 1 = yes
photoslinknewwindow[0]=0;
photoslinknewwindow[1]=0;
photoslinknewwindow[2]=0;
photoslinknewwindow[3]=0;
photoslinknewwindow[4]=0;
photoslinknewwindow[5]=0;
photoslinknewwindow[6]=0;
photoslinknewwindow[7]=0;
photoslinknewwindow[8]=0;
photoslinknewwindow[9]=0;
// line 58
//do NOT edit pass this line

var preloadedimages=new Array()
for (i=0;i<photos.length;i++){
preloadedimages[i]=new Image()
preloadedimages[i].src=photos[i]
}


function applyeffect(id){
if (document.all && photoslider.filters){
photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
//photoslider.filters.revealTrans.Transition=id
photoslider.filters.revealTrans.stop()
photoslider.filters.revealTrans.apply()
}
}



function playeffect(){
if (document.all && photoslider.filters)
photoslider.filters.revealTrans.play()
}

function keeptrack(){
// window.status="Image "+(which+1)+" of "+photos.length
}


// function backward(){
// 	clearTimeout ( alertTimerId );
// 	if (which==0){
// 		which=photos.length;
// 	}
// 	which--
// 	applyeffect(7)
// 	document.images.photoslider.src=photos[which]
// 	playeffect()
// 	keeptrack()
// 	alertTimerId = setTimeout ("forward(1)", 10000 );
// }
//line 101
function forward(id){
	var txt='';
	var final_score=0;
	user_answers[which]=get_radio_value()

	if (which==photos.length-1){
		// calculate score
		if (user_answers[0] == 'Harvester Beans') {
			final_score++;
		}
		if (user_answers[1] == 'Cylindra Beets') {
			final_score++;
		}
		if (user_answers[2] == 'Red Acre Cabbage') {
			final_score++;
		}
		if (user_answers[3] == 'Purple Haze Hybrid Carrot') {
			final_score++;
		}
		if (user_answers[4] == 'Armenian Yard-Long Cucumber') {
			final_score++;
		}
		if (user_answers[5] == 'Ichiban Eggplant') {
			final_score++;
		}
		if (user_answers[6] == 'Iceberg Lettuce') {
			final_score++;
		}
		if (user_answers[7] == 'White Sweet Spanish Onion') {
			final_score++;
		}
		if (user_answers[8] == 'Thai Dragon Pepper') {
			final_score++;
		}
		if (user_answers[9] == 'Beefsteak Tomato') {
			final_score++;
		}

		my_percentage=final_score*10;

		body_text='scored a '+my_percentage+'% on Mike the Gardeners`s quiz, `How well do you know your vegetables`.  Test your knowledge by visiting http://www.averagepersongardening.com/guess_that_seed.html today';

//		txt='<table width=100% cellspacing=1 cellpadding=1>';
//		txt+='	<tr><td valign=top align=left><span class="websitefeaturedarticlefont">Post your results on Facebook</span></td>';
//		txt+='	<td valign=top align=right><a href="#" onclick="callPublish(\'\',{\'name\':\'How well do you know your Vegetables?\',\'href\':\'http://www.averagepersongardening.com/guess_that_seed.html\',\'description\':\''+body_text+'\',\'media\':[{\'type\':\'image\',\'src\':\'http://www.averagepersongardening.com/big_square_logo.jpg\',\'href\':\'http://www.averagepersongardening.com\'}]},null);return false;"><img src="facebook_share_your_results.png" border="0" alt="Share your results on Facebook"></a></td></tr>';
//		txt+='</table>';
//see if we can automate the call to publish
//		callPublish('',{'name':'How well do you know your Vegetables? (version 2.0)','href':'http://www.averagepersongardening.com/guess_that_seed.html','description':''+body_text+'','media':[{'type':'image','src':'http://www.averagepersongardening.com/big_square_logo.jpg','href':'http://www.averagepersongardening.com'}]},null);

//		callPublish('',{'name':'How well do you know your Vegetables?','href':'http://www.averagepersongardening.com/guess_that_seed.html','description':''+body_text+'','media':[{'type':'image','src':'http://www.averagepersongardening.com/big_square_logo.jpg','href':'http://www.averagepersongardening.com'}]},null);

		document.getElementById('game_seed_options').innerHTML=txt;
		document.getElementById('display_icon').innerHTML='';
		document.getElementById('question_header').innerHTML='You scored: '+my_percentage+'%';
		document.getElementById('game_seed_images').innerHTML='';
	}
	else {
		which++
		applyeffect(6)
		document.images.photoslider.src=photos[which]
		playeffect()
		keeptrack()
		game_seed_choices(which)
	}
}

function transport(){
	if (photoslinknewwindow[which]==1) {
		window.open(photoslink[which])	//new window
	}
	else {		
		window.location=photoslink[which]	//same window
	}

}

// function start_our_timer() {
// 	alertTimerId = setTimeout ("forward(1)", 5000 );
// }


function get_radio_value()
{
for (var i=0; i < document.frmgameseed.seed_game.length; i++)
   {
   if (document.frmgameseed.seed_game[i].checked)
      {
      var rad_val = document.frmgameseed.seed_game[i].value;
      }
   }
	return rad_val;
}

function game_seed_choices(id) {
	var txt='';
	var choice_array=new Array();

	switch (id){
		case 0:	
			choice_array[0]="Royal Burgundy Beans";
			choice_array[1]="Harvester Beans";
			choice_array[2]="Golden Wax Beans";
			choice_array[3]="Henderson Lima Beans";
			choice_array[4]="Broad Windsor Beans";
			break;
		case 1:	
			choice_array[0]="Sugar Beets";
			choice_array[1]="Bulls Blood Beets";
			choice_array[2]="Golden Detroit Beets";
			choice_array[3]="Early Wonder Tall Top Beets";
			choice_array[4]="Cylindra Beets";
			break;
		case 2:	
			choice_array[0]="Red Acre Cabbage";
			choice_array[1]="Golden Acre Cabbage";
			choice_array[2]="Mammoth Red Rock Cabbage";
			choice_array[3]="Pak Choi White Stem Cabbage";
			choice_array[4]="Savoy Express Cabbage";
			break;
		case 3:	
			choice_array[0]="Chantenay Red Core Carrot";
			choice_array[1]="Danvers Half-Long Carrot";
			choice_array[2]="Imperator Carrot";
			choice_array[3]="Purple Haze Hybrid Carrot";
			choice_array[4]="Scarlet Nantes Carrot";
			break;
		case 4:	
			choice_array[0]="Armenian Yard-Long Cucumber";
			choice_array[1]="Wisconsin SMR Cucumber";
			choice_array[2]="Sweet Success Hybrid Cucumber";
			choice_array[3]="Salad Bush Hybrid Cucumber";
			choice_array[4]="Oriental Express Hybrid Cucumber";
			break;
		case 5:	
			choice_array[0]="Black Beauty Eggplant";
			choice_array[1]="Fairy Tale Hybrid Eggplant";
			choice_array[2]="Gretel Hybrid Eggplant";
			choice_array[3]="Ichiban Eggplant";
			choice_array[4]="Hansel Hybrid Eggplant";
			break;
		case 6:	
			choice_array[0]="Summertime Lettuce";
			choice_array[1]="Parris Island Cos Lettuce";
			choice_array[2]="Cimmaron Lettuce";
			choice_array[3]="Mesclun Mix Lettuce";
			choice_array[4]="Iceberg Lettuce";
			break;
		case 7:	
			choice_array[0]="Red Burgundy Onion";
			choice_array[1]="White Sweet Spanish Onion";
			choice_array[2]="Tokyo Long White Onion";
			choice_array[3]="Crystal White Wax Onion";
			choice_array[4]="Golden Onion";
			break;
		case 8:	
			choice_array[0]="Thai Dragon Pepper";
			choice_array[1]="Anaheim Chili Pepper";
			choice_array[2]="Holy Mole Hybrid Pepper";
			choice_array[3]="Mucha Nacho Pepper";
			choice_array[4]="Banana Pepper";
			break;
		case 9:	
			choice_array[0]="Red Grape Tomato";
			choice_array[1]="LaRoma II Red Tomato";
			choice_array[2]="Large Red Cherry Tomato";
			choice_array[3]="Yellow Pear Tomato";
			choice_array[4]="Beefsteak Tomato";
			break;
	}
	question_number='QUESTION: '+(id+1) + ' of 10';
	document.getElementById('question_header').innerHTML=question_number;

	txt='<table cellspacing=1 cellpadding=1><tr><td valign=top align=left><input type=radio name="seed_game" id="seed_game" value="'+choice_array[0]+'" checked><span class="websitefeaturedarticlefont">'+choice_array[0]+'</span></td></tr><tr><td valign=top align=left><input type=radio name="seed_game" id="seed_game" value="'+choice_array[1]+'"><span class="websitefeaturedarticlefont">'+choice_array[1]+'</span></td></tr><tr><td valign=top align=left><input type=radio name="seed_game" id="seed_game" value="'+choice_array[2]+'"><span class="websitefeaturedarticlefont">'+choice_array[2]+'</span></td></tr><tr><td valign=top align=left><input type=radio name="seed_game" id="seed_game" value="'+choice_array[3]+'"><span class="websitefeaturedarticlefont">'+choice_array[3]+'</span></td></tr><tr><td valign=top align=left><input type=radio name="seed_game" id="seed_game" value="'+choice_array[4]+'"><span class="websitefeaturedarticlefont">'+choice_array[4]+'</span></td></tr></table>';
	document.getElementById('game_seed_options').innerHTML = txt;
}	
function post_results() {
	title='I%Scored%a%10%out%of%10';
	strHref = 'http://www.facebook.com/sharer.php?u=' + window.location.href + '&amp;t=' + title + '';
	window.open(strHref);	
//	alert('HELLO WORLD');
}



function callPublish(msg, attachment, action_link) {
  FB.ensureInit(function () {
    FB.Connect.streamPublish('Ask your friends to take the test...', attachment, action_link,);
  });
}


function publish_to_facebook() {
		body_text='Mike the Gardener Enterprises';
		callPublish('',{'name':'How well do you know your Vegetables?','href':'http://www.averagepersongardening.com/guess_that_seed.html','description':''+body_text+'','media':[{'type':'image','src':'http://www.averagepersongardening.com/big_square_logo.jpg','href':'http://www.averagepersongardening.com'}]},null);
}