$(document).ready(function() {
//DROPDOWN MAIN
$('#dropdown li ul').hide();
$('#dropdown li').hover(function () {
$(this).find('ul').stop(true, true).slideDown('fast');
}, function() {
$(this).find('ul').stop(true, true).slideUp('fast');
});

// MENU IMAGE ROLLOVERS //
// Preload all rollovers
$("#dropdown a.menuimage img").each(function() {
// Set the original src
rollsrc = $(this).attr("src");
if (!rollsrc.match(/_over/)) {
rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
$("<img>").attr("src", rollON);
}
});
		
// Navigation rollovers
$("#dropdown li a.menuimage").mouseover(function(){
imgsrc = $(this).children("img").attr("src");
matches = imgsrc.match(/_over/);
if (!matches) {
imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
$(this).children("img").attr("src", imgsrcON);
}
});
$("#dropdown li a.menuimage").mouseout(function(){
$(this).children("img").attr("src", imgsrc);
});





// HOVER-FADE FUNCTIONS
$("a.fade img").hover(function () {
// animate opacity to full
$(this).stop().animate({
opacity: 0.75
}, 200);
},
// on mouse out
function () {
// animate opacity to nill
$(this).stop().animate({
opacity: 1
}, 200);
});




//CLEAR ZIP CODE - THEATER
$("input[name=zipvalue]").focus(function () {
if ($(this).val() == "Enter Your Zip") {
$(this).val("");
}
});

$("input[name=mobile]").focus(function () {
if ($(this).val() == "xxx-xxx-xxxx") {
$(this).val("");
}
});



//SCROLLING
$(".scroll").click(function(event){
//prevent the default action for the click event
event.preventDefault();
//get the full url - like mysitecom/index.htm#home
var full_url = this.href;
//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
var parts = full_url.split("#");
var trgt = parts[1];
//get the top offset of the target anchor
var target_offset = $("#"+trgt).offset();
var target_top = target_offset.top;
//goto that anchor by setting the body scroll top to anchor top
$('html, body').animate({scrollTop:target_top}, 500);
});


//QUOTES
$('#quotes .slide');
	setInterval(function(){
		$('#quotes .slide').filter(':visible').fadeOut(300,function(){
			if($(this).next('li.slide').size()){
				$(this).next().fadeIn(300);
			} else{
				$('#quotes .slide').eq(0).fadeIn(300);
			}
		});
	},9000);



});//END DOM LOADING






// CHECK REGISTRATION
function SignupCheck(form) {
valcheck = form.email;
hasDot = valcheck.value.indexOf(".");
hasAt = valcheck.value.indexOf("@");

if (hasDot == -1 || hasAt == -1) {
	alert("Please enter your Email Address.");
	valcheck.focus();
	return false;
}

//First Name Check
valcheck = document.getElementById("CustomFields_1_43");
if (valcheck.value == "" || valcheck.length < 2) {
	alert("Please enter your First Name");
	valcheck.focus();
	return false;
}

//Last Name Check			
valcheck = document.getElementById("CustomFields_2_43");
if (valcheck.value == "" || valcheck.length < 2) {
	alert("Please enter your Last Name");
	valcheck.focus();
	return false;
} 

//State Check			
valcheck = document.getElementById("CustomFields_13_43");
if(valcheck.selectedIndex == -1 || valcheck.value == "") {
	alert("Please enter your State");
	valcheck.focus();
	return false;
}

//Zip Check	
valcheck = document.getElementById("CustomFields_3_43");
if (valcheck.value == "" || valcheck.length < 2) {
	alert("Please enter your Zip Code");
	valcheck.focus();
	return false;
}
 else {
	return true;
}
}
