﻿function powerSlider() {
    $("#section1a .btn-continua").click(function(){
        if((parseInt($("#section1a .got_no_pachets").val()) >= 0)&&($("#section1a .got_no_pachets").val())) {
            $(this).attr('href', '#section1b');
            $("#no_pachets_result").text(parseInt($("#section1a .got_no_pachets").val()));
            
            computeTotal();
	                
            $("#section1a .got_no_pachets").css('border', '2px solid #999');
        } else {
            $("#section1a .got_no_pachets").css('border', '2px solid #c00');
            alert("Numarul de licente suplimentare trebuie sa fie un numar natural");
            $(this).attr('href', '');
            return false;        
        }
    });
    function computeTotal() {
        support_option = $("#section1b input[name=ctl00$ContentPlaceHolder1$support_service][checked]");
        if(support_option.val() == "support_service_1") {
            support_sum = 0;
            
        }
        if(support_option.val() == "support_service_2") {
            support_sum = 209;
           
        }
        if(support_option.val() == "support_service_3") {
            support_sum = 299;
        }
        no_licences = $("#section1a .got_no_pachets").val();
        $("#the_nom_of_licences").html(parseInt(no_licences));
        if ($(".got_econ").attr("checked")) {
            total = parseInt(no_licences) * 65 + support_sum;
        } else {
            total = 99 + parseInt(no_licences) * 65 + support_sum;
        }
        $("#section1b p.final_price em").html(total);
	    
    }
    $("#section1a .got_no_pachets").keyup(function(){
	    no_licences = $(this).val();	    
	    if (no_licences > 0) {
	        $(this).val(parseInt(no_licences));
	    } else {
	        $(this).val(0);
	    }
	})
    $("#ctl00_ContentPlaceHolder1_btnSubmit2").click(function(){
        has_errors = 0;
        if (!$("#ctl00_ContentPlaceHolder1_txtNameLast").val()) {
            has_errors = 1;
            $("#ctl00_ContentPlaceHolder1_txtNameLast").css("border", "2px solid #c00");
            return false;
        }
        if (!$("#ctl00_ContentPlaceHolder1_txtNameFirst").val()) {
            has_errors = 1;
            $("#ctl00_ContentPlaceHolder1_txtNameFirst").css("border", "2px solid #c00");
            return false;
        }
        if (!$("#ctl00_ContentPlaceHolder1_txtPhone").val()) {
            has_errors = 1;
            $("#ctl00_ContentPlaceHolder1_txtPhone").css("border", "2px solid #c00");
            return false;
        }
        if (!$("#ctl00_ContentPlaceHolder1_txtEmail").val()) {
            has_errors = 1;
            $("#ctl00_ContentPlaceHolder1_txtEmail").css("border", "2px solid #c00");
            return false;
        }
        if (!$("#ctl00_ContentPlaceHolder1_allow_comunication").attr('checked')) {
            has_errors = 1;
            $(".confirm_date").css("border", "2px solid #c00");
            return false;
        }
        if (has_errors) {
            $("#section1c .error_pane").show().text("Completaţi toate câmpurile obligatorii.");
            return false;
        }
        
        return true;
    });
    
    //alert($('#slide_2 input:radio[name=ctl00$ContentPlaceHolder1$support_service]:checked').val());
	$("#section1b input[name=ctl00$ContentPlaceHolder1$support_service]").change(function() {
	    computeTotal();
	});
	$("#section1b input[name=ctl00$ContentPlaceHolder1$support_service]").click(function() {
	    computeTotal();
	});
	$(".lic_name").hide();
	$(".got_econ").change(function(){
	    if ($(this).attr('checked')) {
	        $(".lic_name").show();
	    } else {
	        $(".lic_name").hide();
	    }
	});
	$(".got_econ").click(function(){
	    if ($(this).attr('checked')) {
	        $(".lic_name").show();
	    } else {
	        $(".lic_name").hide();
	    }
	});
}

function goSlider() {
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'x';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#slider_container', // Could be a selector or a jQuery object too.
		queue:true,
		duration:1500
	});
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		target: '#slider_container', // could be a selector or a jQuery object too.
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});

}

// when the DOM is ready...
$(document).ready(function () {
//powerSlider();
$("#no_pachets_result").text($("#no_pachets").val());
$("#no_pachets").change(function(){
    $("#no_of_licenses").text($(this).val());
});
goSlider();
});