var BottomNavTimeoutBag = new Array();
var AllFlyOutSelector = "#JockeyCatalogFlyOut, #EmailSignUpFlyOut, #JockeyClubFlyOut, #CustomerServiceFlyOut, #SocialFlyOut, #YourAccountFlyOut, #OurCompanyFlyOut, #OtherSitesFlyOut";
var BottomNavChat;

$(document).ready(function() {
		
	if ($("#HiddenCallImage img").width() > 1) //if the image is not 1px wide, then chat and click to call are available
	{
		$("#ChatOpen").css("display", "block");
		$("#ChatClosed").css("display", "none");
	}
	else
	{
		$("#ChatOpen").css("display", "none");
		$("#ChatClosed").css("display", "block");
	}	
	
	$("#EmailTextBox").val("Enter your email address");
	
	
	BindBottomNavBehaviors();
});

function BindBottomNavBehaviors()
{
	//bind the behaviors of...

	//catalog search		
	$("#JockeyCatalog").bind("mouseover", function(){
		if ($("#JockeyCatalogFlyOut:animated").length == 0)
		{
			clearTimeouts(BottomNavTimeoutBag, ["JockeyCatalogFlyOut"]);
			$("#JockeyCatalogFlyOut").slideDown(250);
			$(AllFlyOutSelector.replace("#JockeyCatalogFlyOut,", "")).slideUp(250);
		}
	});
	
	$("#JockeyCatalogFlyOut").bind("mouseleave", function(){
		if ($("#JockeyCatalogFlyOut:animated").length == 0)
		{
			var TimeoutId = setTimeout(function(){
				$("#JockeyCatalogFlyOut").slideUp(250);
			}, 10);		
			BottomNavTimeoutBag["JockeyCatalogFlyOut"] = { 'name' : 'JockeyCatalogFlyOut', 'TimeoutId' : TimeoutId };	
		}
	});
	
	//email signup
	$("#EmailSignUp").bind("mouseover", function(){
		if ($("#EmailSignUpFlyOut:animated").length == 0)
		{
			clearTimeouts(BottomNavTimeoutBag, ["EmailSignUpFlyOut"]);
			$("#EmailSignUpFlyOut").slideDown(250);
			$(AllFlyOutSelector.replace("#EmailSignUpFlyOut,", "")).slideUp(250);
			
			if ($("#EmailTextBox").val() == "Please enter a valid email address")
				$("#EmailTextBox").css("color", "red");
		}
	});
	
	$("#EmailSignUpFlyOut").bind("mouseleave", function(){
		if ($("#EmailSignUpFlyOut:animated").length == 0)
		{
			var TimeoutId = setTimeout(function(){
				$("#EmailSignUpFlyOut").slideUp(250);
			}, 10);		
			BottomNavTimeoutBag["EmailSignUpFlyOut"] = { 'name' : 'EmailSignUpFlyOut', 'TimeoutId' : TimeoutId };			
		}
	});
	
	$("#EmailFeedBackCloseButton").bind("click", function(){
		$("#EmailFeedbackFlyOut").slideUp();
	});
	
	//email signup forms
	$("#EmailTextBox").bind("keypress", function(e){
		if (e.keyCode == 13)
			PresentCaptcha();
	});
	
	$("#EmailTextBox, #txtEmail, #txtConfirmEmail, #txtFirstName, #txtLastName").bind("focus click", function(){
		if ($(this).css("color") == "red" || this.value.toLowerCase() == this.title.toLowerCase())
			this.value = "";			
		$(this).css({"color": "#727375", "font-style": "normal"});
	}).bind("blur", function(){
		if (this.value == "")
		{
			this.value = this.title;
			$(this).css({"color": "#727375", "font-style": "italic"});
		}
	});


		
		$("#EmailSignUpSubmit").bind("click", function(){
			PopUpCaptchaWindow();
		});

	$("#EmailFormSubmit").bind("click", function(){
		SubmitEmail();
	});
	
	$("#CaptchaFormCloseButton").bind("click", function(){
		$("#CaptchaFlyOut").slideUp();
	});
	
	$("#selDay").bind("change", function(){
		OnDayChange();
	});
	
	$("#selMonth").bind("change", function(){
		OnMonthChange();
	});
		
	//jockey club
	$("#JockeyClub").bind("mouseover", function(){
		if ($("#JockeyClubFlyOut:animated").length == 0)
		{
			clearTimeouts(BottomNavTimeoutBag, ["JockeyClubFlyOut"]);
			$("#JockeyClubFlyOut").slideDown(250);			
			$(AllFlyOutSelector.replace("#JockeyClubFlyOut,", "")).slideUp(250);
		}
	});
	
	$("#JockeyClubFlyOut").bind("mouseleave", function(){
		if ($("#JockeyClubFlyOut:animated").length == 0)
		{
			var TimeoutId = setTimeout(function(){
				$("#JockeyClubFlyOut").slideUp(250);
			}, 10);		
			BottomNavTimeoutBag["JockeyClubFlyOut"] = { 'name' : 'JockeyClubFlyOut', 'TimeoutId' : TimeoutId };	
		}
	});	
	
	//customer service
	$("#CustomerService").bind("mouseover", function(){
		if ($("#CustomerServiceFlyOut:animated").length == 0)
		{
			clearTimeouts(BottomNavTimeoutBag, ["CustomerServiceFlyOut"]);
			$("#CustomerServiceFlyOut").slideDown(250);
			$(AllFlyOutSelector.replace("#CustomerServiceFlyOut,", "")).slideUp(250);
		}
	});
	
	$("#CustomerServiceFlyOut").bind("mouseleave", function(){
		if ($("#CustomerServiceFlyOut:animated").length == 0)
		{				
			var TimeoutId = setTimeout(function(){
				$("#CustomerServiceFlyOut").slideUp(250);
			}, 10);		
			BottomNavTimeoutBag["CustomerServiceFlyOut"] = { 'name' : 'CustomerServiceFlyOut', 'TimeoutId' : TimeoutId };	
		}
	});	
	
	$("#ChatFormFlyOut").bind("mouseover", function(){
		$(AllFlyOutSelector).slideUp(250);
	});
	
	$("#ChatFormCloseButton").bind("click", function(){
		$("#ChatFormFlyOut").slideUp(250);
	});
	
	//your account
	$("#YourAccount").bind("mouseover", function(){
		if ($("#YourAccountFlyOut:animated").length == 0)
		{
			clearTimeouts(BottomNavTimeoutBag, ["YourAccountFlyOut"]);
			$("#YourAccountFlyOut").slideDown(250);
			$(AllFlyOutSelector.replace("#YourAccountFlyOut,", "")).slideUp(250);
		}
	});
	
	$("#YourAccountFlyOut").bind("mouseleave", function(){
		if ($("#YourAccountFlyOut:animated").length == 0)
		{
			var TimeoutId = setTimeout(function(){
				$("#YourAccountFlyOut").slideUp(250);
			}, 10);		
			BottomNavTimeoutBag["YourAccountFlyOut"] = { 'name' : 'YourAccountFlyOut', 'TimeoutId' : TimeoutId };			
		}
	});
	
	//our company
	$("#OurCompany").bind("mouseover", function(){
		if ($("#OurCompanyFlyOut:animated").length == 0)
		{
			clearTimeouts(BottomNavTimeoutBag, ["OurCompanyFlyOut"]);
			$("#OurCompanyFlyOut").slideDown(250);
			$(AllFlyOutSelector.replace("#OurCompanyFlyOut,", "")).slideUp(250);
		}
	});
	
	$("#OurCompanyFlyOut").bind("mouseleave", function(){
		if ($("#OurCompanyFlyOut:animated").length == 0)
		{			
			var TimeoutId = setTimeout(function(){
				$("#OurCompanyFlyOut").slideUp(250);
			}, 10);		
			BottomNavTimeoutBag["OurCompanyFlyOut"] = { 'name' : 'OurCompanyFlyOut', 'TimeoutId' : TimeoutId };	
		}
	});
	
	//other sites
	$("#OtherSites").bind("mouseover", function(){
		if ($("#OtherSitesFlyOut:animated").length == 0)
		{
			clearTimeouts(BottomNavTimeoutBag, ["OtherSitesFlyOut"]);
			$("#OtherSitesFlyOut").slideDown(250);
			$(AllFlyOutSelector.replace("#OtherSitesFlyOut", "")).slideUp(250);
		}
	});
	
	$("#OtherSitesFlyOut").bind("mouseleave", function(){
		if ($("#OtherSitesFlyOut:animated").length == 0)
		{			
			var TimeoutId = setTimeout(function(){
				$("#OtherSitesFlyOut").slideUp(250);
			}, 10);		
			BottomNavTimeoutBag["OtherSitesFlyOut"] = { 'name' : 'OtherSitesFlyOut', 'TimeoutId' : TimeoutId };
		}
	});
	
	//social links	
	$(".SocialLink").bind("mouseover", function(){
		if ($("#SocialFlyOut:animated").length == 0)
		{
			$(AllFlyOutSelector.replace("#SocialFlyOut,", "")).slideUp(250);
			clearTimeouts(BottomNavTimeoutBag, ["SocialFlyOut"]);	
			switch ($(this).attr("id"))
			{
				case "BlogLink":
					$("#SocialFlyOut").removeClass().addClass("BlogTag").attr("href", "http://blog.jockey.com/");					
					break;
				case "FacebookLink":
					$("#SocialFlyOut").removeClass().addClass("FacebookTag").attr("href", "http://www.facebook.com/Jockey");
					break;
				case "TwitterLink":
					$("#SocialFlyOut").removeClass().addClass("TwitterTag").attr("href", "http://www.twitter.com/jockey");					
					break;
				case "YouTubeLink":
					$("#SocialFlyOut").removeClass().addClass("YouTubeTag").attr("href", "http://www.youtube.com/jockey");					
					break;
				default:
					break;
			}
			
			$("#SocialFlyOut").slideDown(250);
		}
	}).bind("mouseleave", function(){
		if ($("#SocialFlyOut:animated").length == 0)
		{
			var TimeoutId = setTimeout(function(){
				$("#SocialFlyOut").slideUp(250);
				$(".SocialLink").removeClass("BlogLinkHover FacebookLinkHover TwitterLinkHover YouTubeLinkHover");
			}, 10);		
			BottomNavTimeoutBag["SocialFlyOut"] = { 'name' : 'SocialFlyOut', 'TimeoutId' : TimeoutId };						
		}
	});		
	
	$("#SocialFlyOut").bind("mouseover", function(){
		clearTimeouts(BottomNavTimeoutBag, ["SocialFlyOut"]);
		
		$(".SocialLink").removeClass("BlogLinkHover FacebookLinkHover TwitterLinkHover YouTubeLinkHover");
		switch ($(this).attr("class"))
		{
			case "BlogTag":
				$("#BlogLink").addClass("BlogLinkHover");
				break;
			case "FacebookTag":
				$("#FacebookLink").addClass("FacebookLinkHover");
				break;
			case "TwitterTag":
				$("#TwitterLink").addClass("TwitterLinkHover");
				break;
			case "YouTubeTag":
				$("#YouTubeLink").addClass("YouTubeLinkHover");
				break;
			default:
				break;
		}
	}).bind("mouseleave", function(){
		$(".SocialLink").removeClass("BlogLinkHover FacebookLinkHover TwitterLinkHover YouTubeLinkHover");
	});
	
	//hide flyouts when mouse enters area below where the dropdowns could be (note: many selectors due to inconsistent page layouts)
	$("#dptouterm, #dptouter, #dptouterd, #dptouter2, .mainbody, #ShoppingBagPageContent").bind("mouseover", function() {
		$(AllFlyOutSelector).slideUp(250);
	});
	
	//hide flyouts when the mouse leaves the center area
	$("#Form1, #Form2, #ProductDetails, #Error, #Logout, #form, #PR, #frmSiteMap, #UpdateProfile").mouseleave(function() {
		$(AllFlyOutSelector).slideUp(250);
	});
	
	//other elements that should trigger hiding of flyouts
	$("#FooterBottomRow, #GetBriefed, #pnlEmpty, .head1").mouseover(function() {
		$(AllFlyOutSelector).slideUp(250);
	});
		
}

