$(document).ready(function(){    
    
// http and https check
	// get the protocol
	var strProtocol = jQuery.url.attr("protocol") // returns 'http'
	// Get First Directory
    var strDir = jQuery.url.segment(0)	
    // get the path
	var strPath = jQuery.url.attr("path") // returns '/information/about/index.html'
	// get the host
	var strHost = jQuery.url.attr("host") // returns 'mysite.com'

	if ((strDir == "registration") && (strProtocol == "http")){
		strProtocol = "https";
		window.location = strProtocol +"://mdc2010.worldsecuresystems.com"+ strPath;
	}

	if ((strDir != "registration") && (strProtocol == "https")){
		strProtocol = "http";
		window.location = strProtocol +"://mdc2010.com"+ strPath;		
	} 
    
// Navigation - Superfish
	  jQuery('#main-nav ul').superfish({
	  
				delay:       1000,                            // one second delay on mouseout 
				animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
				speed:       'fast',                          // faster animation speed 
				autoArrows:  false,                           // disable generation of arrow mark-up 
				dropShadows: false                            // disable drop shadows 
				});			
	
// Form tab navigation    
    	$("#step1 .step-nav .next").click(function () {
        	$("#step1").hide();
            $("#step2").show();
            return false;
        });
    	$("#step2 .step-nav .next").click(function () {
        	$("#step2").hide();
            $("#step3").show();
            return false;
        });
    	$("#step2 .step-nav .prev").click(function () {
        	$("#step2").hide();
            $("#step1").show();
            return false;
        });
    	$("#step3 .step-nav .next").click(function () {
        	$("#step3").hide();
            $("#step4").show();
            return false;
        });
    	$("#step3 .step-nav .prev").click(function () {
        	$("#step3").hide();
            $("#step2").show();
            return false;
        });
    	$("#step4 .step-nav .prev").click(function () {
        	$("#step4").hide();
            $("#step3").show();
            return false;
        });
    	$("#step4 .step-nav .next").click(function () {
        	$("#step4").hide();
            $("#step5").show();
            return false;
        });
    	$("#step5 .step-nav .prev").click(function () {
        	$("#step5").hide();
            $("#step4").show();
            return false;
        });
    	$("#step5 .step-nav .next").click(function () {
        	$("#step5").hide();
            $("#step6").show();
            return false;
        });

    	$("#step6 .step-nav .prev").click(function () {
        	$("#step6").hide();
            $("#step5").show();
            return false;
        });        


// Accompanying Person Selector Redirect

// get your select element and listen for a change event on it
$('#CAT_Custom_95954').change(function() {
  if ($('#CAT_Custom_95954').val() == "Accompanying Person"){
  // set the window's location property to the value of the option the user has selected
  window.location = "https://mdc2010.worldsecuresystems.com/registration/accompanying-person-form";
  }
});



//



	$("#accompanying-person").change(function() 
	    { 
        	var message_index;
 
        	message_index = $("#accompanying-person").val(); 
        	if (message_index == "Yes") 
            	$("#accompanying-person-details").show();
            else
            	$("#accompanying-person-details").hide();
    	}); 
    
       	
		$("#registered-person .step-nav a").click(function(){ 
// Set Conference Price
			var conference_price = 0;
			var conference_name = 'No Conference Selected'

            conference_price = $("#CAT_Custom_95954")[0].selectedIndex;
            switch (conference_price)
            {
            case 1:
              conference_price = 850;
              conference_name = 'Member mint delegate';
              break;
            case 2:
              conference_price = 950;
              conference_name = 'Observer mint delegate';              
              break;
            case 3:
              conference_price = 2000;
              conference_name = 'Industrial observers';              
              break;
            case 4:
               window.location = "https://mdc2010.worldsecuresystems.com/registration/accompanying-person-form";
              break;
            default:
              conference_price = 0;
            }


			var strPath = jQuery.url.attr("path") // returns '/information/about/index.html'
			if( strPath == '/registration/che-test-1' ){
        		conference_price = 0.01;
        	}

// Conference Activities    
		$("#CAT_Custom_95112_0").click(function() 
	    { 
        	if($("#CAT_Custom_95112_0").is(':checked')){
            	$("#handicap").show();
            }else{
            	$("#handicap").hide();	
                $("#CAT_Custom_95113").val(" ");
            }               
    	});     

		$("#CAT_Custom_95112_1").click(function() 
	    { 			
        	if($("#CAT_Custom_95112_1").is(':checked')){
            	$("#ballooning").show();
            }else{
            	$("#ballooning").hide();
            }
    	});  
        
        
        

            	

		$("#CAT_Custom_94926").change(function() 
	    { 
        	var message_index; 
 
        	message_index = $("#CAT_Custom_94926").val(); 
        	if (message_index.indexOf("Yes") != -1){ 
            	$("#post-conference").show();
            }else{
            	$("#post-conference").hide();
                $("#CAT_Custom_94928_0").attr('checked', false);
                $("#CAT_Custom_94928_1").attr('checked', false);                
            }
    	});   


// Conference Activities
			var conference_activities = 0;
      	if ($('#CAT_Custom_95112_0').is(':checked')){
        	conference_activities = 250;
        }

// Set Post Conference Price
			var post_conference_price = 0;      
      	post_conference_price = $("#CAT_Custom_94926")[0].selectedIndex;
        switch(post_conference_price)
        {
        	case 1:
          	post_conference_price = 1350;
            break;
          case 2:
            post_conference_price = 0;
            break;
          default:
            post_conference_price = 0;
        }
            
// Total Conference Price			
      var conference_total = 0;
      conference_total = conference_price + post_conference_price + conference_activities;

			var strPath = jQuery.url.attr("path") // returns '/information/about/index.html'
			if( strPath == '/registration/che-test-1' ){
        		conference_total = 0.01;
        	}                        
            
// Display Conference Price and Options
			var strInvoice = "";
            $("#conference-name").html(conference_name);	
    		strInvoice += conference_name +" - ";
            $("#conference-price").html("$" + conference_price);
    		strInvoice += "$"+ conference_price +"<br />";
//			$("#conference-activites").html("$" + conference_activities);
			if($("#CAT_Custom_95112_0").is(':checked')){           
            	$("#golf-day-total").show();
                $("#activities-total").show();
	    		strInvoice += "Optional Golf Day - $250<br />";
            }
			if($("#CAT_Custom_95112_1").is(':checked')){           
            	$("#ballooning-total").show();
                $("#activities-total").show();
                strInvoice += "Optional Hot Air Ballooning - Payment via Dawn Drifters<br />";
            }
//			$("#post-conference-options").html("$" + post_conference_price);
			if($("#CAT_Custom_94928_0").is(':checked')){           
            	$("#mossman-gorge-total").hide();
                $("#sky-rail-total").show();
                $("#post-total").show();
                strInvoice += "Skyrail & Kuranda Village and Railway Sightseeing - $1350";
            }
			if($("#CAT_Custom_94928_1").is(':checked')){           
                $("#sky-rail-total").hide();            
            	$("#mossman-gorge-total").show();
                $("#post-total").show();
                strInvoice += "Mossman Gorge & Daintree Rainforest - $1350";                
            }
			$("#conference-total").html("$" + conference_total);
            
            
            
            
            			
			$("#Amount").val(conference_total);
            $("#DisplayAmount").html("$" + conference_total);	
            
            $("input[name=ShippingInstructions]").val(strInvoice);
        });
            
$("#registered-person .step-nav a.submit").click(function(){

		location.href = "/registration/accompanying-person";
		
        });


///////////////////////////////////////////////////////////////////
            

$("#accompanying-person .step-nav a").click(function(){

        var conference_price = 700;

		var strPath = jQuery.url.attr("path") // returns '/information/about/index.html'
		if( strPath == '/registration/che-test' ){
        	conference_price = 0.01;
        }

		$("#CAT_Custom_96376_0").click(function() 
	    { 
        	if($("#CAT_Custom_96376_0").is(':checked')){
            	$("#handicap").show();
            }else{
            	$("#handicap").hide();	
                $("#CAT_Custom_96377").val(" ");
            }
                
    	});     

		$("#CAT_Custom_96376_1").click(function() 
	    { 			
        	if($("#CAT_Custom_96376_1").is(':checked')){
            	$("#ballooning").show();
            }else{
            	$("#ballooning").hide();
            }
    	});          



		$("#CAT_Custom_96372").change(function() 
	    { 
        	var message_index; 
 
        	message_index = $("#CAT_Custom_96372").val(); 
        	if (message_index.indexOf("Yes") != -1) 
            	$("#post-conference").show();
            else
            	$("#post-conference").hide();
                $("#CAT_Custom_96373_0").attr('checked', false);
                $("#CAT_Custom_96373_1").attr('checked', false);                   
    	}); 


			var conference_activities = 0;
            if ($('#CAT_Custom_96376_0').is(':checked')){
            	conference_activities = 250;
          
            }

            var post_conference_price = $("#CAT_Custom_96372")[0].selectedIndex;
            switch(post_conference_price)
            {
            case 1:
              post_conference_price = 1350;
              break;
            case 2:
              post_conference_price = 0;
              break;
            default:
              post_conference_price = 0;
            }

// Total Conference Price
			var conference_total = 0;
            
            conference_total = conference_price + post_conference_price + conference_activities;


// Display Conference Price and Options

			var strInvoice = "";
            strInvoice += "Accompanying Person - $"+ conference_price +"<br />";
			$("#conference-price").html("$" + conference_price);
//			$("#conference-activites").html("$" + conference_activities);
			if($("#CAT_Custom_96376_0").is(':checked')){           
            	$("#golf-day-total").show();
                $("#activities-total").show();
                strInvoice += "Optional Golf Day - $250<br />";
            }
			if($("#CAT_Custom_96376_1").is(':checked')){           
            	$("#ballooning-total").show();
                $("#activities-total").show();
                strInvoice += "Optional Hot Air Ballooning - Payment via Dawn Drifters<br />";                
            }            
//			$("#post-conference-options").html("$" + post_conference_price);
			if($("#CAT_Custom_96373_0").is(':checked')){           
            	$("#mossman-gorge-total").hide();
            	$("#sky-rail-total").show();
                $("#post-total").show();
                strInvoice += "Skyrail & Kuranda Village and Railway Sightseeing - $1350";
            }
			if($("#CAT_Custom_96373_1").is(':checked')){           
            	$("#sky-rail-total").hide();            
            	$("#mossman-gorge-total").show();
                $("#post-total").show();
                strInvoice += "Mossman Gorge & Daintree Rainforest - $1350";
            }
			$("#conference-total").html("$" + conference_total);			
			$("#Amount").val(conference_total);
            $("#DisplayAmount").html("$" + conference_total);			

			 $("input[name=ShippingInstructions]").val(strInvoice);
		});



$("#accompanying-person .step-nav a.submit").click(function(){
			location.href = "/registration/thank-you";
		});
    
	});
