function hideVideo(){
	document.getElementById('commercialVideo').style.visibility="hidden";
}
function showVideo(){
	document.getElementById('commercialVideo').style.visibility="visible";
}

var oButton = new YAHOO.widget.Button({ 
	id: "mybuttonid",  
       type: "button",  
       label: "Get Estimate",  
       container: "sendMessage"  
}); 
  
function onButtonClick(e) {
		var noName = 0;
		var noSubject = 0;
		var noEmail = 0;
		var noComments = 0;
        with(document.contactUsForm){
			if(name.value == ""){
				noName = 1;
				name.className = "notValid";
				document.getElementById("nameLabel").className = "labelNotValid";
			}
			else{
				noName = 0;
				name.className = "validated";
				document.getElementById("nameLabel").className = "label";
			}
			if(email.value == ""){
				noEmail = 1;
				email.className = "notValid";
				document.getElementById("emailLabel").className = "labelNotValid";
			}
			else{
				noEmail = 0;
				email.className = "validated";
				document.getElementById("emailLabel").className = "label";
			}
			if(phone.value == ""){
				noPhone = 1;
				phone.className = "notValid";
				document.getElementById("phoneLabel").className = "labelNotValid";
			}
			else{
				noPhone = 0;
				phone.className = "validated";
				document.getElementById("phoneLabel").className = "label";
			}
			if(zip.value == ""){
				noZip = 1;
				zip.className = "notValid";
				document.getElementById("zipLabel").className = "labelNotValid";
			}
			else{
				noZip = 0;
				zip.className = "validated";
				document.getElementById("zipLabel").className = "label";
			}
			if( noName==1 || noZip==1 || noPhone==1 || noEmail==1 ){
				alert("Please verify that you have entered your name, phone number, zip code and email address.");
			}
			else{
				document.contactUsForm.submit();
			}
		}
}
     
oButton.addListener("click", onButtonClick); 		
oaPic = 1;
spPic = 1;
pvcPic = 1;
function previousOAPic(){
	oaPic = oaPic - 1;
	if(oaPic == 0){
		oaPic = 8;
	}	
	document.getElementById('oa_photo').src = "photos/loading_static.png";
	document.getElementById('oa_photo').src = "photos/ornamentalAluminum/" + oaPic + ".jpg";
}
function nextOAPic(){
	oaPic = oaPic + 1;
	if(oaPic == 9){
		oaPic = 1;
	}	
	document.getElementById('oa_photo').src = "photos/loading_static.png";
	document.getElementById('oa_photo').src = "photos/ornamentalAluminum/" + oaPic + ".jpg";
}
function previousPVCPic(){
	pvcPic = pvcPic - 1;
	if(pvcPic == 0){
		pvcPic = 6;
	}	
	document.getElementById('pvc_photo').src = "photos/loading_static.png";
	document.getElementById('pvc_photo').src = "photos/pvc/" + pvcPic + ".jpg";
}
function nextPVCPic(){
	pvcPic = pvcPic + 1;
	if(pvcPic == 7){
		pvcPic = 1;
	}	
	document.getElementById('pvc_photo').src = "photos/loading_static.png";
	document.getElementById('pvc_photo').src = "photos/pvc/" + pvcPic + ".jpg";
}
function previousSPPic(){
	spPic = spPic - 1;
	if(spPic == 0){
		spPic = 6;
	}	
	document.getElementById('sp_photo').src = "photos/loading_static.png";
	document.getElementById('sp_photo').src = "photos/pools/" + spPic + ".jpg";
}
function nextSPPic(){
	spPic = spPic + 1;
	if(spPic == 7){
		spPic = 1;
	}	
	document.getElementById('sp_photo').src = "photos/loading_static.png";
	document.getElementById('sp_photo').src = "photos/pools/" + spPic + ".jpg";
}
var modalPanel;
function initModal(){
		modalPanel = new YAHOO.widget.Panel("modal_panel", {
		fixedcenter: false,
		height: "600px",
		width: "840px", 
		zindex: 1998,
		modal: true,	
		visible: false,
		draggable: true,
		close: true
	});
	var bodyHTML = '<div align="center">'
	+ '<table><tr><td align="center">'
	+ '<img src="photos/loading_static.png" width="800" height="533" border="0">'
	+ '</td></tr><tr><td align="center">'
	+ '<a href="javascript:previousOAPic();">Previous</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:nextOAPic();">Next<a/>'
	+ '</td></tr></table></div>';
	modalPanel.setBody(bodyHTML);
	modalPanel.beforeShowEvent.subscribe(function() {hideVideo();});
	modalPanel.hideEvent.subscribe(function() {showVideo();});
	modalPanel.render(document.body);
}
function showOrnamentalAluminum(){
	hideVideo();
	modalPanel.setHeader("Ornamental Aluminum");
	var bodyHTML = '<div align="center">'
	+ '<table><tr><td align="center">'
	+ '<img id="oa_photo" src="photos/loading_static.png" width="800" height="533" border="0">'
	+ '</td></tr><tr><td align="center">'
	+ '<a href="javascript:previousOAPic();"><img src="images/previousArrow.gif" alt="" width="67" height="12" border="0"></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:nextOAPic();"><img src="images/nextArrow.gif" alt="" width="46" height="12" border="0"><a/>'
	+ '</td></tr></table></div>';
	modalPanel.setBody(bodyHTML);
	modalPanel.show();
	oaPic = 1;
	document.getElementById('oa_photo').src = "photos/ornamentalAluminum/1.jpg";
}
function showPVC(){
	hideVideo();
	modalPanel.setHeader("PVC Styles");
	var bodyHTML = '<div align="center">'
	+ '<table><tr><td align="center">'
	+ '<img id="pvc_photo" src="photos/loading_static.png" width="800" height="533" border="0">'
	+ '</td></tr><tr><td align="center">'
	+ '<a href="javascript:previousPVCPic();"><img src="images/previousArrow.gif" alt="" width="67" height="12" border="0"></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:nextPVCPic();"><img src="images/nextArrow.gif" alt="" width="46" height="12" border="0"><a/>'
	+ '</td></tr></table></div>';
	modalPanel.setBody(bodyHTML);
	modalPanel.show();
	pvcPic = 1;
	document.getElementById('pvc_photo').src = "photos/pvc/1.jpg";
}
function showSwimmingPools(){
	hideVideo()
	modalPanel.setHeader("Swimming Pool Pics");
	var bodyHTML = '<div align="center">'
	+ '<table><tr><td align="center">'
	+ '<img id="sp_photo" src="photos/loading_static.png" width="800" height="533" border="0">'
	+ '</td></tr><tr><td align="center">'
	+ '<a href="javascript:previousSPPic();"><img src="images/previousArrow.gif" alt="" width="67" height="12" border="0"></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:nextSPPic();"><img src="images/nextArrow.gif" alt="" width="46" height="12" border="0"><a/>'
	+ '</td></tr></table></div>';
	modalPanel.setBody(bodyHTML);
	modalPanel.show();
	spPic = 1;
	document.getElementById('sp_photo').src = "photos/pools/1.jpg";
}