function DoSearch()
{	
	var SearchTerm = $("#QuickOrderTextBox").val();
	if (SearchTerm != "Search item #" && SearchTerm != "")
		window.location = "http://search.jockey.com/exec/?kw=" + SearchTerm;
}

function ValidateEmail(elementValue)
{  
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	return emailPattern.test(elementValue);
}

function PresentCaptcha()
{
	var EmailAddress = $("#EmailTextBox").val();
	if (ValidateEmail(EmailAddress))
	{
		$("#txtEmail").val(EmailAddress).css({"color": "#727375", "font-style": "normal"});
		$("#txtConfirmEmail").val("Confirm email address").css({"color": "#727375", "font-style": "italic"});
		$("#txtFirstName").val("First name").css({"color": "#727375", "font-style": "italic"});
		$("#txtLastName").val("Last name").css({"color": "#727375", "font-style": "italic"});

		
		$("#CaptchaFlyOut").slideDown(250);
	}
	else
	{
		$("#EmailTextBox").val("Please enter a valid email address").css("color", "red");
	}
	$("#EmailFeedbackFlyOut").slideUp(250);
	$("#EmailFeedBackCopy").html("");
}


function SubmitEmail()
{
	$("#CaptchaFormLoadingGif").css({"display":"block"});
	if (ValidateCaptchaForm())
	{	
		$.ajax({
			type: "POST",
			url: window.location.href,
			dataType: "json",
			data:
				{
					"CallBackType" : "SubmitEmail", 
					"recaptcha_challenge_field" : document.getElementById("recaptcha_challenge_field").value,
					"recaptcha_response_field" : document.getElementById("recaptcha_response_field").value,
					"Email" : $("#txtEmail").val(),
					"ConfirmEmail" : $("#txtConfirmEmail").val(),
					"FirstName" : $("#txtFirstName").val(),
					"LastName" : $("#txtLastName").val(),
					"BirthDateDay" : $("#selDay").val(),
					"BirthDateMonth" : $("#selMonth").val(),
					"Gender" : $("input[name='gender']:checked").val() == null ? "0" : $("input[name='gender']:checked").val()
				},
			success: function(response){
				SubmitEmailSuccess(response);
			},
			error: function(xhr, ajaxOptions, thrownError){
				SubmitEmailFailure(xhr, ajaxOptions, thrownError);
			}
		});	
	}
	else
	{
		$("#CaptchaFormLoadingGif").css({"display":"none"});
	}
}

