visible=0;
visible2=0;
var currentsubject=1;
var currentthumb=1;

var Gallery=new Array();
Gallery[1] = "mining";
Gallery[2] = "transportation";
Gallery[3] = "marine";
Gallery[4] = "residential";
Gallery[5] = "garbage";
Gallery[6] = "highway6";

var GallerySize=new Array();
GallerySize[1] = 3;
GallerySize[2] = 9;
GallerySize[3] = 5;
GallerySize[4] = 5;
GallerySize[5] = 3;
GallerySize[6] = 8;

var GalleryText=new Array();
GalleryText[1] = "MINING";
GalleryText[2] = "TRANSPORTATION";
GalleryText[3] = "WATER RESERVOIRS & MARINE PROJECTS";
GalleryText[4] = "RESIDENTIAL ZONES";
GalleryText[5] = "GARBAGE PITS";
GalleryText[6] = "HIGHWAY 6";

// open big picture
function openBig(picN)
{
	var source = 'bigPic.asp?picN='+ picN;
	win = window.open(source, "galleryBig", "top=0, left=0, width=350, height=400, status=no, resizable, scrollbars=yes")
	window.focus;
}


// hide all divs on onload
function hideDivs()
{
	var arrayOfDivs = document.all.tags("div");
	for (i=0 ; i< arrayOfDivs.length ; i++) {
		arrayOfDivs[i].style.visibility = 'hidden';
	}
}



// handle the sub menu opener
function dispSub(id,status,pos)
{
	var leftPos = ((screen.width-528)/2)+pos;
	document.all[id].style.left=leftPos;
	document.all[id].style.visibility=status;
}


// handle the menu over
function menuOver(id,img,fld)
{
	document.all[id].src = eval(img);
	document.all[fld].style.borderColor = '#751119';
}

// handle the menu out
function menuOut(id,img,fld)
{
	document.all[id].src = eval(img);
	document.all[fld].style.borderColor = '#A2A2A2';
}

// handle the Sub menu over
function menuOverSub(id,img)
{
	document.all[id].src = eval(img);
}



function checkForm()
{
	var fContact = document.contactForm;
	// last name
	if (fContact.Lname.value==""){
		fContact.Lname.style.backgroundColor="red";
	}
	
	// first name
	if (fContact.Fname.value==""){
		fContact.Fname.style.backgroundColor="red";
	}
	
	// position
	if (fContact.Position.value==""){
		fContact.Position.style.backgroundColor="red";
	}
	
	// property
	if (fContact.Property.value==""){
		fContact.Property.style.backgroundColor="red";
	}
	
	// city
	if (fContact.City.value==""){
		fContact.City.style.backgroundColor="red";
	}
	
	/* 
	//country
	if (fContact.Country.value==""){
		alert("Please select a country");
		return;
	}
	
	// state US only
	if (fContact.Country.value=="United States of America" && fContact.State.value==""){
		alert("Please select a state");
		return;
	}
	
	
	// tel from
	if (fContact.TelFrom.value==""){
		alert("Please select Calling to Office/Mobile/Home");
	}
	*/
	// tel
	if (fContact.Tel.value==""){
		fContact.Tel.style.backgroundColor="red";
	}
	
	// best time to call
	if (fContact.BestTime.value==""){
		fContact.BestTime.style.backgroundColor="red";
	}
	
	// email validation
	var mail = document.contactForm.Email.value;
	var x = mail.indexOf ("@");
	var y = mail.indexOf (".");

	if (mail=='') {
		fContact.Email.style.backgroundColor="red";
	}
	
	if (mail!="") {
		if (x==-1 || y==-1) {
			fContact.Email.style.backgroundColor="red";
			document.contactForm.Email.value = "Invalid E-mail Address";
		}
	}
	
		
	// Topic
	if (fContact.Topic.value==""){
		fContact.Topic.style.backgroundColor="red";
	}
	
	// Message
	if (fContact.Message.value==""){
		fContact.Message.style.backgroundColor="red";
	}
	
	//fContact.submit();
	
}

