// JavaScript Document

//DIRECTIONS
// create preloaded arrays for each gallery subfolder.
//limit each gallery subfolder to 20 images max
//each gallery subfolder should contain a thumb image (100px x 100px) and a viewport image (400px x 400px)
//even numbers are thumbs and odd numbers are viewport images


//preloaded galleries

//Test gallery
var testgal= new String (">>Test Gallery");

var testbor=new Array ();
testbor[0]="../images/gallery/test_images/camp_thumb_bordered.png";
testbor[1]="../images/gallery/test_images/kata_thumb_bordered.png";
testbor[2]="../images/gallery/test_images/kyu_thumb_bordered.png";
testbor[3]="../images/gallery/test_images/sensei_thumb_bordered.png";
testbor[4]="../images/gallery/test_images/shihan_thumb_bordered.png";
testbor[5]="../images/gallery/test_images/shodan_thumb_bordered.png";
testbor[6]="../images/gallery/test_images/tourney_thumb_bordered.png";

var testtit= new Array ();
testtit[0]=new String('Camp');
testtit[1]=new String('Kata');
testtit[2]=new String('Kyu');
testtit[3]=new String('Sensei');
testtit[4]=new String('Shihan');
testtit[5]=new String('Shodan');
testtit[6]=new String('Tourney');

var test= new Array ();
test[0]="../images/gallery/test_images/camp.png";
test[1]="../images/gallery/test_images/camp_vp.png";
test[2]="../images/gallery/test_images/kata.png";
test[3]="../images/gallery/test_images/kata_vp.png";
test[4]="../images/gallery/test_images/kyu.png";
test[5]="../images/gallery/test_images/kyu_vp.png";
test[6]="../images/gallery/test_images/sensei.png";
test[7]="../images/gallery/test_images/sensei_vp.png";
test[8]="../images/gallery/test_images/shihan.png";
test[9]="../images/gallery/test_images/shihan_vp.png";
test[10]="../images/gallery/test_images/shodan.png";
test[11]="../images/gallery/test_images/shodan_vp.png";
test[12]="../images/gallery/test_images/tourney.png";
test[13]="../images/gallery/test_images/tourney_vp.png";
//end Test gallery

//calyud Gallery
var calyudgal= new String (">>California Yudansha");

var calyudbor=new Array ();
calyudbor[0]="../images/gallery/California_Yudansha/Calwk_thumb_bordered.png";
calyudbor[1]="../images/gallery/California_Yudansha/blkcamp_thumb_bordered.jpg";
calyudbor[2]="../images/gallery/California_Yudansha/ClaSol_thumb_bordered.png";
calyudbor[3]="../images/gallery/California_Yudansha/Conferencing_thumb_bordered.png";
calyudbor[4]="../images/gallery/California_Yudansha/DenMin_thumb_bordered.png";
calyudbor[5]="../images/gallery/California_Yudansha/Group_thumb_bordered.png";
calyudbor[6]="../images/gallery/California_Yudansha/Group2_thumb_bordered.png";
calyudbor[7]="../images/gallery/California_Yudansha/Group3_thumb_bordered.png";
calyudbor[8]="../images/gallery/California_Yudansha/Satwk_thumb_bordered.png";
calyudbor[9]="../images/gallery/California_Yudansha/Shoreimobile_thumb_bordered.png";
calyudbor[10]="../images/gallery/California_Yudansha/TapDen_thumb_bordered.png";

var calyudtit= new Array ();
calyudtit[0]=new String('California Workout with Sanders 1');
calyudtit[1]=new String('California Karate Camp');
calyudtit[2]=new String('Classic Soltis Sensei Pose');
calyudtit[3]=new String('Yudansha Meeting');
calyudtit[4]=new String('Campos and Tamayo');
calyudtit[5]=new String('Group Shot 1');
calyudtit[6]=new String('Group Shot 2');
calyudtit[7]=new String('Group Shot 3');
calyudtit[8]=new String('Saturday Workout');
calyudtit[9]=new String('Infamous Shorei Mobile');
calyudtit[10]=new String('Tapia and Campos');