function SubmitEmailSuccess(response)
{
	$("#CaptchaFormLoadingGif").css({"display":"none"});
	if (response.PassedServerValidate)
	{
		if (response.Result == 0) //the email submitted is new
		{
			$("#CaptchaFlyOut").slideUp(250, function(){
				$("#EmailFeedBackCopy").html("<h5>Thanks for signing up.</h5><span>You will now receive a confirmation email with your special offer.</span><span class='Italic'>Enjoy!</span>");
				$("#EmailFeedbackFlyOut").slideDown(250, function(){
					setTimeout(function(){
						$("#EmailFeedbackFlyOut").slideUp(250);
						$("#EmailFeedBackCopy").html("");						
					},10000);			
				});
			});
		}
		else if(response.Result == 1) //the email submitted already exists
		{
			$("#CaptchaFlyOut").slideUp(250, function(){
				$("#EmailFeedBackCopy").html("<h5>Good news!</h5><span>You are already signed up to receive Jockey&reg; <br/> emails.</span><span>Stay tuned for exclusive news and special offers.</span>");
				$("#EmailFeedbackFlyOut").slideDown(250, function(){
					setTimeout(function(){
						$("#EmailFeedbackFlyOut").slideUp(250);
						$("#EmailFeedBackCopy").html("");						
					},10000);
				});
			});
		}		
	}
	else
	{
		//if server validate failed, get a new captcha
		//set validation messages
		if (response.ValidationJSON.EmailRequired != null)
			$("#txtEmail").val("Email address required").css("color", "red");
		else if (response.ValidationJSON.InvalidFormat != null)
			$("#txtEmail").val("Invalid email address").css("color", "red");
		else if (response.ValidationJSON.DoNotMatch != null)
			$("#txtConfirmEmail").val("Email addresses must match").css("color", "red");
		
		if (response.ValidationJSON.FirstNameRequired != null)
			$("#txtFirstName").val("First name is required").css("color", "red");
		
		if (response.ValidationJSON.LastNameRequired != null)		
			$("#txtLastName").val("Last name is required").css("color", "red");
		
		if (response.ValidationJSON.BirthdayRequired != null)
		{
			$("#BirthdateValidationContainer").addClass("BirthdateValidationContainerOn");		
			$("#BirthdateValidationContainer span").html("Birthdate is required");
		}
	}
}

