$(document).ready(function() {
	
	 $('#hmone').click(function(){
	 	centerRollOffPopup();
	 	loadPopup();
	 });
	$('#hmone').hover(function(){
	$('#imgRollover').attr({src: "images/cheetahTruck.jpg"});
	});

	 
	//CLOSING POPUP
	//Click the x event!
	$("#popRollOffClose").click(function(){
		disableRollOffPopup();
	});
	
	
	$('#hmtwo').click(function(){
		 centerFlatBed();
		 loadFlatBed();
	
	});
	
	$('#hmtwo').hover(function(){
		$('#imgRollover').attr({src: "images/cheetahfb.JPG"});
	});

	$('#popFlatBedClose').click(function(){
		disableFlatBed();
	});
	
	$('#hmthree').click(function(){
		 centerEnviromental();
		 loadEnviromental();
	
	});
	$('#hmthree').hover(function(){
	$('#imgRollover').attr({src: "images/cheetahHauling.JPG"});
	 });

	$('#popEnviromentalClose').click(function(){
		disableEnviromental();
	});
	$('#hmfour').hover(function(){
 	$('#imgRollover').attr({src: "images/dumpingService.JPG"});
	 });
	$('#popDumpingClose').click(function(){
		disableDumping();
	});
	$('#hmfour').click(function(){
		 centerDumping();
		 loadDumping();
	
	});

	$('#hmfive').hover(function(){
 	$('#imgRollover').attr({src: "images/construction.jpg"});
	 });
	
	$('#popConstruction').click(function(){
		disableConstruction();
	});
	$('#hmfive').click(function(){
		 centerConstruction();
		 loadConstruction();
	
	});

	$('#hmsix').hover(function(){
 	$('#imgRollover').attr({src: "images/bmhsCheetah.JPG"});
	 });
	$('#popBMHS').click(function(){
		disableBMHS();
	});
	$('#hmsix').click(function(){
		 centerBMHS();
		 loadBMHS();
	
	});

	$('#hmseven').hover(function(){
 	$('#imgRollover').attr({src: "images/cheetahBarn.jpg"});
	});
	$('#popAgriClose').click(function(){
		disableAgri();
	});
	$('#hmseven').click(function(){
		 centerAgri();
		 loadAgri();
	
	});

	$('#hmeight').hover(function(){
 	$('#imgRollover').attr({src: "images/cheetahRS.JPG"});
	 });
	 $('#popRS').click(function(){
		disableRS();
	});

	$('#hmeight').click(function(){
		 centerRS();
		 loadRS();
	
	});
 	
 	$('#hmnine').hover(function(){
 	$('#imgRollover').attr({src: "images/dsCheetah.JPG"});
	 });
	 $('#popDS').click(function(){
		disableDS();
	});

	$('#hmnine').click(function(){
		 centerDS();
		 loadDS();
	
	});

	$('.menuTextA').hover(function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
           

        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
	/*
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 &amp;amp;amp;&amp;amp;amp; popupStatus==1){
			disablePopup();
		}
	});
	*/

    $('#hmone').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
	    $('#hmtwo').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
	    $('#hmthree').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
	    $('#hmfour').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
	    $('#hmfive').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
		    $('#hmsix').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
		    $('#hmseven').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
		    $('#hmeight').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
        
       $('#hmnine').hover(
        function() {
            $(this).css({ backgroundColor: "#4A4922", color: "#fff" });
        },
        function() {
            $(this).css({ backgroundColor: "#DEDDB8", color: "#000" });

        });
	$("#emailAddress").keyup(function(){  

		 var email = $("#emailAddress").val();  
		 if(email != 0)  
		 {  
			if(isValidEmailAddress(email))  
			{  
				 $("#validEmail").css({ "background-image": "url('images/validYes.png')" });  
				 emailValid = true;
			 } 
			 else 
			 {  
				$("#validEmail").css({ "background-image": "url('images/validNo.png')" });  
			 }  
		 } 
		 else 
		 {  
			 $("#validEmail").css({ "background-image": "none" });  
		 }  
	});  

	$("#emailSubmit").click(function() {
		if (emailValid == false)
		{
			alert("We are sorry but you have not entered a valid email address");
		}
		else
		{
        var myMessage = "Email from: " + $("#emailAddress").val() + "<br/> From website: <br />";
        myMessage = myMessage + "<br/>" + $("#emailBody").val();
        var myMsgFrom  = "info@cheetahservices.net";
        
        //alert(myMsgFrom + " " + myMessage);
        var mySubject = $("#emailSubject").val();
        var mySendTo = "info@cheetahservices.net"
        //public static string sendMail(string toAddr, string fromAddr, string mailSubject, string mailMessage, bool isHTML)
        var myDTO = { 'toAddr': mySendTo , 'fromAddr': myMsgFrom, 'mailSubject': mySubject, 'mailMessage': myMessage, 'isHTML': true};
        var toPass = JSON.stringify(myDTO);
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "MailCtrl.aspx/sendMail",
            data: toPass,
            contentType: "application/json; charset=utf-8",
            success: function() {
                if ("success") {
                    alert("Your message has been sent! Thank you we will get back in touch with you shortly");
                    //$("#txtMsgBoxAdmin").css({ visibility: "hidden" });
                   // $("body").removeClass("greyOut");
                }
                else {
                    alert('We are sorry; there was a problem sending your message!');
                }
            }

        });
   		}
    });

});
/********************************************************/
/******** Ends the document ready portion ***************/
/********************************************************/
var popupStatus = 0; 
var emailValid = false;
//Roll off containers
function loadPopup(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popRollOff").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableRollOffPopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popRollOff").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerRollOffPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popRollOff").height();
	var popupWidth = $("#popRollOff").width();
	//centering
	$("#popRollOff").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}

