	$(document).ready(function() {
	
		$.extend({
  			getUrlVars: function(){
   			var vars = [], hash;
    		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
   			for(var i = 0; i < hashes.length; i++)
    		{
      			hash = hashes[i].split('=');
      			vars.push(hash[0]);
      			vars[hash[0]] = hash[1];
    		}
    		return vars;
  			},
  			getUrlVar: function(name){
    		return $.getUrlVars()[name];
  			}
		});
		
		var pagecalled = $.getUrlVar('t');
		
		//Bring up inital content
		$('#'+pagecalled).fadeIn('slow');
		
		//Navigation
		$(".nav").mouseover(function() {
			
			var currentId = $(this).attr('id');
			
			if ($(this).hasClass(currentId+'_nonactive')){
			
			$('#'+currentId).addClass('hover').removeClass(currentId+'_nonactive').addClass(currentId+'_active');
			
			}
			
			});
		
		$(".nav").mouseout(function() {
		
			var currentId = $(this).attr('id');
			
			if ($(this).hasClass('hover')){
		
			$('#'+currentId).removeClass(currentId+'_active').addClass(currentId+'_nonactive').removeClass('hover');
			
			}
			
			});
			
		
		$(".navcontent").click(function(){
	
	
			//Navigation button states
			
			$('.nav').each(function(index) {
				var currentId = $(this).attr('id');
	
				if ($(this).hasClass('active')){
	 					
	 				$('#'+currentId).removeClass('active').removeClass(currentId+'_active').addClass(currentId+'_nonactive');
				}

  				});

			var currentId = $(this).attr('id');

			if ($(this).hasClass('hover')){
	
				$('#'+currentId).addClass(currentId+'_active').removeClass('hover').addClass('active');
			}
			
			//Fadein and out respective content
			
			$('.content').fadeOut('slow');
			
			var content = $(this).attr('rel');
       
        	switch(content)
       		{
       		
       			case 'home':
     			window.location='/';
	            break;
	            
       			case 'pastlife':
				$('#pastlife').fadeIn('slow');
				break;
	            
	            case 'love':
				$('#love').fadeIn('slow',function(){
				
				//Reset Sliding images
				$("#slider").easySlider({
				auto: true, 
				continuous: true,
				prevText: '',
				nextText: '',
				pause: 4000
				});
				
				});
				break;
	           
	            case 'numerology':
				$('#numerology').fadeIn('slow');
				break;
	           
	           	case 'chinese':
				$('#chinese').fadeIn('slow');
				break;
	            
	            case 'tarot':
				$('#tarot').fadeIn('slow');
				break;
	            
	            case 'vedic':
				$('#vedic').fadeIn('slow');
				break;
	            
	            default:
	            break;
        	}
        	

			});
			
			
		//Index NavBar content
			$(".navindex").click(function(){
	
			var content = $(this).attr('rel');
			
			switch(content)
       		{
       		
       			case 'pastlife':
       			window.location='/?p=astro&t=pastlife';
	            break;
	            
	            case 'love':
       			window.location='/?p=astro&t=love';
	            break;
	           
	            case 'numerology':
       			window.location='/?p=astro&t=numerology';
	            break;
	           
	           	case 'chinese':
       			window.location='/?p=astro&t=chinese';
	            break;
	            
	            case 'tarot':
       			window.location='/?p=astro&t=tarot';
	            break;
	            
	            case 'vedic':
       			window.location='/?p=astro&t=vedic';
	            break;
	            
	            default:
	            break;
        	}
			
			});
			
			//Popup box
			$('.popup-terms').colorbox({transition:'elastic', speed:200, iframe:false,initialWidth:100,initialHeight:100,scrolling:false,preloading:false,slideshow:false,inline:false, href:"/views/content.terms.php"});
			$('.onhold').colorbox({transition:'elastic', speed:200, iframe:false,initialWidth:100,initialHeight:100,scrolling:false,preloading:false,slideshow:false,inline:true, href:".formholder"});
			
			//Sliding images
			$("#slider").easySlider({
				auto: true, 
				continuous: true,
				prevText: '',
				nextText: '',
				pause: 4000
			});
			
			//Columns
			$(".newspaper").columnize({columns: 2, balance: false});
			
			
			
			  

	// afm2_astro_form validate rules	
	//$("#afm1_astro_form").submit(function(event) {afm1_astro_form.submit();});
	
	$("#afm1_astro_form").validate({
	  rules: {
		email: {

		  required: true,
		  email: true/**/,
		  remote: {
			url: "http.php",
			type: "post",
			async: false,
			data: {
			  email: function() {
				return $("#afm1_email").val();
			  },
			  todo:'Atollcheckmail',
			  checkEmailDBExists:function() {
				return $("#afm1_checkEmailDBExists").val();
			  }
			}
		  }
		}/**/,
		email_again: {
		  equalTo: "#afm1_email"
		}
	  },
	  
	  messages: {
		 approval: "",
		 email: {
		   required : "",
		   email: "",
		   remote: ""
		 }/**/,
		 email_again: ""
	   }
	});
	
	
	
	// afm2_astro_form validate rules
	$("#afm2_astro_form").validate({
	  rules: {
		email: {

		  required: true,
		  email: true/**/,
		  remote: {
			url: "http.php",
			type: "post",
			async: false,
			data: {
			  email: function() {
				return $("#afm2_email").val();
			  },
			  todo:'Atollcheckmail',
			  checkEmailDBExists:function() {
				return $("#afm2_checkEmailDBExists").val();
			  }
			}
		  }
		}/*,
		email_again: {
		  equalTo: "#afm2_email"
		}*/
	  },
	  
	  messages: {
		 approval: "",
		 email: {
		   required : "",
		   email: "",
		   remote: ""
		 }/* ,
		email_again: ""*/
	   }
	});
        /*Video menu*/
        var src="";
        $(".monthlyhoroscope-video").hover(function() {
            src = $(this).attr("src");
             $(this).attr("src","../images/portal/video_play.png");
			}, function() {
		 	$(this).attr("src", src);
		});
		
		$("a[rel^='monthlyvideo']").prettyPhoto({social_tools:'',show_title: false,deeplinking: false,callback: function(){window.location.hash ="";}});

	});
