function show(div) {
document.getElementById(div + 'drop').style.display = 'block';
if(div != "search") {
document.getElementById(div).style.border = '1px solid #787878';
document.getElementById(div + 'Black').style.display = 'block';
}
}
function hide(div) {
document.getElementById(div + 'drop').style.display = 'none';
if(div != "search") {
document.getElementById(div).style.border = '1px solid #000000';
document.getElementById(div + 'Black').style.display = 'none';
}
}

	function ajax_submit(frm, type, ajax_cmd)
    {
      if ( type == "people" )
      {
        if ( !check_people_sign_up(frm) )
        {
          return false;
        }
        frm.submit();
        return true;
      }
      var url = "profiles.php?ai_skin=full_page&type=" + escape(type) + "&te_mode=ajax&ajax_cmd=" + escape(ajax_cmd);
      var params = "1";
      for ( var i = 0; i < frm.elements.length; i++ )
      {
        var elem = frm.elements[i];
        if ( (elem.type == "radio" || elem.type == "checkbox") && !elem.checked )
        {
          continue;
        }
        params += "&" + elem.name + "=" + escape(elem.value);
      }
      ajax_post_request(url, params, ajax_handler_default);
		}

		function check_people_sign_up(frm)
		{
		if ( jQuery.trim(frm.first_name.value) == "" ) { jonbox_info("Please enter a valid value for: First Name","Please Complete The Following"); return false; }
		if ( jQuery.trim(frm.last_name.value) == "" ) { jonbox_info("Please enter a valid value for: Last Name","Please Complete The Following"); return false; }
		if ( jQuery.trim(frm.email.value) == "" ) { jonbox_info("Please enter a valid value for: Email","Please Complete The Following"); return false; }
		if ( jQuery.trim(frm.email.value) != jQuery.trim(frm.retype_email.value) ) { jonbox_info("Your Emails do not match","Please Complete The Following"); return false; }
		if ( jQuery.trim(frm.password.value) == "" ) { jonbox_info("Please enter a valid value for: Make Password","Please Complete The Following"); return false; }
		if ( jQuery.trim(frm.password.value) != jQuery.trim(frm.retype_password.value) ) { jonbox_info("Your Passwords do not match","Please Complete The Following"); return false; }
		if ( jQuery.trim(frm.zip.value) == "" ) { jonbox_info("Please enter a valid value for: Zip Code","Please Complete The Following"); return false; }
		if ( jQuery.trim(frm.gender.value) == "" ) { jonbox_info("Please enter a valid value for: Gender","Please Complete The Following"); return false; }
		if ( frm.people_birthdate_m.value == "" || frm.people_birthdate_d.value == "" || frm.people_birthdate_y.value == "" ) { jonbox_info("Please enter a valid value for: Birthdate","Please Complete The Following"); return false; }
		if(document.getElementById('sign_up_form_table_2').style.display === 'none') {
			$('#sign_up_form_table').fadeOut("fast", function() {
				$('#sign_up_form_table_2').fadeIn("fast");
			});
			return false;
		}
		//if ( jQuery.trim(frm.retype_password.value) == "" ) { jonbox_info("Please enter a valid value for: Confirm Password","Please Complete The Following"); return false; }
		//if ( frm.password.value != frm.retype_password.value ) { jonbox_info("The passwords you entered do not match. Please make sure you typed them correctly.","Please Complete The Following"); return false; }
		/*if ( jQuery.trim(frm.filename.value) == "") {
			if ( jQuery.trim(frm.generic_ID.value) == "1" ) {
				window.jonbox_open_special_original('check_photo','<span style="color: #ff0000">A Photo is Required</a>');
				return false;
			}
		}*/
		if ( jQuery.trim(frm.verification_code.value) == "" ) { jonbox_info("Please enter a valid value for: Security Word","Please Complete The Following"); return false; }
		if ( !frm.iagree.checked ) { jonbox_info("You must agree to the Terms of Use & Privacy Policy","Please Complete The Following"); return false; }
		return true;
		}
		function switch_page_back()
		{
			$('#sign_up_form_table').fadeIn(1500);
			$('#sign_up_form_table_2').fadeOut(1500);
		}
		function Switch_Email(val)
		{
			if(val.value === 'email') {
				val.value = "";
				val.style.color = "#000000";
			} else {
				if(val.value === "") {
					val.value = 'email';
					val.style.color = "#888888";
				}
			}
		}
		function Switch_Password()
		{
			document.getElementById('mockpass').style.display='none';
			document.getElementById('realpass').style.display='';
			document.getElementById('realpass').focus();
		}
		function Switch_Password_Back()
		{
			if(document.getElementById('realpass').value=='') {
				document.getElementById('mockpass').style.display='';
				document.getElementById('realpass').style.display='none';
			}
		}
		function check_intivation_yes_form(frm)
		{
			var url = "invitation_requests.php?ai_skin=full_page&te_class=invitation_requests&te_mode=ajax&ajax_cmd=invitation_yes";
			var params = "email=" + escape(frm.email.value);
			ajax_post_request(url, params, ajax_handler_default);
			return true;
		}
		function check_forgot_password_form(frm)
		{
			var url = "invitation_requests.php?ai_skin=full_page&te_class=invitation_requests&te_mode=ajax&ajax_cmd=forgot_password";
			var params = "username=" + escape(frm.username.value);
			ajax_post_request(url, params, ajax_handler_default);
			return true;
		}
		function start_player(id,href) {
			document.getElementById(id).innerHTML = '<a id="yournight_pl_player" href="' + href + '" onclick="return false;"></a>';
			flowplayer("yournight_pl_player", {src:"flowplayer/flowplayer-3.1.1.swf", wmode:"transparent"});
		}
		function switch_pages() {
			if(document.getElementById('splash_page_2').style.display == 'none') {
				$('#splash_page_1').hide(0);
				$('#splash_page_2').show(0);
			} else {
				$('#splash_page_2').hide(0);
				$('#splash_page_1').show(0);
			}
		}
		function call_alert() {
				load_updated();
				//window.jonbox_form('jonbox_invitation_yes', check_intivation_yes_form, 'Exclusive Cash Rewards Offer Is By Invitation Only', '<a href="javascript:void(0)" onclick="switch_pages()">Haven\'t been invited? Click here to accept a celebrity invitation</a>');
				//window.jonbox_form('jonbox_invitation_yes', check_intivation_yes_form, '<span style="color: #2f3699; float: left;">You Must Be Invited To Join YourNight</span>', '<span style="font-size: 11px;">You are currently a member, however, if you have not been invited,<br>please come back and login after you have received an invitation</span>');
		}
		function load_updated() {
			jonbox_open_special_destroy('updated');
			$("#jonbox_jblock").unbind("click");
		}
		function close_popup()
		{
			close_jonbox();
		}
		function check_user() {
			var userID = $("#jonbox_content #lookup_userID").val();
			var email = $("#jonbox_content #lookup_email").val();
			var first_name = $("#jonbox_content #lookup_first").val();
			var last_name = $("#jonbox_content #lookup_last").val();
			var member_ID = $("#jonbox_content #lookup_memberID").val();
			var url = "invitation_requests.php?ai_skin=full_page&te_class=invitation_requests&te_mode=ajax&ajax_cmd=check_user";
			var params = "userID=" + escape(userID) + "&email=" + escape(email) + "&last_name=" + escape(last_name) + "&first_name=" + escape(first_name) + "&member_ID=" + escape(member_ID);
			ajax_post_request(url, params, ajax_handler_default);
			$("#jonbox_content #popup_search").slideUp("slow");
			$("#jonbox_content #return_text").show();
		}
		function insert_html(text) {
			$("#jonbox_content #return_text").html(text);
		}
		function return_html()
		{
			$("#jonbox_content #popup_search").slideDown("slow");
			$("#jonbox_content #return_text").hide();
		}
		function submit_request(id)
		{
			var network = $("#jonbox_content #network_request_value").val();
			var url = "invitation_requests.php?ai_skin=full_page&te_class=invitation_requests&te_mode=ajax&ajax_cmd=confirm_user";
			var params = "id=" + escape(id) + "&network=" + escape(network);
			ajax_post_request(url, params, ajax_handler_default);
			//document.location = "index.php?sponsor=" + encodeURIComponent(id);
		}
		function check_photo_form()
		{
			document.getElementById('generic_ID').value = $('input[name=selected_photo]:checked').val();
			close_jonbox();
		}

		function Switch_Generic(val, def_val)
		{
			if(val.value === def_val) {
				val.value = "";
				val.style.color = "#000000";
			} else {
				if(val.value === "") {
					val.value = def_val;
					val.style.color = "#888888";
				}
			}
		}



$(document).ready(function () {
	var nav_offset = $("#navigation").offset();
	$("#navigation ul li").each(function() {
		var left = $("a.Nav", this).offset().left - nav_offset.left;
		var width = $("a.Nav", this).innerWidth();
		$("div.Navdrop", this).css("left", left + "px");
		$("div.NavBlack", this).css("left", (left + 1) + "px").css("width", width + "px");
		$("a", this).click(function() {
			jonbox_open_div("jonbox_beta");
		});
	});
});
