
var tempTarget;
var tempButton;
var tempToggle;
var tempThumb;
var tempId;
var a_id;
var a_i;


/*
thumbList0 = new Array();
thumbList0[0] = {src:"i/horses/rubix/rubix_1_th.jpg",hero:"i/horses/rubix/rubix_1.jpg",width:"550",height:"458"};
thumbList0[1] = {src:"i/horses/rubix/rubix_2_th.jpg",hero:"i/horses/rubix/rubix_2.jpg",width:"550",height:"458"};
thumbList0[2] = {src:"i/horses/rubix/rubix_3_th.jpg?rnd=b",hero:"i/horses/rubix/rubix_3.jpg",width:"550",height:"458"};
thumbList0[3] = {src:"i/horses/rubix/rubix_4_th.jpg",hero:"i/horses/rubix/rubix_4.jpg",width:"550",height:"458"};
thumbList0[4] = {src:"i/horses/rubix/rubix_5_th.jpg",hero:"i/horses/rubix/rubix_5.jpg",width:"550",height:"458"};
thumbList0[5] = {src:"i/horses/rubix/rubix_6_th.jpg",hero:"i/horses/rubix/rubix_6.jpg",width:"550",height:"458"};

thumbList1 = new Array();
thumbList1[0] = {src:"i/horses/clue/clue_1_th.jpg",hero:"i/horses/clue/clue_1.jpg",width:"550",height:"458"};
thumbList1[1] = {src:"i/horses/clue/clue_2_th.jpg",hero:"i/horses/clue/clue_2.jpg",width:"550",height:"458"};
thumbList1[2] = {src:"i/horses/clue/clue_3_th.jpg",hero:"i/horses/clue/clue_3.jpg",width:"550",height:"458"};
thumbList1[3] = {src:"i/horses/clue/clue_4_th.jpg",hero:"i/horses/clue/clue_4.jpg",width:"550",height:"458"};
thumbList1[4] = {src:"i/horses/clue/clue_5_th.jpg",hero:"i/horses/clue/clue_5.jpg",width:"550",height:"458"};
thumbList1[5] = {src:"i/horses/clue/clue_6_th.jpg",hero:"i/horses/clue/clue_6.jpg",width:"550",height:"458"};
*/




function show(id){	
	
  if (document.getElementById)
        {
        
	var n = 'horse'+id;
	var b = "horse_button"+id;
	var t = "horse_toggle"+id;
        
        
        var target = document.getElementById(n);       
        var buttonName = document.getElementById(b);
	var toggleName = document.getElementById(t);
		
	buttonName.src = "i/close.gif";
	
	toggleName.style.backgroundColor = "#643f17";
	toggleName.style.backgroundImage = "url(i/grad.gif)"
	toggleName.style.backgroundRepeat="no-repeat"
			
	var name = "hero"+id
	var hero_target = document.getElementById(name);

	if(!hero_target.src){
		var tl = this['thumbList'+id];
		swapHero(tl[0].hero,id,0,tl[0].width,tl[0].height);	        
	}else{
				
		manageThumb(horseList[id].a_id,horseList[id].a_i);
	}
			

		
        }
      

        tempTarget = target;
        tempButton = buttonName;
        tempToggle = toggleName;
        
}
function toggleObject(id){
	 if (document.getElementById){
		var n = 'horse'+id;
		var b = "horse_button"+id;
		var t = "horse_toggle"+id;
	 	
		var target = document.getElementById(n);       
		var buttonName = document.getElementById(b);
		var toggleName = document.getElementById(t);
		
	 	if (target.style.display == "none"){
	 		target.style.display = "block";
	 		buttonName.src = "i/close.gif";
	 		toggleName.style.backgroundImage = "url(i/grad.gif)";
	 		toggleName.style.backgroundRepeat="no-repeat";
	 		toggleName.style.backgroundColor = "#643f17";
	 	}else{
	 		target.style.display = "none";
	 		buttonName.src = "i/open.gif";
	 		toggleName.style.backgroundImage = "";
			if(toggleName.className=="toggle"){
				toggleName.style.backgroundColor = "#797475";
			}else{
				toggleName.style.backgroundColor = "#666465";
			}	 		
	 	}
	 	
	 	
	 }
}

function buildThumbs(num){
	
	var tl = this['thumbList'+num];
	var h = (458-((tl.length)*74))-20

	var th ='';
	for(i=0;i<tl.length;i++){
		th +='<tr><td><a href="#" onclick="swapHero(\''+tl[i].hero+'\',\''+num+'\',\''+i+'\',\''+tl[i].width+'\',\''+tl[i].height+'\');return false;"><img  id = "th_'+num+i+'" class="thumb" src="'+tl[i].src+'" width = "88" height = "64"></a></td></tr><tr height="10"/>';
	}
	th +='<tr height="'+h+'"/>'
	return th;
}
function swapHero(path,id,i,w,h){


	var name = "hero"+id
	var hero_target = document.getElementById(name);
	
	hero_target.width=w;
	hero_target.height=h;
	hero_target.src=path;
	

	manageThumb(id,i)	
}

function manageThumb(id,i){
	var t_id = 'th_'+id+i	
	var thumb = document.getElementById(t_id);
	
	var l = this['thumbList'+id].length;
	for(j=0;j<l;j++){
		var tId = 'th_'+id+j
		var temp_thumb = document.getElementById(tId);
		temp_thumb.style.borderWidth= '0em';
	}
	if(thumb){
		thumb.style.borderWidth= '1px';
	}
	//
	if(tempThumb&&id==tempId){
		
		tempThumb.style.borderWidth= '0em';
	}
	//
	tempThumb = thumb;
	tempId = id;
}
function init(){	

	show('0');
	show('1');
	
}