// JavaScript Document
var issueFlag ="no";
var thumbNavVal = "thumbVideoTab";
var mediaType="";

var mediaFlag ="n";
var mediaBox="";
var mediaCount=0;
var randomnumber = (Math.floor(Math.random()*5)+1)

function getRandom(){
	var thisRand = randomnumber;
	//alert(randomnumber);
	return randomnumber;
	
}


function setArray(argMedia){
	switch(argMedia){
		case "video":
			 return videoArray;
		break;
		case "audio":
			return audioArray;
		break;
		case "image":
			return imageArray;
		break;
		
	}
	//alert(mediaCount);
}

function testBox(argTest){
	var d = document.getElementById(argTest);
	if (d) {
		if(d.style.display=="block"){
			return false;
		} else {
			return true;	
		}
	}
}

function simpleswitchon(argTest){
	var q = document.getElementById(argTest);
	if (q) {q.style.display="block"};
}

function simpleswitchoff(argTest){
	var d = document.getElementById(argTest);
	if (d) {d.style.display="none"};
}


function galleryswitch(argSelect){
	if(argSelect != currgallery){
		simpleswitchon(argSelect);
		simpleswitchoff(currgallery);
		currgallery=argSelect;
	}
}


function thumbChanger(argThumb, argMedia, argState, argArray){
	var tempCount = ((argArray.length)-1);
	if(argState=="on"){
		for (i=0; i<= tempCount; i++) {	
			var tempThumb = argArray[i]
			var thumbOn = "images/dcx_"+argArray[i]+"a.jpg";
			var thumbUn = "images/dcx_"+argArray[i]+"g.jpg";
			if(argThumb != tempThumb){
				//alert(thumbUn);
				if (document.images[tempThumb].src) { document.images[tempThumb].src = thumbUn;}
			} else {
				document.images[argThumb].src = thumbOn;//switch the current thumb to now playing
			}
		}	
	}
		
	if(argState=="off"){	
		for (i=0; i <= tempCount; i++) {	
		
			var tempThumb = argArray[i]; 
			var thumbOff = "images/dcx_"+tempThumb+".jpg";
			
			document.images[tempThumb].src = thumbOff;//switch the all thumbs back to normal
		}
	}
	
}


function switchThumbs(argThumb, argMedia, argCount){
	setCount(argMedia);
	var thisCount = mediaCount;
	for (i=1; i <= thisCount; i++) {	
		simpleswitchoff(thumbArray[i]);
	}
}


function callSwitch(argBox, argThumb, argMedia){
	var switchVal= argMedia+ "container";
	var switchNub= argMedia+ "nub";
	//alert(switchVal)
		simpleswitchon(switchVal);
		simpleswitchon(argBox);
		simpleswitchon(switchNub);
		mediaType  = argMedia;
		mediaFlag="y";
		mediaBox=argBox;


}

function callMediaSwitch(argBox, argThumb, argMedia){
	if (mediaFlag=="n"){	
		if(argMedia =="video"){
			//alert(argBox+"   "+argThumb+"   "+argMedia)
			thumbChanger(argThumb, argMedia, "on", videoArray)
			callSwitch(argBox, argThumb, argMedia);
		}
			
		if(argMedia =="audio"){
			
			thumbChanger(argThumb, argMedia, "on", audioArray)
			callSwitch(argBox, argThumb, argMedia);
		}
			
		if(argMedia =="image"){
			//alert("in");
			thumbChanger(argThumb, argMedia, "on", imageArray)
			callSwitch(argBox, argThumb, argMedia);
		}
		
	} 
}


function containerClose(){

var thumbArray = new Array("videocontainer", "audiocontainer", "imagecontainer");

	for (i=0; i < thumbArray.length; i++) {	
	
		simpleswitchoff(thumbArray[i]);
	}
}


function thumbSwitch(argThumb){
	var tempArg = argThumb+"Tab";
	var n = document.getElementById(tempArg);
	var j = document.getElementById(thumbNavVal);
	var thumbArray = new Array("thumbVideo", "thumbAudio", "thumbImages", "thumbContact");
	for (i=0; i < thumbArray.length; i++) {
			simpleswitchoff(thumbArray[i]);
	}
	if (tempArg != thumbNavVal){
		if(n){ n.className="selected"}
		if(j){ j.className="notselected"}
	}
	thumbNavVal = tempArg;
	simpleswitchon(argThumb);
	mediaFlag="n"
}
function mbbSwitch(){
	var testVal = testBox("mbblist");
	var n = document.getElementById('mediabb');
	
	if (testVal){
		simpleswitchon("mbblist");
		if(n){ n.className="openmbb"}
	} else {
		simpleswitchoff("mbblist");
		if(n){ n.className="closembb"}
		
	}
  
  
}

function issueSwitch(){
	var testVal = testBox("issuelist");
	var n = document.getElementById('issues');
	
	if (testVal){
		simpleswitchon("issuelist");
		if(n){ n.className="openissue"}
	} else {
		simpleswitchoff("issuelist");
		if(n){ n.className="closeissue"}
		
	}
  
  
}


