var picID = '';
var picArr = new Array();
var txtArr = new Array();
var nextPic = 0;
var prevPic = 0;
var infoStatus = false;
function displayBigPic(img,full){
	var bigpic = document.getElementById('mid_sized');
	var fullpic = document.getElementById('full_sized');
	bigpic.src = img; 
	fullpic.src = full; 

}

function showLayer(thisLayer) {
	if (document.getElementById) {
		if (document.getElementById(thisLayer) != null) {
			document.getElementById(thisLayer).style.visibility = 'visible';
			//document.getElementById(thisLayer).style.width = '160px';	
				
		}
	} 
	else if (document.layers) {
		if (document.layers[thisLayer] != null) {
			document.layers[thisLayer].style.visibility = 'visible';			
		}
	} 
	else if (document.all) {
		document.all[thisLayer].style.visibility = 'visible';		
		alert(document.all[thisLayer].style.top);			
	}
}

function hideLayer(thisLayer) {
	if (document.getElementById) {
		if (document.getElementById(thisLayer) != null) {
			document.getElementById(thisLayer).style.visibility = 'hidden';
			//document.getElementById(thisLayer).style.width = '0px';
		}
	} 
	else if (document.layers) {
		if (document.layers[thisLayer] != null) {
			document.layers[thisLayer].style.visibility = 'hidden';
			//document.layers[thisLayer].style.width = '0px';
		}
	} 
	else if (document.all) {
		document.all[thisLayer].style.visibility = 'hidden';
		//document.all[thisLayer].style.width = '0px';
	}
}

function swapText(sourceText,dest){

	if (document.getElementById) {
		if (document.getElementById(sourceText) != null && document.getElementById(dest) != null) {
			document.getElementById(dest).innerHTML = document.getElementById(sourceText).innerHTML;
			//document.getElementById(thisLayer).style.width = '160px';	
				
		}
	} else if (document.all) {
		document.all[thisLayer].style.visibility = 'hidden';
		//document.all[thisLayer].style.width = '0px';
	}
	showLayer(dest);

}

function swapNav(sourceText,dest){
	if (document.getElementById) {
		if (document.getElementById(sourceText) != null && document.getElementById(dest) != null) {
		
			document.getElementById(dest).innerHTML = document.getElementById(sourceText).innerHTML;
			//document.getElementById(thisLayer).style.width = '160px';	
				
		}
	}

}

function swapBGSrc(t,src,position){
	hideLayer('imageTxt');
	infoStatus = false;
	var maxPics = picArr.length - 1;
	if(position<maxPics){
		
		nextPic = position+1;
	}else{
		nextPic = 0;
	}
	if(position>0){
		prevPic = position-1;
	}else{
		prevPic = maxPics;
	}
	var bgElem = document.getElementById(t);
	bgElem.style.backgroundImage = 'url('+src+')';
	var photoInfo = document.getElementById('imageTxt');
	photoInfo.innerHTML = txtArr[position];
	//alert(prevPic+'-'+position+'-'+nextPic+':'+maxPics);
}
function swapBG(t,src){
	var bgElem = document.getElementById(t);
	bgElem.style.backgroundImage = 'url('+src+')';

}
function swapBGColor(t,c){
	var bgElem = document.getElementById(t);
	bgElem.style.backgroundColor = c;

}

function init(){
	var bgElem = document.getElementById('mainImg');
	var infoElem = document.getElementById('imageTxt');
	var randomnumber=Math.floor(Math.random()*(picArr.length));
	bgElem.style.backgroundImage = 'url('+picArr[randomnumber]+')';
	infoElem.innerHTML = txtArr[randomnumber];
	var maxPics = picArr.length - 1;
	if(randomnumber<maxPics){
		
		nextPic = randomnumber+1;
	}else{
		nextPic = 0;
	}
	if(randomnumber>0){
		prevPic = randomnumber-1;
	}else{
		prevPic = maxPics;
	}
}

function swapInfoLayer(){
	if(infoStatus){
		hideLayer('imageTxt');
		infoStatus = false;
	}else{
		
		showLayer('imageTxt');
		infoStatus = true;
	}


}

/////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////
///           MM functions

function winpop(theURL,winName,features) { 
  window.open(theURL,winName,features); 
}