//    end of Roll off containers

//Enclosed Containers
function loadFlatBed(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#flatBedHauling").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableFlatBed(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#flatBedHauling").fadeOut("fast");
		popupStatus = 0;
	}
}

function loadAgri(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popAgri").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  
//disabling popup with jQuery magic!
function disableAgri(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popAgri").fadeOut("fast");
		popupStatus = 0;
	}
}

function centerAgri(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popAgri").height();
	var popupWidth = $("#popAgri").width();
	//centering
	$("#popAgri").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}


//centering popup
function centerFlatBed(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#flatBedHauling").height();
	var popupWidth = $("#flatBedHauling").width();
	//centering
	$("#flatBedHauling").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}


// end enclosed containers

// Start of Refuse Containers
function loadEnviromental(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popEnviromental").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableEnviromental(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popEnviromental").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerEnviromental(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popEnviromental").height();
	var popupWidth = $("#popEnviromental").width();
	//centering
	$("#popEnviromental").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}

function isValidEmailAddress(emailAddress) {  
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);  
	return pattern.test(emailAddress);  
} 

function isEmailValid () {
	return emailValid;
}
function loadConstruction(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popConstruction").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableConstruction(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popConstruction").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerConstruction(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popConstruction").height();
	var popupWidth = $("#popConstruction").width();
	//centering
	$("#popConstruction").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}

function loadDumping(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popDumping").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableDumping(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popDumping").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerDumping(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popDumping").height();
	var popupWidth = $("#popDumping").width();
	//centering
	$("#popDumping").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}

function loadBMHS(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popBMHS").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableBMHS(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popBMHS").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerBMHS(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popBMHS").height();
	var popupWidth = $("#popBMHS").width();
	//centering
	$("#popBMHS").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}

function loadRS(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popRS").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableRS(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popRS").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerRS(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popRS").height();
	var popupWidth = $("#popRS").width();
	//centering
	$("#popRS").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}

function loadDS(){  
	//loads popup only if it is disabled  
	if(popupStatus==0){  
		$("#backgroundPopup").css({ 
			"opacity": "0.5" 
		});  
		$("#backgroundPopup").fadeIn("fast"); 
		$("#popDS").fadeIn("fast");  
		popupStatus = 1;  
	}   
}  


//disabling popup with jQuery magic!
function disableDS(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popDS").fadeOut("fast");
		popupStatus = 0;
	}
}

//centering popup
function centerDS(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popDS").height();
	var popupWidth = $("#popDS").width();
	//centering
	$("#popDS").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}