function SubmitEmailFailure(xhr, ajaxOptions, thrownError)
{
	$("#CaptchaFormLoadingGif").css({"display":"none"});
	$("#CaptchaFlyOut").slideUp(250, function(){
		$("#EmailFeedBackCopy").html("<h5>We're sorry.</h5><span>An error has occurred. We are currently looking into this issue.</span><span>Please try again soon.</span>");
		$("#EmailFeedbackFlyOut").slideDown(250, function(){
			setTimeout(function(){
				$("#EmailFeedbackFlyOut").slideUp(250);
				$("#EmailFeedBackCopy").html("");						
			},10000);
		});
	});	
}
function ValidateCaptchaForm()
{
	var Passed = true;
	if ($("#txtEmail").val() == "")
	{
		$("#txtEmail").val("Email address required").css("color", "red");
		Passed = false;
	}	
	else if (!ValidateEmail($("#txtEmail").val()))
	{
		$("#txtEmail").val("Invalid email address").css("color", "red");
		Passed = false;
	}	
	else if ($("#txtEmail").val() != $("#txtConfirmEmail").val())
	{
		$("#txtConfirmEmail").val("Email addresses must match").css("color", "red");
		Passed = false;
	}
	
	if ($("#txtFirstName").val() == "" || $("#txtFirstName").val().toLowerCase() == "first name is required" || $("#txtFirstName").val().toLowerCase() == "first name")
	{
		$("#txtFirstName").val("First name is required").css("color", "red");
		Passed = false;
	}
	
	if ($("#txtLastName").val() == "" || $("#txtLastName").val().toLowerCase() == "last name is required" || $("#txtLastName").val().toLowerCase() == "last name")
	{
		$("#txtLastName").val("Last name is required").css("color", "red");
		Passed = false;
	}
	
	if ($("#selDay").val() == "0" || $("#selMonth").val() == "0")
	{
		$("#BirthdateValidationContainer").addClass("BirthdateValidationContainerOn");		
		$("#BirthdateValidationContainer span").html("Birthdate is required");
		Passed = false;
	}	
	
	if ($("#recaptcha_response_field").val() == "" || $("#recaptcha_response_field").val() == "Captcha response is required" || $("#recaptcha_response_field").val() == "Incorrect captcha answer")
	{
		$("#recaptcha_response_field").val("Captcha response is required").css("color", "red");
		Passed = false;
	}
	
	return Passed;	
}


