// 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 closeFlPlayer(){
	if (mediaType == "video2"){
		var switchVal = mediaType+ "container";
		var switchNub = mediaType+ "nub";
		var tempArray = new Array();
	
		containerClose2();
		tempArray =  setArray("video")
		thumbChanger("", "video", "off", tempArray);
		mediaFlag="n";
		simpleswitchoff(mediaBox);
	} else {
	var switchVal = mediaType+ "container";
	var switchNub = mediaType+ "nub";
	var tempArray = new Array();
	
	containerClose();
	tempArray =  setArray(mediaType)
	thumbChanger("", mediaType, "off", tempArray);
	simpleswitchoff(switchNub);
	mediaFlag="n";
	simpleswitchoff(mediaBox);
	}
}

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){
	if (argMedia == "video2"){
		setCount("video");
		var thisCount = mediaCount;
		alert(thisCount);
		for (i=1; i <= thisCount; i++) {	
			simpleswitchoff(thumbArray[i]);
		}
	} else {
		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 secondSwitch(argBox, argThumb, argMedia){
	var switchVal= "videocontainer2";
	//alert(switchVal)
		simpleswitchon(switchVal);
		simpleswitchon(argBox);
		mediaType  = argMedia;
		mediaFlag="y";
		mediaBox=argBox;

}
function callMediaSwitch(argBox, argThumb, argMedia){
	
	if (mediaFlag=="n"){	
		if(argMedia =="video2"){
			//alert(argBox+"   "+argThumb+"   "+argMedia)
			thumbChanger(argThumb, argMedia, "on", videoArray)
			secondSwitch(argBox, argThumb, argMedia);
		}
			
	
		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);
		}
		mediaFlag="y";
	} 
	//alert(mediaFlag);
}


function containerClose(){

var thumbArray = new Array("videocontainer", "audiocontainer", "imagecontainer");

	for (i=0; i < thumbArray.length; i++) {	
	
		simpleswitchoff(thumbArray[i]);
	}
}

function containerClose2(){

	simpleswitchoff("videocontainer2");

}


function thumbSwitch(argThumb){
	if(mediaFlag=="n"){
		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);
	}
}
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"}
		
	}
  
  
}



