// JavaScript Document


var first = 1;
var totalImages = imageArray.length;
var currentImage = 1;

if(!document.getElementById){
  if(document.all)
  document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined")
    return document.all[arguments[0]];
    else
    return null;
  }
  else if(document.layers)
  document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined")
    return document[arguments[0]];
    else
    return null;
  }
}


function CheckForm(Objform){
	var bValid = true, sAlert="";
	
	if(document.contact.name.value==""){
	sAlert=sAlert + "No Name entered\n";
	bValid=false;
	}

	if(document.contact.email.value==""){
	sAlert=sAlert + "No Email Address entered\n";
	bValid=false;
	}
	if(document.contact.message.value==""){
	sAlert=sAlert + "No message entered\n";
	bValid=false;
	}
	
	if (bValid==true){
	   return true;
	}else{
		alert(sAlert+ "\n\nYou must add this information to continue");
		return false;
	}
	
	
}

function form_submit() {
    document.contact.submit();
}

function form_reset() {
    document.contact.reset();
}

function popup(url, start, record) {
	
	/*if (currentImage == 1) { 
		url += "&send_string=../"+record+"/"+imageArray[currentImage+start]+"&name_of_column=Picture"+(currentImage-1+start);
	} else { 
		url += "&send_string=../"+record+"/"+imageArray[currentImage]+"&name_of_column=Picture"+(currentImage-1);
	}*/
	url += "&number_of_column="+currentImage;

	gifwindow = window.open(url,"picwindow",'toolbar=0,location=0,menubar=0,scrollbars=0,resizable=1,width=800,height=600');
}

function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
		}
		window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		
	}
}


function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}


function switchImage(objId, imgNo, play, title) {

	currentImage = imgNo;
	switchImage2(objId, imgNo, play, title);
	if (document.getElementById) {
		obj = document.getElementById(objId);
		setOpacity(obj, 0);
	}
}

function switchImage2(objId, imgNo, play, strTitle) {
	if (imgNo<totalImages) {
		if (document.getElementById) {
			document.getElementById(objId).src = imageArray[imgNo];
			scale = Math.min (550/imageWidth[imgNo], 430/imageHeight[imgNo]);
			document.getElementById(objId).width = imageWidth[imgNo]*scale;
			document.getElementById(objId).height = imageHeight[imgNo]*scale;
			document.getElementById('title').innerHTML = strTitle;
		} else {
			thephoto.src = imageArray[imgNo];
			scale = Math.min (550/imageWidth[imgNo], 430/imageHeight[imgNo]);
			thephoto.width = imageWidth[imgNo]*scale;
			thephoto.height = imageHeight[imgNo]*scale;
			title.innerHTML = strTitle;
		}
		
	}
	fadeIn(objId,0);
	if (play == 1 ) {
		if (imgNo<(totalImages-1)) imgNo++;
		else imgNo = 1;
		var timer=setTimeout("switchImage('thephoto',"+imgNo+",1,'')",5000) ;
	}
}

function startImage (imgNo, strTitle) {
	//alert (imageArray[imgNo]);
	if (imageArray[imgNo]) {
		if (document.getElementById) {
				document.getElementById('thephoto').src = imageArray[imgNo];
				scale = Math.min (550/imageWidth[imgNo], 430/imageHeight[imgNo]);
				document.getElementById('thephoto').width = imageWidth[imgNo]*scale;
				document.getElementById('thephoto').height = imageHeight[imgNo]*scale;
				document.getElementById('title').innerHTML = strTitle;
		} else {
				thephoto.src = imageArray[imgNo];
				scale = Math.min (550/imageWidth[imgNo], 430/imageHeight[imgNo]);
				thephoto.width = imageWidth[imgNo]*scale;
				thephoto.height = imageHeight[imgNo]*scale;
				title.innerHTML = strTitle;
		}	
	}
			
}
