var linkColorState = 0; // 0 is OurWines dropdown not shown, 1 is OurWines dropped down, 2 is OurWines selected

function swfF(ele,str) {
	if (ele.value == str) {
		ele.value = '';
	}
}
function swfB(ele,str) {
	if (ele.value == '') {
		ele.value=str;
	}
}

function showWine(wId) {
	$("#pageContent").fadeOut("slow", function(){
		//once the fade out is completed, we start to fade in the new div
		// let's do this with ajax
		$.ajax({
			type: "GET",
			url: "/ajaxDo.php",
			data: "action=getWinePage&name=" + wId + "&sid=" + Math.random(),
			success: function(responseData) {
				$("#pageContent").html(responseData).fadeIn();
				// alert(responseData);
			}
		});
	 	//$(this).parent().find("#wine1").fadeIn();
		// fade out the other top 2 links even more...
		linkColorState = 2;
		$("#ddLink2").addClass("colorDarkest",400);
		$("#ddLink3").addClass("colorDarkest",400);
	});
}

function showEvent(eId) {
	$("#eventDetails").fadeOut("slow", function(){
		//once the fade out is completed, we start to fade in the new div
		// let's do this with ajax
		$.ajax({
			type: "GET",
			url: "/ajaxDo.php",
			data: "action=getEvent&event_id=" + eId + "&sid=" + Math.random(),
			success: function(responseData) {
				$("#eventDetails").html(responseData).fadeIn();
			}
		});
	});
}

// set ALL links to fade to another color then back to 
// original color on mouse out
$(document).ready(function(){
    $("a").hover(function() {
        $(this).stop(true, true).addClass("aHover",400);
    }, function(){
        $(this).stop(true, true).removeClass("aHover",500);
    });
});

$(function() {
	// init fancy scroller
	$('.boxContentMain').jScrollPane({showArrows:true, scrollbarWidth: 8});
});




function isValidEmail(str) {
	return (str.indexOf('@') > 0);
}

function wgCheckForm(theform) {

	var msg = 'Please check the following:\n\n';
	var retVal = true;

	if(theform.name.value.length < 2 || theform.name.value == "Name"){
		msg = msg + '* Enter your name \n';
		retVal = false;
	}

	if(theform.address.value.length < 2 || theform.address.value == "Address"){
		msg = msg + '* Enter your address \n';
		retVal = false;
	}

	if(theform.city.value.length < 2 || theform.city.value == "City, State, Zip"){
		msg = msg + '* Enter your city, state and zip \n';
		retVal = false;
	}

	if(!isValidEmail(theform.email.value) || theform.email.value == "Email"){
		msg = msg + '* Enter a valid email address \n';
		retVal = false;
	}

	if(theform.ccType.value.length < 2 || theform.ccType.value == "Credit Card Type"){
		msg = msg + '* Enter your credit card type \n';
		retVal = false;
	}

	if(theform.ccNumber.value.length < 2 || theform.ccNumber.value == "Credit Card Number"){
		msg = msg + '* Enter your credit card number \n';
		retVal = false;
	}

	if(theform.ccExpires.value.length < 2 || theform.ccExpires.value == "Expires"){
		msg = msg + '* Enter your credit card expiration date \n';
		retVal = false;
	}

	if (retVal == false) {
		alert(msg);
	}
	
	return retVal;
}

function mlCheckForm(theform) {

	var msg = 'Please check the following:\n\n';
	var retVal = true;

	if(theform.name.value.length < 2 || theform.name.value == "Name"){
		msg = msg + '* Enter your name \n';
		retVal = false;
	}

	if(!isValidEmail(theform.email.value) || theform.email.value == "Email"){
		msg = msg + '* Enter a valid email address \n';
		retVal = false;
	}

	if (retVal == false) {
		alert(msg);
	}
	
	return retVal;
}