var calyud= new Array ();
calyud[0]="../images/gallery/California_Yudansha/Calwk.png";
calyud[1]="../images/gallery/California_Yudansha/Calwk_vp.png";
calyud[2]="../images/gallery/California_Yudansha/blkcamp.jpg";
calyud[3]="../images/gallery/California_Yudansha/blkcamp_vp.png";
calyud[4]="../images/gallery/California_Yudansha/ClaSol.png";
calyud[5]="../images/gallery/California_Yudansha/ClaSol_vp.png";
calyud[6]="../images/gallery/California_Yudansha/Conferencing.png";
calyud[7]="../images/gallery/California_Yudansha/Conferencing_vp.png";
calyud[8]="../images/gallery/California_Yudansha/DenMin.png";
calyud[9]="../images/gallery/California_Yudansha/DenMin_vp.png";
calyud[10]="../images/gallery/California_Yudansha/Group.png";
calyud[11]="../images/gallery/California_Yudansha/Group_vp.png";
calyud[12]="../images/gallery/California_Yudansha/Group2.png";
calyud[13]="../images/gallery/California_Yudansha/Group2_vp.png";
calyud[14]="../images/gallery/California_Yudansha/Group3.png";
calyud[15]="../images/gallery/California_Yudansha/Group3_vp.png";
calyud[16]="../images/gallery/California_Yudansha/Satwk.png";
calyud[17]="../images/gallery/California_Yudansha/Satwk_vp.png";
calyud[18]="../images/gallery/California_Yudansha/Shoreimobile.png";
calyud[19]="../images/gallery/California_Yudansha/Shoreimobile_vp.png";
calyud[20]="../images/gallery/California_Yudansha/TapDen.png";
calyud[21]="../images/gallery/California_Yudansha/TapDen_vp.png";
//end California Yudansha

//group gallery
var groupgal= new String (">>Group Gallery");

var groupbor=new Array ();
groupbor[0]="../images/gallery/Group/3of5_thumb_bordered.png";
groupbor[1]="../images/gallery/Group/award_thumb_bordered.png";
groupbor[2]="../images/gallery/Group/kyu_thumb_bordered.png";
groupbor[3]="../images/gallery/Group/kyu2_thumb_bordered.png";
groupbor[4]="../images/gallery/Group/mon_thumb_bordered.png";
groupbor[5]="../images/gallery/Group/nm_thumb_bordered.png";
groupbor[6]="../images/gallery/Group/nm2_thumb_bordered.png";
groupbor[7]="../images/gallery/Group/whbelt_thumb_bordered.png";

var grouptit= new Array ();
grouptit[0]=new String('3 Out of 5 Promoted to Black Belt');
grouptit[1]=new String('Receiving an Award');
grouptit[2]=new String('Attentive Kyu Ranks');
grouptit[3]=new String('Los Angeles Shorei-ryu Students');
grouptit[4]=new String('Shorei-ryu Mon Designer: John S. Soltis');
grouptit[5]=new String('Visit to New Mexico 1');
grouptit[6]=new String('Visit to New Mexico 2');
grouptit[7]=new String('White Belts');

var group= new Array ();
group[0]="../images/gallery/Group/3of5.png";
group[1]="../images/gallery/Group/3of5_vp.png";
group[2]="../images/gallery/Group/award.png";
group[3]="../images/gallery/Group/award_vp.png";
group[4]="../images/gallery/Group/kyu.png";
group[5]="../images/gallery/Group/kyu_vp.png";
group[6]="../images/gallery/Group/kyu2.png";
group[7]="../images/gallery/Group/kyu2_vp.png";
group[8]="../images/gallery/Group/mon.png";
group[9]="../images/gallery/Group/mon_vp.png";
group[10]="../images/gallery/Group/nm.png";
group[11]="../images/gallery/Group/nm_vp.png";
group[12]="../images/gallery/Group/nm2.png";
group[13]="../images/gallery/Group/nm2_vp.png";
group[14]="../images/gallery/Group/whbelt.png";
group[15]="../images/gallery/Group/whbelt_vp.png";
//end group gallery