function ShowChatForm()
{	
	BottomNavWTonReady();
}

function btnChatNowb_onClick() 
{
	document.getElementById("emlbb").style.display = "none";
	document.getElementById("msgbb").style.display = "none";

	if (isNonblank(document.Form1.wt_emailb.value))
	{
		if (!regIsEmail(document.Form1.wt_emailb.value))
		{
			document.getElementById("emlbb").style.display = "block";
			return;
		}
	}

	if (!isNonblank(document.Form1.init_textb.value))
	{	
		document.getElementById("msgbb").style.display = "block";
		return;
	}

	if (document.Form1.wt_firstb.value == '')
		set_cookie ( "WTFirst", "null");
	else	
		set_cookie ( "WTFirst", document.Form1.wt_firstb.value);
	
	if (document.Form1.wt_lastb.value == '')
		set_cookie ( "WTLast", "null");
	else 
		set_cookie ( "WTLast", document.Form1.wt_lastb.value);

	if (document.Form1.wt_emailb.value == '')
		set_cookie ( "WTEmail", "null");
	else
		set_cookie ( "WTEmail", document.Form1.wt_emailb.value);
 
	set_cookie ( "WTtxt", document.Form1.init_textb.value);
 	
 	BottomNavChat.start({
    	initialText: 'message',
		info: {
			'Name_First': WTfnameb(),
			'Name_Last': WTlnameb(),
			'email': WTemailb(),
			'message' : WTinittestb()	        
		}
	});
}

function isNonblank(s)
{ 
   var isNonblank_re    = /\S/; 
   return String (s).search (isNonblank_re) != -1 
}

