	$.validator.addMethod("acepto", function(value) {
		return value == "acepto";
	}, 'por favor introduzca "acepto"!');
	
	
	$(document).ready(function() {
    // hide js message
    $('#js_note').hide();
    //hide next buttons
    $('#goto_page2').hide();
    //slider init
    // $("#slider").easySlider({vertical: true});
    $(".ycodaslider").ycodaslider({
        arrows: false,
		navigator: false,
        height: 590,
        width: 570,
        scroll: true
    });
	//navigator: false,
    //facebox
	$('a[rel*=facebox]').facebox();
	$.facebox.settings.opacity = 0.75;
	
	
	//buttons
    //start
	
	
    $("#start").click(function() {
        jQuery(".ycodaslider").ycodaslider("go", 1);
		activatenumber("one");
        //start from 0
        return false;
    });
	$("#gobackto_page1").click(function() {
        jQuery(".ycodaslider").ycodaslider("go", 0);
		$("#one").removeClass("oneactive");
        //start from 0
        return false;
    });
	$("#gobackto_page2").click(function() {
        jQuery(".ycodaslider").ycodaslider("go", 1);
		activatenumber("one");
        //start from 0
        return false;
    });
	$("#gobackto_page3").click(function() {
        jQuery(".ycodaslider").ycodaslider("go", 2);
		activatenumber("two");
        //start from 0
        return false;
    });
    //goto page 2
    $("#goto_page2").click(function() {
        jQuery(".ycodaslider").ycodaslider("go", 2);
		activatenumber("two");
        //start from 0
        return false;
		
    });
    //goto page 3
    $("#goto_page3").click(function() {
        var ok = true;
        //check if the fields are empty
        if ($("#financial").val() == "") {
            $("#error_financial").removeClass("hide");
            ok = false;
        } else {
            $("#error_financial").addClass("hide");
        }
        if ($("#why_study").val() == "") {
            $("#error_why_study").removeClass("hide");
            ok = false;
        } else {
            $("#error_why_study").addClass("hide");
        }
        if ($("#reason").val() == "") {

            $("#error_reason").removeClass("hide");
            ok = false;

        } else {
            $("#error_reason").addClass("hide");
        }

        if (ok == true) {
			activatenumber("three");
            jQuery(".ycodaslider").ycodaslider("go", 3);
            return false;
        } else {
            return false;
        }
    });

    //display locations
	$("#course").change(function() {
	        showform($("#course").val());
	}
		);
    $("#liveaudio").click(function() {
        showform("liveaudio");
    }
    );
	$("#music_business").click(function() {
        showform("music_business");
    }
    );   
    $("#ae").click(function() {
        showform("ae");
    }
    );
	$("#audiodegree").click(function() {
        showform("audiodegree");
    }
    );
    $("#film").click(function() {
        showform("film");
    }
    );    
    $("#filmdegree").click(function() {
        showform("filmdegree");
    }
    );

    //display page 2
    $("#locationselectors select").change(
    function() {
        shownext("2");
    });


    //radio button behaviour
    function showform(elementid) {
        //hide all
        $("#locationselectors fieldset").hide();
        //reset selections of locations
        $("#locationselectors select")[0].selectedIndex = 0;
        $("#locationselectors select")[1].selectedIndex = 0;
        $("#locationselectors select")[2].selectedIndex = 0;
        $("#locationselectors select")[3].selectedIndex = 0;
        $("#locationselectors select")[4].selectedIndex = 0;
        $("#locationselectors select")[5].selectedIndex = 0;

        //make sure the next button gets disabled
        $("#goto_page2").hide();
        //open new
        $("#fs_" + elementid).slideDown();
    }
    //select box behaviour
    function shownext(page) {
        $('#goto_page' + page).show();

    }
	//add default states
	$("#one").addClass("oneinactive");
	$("#two").addClass("twoinactive");
	$("#three").addClass("threeinactive");
	function activatenumber(number) {
		$("#one").removeClass("oneactive");
		$("#two").removeClass("twoactive");
		$("#three").removeClass("threeactive");
		//activate
		$("#"+number).addClass(number+"active");
		}
    //prevent tabbing (breaks form)
    $('.preventTab').preventTab();

//form validation

$("#applicationform").validate({
		messages: {
			firstname: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			lastname: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			sex: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			age: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			address1: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			address2: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			address3: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},			
			city: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			postcode: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			country: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			email: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			phone: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},			
			how_did_you_hear: {
				required: '<img src="images/arrow_red.png"> Este campo es obligatorio.'
			},
			acepto: {
				required: '<img src="images/arrow_red.png"> Tienes que leer y aceptar las Condiciones Generales.'
			}
		},
		rules: {
				acepto: 'acepto'
		}
	});

//ticker
/*
  $("#jobs").marquee({
					 
				         yScroll: "top"                          // the position of the marquee initially scroll (can be  
                                                 // either "top" or "bottom") 
       , showSpeed: 200                          // the speed of to animate the initial dropdown of the messages 
       , scrollSpeed: 7                         // the speed of the scrolling (keep number low) 
       , pauseSpeed: 1000                        // the time to wait before showing the next message or  
                                                 // scrolling current message 
       , pauseOnHover: false                      // determine if we should pause on mouse hover 
       , loop: -1                                // determine how many times to loop through the marquees  
                                                 // (#'s < 0 = infinite) 
     
 			 
					 
					 }); */
});