//lynwood gallery
var lynwoodgal= new String (">>Lynwood Gallery");

var lynwoodbor=new Array ();
lynwoodbor[0]="../images/gallery/lynwood/clpic_thumb_bordered.png";
lynwoodbor[1]="../images/gallery/lynwood/olly_thumb_bordered.png";
lynwoodbor[2]="../images/gallery/lynwood/olcla_thumb_bordered.png";
lynwoodbor[3]="../images/gallery/lynwood/olbu_thumb_bordered.png";
lynwoodbor[4]="../images/gallery/lynwood/ogly_thumb_bordered.png";
lynwoodbor[5]="../images/gallery/lynwood/ogly1_thumb_bordered.png";
lynwoodbor[6]="../images/gallery/lynwood/new1_thumb_bordered.png";
lynwoodbor[7]="../images/gallery/lynwood/new2_thumb_bordered.png";
lynwoodbor[8]="../images/gallery/lynwood/new4_thumb_bordered.png";
lynwoodbor[9]="../images/gallery/lynwood/banner_thumb_bordered.jpg";

var lynwoodtit= new Array ();
lynwoodtit[0]=new String('Lynwood Class Picture');
lynwoodtit[1]=new String('Recently Relocated to New Dojo');
lynwoodtit[2]=new String('Original Lynwood Class');
lynwoodtit[3]=new String('Bunche Class (Now merged with Lynwood)');
lynwoodtit[4]=new String('Old Lynwood Dojo Wall 1');
lynwoodtit[5]=new String('Old Lynwood Dojo Wall 2');
lynwoodtit[6]=new String('Lynwood in Newspaper 1');
lynwoodtit[7]=new String('Lynwood in Newspaper 2');
lynwoodtit[8]=new String('Lynwood in Newspaper 3');
lynwoodtit[9]=new String('Infamous Banner with Misspelling')



var lynwood= new Array ();
lynwood[0]="../images/gallery/lynwood/clpic.png";
lynwood[1]="../images/gallery/lynwood/clpic_vp.png";
lynwood[2]="../images/gallery/lynwood/olly.png";
lynwood[3]="../images/gallery/lynwood/olly_vp.png";
lynwood[4]="../images/gallery/lynwood/olcla.png";
lynwood[5]="../images/gallery/lynwood/olcla_vp.png";
lynwood[6]="../images/gallery/lynwood/olbu.png";
lynwood[7]="../images/gallery/lynwood/olbu_vp.png";
lynwood[8]="../images/gallery/lynwood/ogly.png";
lynwood[9]="../images/gallery/lynwood/ogly_vp.png";
lynwood[10]="../images/gallery/lynwood/ogly1.png";
lynwood[11]="../images/gallery/lynwood/ogly1_vp.png";
lynwood[12]="../images/gallery/lynwood/new1.png";
lynwood[13]="../images/gallery/lynwood/new1_vp.png";
lynwood[14]="../images/gallery/lynwood/new2.png";
lynwood[15]="../images/gallery/lynwood/new2_vp.png";
lynwood[16]="../images/gallery/lynwood/new4.png";
lynwood[17]="../images/gallery/lynwood/new4_vp.png";
lynwood[18]="../images/gallery/lynwood/banner.jpg";
lynwood[19]="../images/gallery/lynwood/banner_vp.png";
//end lynwood gallery

//tourn gallery
var tourngal= new String (">>Tournament Gallery");

var tournbor=new Array ();
tournbor[0]="../images/gallery/tournament/demo_thumb_bordered.png";
tournbor[1]="../images/gallery/tournament/lyntou_thumb_bordered.png";
tournbor[2]="../images/gallery/tournament/soljud_thumb_bordered.png";
tournbor[3]="../images/gallery/tournament/soljuds_thumb_bordered.png";
tournbor[4]="../images/gallery/tournament/wisjud_thumb_bordered.png";
tournbor[5]="../images/gallery/tournament/wisjuds_thumb_bordered.png";
tournbor[6]="../images/gallery/tournament/yelspar_thumb_bordered.png";
tournbor[7]="../images/gallery/tournament/upkyu_thumb_bordered.png";
tournbor[8]="../images/gallery/tournament/weap_thumb_bordered.png";
tournbor[9]="../images/gallery/tournament/tapaw_thumb_bordered.png";