function toggle()
{
	
if (typeof submenu != "undefined")
	{
	if (visible==1) 
		{
		submenu.style.visibility='hidden';
		submenu.style.display='none';
		submenu.style.height=0;
		visible=0;
		} 
	else 
		{
		submenu.style.visibility='visible';
		submenu.style.display='block';
		submenu.style.height=30;
		visible=1;
		}
	}
	
	// hide the gallery
	submenu2.style.visibility='hidden';
	submenu2.style.display='none';
	submenu2.style.height=0;
	visible2=0;
}

function toggle2()
{
	
if (typeof submenu2 != "undefined")
	{
	if (visible2==1) 
		{
		submenu2.style.visibility='hidden';
		submenu2.style.display='none';
		submenu2.style.height=0;
		visible2=0;
		} 
	else 
		{
		submenu2.style.visibility='visible';
		submenu2.style.display='block';
		submenu2.style.height=30;
		visible2=1;
		}
	}
	
	// hide the projects
	submenu.style.visibility='hidden';
	submenu.style.display='none';
	submenu.style.height=0;
	visible=0;
}

function GalleryClick(subject, photoNum, mainclick)
{	
	var photoSrc
	
	currentsubject=subject;
	
	photoSrc = "images/gallery/" + Gallery[subject] + "-";
	if (photoNum < 10) { photoSrc += "0"; }
	
	photoSrc += photoNum + ".jpg";
	document.getElementById("photo").src = photoSrc;
	
	if (mainclick==1) {
		currentthumb = 1;
		
		document.getElementById("desc").innerHTML = GalleryText[subject];
		
		
		for (i=1;i<Gallery.length;i++) { 
			if (i != subject) 
				{
				document.getElementById(Gallery[i]).style.visibility='hidden';
				document.getElementById(Gallery[i]).style.display='none';
				document.getElementById(Gallery[i]).style.height=0;
				} 
			else 
				{
				document.getElementById(Gallery[i]).style.visibility='visible';
				document.getElementById(Gallery[i]).style.display='block';
				document.getElementById(Gallery[i]).style.height=30;
				}
				
		}
		ThumbsMove(subject, 0);
	}
	
}

function ThumbsMove (subject, direction)
{ 	
var thumbNum

if (direction==1) { currentthumb++; } 
if (direction==2) { currentthumb--; } 


thumbNum = (document.body.clientWidth - 400) / 105;

document.getElementById("side1").style.visibility='hidden';
document.getElementById("side1").style.display='none';
document.getElementById("side2").style.visibility='hidden';
document.getElementById("side2").style.display='none';
document.getElementById("side1_off").style.visibility='hidden';
document.getElementById("side1_off").style.display='none';
document.getElementById("side2_off").style.visibility='hidden';
document.getElementById("side2_off").style.display='none';


if (GallerySize[subject] > thumbNum)
{
	var counter
	counter = currentthumb;
	
	
	if (currentthumb > 1) {
		document.getElementById("side1").style.visibility='visible';
		document.getElementById("side1").style.display='block';
	}
	else
	{
		document.getElementById("side1_off").style.visibility='visible';
		document.getElementById("side1_off").style.display='block';
	}
	
	if (currentthumb +thumbNum < GallerySize[subject]+1) {
		document.getElementById("side2").style.visibility='visible';
		document.getElementById("side2").style.display='block';
	}
	else
	{
		document.getElementById("side2_off").style.visibility='visible';
		document.getElementById("side2_off").style.display='block';
	}
	
	
	for (i=1;i<GallerySize[subject]+1;i++)
		{
			
			if (i>thumbNum)
			{
				
				document.getElementById(Gallery[subject]+"0"+counter).style.visibility='hidden';
				document.getElementById(Gallery[subject]+"0"+counter).style.display='none';
				
				
			}
			else
			{
				
				document.getElementById(Gallery[subject]+"0"+counter).style.visibility='visible';
				document.getElementById(Gallery[subject]+"0"+counter).style.display='block';
				
				
			}
			
			
			counter++;
			if (counter > GallerySize[subject]) { counter = 1; }
			
		}
	}

}