function regIsEmail(fData) 
{ 
	var reg = new RegExp("^[0-9a-zA-Z\.]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$"); 
    return reg.test(fData); 
}

function set_cookie(name, value)
{

	var expdate = new Date (); // pre-set to the current time and date
	expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 24 * 365); // add one year to it 
	//365 days/year * 24 hours/day * 60 minutes/hour * 60 seconds/minute * 1000 milliseconds/second
	// = howevermany milliseconds/year. So this adds one year, it'll expire in one year.

	document.cookie = name + "=" + escape(value) + "; expires=" + expdate.toGMTString() + "; path=/";
}

function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name,
  'width=' + w + ', height=' + h + ', ' +
  'location=yes, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=yes');
 win.resizeTo(w, h);
 win.focus();
}


function BottomNavtestStatus() 
{
	//LINE BELOW IS BOGUS! setting BottomNavChat.status to "ready" because chat is not set up on dev
	BottomNavChat.status = "ready";
	
	if (BottomNavChat.status === "ready") 
	{
		$("#ChatFormFlyOut").slideDown(250);
	}
	else
	{
		wopen('/en-us/customerservice/contactus/chatcontactus.aspx?a=|','popup',400,500);
	}
};

function BottomNavWTonReady() 
{
	BottomNavChat = Wt.chat.PublicChat;
	BottomNavChat.init ({
		statusCallback: BottomNavtestStatus,
		startOptions: {
			window: {
			top: 100,
			left: 100,
			width: 425,
			height: 600,
			cssUrl: 'http://www.jockey.com/css/chat.css',
			logoUrl: 'http://www.jockey.com/images/livehelp/HeadlineImage.jpg',
			title: 'Chat with a Live Representative!'
			}
		}
	});
}

function WTfnameb()
{
	return document.Form1.wt_firstb.value;
}

function WTlnameb()
{
	return document.Form1.wt_lastb.value;
}

function WTemailb()
{
	return document.Form1.wt_emailb.value;
}

function WTinittestb()
{
	return document.Form1.init_textb.value;
}

function OnDayChange()
{
	if ($("#selDay").val() != "0" && $("#selMonth").val() != "0")
	{
		$("#BirthdayRequired").html("");
	}	
}

function OnMonthChange()
{		
	var indexLength = document.getElementById("selDay").options.length;
	for (var i = indexLength-1; i >= 0; i--)
	{
		var optionChild = document.getElementById("selDay").options[i];
		document.getElementById("selDay").removeChild(optionChild);
	}
	
	switch ($("#selMonth").val())
	{
		case '1':
			for (var i = 0; i < 32; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;		
		case '2':
			for (var i = 0; i < 29; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;		
		case '3':
			for (var i = 0; i < 32; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;
		case '5':
			for (var i = 0; i < 32; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;	
		case '7':
			for (var i = 0; i < 32; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;	
		case '8':
			for (var i = 0; i < 32; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;	
		case '10':
			for (var i = 0; i < 32; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;
		case '12':
			for (var i = 0; i < 32; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;			
		case '4':
			for (var i = 0; i < 31; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;
		case '6':
			for (var i = 0; i < 31; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;	
		case '9':
			for (var i = 0; i < 31; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;	
		case '11':
			for (var i = 0; i < 31; ++i)
			{
				var option = document.createElement('OPTION');
				option.value = i;
				option.innerHTML = i;
				if (i == 0){option.innerHTML = 'Day';}
				document.getElementById("selDay").appendChild(option);
			}
			break;	
		default:
			var option = document.createElement('OPTION');
			option.value = 0;
			option.innerHTML = 'Day';
			document.getElementById("selDay").appendChild(option);
			break;		
	}
	
	if ($("#selDay").val() != "0" && $("#selMonth").val() != "0")
	{
		$("#BirthdayRequired").html("");
	}		
}

function PopUpCaptchaWindow()
{
{var wn = window.open('http://www.jockey.com/emailsignuppopup.aspx?emailid=' + $("#EmailTextBox").val(),'emailsignup', 'width=' + 490 + ', height=' + 340 + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=yes, resizable=yes'); wn.focus();}
}

function capopen(u,n,w,h)
{var w = window.open(u, n, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=yes, resizable=yes'); w.focus();}