var tourntit= new Array ();
tourntit[0]=new String('Century Demo Team');
tourntit[1]=new String('Lynwood Tournament Awards');
tourntit[2]=new String('Soltis Judges at Lynwood Tournament 1');
tourntit[3]=new String('Soltis Judges at Lynwood Tournament 2');
tourntit[4]=new String('Wiseman Judges at Lynwood Tournament 1');
tourntit[5]=new String('Wiseman Judges at Lynwood Tournament 2');
tourntit[6]=new String('Yellow Belts Spar at Lynwood Tournament');
tourntit[7]=new String('Upper Ranks Spar at Lynwood Tournament');
tourntit[8]=new String('Pantoja as Kyu Rank Places in Weapons Division');
tourntit[9]=new String('Tapia as Kyu Rank Places');


var tourn= new Array ();
tourn[0]="../images/gallery/tournament/demo.png";
tourn[1]="../images/gallery/tournament/demo_vp.png";
tourn[2]="../images/gallery/tournament/lyntou.png";
tourn[3]="../images/gallery/tournament/lyntou_vp.png";
tourn[4]="../images/gallery/tournament/soljud.png";
tourn[5]="../images/gallery/tournament/soljud_vp.png";
tourn[6]="../images/gallery/tournament/soljuds.png";
tourn[7]="../images/gallery/tournament/soljuds_vp.png";
tourn[8]="../images/gallery/tournament/wisjud.png";
tourn[9]="../images/gallery/tournament/wisjud_vp.png";
tourn[10]="../images/gallery/tournament/wisjuds.png";
tourn[11]="../images/gallery/tournament/wisjuds_vp.png";
tourn[12]="../images/gallery/tournament/yelspar.png";
tourn[13]="../images/gallery/tournament/yelspar_vp.png";
tourn[14]="../images/gallery/tournament/upkyu.png";
tourn[15]="../images/gallery/tournament/upkyu_vp.png";
tourn[16]="../images/gallery/tournament/weap.png";
tourn[17]="../images/gallery/tournament/weap_vp.png";
tourn[18]="../images/gallery/tournament/tapaw.png";
tourn[19]="../images/gallery/tournament/tapaw_vp.png";
//end tourn gallery

//trist gallery
var tristgal= new String (">>Trias' Students Gallery");

var tristbor=new Array ();
tristbor[0]="../images/gallery/trias_students/brea_thumb_bordered.png";
tristbor[1]="../images/gallery/trias_students/percon_thumb_bordered.png";
tristbor[2]="../images/gallery/trias_students/perconsp_thumb_bordered.png";
tristbor[3]="../images/gallery/trias_students/spc_thumb_bordered.png";
tristbor[4]="../images/gallery/trias_students/tricon_thumb_bordered.png";
tristbor[5]="../images/gallery/trias_students/trisch_thumb_bordered.png";
tristbor[6]="../images/gallery/trias_students/cont_thumb_bordered.jpg";
tristbor[7]="../images/gallery/trias_students/ycont_thumb_bordered.jpg";


var tristtit= new Array ();
tristtit[0]=new String('Trias, Contreras, and Perales Breaking Bricks');
tristtit[1]=new String('Perales and Contreras Posing');
tristtit[2]=new String('Perales and Contreras Sparring');
tristtit[3]=new String('Sanders, Perales, and Contreras');
tristtit[4]=new String('Trias and Contreras');
tristtit[5]=new String('Trias Class Picture');
tristtit[6]=new String('Contreras with other Trias Students');
tristtit[7]=new String('Young Contreras');



