// JavaScript Document
function Webcams(webcamData,maxWidth,maxHeight){ 
	this.cData = webcamData;		//webcamData = multi dim array: webcamData[x] = new Array(absUrl,txt,originalImageWidth,originalImageHeight)
	this.maxWidth = maxWidth;		//max width of webcam image
	this.maxHeight = maxHeight;		//max height of webcam image
	this.numCams = this.cData.length;
	this.camera = null; 			//will be one of the arrays in wData
	
	this.setImage = function(imgId,linkId){
		//determinig whether the ORIGINAL image is hor or vert
		newWidth = 0;
		newHeight = 0;
		if(this.camera[2] > this.camera[3]){ //horizontal
			newWidth = this.maxWidth;
			newHeight = Math.ceil(this.maxWidth/this.camera[2]*this.camera[3]);
		}else{ //vertical
			newHeight = this.maxHeight;
			newWidth = Math.ceil(this.maxHeight/this.camera[3]*this.camera[2]);
		}
		//getting img ref
		imgRef = document.getElementById(imgId);
		imgRef.src = this.camera[0];
		imgRef.width = newWidth;
		imgRef.height = newHeight;
		//getting link ref
		linkRef = document.getElementById(linkId);
		linkRef.href = this.camera[0];
	}
	
	this.setCamera = function(camNum,imgId,linkId){
		if(camNum >= 0 && camNum <= (this.numCams - 1)){
			this.camera = this.cData[camNum];
			this.setImage(imgId,linkId);
		}
	}
}

