// JavaScript Document

var NAMES = new Array 
	("Home", "About Us", "Company History", "Gallery", "Quick Facts", "Specials",  "Get a Quote", "Contact Info", "Links", "FAQ", "Financing", "", "", "", "", "");					
var URL = new Array 
	("Home", "About", "History", "Gallery", "Facts", "Specials", "Quote", "Contact", "Links", "FAQ", "Financing", "History_cert", "History_award", "History_pub", "ConWar", "VinWar");	
	
var Gallery =[["con_a.JPG", "con_b.JPG", "con_c.JPG", "con_d.JPG",
				 "Concrete1.jpg",  "Concrete3.jpg", "Concrete4.jpg", "Concrete5.jpg",
				 "Concrete6.jpg", "Concrete7.jpg", "Concrete8.jpg", "Concrete9.jpg", "Concrete10.jpg",
				 "Concrete11.jpg", "Concrete12.jpg", "Concrete13.jpg",  "Concrete15.jpg",
				 "Concrete16.jpg", "Concrete17.jpg", "Concrete18.jpg", "Concrete19.jpg", "Concrete20.jpg",
				 "Concrete21.jpg", "Concrete22.jpg", "Concrete23.jpg", "Concrete24.jpg", "Concrete25.jpg",
				 "Concrete26.jpg", "Concrete27.jpg", "Concrete28.jpg", "Concrete29.jpg", "Concrete31.jpg"],
				 
			["Vinyl1.jpg", "Vinyl2.jpg", "Vinyl3.jpg", "Vinyl4.jpg", "Vinyl5.jpg",
				 "Vinyl6.jpg", "Vinyl7.jpg", "Vinyl9.jpg", "Vinyl10.jpg", "Vinyl11.jpg",
				 "Vinyl12.jpg"],
				 
				["Cave1.jpg", "Cave2.jpg", "Cave3.jpg", "Cave4.jpg", "Cave5.jpg", "Cave6.jpg", "Cave7.jpg"] ];
          
var Gallery_prefix = "assets/pools/"; 
var Gallery_pic = 0;
var Gallery_type = 0;
var Gallery_size = new Array();
Gallery_size[0] = Gallery[0].length;
Gallery_size[1] = Gallery[1].length;
Gallery_size[2] = Gallery[2].length;

var Gallery_pretext = [["Concrete Pool #"], ["Vinyl Pool #"], ["Grotto's, Caves, Rivers, Etc. #"]];
	
	
function End_intro(){
	$("#Title").addClass("Intro_done");
	$("#Content").removeClass("Hide");
	$("#Content").show();
}


      //hides and shows sections when they are navigated to


function Hide_show(show){
	for(x in URL){
		if(show == URL[x]){
			$("#"+URL[x]).removeClass("Hide");
			$("#"+URL[x]).show();
     }else{
			$("#"+URL[x]).hide();
		}
	}
}


        //Records the visiters page views

function Add_hit(page){
	
	$.ajax({
		type: "POST",
		url: "counter.php",
		data: "page=" + page,
		cache: false,
		success: function(html){

   				 }
		});
}