var trist= new Array ();
trist[0]="../images/gallery/trias_students/brea.png";
trist[1]="../images/gallery/trias_students/brea_vp.png";
trist[2]="../images/gallery/trias_students/percon.png";
trist[3]="../images/gallery/trias_students/percon_vp.png";
trist[4]="../images/gallery/trias_students/perconsp.png";
trist[5]="../images/gallery/trias_students/perconsp_vp.png";
trist[6]="../images/gallery/trias_students/spc.png";
trist[7]="../images/gallery/trias_students/spc_vp.png";
trist[8]="../images/gallery/trias_students/tricon.png";
trist[9]="../images/gallery/trias_students/tricon_vp.png";
trist[10]="../images/gallery/trias_students/trisch.png";
trist[11]="../images/gallery/trias_students/trisch_vp.png";
trist[12]="../images/gallery/trias_students/cont.jpg";
trist[13]="../images/gallery/trias_students/cont_vp.png";
trist[14]="../images/gallery/trias_students/ycont.jpg";
trist[15]="../images/gallery/trias_students/ycont_vp.png";

//end trist gallery


//START THE APP CODE______________________________________________

//array with the working gallery
var displayimg=new Array();
var pictit=new Array ();
var galtit=new String();
var bord=new Array();
//filmstrip start pointer
var pointer= new Number (0);
var pointermax=new Number();


//load gallery
function preloads(a,b,c,d){
	pointer=0;
	for(i=0; i<a.length; i++){
		displayimg[i]=new Image();
		displayimg[i].src=a[i];
	}
	if (a.length<displayimg.length){
		for (i=a.length; i<displayimg.length;i++){
			displayimg[i].src="../images/gallery/gallery_ui/Gallery_thumb_emp.png";
		}
	}
	
	for(j=0; j<b.length; j++){
		pictit[j]=b[j];
		bord[j]=new Image();
		bord[j].src=d[j];
	}
	if (b.length<pictit.length){
		for (i=b.length; i<pictit.length;i++){
			bord[i].src="../images/gallery/gallery_ui/Gallery_thumb_emp.png";
			pictit[i]='';
		}
	}
	galtit=c;
}

//array of containers
var containers= new Array ();
containers[0]="vp";
containers[1]="one";
containers[2]="two";
containers[3]="three";
containers[4]="four";
containers[5]="five";



//hover over thumb
function imgswap(c,p){
	document.getElementById(c).src=bord[(p-1)+(pointer/2)].src;
}

function imgrest(c,p){
	document.getElementById(c).src=displayimg[(2*p-2)+pointer].src;
}



//display filmstrip
function loadfilm(){
	document.getElementById('galtitle').innerHTML=galtit;
	for (j=0; j<containers.length-1; j++){
		if (j==0+pointer){
			document.getElementById(containers[j]).src=displayimg[(2*j)+pointer+1].src;
			document.getElementById(containers[j+1]).src=displayimg[(2*j)+pointer].src;
			document.getElementById('pict').innerHTML=pictit[j+(pointer/2)];
		}
		else if(((2*j)+pointer)<displayimg.length-1){
				document.getElementById(containers[j+1]).src=displayimg[(2*j)+pointer].src;
		}	
		else {
			document.getElementById(containers[j+1]).src="../images/gallery/gallery_ui/Gallery_thumb_emp.png";
		}
		
		
	}
	
}
//end loadfilm


//change filmstrip start pointer
function pointerchg(a){
	//set pointer limits
	var metric=new Number((displayimg.length/10));
	if(metric<1){
		pointermax=0;
	}
	else {
		pointermax=Math.floor(metric)*10;
	}
	//end pointer limits
	pointer=pointer+a;
	if (pointer<0){
		pointer=0;
	}
	else if (pointer>pointermax){
		pointer=pointermax;
	}
	loadfilm();
}
//end pointerchg


//change the viewport image
function vpimg(a){
	if (displayimg[pointer+((2*a)-1)].src){
	document.getElementById('vp').src=displayimg[pointer+((2*a)-1)].src;
	//alert((pointer/2)+(a-1));
	document.getElementById('pict').innerHTML=pictit[(pointer/2)+(a-1)];
	}
}
//end vpimg