YAHOO.util.Event.onDOMReady(initModal); 	

var pictureRef;
var pictureIndex = 1;
var picScrollTimer;
function fadeInNextPicture(){
	pictureIndex = pictureIndex + 1;
  		if(pictureIndex == 9){
		pictureIndex = 1;
	}
	pictureRef.src = "photos/pyleFence_" + pictureIndex + ".jpg";
	pictureFade2 = new YAHOO.util.Anim(pictureRef, { opacity: { to: 1.0 } }, 1.0);
	pictureFade2.animate();
	picScrollTimer = setTimeout('scrollPics()',4000);
}
function scrollPics(){
	pictureFade = new YAHOO.util.Anim(pictureRef, { opacity: { to: 0.0 } }, 1.0);
	pictureFade.onComplete.subscribe(fadeInNextPicture);
	pictureFade.animate();
}
function init() {
	pictureRef = document.getElementById('scrollImage');
	picScrollTimer = setTimeout('scrollPics()', 4000);
	/**
	 * Format:
	 * Image_ID : {url : 'point_to_original_image', title: 'optional title'}
	 */
	 var dataSource = {
			photo1:{url:"photos/williamsburgColonialPicket.jpg", title:'Williamsburg Colonial Picket'},
			photo2:{url:"photos/GettysburgPostandSplitRail.jpg", title:'Gettysburg Post & Split Rail'},
			photo3:{url:"photos/shadowboardPrivacy.jpg", title:'Shadowboard Privacy'},
			photo4:{url:"photos/salemStockade.jpg", title:'Salem Stockade'},
			photo5:{url:"photos/homelandGothicPicket.jpg", title:'Homeland Gothic Picket'},
			photo6:{url:"photos/marlboroRusticPicket.jpg", title:'Marlboro Rustic Picket'},
			photo7:{url:"photos/chainLink.jpg", title:'Chain Link'},
			photo8:{url:"photos/westminsterBasketWeave.jpg", title:'Westminster Basket Weave'},			
			photo9:{url:"photos/estateStyle.jpg", title:'Estate Style'},			
			photo10:{url:"photos/mtVernonPicket.jpg", title:'Mt. Vernon Picket'},
			photo11:{url:"photos/scallopedWilliamsburgColonialPicket.jpg", title:'Scalloped Williamsburg Colonial Picket'},			
			photo12:{url:"photos/pvcStyles.jpg", title:'P.V.C. Styles'},
			photo13:{url:"photos/ornamentalAluminum.jpg", title:'Ornamental Aluminum'},
			photo14:{url:"photos/basketWeave.jpg", title:'Basket Weave'},
			photo15:{url:"photos/boardOnBatten.jpg", title:'Board on Batten'},
			photo16:{url:"photos/concaveGothicPicket.jpg", title:'Concave Gothic Picket'},
			photo17:{url:"photos/solidBoardPrivacywithLattice.jpg", title:'Solid Board Privacy with Lattice'},
			photo18:{url:"photos/convexShadowboard.jpg", title:'Convex Shadowboard'}
	 };
	 /**
	  * imageBase: tell lightbox where to find images need to render the ui
	  *            this usual located in the same folder as the Lightbox.js
	  * dataSource: a JavaScript object contains a list of images that
	                we are going to attach the lightbox to
	  */
	 var lightbox = new YAHOO.com.thecodecentral.Lightbox({
	 	imageBase:'',
	 	dataSource: dataSource
	 });

}   
YAHOO.util.Event.onDOMReady(init); 

var currentTestimonial = 1;
function nextTestimonial(){
	document.getElementById("testimonials_" + currentTestimonial).style.display = "none";
	currentTestimonial = currentTestimonial + 1;
	if(currentTestimonial == 5){
		currentTestimonial = 1;
	}
	document.getElementById("testimonials_" + currentTestimonial).style.display = "";
}

