
jQuery.cookie=function(name,value,options){
if(typeof value !='undefined'){
options=options ||{}
if(value===null){
value=''
options=$.extend({},options)
options.expires=-1}
var expires=''
if(options.expires&&(typeof options.expires=='number' || options.expires.toUTCString)){
var date
if(typeof options.expires=='number'){
date=new Date()
date.setTime(date.getTime()+(options.expires*24*60*60*1000))
}else{
date=options.expires}
expires='; expires='+date.toUTCString()}
var path=options.path ? '; path='+(options.path): ''
var domain=options.domain ? '; domain='+(options.domain): ''
var secure=options.secure ? '; secure' : ''
document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')
}else{
var cookieValue=null
if(document.cookie&&document.cookie !=''){
var cookies=document.cookie.split(';')
for(var i=0;i<cookies.length;i++){
var cookie=jQuery.trim(cookies[i])
if(cookie.substring(0,name.length+1)==(name+'=')){
cookieValue=decodeURIComponent(cookie.substring(name.length+1))
break}}}
return cookieValue}}
// JavaScript Document
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
			});
	$("#backgroundPopup").fadeIn("slow");	
	$("#loading").show();
	$("#popUp").load("step3.php", function(){
						/* 
						Setup CSS for Safari bug which doesn't adhere new CSS file
						*/
						var d = document;
						var dHead = d.getElementsByTagName('head')[0];
						var newStyle = d.createElement('link');
						newStyle.setAttribute('rel','stylesheet');
						newStyle.setAttribute('type','text/css');
						newStyle.setAttribute('media','screen,projection');
						newStyle.setAttribute('href','/css/step2.css');
						dHead.appendChild(newStyle); 
					
						<!-- fade in the new div-->

						  $("#popUp").fadeIn("slow");
						 });


		popupStatus = 1;
		$("#loading").hide();
	}
}
//disabling popup with jQuery magic!
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popUp").fadeOut("slow");
popupStatus = 0;
}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popUp").height();
	var popupWidth = $("#popUp").width();
	//centering
	$("#popUp").css({
	"position": "absolute",
	"top": windowHeight/2-popupHeight/2,
	"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});

}
<!-- when the page loads...->
$(document).ready(function(){
			//initialize the first selected tab
			$("#navigation ul #tab1 a").addClass("selected");
			//hide the sub-nav for start
			$("#sub-nav").hide();
			
			//setup the tab click functions
			//TAB 1
			$("#navigation ul #tab1").click(function()
				{
					//add the selected tab
					$("#navigation ul #tab1 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #tab2 a").removeClass("selected");
					$("#navigation ul #tab3 a").removeClass("selected");
					$("#navigation ul #tab4 a").removeClass("selected");
					$("#navigation ul #tab5 a").removeClass("selected");
					
					//hide sub-nav : no need for it
					$("#sub-nav").hide();
					
					//reposition the column-r image
					$("#content-r").css("margin-top","40px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./index.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			
			//TAB 2
			$("#navigation ul #tab2").click(function()
				{
					//add the selected tab
					$("#navigation ul #tab2 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #tab1 a").removeClass("selected");
					$("#navigation ul #tab3 a").removeClass("selected");
					$("#navigation ul #tab4 a").removeClass("selected");
					$("#navigation ul #tab5 a").removeClass("selected");
					
					//fade in sub-nav
					$("#sub-nav").fadeIn("slow");
					
					//reposition the column-r image
					$("#content-r").css("margin-top","0px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./plans.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			
			//TAB 3
			$("#navigation ul #tab3").click(function()
				{
					//add the selected tab
					$("#navigation ul #tab3 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #tab1 a").removeClass("selected");
					$("#navigation ul #tab2 a").removeClass("selected");
					$("#navigation ul #tab4 a").removeClass("selected");
					$("#navigation ul #tab5 a").removeClass("selected");
					
					//hide sub-nav : no need for it
					$("#sub-nav").hide();
					
					//reposition the column-r image
					$("#content-r").css("margin-top","40px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./faq.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			
			//TAB 4
			$("#navigation ul #tab4").click(function()
				{
					//add the selected tab
					$("#navigation ul #tab4 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #tab1 a").removeClass("selected");
					$("#navigation ul #tab2 a").removeClass("selected");
					$("#navigation ul #tab3 a").removeClass("selected");
					$("#navigation ul #tab5 a").removeClass("selected");
					
					//hide sub-nav : no need for it
					$("#sub-nav").hide();
					
					//reposition the column-r image
					$("#content-r").css("margin-top","40px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./studies.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			

			/** Sub Navigation **/
			
			//setup the sub-tab click functions
			//Sub TAB 1
			$("#sub-nav ul #sub1").click(function()
				{
					/*add the selected tab
					$("#navigation ul #sub1 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #sub2 a").removeClass("selected");
					$("#navigation ul #sub3 a").removeClass("selected");
					$("#navigation ul #sub4 a").removeClass("selected");
					$("#navigation ul #sub5 a").removeClass("selected");
					
					//hide sub-nav : no need for it
					$("#sub-nav").hide();*/
					
					//reposition the column-r image
					//$("#content-r").css("margin-top","40px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./plans.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			
			//Sub TAB 2
			$("#sub-nav ul #sub2").click(function()
				{
					/*add the selected tab
					$("#navigation ul #sub1 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #sub2 a").removeClass("selected");
					$("#navigation ul #sub3 a").removeClass("selected");
					$("#navigation ul #sub4 a").removeClass("selected");
					$("#navigation ul #sub5 a").removeClass("selected");
					
					//hide sub-nav : no need for it
					$("#sub-nav").hide();*/
					
					//reposition the column-r image
					//$("#content-r").css("margin-top","40px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./healthcareMediation.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			
			//Sub TAB 3
			$("#sub-nav ul #sub3").click(function()
				{
					/*add the selected tab
					$("#navigation ul #sub1 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #sub2 a").removeClass("selected");
					$("#navigation ul #sub3 a").removeClass("selected");
					$("#navigation ul #sub4 a").removeClass("selected");
					$("#navigation ul #sub5 a").removeClass("selected");
					
					//hide sub-nav : no need for it
					$("#sub-nav").hide();*/
					
					//reposition the column-r image
					//$("#content-r").css("margin-top","40px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./dentalCare.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			
			//Sub TAB 4
			$("#sub-nav ul #sub4").click(function()
				{
					/*add the selected tab
					$("#navigation ul #sub1 a").addClass("selected");
					//remove it from everythinge else
					$("#navigation ul #sub2 a").removeClass("selected");
					$("#navigation ul #sub3 a").removeClass("selected");
					$("#navigation ul #sub4 a").removeClass("selected");
					$("#navigation ul #sub5 a").removeClass("selected");
					
					//hide sub-nav : no need for it
					$("#sub-nav").hide();*/
					
					//reposition the column-r image
					//$("#content-r").css("margin-top","40px");
					
					//load the specific content
					$("#content-l").empty();
					$("#content-l").hide();
					$("#content-l").load("./prescriptionDrugs.html #content-l:first", function(){
						$("#content-l").show();
					});
					return false;
				});
			
			
			
	/** Sign Up Form **/		
	//If the submit button is clicked...
	$("#submit-btn").click(function()
	{
		var fname = $("input#fname").val();
		var lname = $("input#lname").val();
		var email = $("input#email").val();
  		var cemail = $("input#emailconfirm").val();
  		var postal = $("input#postal").val();
	   var country=$("input#country").val();
	   /*
  		if (fname == "")
		{
        	$("label#errFname").show();
			$("input#fname").css('background-color', '#d7e3ba');
			$("input#fname").css('border', '1px solid #8dab4a');
        	$("input#fname").focus();
       		return false;
     	}		
		$("label#errFname").hide();		
  		if (lname == "")
		{
        	$("label#errLname").show();
			$("input#lname").css('background-color', '#d7e3ba');
			$("input#lname").css('border', '1px solid #8dab4a');
        	$("input#lname").focus();
       		return false;
     	}
		$("label#errLname").hide();
		var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i;  		
  		if (email == "" || !(re.test(email))) 
		{
			$("label#errEmail").show();
			$("input#email").css('background-color', '#d7e3ba');
			$("input#email").css('border', '1px solid #8dab4a');
			$("input#email").focus();
			return false;
        }

		$("label#errEmail").hide();		
  		if (cemail == "" || cemail != email || !(re.test(cemail))) 
		{
			$("label#errCEmail").show();
			$("input#emailconfirm").css('background-color', '#d7e3ba');
			$("input#emailconfirm").css('border', '1px solid #8dab4a');
			$("input#emailconfirm").focus();
			return false;
        }
		$("label#errCEmail").hide();
  		if (postal == "" || isNaN(postal))
		{
			$("label#errPostal").show();
			$("input#errPostal").css('background-color', '#d7e3ba');
			$("input#errPostal").css('border', '1px solid #8dab4a');
			$("input#postal").focus();
			return false;
       }
	   */
	  
	  $.cookie('fn', fname);
	  $.cookie('ln', lname);
	  $.cookie('em', email);	
	  $.cookie('po', postal);
	  $.cookie('cn', country);

	  //start the AJAX process
	  var dataString = 'fn='+ fname + '&ln' + lname + '&em=' + email + '&po=' + postal + '&co' + country;
	  //alert (dataString);return false;
	  $("#loading").show();

	  /*
	  $.ajax({
      type: "POST",
      url: "scripts/signup.php",
      data: dataString,
      success: function() {
			//centering with css
			centerPopup();
			//load popup
			loadPopup();
			}
		});	

		*/

			centerPopup();
			//load popup
			loadPopup();

  	 // $("#loading").hide();
	  return false;
	  $("#loading").hide();

	
	});
	
	
	$("#backgroundPopup").click(function()
		{
		//disable the pop-up and return the user to the main page
		disablePopup()
		});

	$("#retun-btn").click(function()
		{
		//disable the pop-up and return the user to the main page
		disablePopup()
		});


			
});