$(document).ready(function(){

          //Hides all pages

	$(".Hide").hide();
	
	       //supprots the 'end intro' link
	
	$(".Skip_intro").click(function(){
	 End_intro();
	 $("#Title").html("<h1>Hilltop Pools and Spas Inc.</h1>");
  });
  
          //creates the button roll-over effect
	
	$(".Push_navigation.Push_goto").mouseover(function(){$(this).addClass("Push_over");});
	$(".Push_navigation.Push_goto").mouseout(function(){$(this).removeClass("Push_over");});
	
	         //Allows button presses to navigate the site	   
	
	
	$(".Push_navigation.Push_goto").click(function(){
		$(".Push_at").addClass("Push_goto");
		$(".Push_at").removeClass("Push_at");
		$(this).addClass("Push_at");
		$(this).removeClass("Push_goto");
		var temp = $(this).attr("title");
		Add_hit(temp);
		Hide_show(temp);
		if(temp == "Specials"){
                    window.open("special_popup.php");
                    window.open("special_popup_2.php");
                }
	});
	
	         //Allows word links to function like button presses
	
	$(".Linked").click(function(){
		$(".Push_at").addClass("Push_goto");
		$(".Push_at").removeClass("Push_at");
		var temp = $(this).attr("title");
		Add_hit(temp);
		$("#"+temp).addClass("Push_at");
		$("#"+temp).removeClass("Push_goto");
		Hide_show(temp);
		if(temp == "Specials"){
			window.open("special_popup.php");
                        window.open("special_popup_2.php");
                }
	});	
        
	
	            //Makes the home page the active page
	
	$("[title='Home']").removeClass("Push_goto");
	$("[title='Home']").addClass("Push_at");



    	       //Performs the AJAX call for the COMMENT page

	$("#send_contact").click(function(){
		var FName = $("#contact_FName").attr("value");
		var LName = $("#contact_LName").attr("value");
		var EMail = $("#contact_EMail").attr("value");
		var Message = $("#contact_Message").attr("value");
		$.ajax({
			type: "POST",
			url: "send_contact.php",
			data: "FName="+FName+"&LName="+LName+"&EMail="+EMail+"&Message="+Message,
			cache: false,
 			success: function(html){
   				 alert( html );
   				 $("#contact_EMail").val("");
 			}
		});
	});
	
	       //Performs the AJAX call for the GET A QUOTE page
	
	$("#send_quote").click(function(){
		var FName = $("#quote_FName").attr("value");
		var LName = $("#quote_LName").attr("value");
		var EMail = $("#quote_EMail").attr("value");
		var Message = $("#quote_Message").attr("value");
		var HPhone = $("#quote_HPhone").attr("value"); 
		var SPhone = $("#quote_SPhone").attr("value");
		var Street = $("#quote_Street").attr("value");
		var City = $("#quote_City").attr("value"); 
		var Zip = $("#quote_Zip").attr("value");
		var State = $("#quote_State").attr("value");
		var Interest = $("#quote_Interest").attr("value");
		var Loc = $("#quote_Location").attr("value");
		var Finance = $("#quote_Finance").attr("value");
		
		$.ajax({
			type: "POST",
			url: "send_quote.php",
			data: "FName="+FName+ "&LName="+LName+ "&EMail="+EMail+ "&Message="+Message+  
            "&HPhone="+HPhone+ "&SPhone="+SPhone+ "&Street="+Street+ "&City="+City+  
            "&Zip="+Zip+ "&State="+State+ "&Interest="+Interest+ "&Loc="+Loc+ "&Finance="+Finance,
			cache: false,
 			success: function(html){
   				 alert( html );
   				 $("#quote_EMail").val("");
 			}
		});
	});
	
	     //Sets up the first gallery image and text
	
	$("#Gallery_image").attr("src", Gallery_prefix + Gallery[Gallery_type][Gallery_pic]);
	$("#Gallery_text").html(Gallery_pretext[Gallery_type] + (Gallery_pic + 1));
	    
	    //These functions handle the Gallery Buttons 
	    
	$(".Push_gallery").mouseover(function(){$(this).addClass("Push_over");});
	$(".Push_gallery").mouseout(function(){$(this).removeClass("Push_over");});
	    
	$("#Prev").click(function(){
	 Gallery_pic = Gallery_pic - 1;
	 if(Gallery_pic < 0)
    Gallery_pic = Gallery_size[Gallery_type] - 1;
   $("#Gallery_image").attr("src", Gallery_prefix + Gallery[Gallery_type][Gallery_pic]);
   $("#Gallery_text").html(Gallery_pretext[Gallery_type] + (Gallery_pic + 1));
  });	
	
	$("#Next").click(function(){
	 Gallery_pic = Gallery_pic + 1;
	 if(Gallery_pic > Gallery_size[Gallery_type] - 1)
    Gallery_pic = 0;
   $("#Gallery_image").attr("src", Gallery_prefix + Gallery[Gallery_type][Gallery_pic]); 
   $("#Gallery_text").html(Gallery_pretext[Gallery_type] + (Gallery_pic + 1)); 
  });	

	$("#Concrete.Grey_box").click(function(){
	 Gallery_type = 0;
	 Gallery_pic = 0;
   $("#Gallery_image").attr("src", Gallery_prefix + Gallery[Gallery_type][Gallery_pic]); 
   $("#Gallery_text").html(Gallery_pretext[Gallery_type] + (Gallery_pic + 1)); 
  });	
  
 	$("#Vinyl.Grey_box").click(function(){
 	  Gallery_type = 1;
	  Gallery_pic = 0;
   $("#Gallery_image").attr("src", Gallery_prefix + Gallery[Gallery_type][Gallery_pic]);
   $("#Gallery_text").html(Gallery_pretext[Gallery_type] + (Gallery_pic + 1));  
  });		
	    
 	$("#Cave.Grey_box").click(function(){
 	  Gallery_type = 2;
	  Gallery_pic = 0;
   $("#Gallery_image").attr("src", Gallery_prefix + Gallery[Gallery_type][Gallery_pic]);
   $("#Gallery_text").html(Gallery_pretext[Gallery_type] + (Gallery_pic + 1));  
  });		
	    		
	
});



