$(document).ready(function() {

//homepage URL


						   
/*	$('.open-close').toggle(function(){
      var $this = $(this);
      $this.prev().fadeIn();
      $this.text('Close')
	},
	function(){
      var $this = $(this);
      $this.prev().fadeOut();
      $this.text('Read More...')
	});*/
	
	$('.open-close').text('Read More...')
	
 //	$('.faq-1oc, .faq-2oc, .faq-3oc, .faq-4oc, .faq-5oc, .faq-6oc, .faq-7oc, .faq-8oc, .faq-9oc, .faq-10oc, .faq-11oc, .faq-12oc, .faq-13oc').toggle(function() {
 // 		$(".ellipses").fadeOut();
		
//	},
	
 	$('.faq-1oc').toggle(function() {
  		$(".faq-1").fadeIn();
		$(".ellipses1").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-1").fadeOut();
		$(".ellipses1").show();
		$(this).text('Read More...');
	});
	
	
	$('.faq-2oc').toggle(function() {
  		$(".faq-2").fadeIn();
		$(".ellipses2").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-2").fadeOut();
		$(".ellipses2").show();
		$(this).text('Read More...');
	});
	
	$('.faq-3oc').toggle(function() {
  		$(".faq-3").fadeIn();
		$(".ellipses3").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-3").fadeOut();
		$(".ellipses3").show();
		$(this).text('Read More...');
	});
	
	$('.faq-4oc').toggle(function() {
  		$(".faq-4").fadeIn();
		$(".ellipses4").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-4").fadeOut();
		$(this).text('Read More...');
		$(".ellipses4").show();
	});
	
	$('.faq-5oc').toggle(function() {
  		$(".faq-5").fadeIn();
		$(".ellipses5").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-5").fadeOut();
		$(this).text('Read More...');
		$(".ellipses5").show();
	});
	
	$('.faq-6oc').toggle(function() {
  		$(".faq-6").fadeIn();
		$(".ellipses6").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-6").fadeOut();
		$(this).text('Read More...');
		$(".ellipses6").show();
	});
	
	$('.faq-7oc').toggle(function() {
  		$(".faq-7").fadeIn();
		$(".ellipses7").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-7").fadeOut();
		$(this).text('Read More...');
		$(".ellipses7").show();
	});
	$('.faq-8oc').toggle(function() {
  		$(".faq-8").fadeIn();
		$(".ellipses8").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-8").fadeOut();
		$(this).text('Read More...');
		$(".ellipses8").show();
	});
	
	$('.faq-9oc').toggle(function() {
  		$(".faq-9").fadeIn();
		$(".ellipses9").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-9").fadeOut();
		$(this).text('Read More...');
		$(".ellipses9").show();
	});
	
	$('.faq-10oc').toggle(function() {
  		$(".faq-10").fadeIn();
		$(this).text('Close');
		$(".ellipses10").hide();
	}, 	
	function() {
  		$(".faq-10").fadeOut();
		$(this).text('Read More...');
		$(".ellipses10").show();
	});
	$('.faq-11oc').toggle(function() {
  		$(".faq-11").fadeIn();
		$(".ellipses11").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-11").fadeOut();
		$(this).text('Read More...');
		$(".ellipses11").show();
	});
	
	$('.faq-12oc').toggle(function() {
  		$(".faq-12").fadeIn();
		$(".ellipses12").hide();
		$(this).text('Close');
	}, 	
	function() {
  		$(".faq-12").fadeOut();
		$(".ellipses12").show();
		$(this).text('Read More...');
	});
	
	//Success Storeis
	
	var trans = 00;
	var dla = 00;
	
    $(".rm-adrian").click(function () {
	  
      $(".hilary,.brian,.mark,.more-stories").fadeOut(trans).delay(dla);
	  $(".adrian").delay(dla).fadeIn('slow');
	  
    });
	
	$(".rm-hilary").click(function () {
	  
      $(".adrian,.brian,.mark,.more-stories").fadeOut(trans).delay(dla);
	  $(".hilary").delay(dla).fadeIn('slow');
    });
	
	$(".rm-brian").click(function () {
	  
      $(".adrian,.hilary,.mark,.more-stories").fadeOut(trans).delay(dla);
	  $(".brian").delay(dla).fadeIn('slow');
    });
	
	$(".rm-mark").click(function () {
	  
      $(".adrian,.hilary,.brian,.more-stories").fadeOut(trans).delay(dla);
	  $(".mark").delay(dla).fadeIn('slow');
    });
	$(".rm-more-stories").click(function () {
	  
      $(".adrian,.hilary,.brian,.mark").fadeOut(trans).delay(dla);
	  $(".more-stories").delay(dla).fadeIn('slow');
    });
	

	//Products
	$(".pro-fm-agel").click(function () {
	  
      $(".r-default,.r-body,.r-core,.r-thrive").fadeOut(trans).delay(dla);
	  $(".l-default,.l-body,.l-core,.l-thrive").removeClass('pr-selected');
	  $(".r-agel,").delay(dla).fadeIn('slow');
	  $(".l-agel,").addClass('pr-selected');
	  
	 // $("div.first").slideUp(300).delay(800).fadeIn(400);
     // $("div.second").slideUp(300).fadeIn(400);

	  
    });
	$(".pro-fm-body").click(function () {
	  
      $(".r-default,.r-agel,.r-core,.r-thrive").fadeOut(trans).delay(dla);
	  $(".l-default,.l-agel,.l-core,.l-thrive").removeClass('pr-selected');
	  $(".r-body").delay(dla).fadeIn('slow');
	  $(".l-body").addClass('pr-selected');
	  
    });
	$(".pro-fm-core").click(function () {
	  
      $(".r-default,.r-body,.r-agel,.r-thrive").fadeOut(trans).delay(dla);
	  $(".l-default,.l-body,.l-agel,.l-thrive").removeClass('pr-selected');
	  $(".r-core").delay(dla).fadeIn('slow');
	  $(".l-core").addClass('pr-selected');
	  
    });
	$(".pro-fm-thrive").click(function () {
	  
      $(".r-default,.r-body,.r-core,.r-agel").fadeOut(trans).delay(dla);
	  $(".l-default,.l-body,.l-core,.l-agel").removeClass('pr-selected');
	  $(".r-thrive").delay(dla).fadeIn('slow');
	  $(".l-thrive").addClass('pr-selected');
	  
    });
	
	//$('.faqoc').toggle(function(){
     //  var $this = $(this);
     //     $this.siblings('.faq').fadeIn(); // this line depends on where .faq is in relation to .faqoc
    //      $this.text('Close')
   // },function(){
    //      var $this = $(this);
    //      $this.siblings('.faq').fadeOut(); // this line depends on where .faq is in relation to .faqoc
    //      $this.text('Read More...')
    //});
	
	
	//$()
	//<a href="/agel-tour.php">Find out more!</a>
	//<a href="/compensation.php">Find out more!</a>
	

	//Homepage Login
	//$('.gb-at, .gb-comp').addClass('empty-link');
	$('.gb-at, .gb-comp').html('<a href="#" class="destURL1">Find out more!</a>');
	$('.gb-at, .gb-comp').html('<a href="#" class="destURL2">Find out more!</a>');
	
/*	$(".empty-link").click(function () {
	  $("#fillout").fadeIn();
    });
*/	
	$("#fillout").click(function () {
	  $(this).fadeOut();
    });
	
	var COOKIE_NAME = 'IsRegisteredUser';
	var COOKIE_NAME_FORM = 'DestinationURL';
	var COOKIE_NAME_JOIN = 'Form';
	
	var options = { path: '/', expires: 90 };	
	
	if ($.cookie(COOKIE_NAME) == 'registered'){
		 $("#nav ul li.products, #nav ul li.agel-tour, #nav ul li.compensation").show();
		 $('.gb-at').html('<a href="/agel-system.php">Find out more!</a>');
		 $('.gb-comp').html('<a href="/compensation.php">Find out more!</a>');
		 $("#fillout, #join-btn, #join-us-btn2").remove();
		
	}
	
	if ($.cookie(COOKIE_NAME_JOIN) == 'fillout'){
		 $("#fillout").delay(200).fadeIn();
		
	}

	
	//


	$("#hm-submit-form").click(function () {
	  $.cookie(COOKIE_NAME, 'registered', options);
	  $.cookie(COOKIE_NAME_JOIN, '', options);
	  $("#nav ul li.products").delay(200).fadeIn();
	  $("#nav ul li.agel-tour").delay(600).fadeIn();
	  $("#nav ul li.compensation").delay(1000).fadeIn();
	  $('.gb-at').html('<a href="/agel-system.php">Find out more!</a>');
	  $('.gb-comp').html('<a href="/compensation.php">Find out more!</a>');
	  $('.gb-at, .gb-comp').removeClass('empty-link');
	  $("#fillout, #join-btn").remove();
	  
	  $("#thanks-box").delay(200).fadeIn();
	  $("#thanks-box").delay(1500).fadeOut();
	  
	  var destinationURL = $.cookie(COOKIE_NAME_FORM);
	  if (destinationURL != null){
		//$(location).attr('href',destinationURL);
		$("#redirect_ccdbdbd19c2724e754b4746e5b049eb3").val('http://www.buildingdynamicfutures.com' + destinationURL);
	  }
	  else {
		//$(location).attr('href','/agel-system.php');
		$("#redirect_ccdbdbd19c2724e754b4746e5b049eb3").val('http://www.buildingdynamicfutures.com/agel-system.php');
	  }	  
	  		
	  setTimeout(function(){
		$("#target").submit();
	  },1000);
	});
	
	
	
	
	
	$('#join-btn, #join-btn2, .why-tour-now').click(function() {
		$(location).attr('href','/index.php');
	});
	
	// Cookies
	// set cookie by number of days
	$('#join-btn').click(function() {
		$.cookie(COOKIE_NAME_JOIN, 'fillout', options);
		return false;
	});
	
	$('#join-btn2').click(function() {
		$.cookie(COOKIE_NAME_JOIN, 'fillout', options);
		return false;
	});
	
		$('.why-tour-now').click(function() {
		$.cookie(COOKIE_NAME_JOIN, 'fillout', options);
		return false;
	});
	
	
	

	// set cookie by number of days
	//$('#hm-submit-form').click(function() {
										
										
	//});
	
	
	$('.destURL1').click(function() {
		$.cookie(COOKIE_NAME_FORM, '/agel-system.php', options);
		$("#fillout").fadeIn();
		return false;
	});
	
	$('.destURL2').click(function() {
		$.cookie(COOKIE_NAME_FORM, '/compensation.php', options);
		$("#fillout").fadeIn();
		return false;
	});

	// get cookie
	$('#get_cookie').click(function() {
		alert($.cookie(COOKIE_NAME));
		return false;
	});

	// delete cookie
	$('#delete_cookie').click(function() {
		$.cookie(COOKIE_NAME, null, options);
		$.cookie(COOKIE_NAME_FORM, null, options);
		return false;
	});

	

   
 });


 function clickExplorer() {
						if( document.all ) {
							alert('All materials on this site are copyright protected.');
						}
						return false;
					}

					function clickOther(e) {
						if( document.layers || ( document.getElementById && !document.all ) ) {
							if ( e.which == 2 || e.which == 3 ) {
								alert('All materials on this site are copyright protected.');
								return false;
							}
						}
					}
					if( document.layers ) {
						document.captureEvents( Event.MOUSEDOWN );
						document.onmousedown=clickOther;
					}
					else {
						document.onmouseup = clickOther;
						document.oncontextmenu = clickExplorer;
					} 
 window.onload = function() { document.body.oncopy = function() { alert('All materials on this site are copyright protected.'); 
					 return false; } }  
						 if( typeof( document.onselectstart ) != 'undefined' )
							document.onselectstart = function(){ return false };
						 document.ondragstart = function(){ return false } 
