// JavaScript Document
/* ------------------------------------------------------------------------ */
/* ----------------------------- Includes --------------------------------- */
/* ------------------------------------------------------------------------ */
function runSwf_intro()
{
	document.write('<div id="intro">')
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100%" height="370">\n')
    document.write('<param name="movie" value="images/intro.swf">\n')
	document.write('<param name="wmode" value="transparent">\n')
    document.write('<param name="quality" value="high"/>\n')
	document.write('<param name="scale" value="noscale" />\n')
    document.write('<param name="menu" value="false">\n')	
    document.write('<embed src="images/intro.swf" wmode="transparent" quality="high" scale="noscale" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="370"></embed>\n')
    document.write('</object>\n')
	document.write('</div>')
}
/* ------------------------------------------------------------------------ */
function generate_header(){
		document.write('<div id="header">')
		document.write('<ul class="menu-top">')
		document.write('<li><a id="navID_01-01" href="index.html">Home</a></li>')
		document.write('<li><a id="navID_01-02" href="pricing.html">Pricing Guide</a></li>')
		document.write('<li><a id="navID_01-03" href="contact.html">Contact Us</a></li>')
		document.write('</ul>')
		document.write('</div>')
}
/* ------------------------------------------------------------------------ */
function generate_menuMain(){
		document.write('<div id="menu-main">')
		document.write('<ul>')
		document.write('<li><a id="navID_02-01" href="whoIsAngelin.html">Who&rsquo;s Angelin?</a></li>')
		document.write('<li><a id="navID_02-02" href="isSheQualified.html">Is she qualified?</a></li>')
		document.write('<li><a id="navID_02-03" href="canSheHelpMe.html">Can she help me?</a></li>')
		document.write('<li><a id="navID_02-04" href="showMeResults.html">Show me results</a></li>')
		document.write('<li><a id="navID_02-05" href="quickFacts.html">Quick Facts</a></li>')
		document.write('</ul>')
		document.write('</div>')
}
/* ------------------------------------------------------------------------ */
var d = new Date();
var year = d.getFullYear();
function generate_footer(){
		document.write('<div id="footer">')
		document.write('<p>Copyright &copy; ' + year  + ' Fitness Solution. All Rights Reserved.</p>')
		document.write('</div>')
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/**
function generate_form(){
		document.write('<div class="form">')
		document.write('<p class="headText">Sign up for a non <br />obligated trial now!</p>')
		document.write('<form action="" method="get">')
		document.write('<p class="field"><input type="text" name="sName" id="sName" value="Your Name"/></p>')
		document.write('<p class="field"><input type="text" name="sMobile" id="sMobile" value="Your Mobile"/></p>')
		document.write('<p class="field"><input type="text" name="sEmail" id="sEmail" value="Your Email"/></p>')
		document.write('<p class="button"><input type="submit" value="Sign Up Now" /></p>')
		document.write('</form>')
		document.write('</div>')
}
**/


function generate_form(){
		document.write('<div class="form">')
		document.write('<p class="headText">Sign up for a non <br />obligated trial now!</p>')
		document.write('<form action="" method="POST" id="sForm">')
		document.write('<p class="field"><input type="text" name="sName" id="sName" value="Your Name"/></p>')
		document.write('<p class="errmsg" id="sNameMsg"></p>')
		document.write('<p class="field"><input type="text" name="sMobile" id="sMobile" value="Your Mobile"/></p>')
		document.write('<p class="errmsg" id="sMobileMsg"></p>')
		document.write('<p class="field"><input type="text" name="sEmail" id="sEmail" value="Your Email"/></p>')
		document.write('<p class="errmsg" id="sEmailMsg"></p>')
		document.write('<p class="button"><input type="button" id="sBtn" value="Sign Up Now" /></p>')
		document.write('<p class="thankyoumsg" id="sMsg"></p>')
		document.write('</form>')
		document.write('</div>')
}


$(document).ready(function() {

	$.ajaxSetup({ cache: false });

	    $("#sMsg").html("");
	    $("#sMsg").hide();
		$("#sNameMsg").html("");
		$("#sNameMsg").hide();
		$("#sMobileMsg").html("");
		$("#sMobileMsg").hide();
		$("#sEmailMsg").html("");
		$("#sEmailMsg").hide();


	var validate_sform = function () {

	    $("#sMsg").html("");
	    $("#sMsg").hide();
		$("#sNameMsg").html("");
		$("#sNameMsg").hide();
		$("#sMobileMsg").html("");
		$("#sMobileMsg").hide();
		$("#sEmailMsg").html("");
		$("#sEmailMsg").hide();

		if( $("#sName").val()=="Your Name" || $("#sName").val()=="" ){
			$("#sNameMsg").html("Please enter your name.");
			$("#sNameMsg").show();
			$("#sName").focus();
			return false;
		}else{
			$("#sNameMsg").html("");
			$("#sNameMsg").hide();
		}
		var numericExp = /^[0-9\-\(\)\s\+]+$/;
		if( $("#sMobile").val()=="Your Mobile" || $("#sMobile").val()=="" ){
			$("#sMobileMsg").html("Please enter your mobile.");
			$("#sMobileMsg").show();
			$("#sMobile").focus();
			return false;
		}else if( !$("#sMobile").val().match(numericExp) ){
			$("#sMobileMsg").html("Please enter a valid mobile.");
			$("#sMobileMsg").show();
			$("#sMobile").focus();
			return false;
		}else{
			$("#sMobileMsg").html("");
			$("#sMobileMsg").hide();
		}
		var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
		if( $("#sEmail").val()=="Your Email" || $("#sEmail").val()=="" ){
			$("#sEmailMsg").html("Please enter your email.");
			$("#sEmailMsg").show();
			$("#sEmail").focus();
			return false;
		}else if( !$("#sEmail").val().match(emailExp) ){
			$("#sEmailMsg").html("Please enter a valid email.");
			$("#sEmailMsg").show();
			$("#sEmail").focus();
			return false;
		}else{
			$("#sEmailMsg").html("");
			$("#sEmailMsg").hide();
		}
		return true;
	}


	$("#sBtn").click(function(){
		if( validate_sform() ){
			$.ajax({
				type: "POST",
				url: "signup.php",
				global: false,
				dataType: "json",
				data: $("#sForm :input[value]").serialize(),
				success: function(data){
					if(data.status=="success"){
						//$("#RegistrationMsg").html(data);
						$("#sMsg").html("Thank you! Your subscription has been submitted.");
						$("#sMsg").show();
						$("#sName").val("Your Name");
						$("#sMobile").val("Your Mobile");
						$("#sEmail").val("Your Email");
					}else{
						$("#sMsg").html("Sorry, an error has occured while trying to submit your subscription.");
						$("#sMsg").show();
					}
				}
			});
		}
	});


	$('#sName').mouseover(function() {
		if( $("#sName").val()=="Your Name" ){
			$("#sName").val("");
		}
	}).mouseout(function(){
		if( $("#sName").val()=="" ){
			$("#sName").val("Your Name");
		}
	});
		
	$('#sMobile').mouseover(function() {
		if( $("#sMobile").val()=="Your Mobile" ){
			$("#sMobile").val("");
		}
	}).mouseout(function(){
		if( $("#sMobile").val()=="" ){
			$("#sMobile").val("Your Mobile");
		}
	});

	$('#sEmail').mouseover(function() {
		if( $("#sEmail").val()=="Your Email" ){
			$("#sEmail").val("");
		}
	}).mouseout(function(){
		if( $("#sEmail").val()=="" ){
			$("#sEmail").val("Your Email");
		}
	});

});




    
    
  		
  		
        
  		
	
  	





	

