(function($){
arranque = function() {
    $('.curvy').corners();
	
	/* EASY SLIDER */
	
	$("#slider").easySlider({
				auto: true,
				continuous: true, 
			});
	$("#registo_edb").validate({
		rules: {
			nome: "required",
			apelido: "required",
			mail: "required",
			morada: "required",
			movel: "required",
			user: "required",
			password: {
				required: true,
				minlength: 5
			},
			confpass: {
				required: true,
				minlength: 5,
				equalTo: "#password"
			},
			username: {
				required: true,
				minlength: 2
			},
			email: {
				required: true,
				email: true
			},
		},
		messages: {
			email: {
				email: "<br />Por favor introduza um e-mail v&aacute;lido",
			}
			}
	});
	$("#user").blur(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('A verificar...').fadeIn("slow");
		//check the username exists or not from ajax
		$.post("../checkuser.php",{ username:$(this).val() } ,function(data)
        {
		  if(data=='no') //if username not avaiable
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Nome de utilizador j&aacute; existente').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
		  else
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Nome de utilizador dispon&iacute;vel').addClass('messageboxok').fadeTo(900,1);	
			});
		  }
		});
	});
			};
})(jQuery);
		
		
	/* CUFÓN */
	
	function trocaTextos() {
	Cufon.replace('h1', {fontFamily: 'AllerDisplay', textShadow: '1px 1px rgba(0,0,0,0.2)', color: '-linear-gradient(white, grey)'});
	Cufon.replace('h3', {fontFamily: 'Omnes-LightItalic'});
	Cufon.replace('h4', {fontFamily: 'AllerDisplay', textShadow: '1px 1px rgba(0,0,0,0.2)'});
	Cufon.replace('h5', {fontFamily: 'AllerDisplay', textShadow: '1px 1px rgba(0,0,0,0.2)'});
	Cufon.replace('h6', {fontFamily: 'AllerDisplay', textShadow: '1px 1px rgba(0,0,0,0.2)', color: '-linear-gradient(white, grey)'});
	}
	
	/* JANELA MODAL */
	
jQuery(function ($) {
	$('.basic').click(function (e) {
		//var src = "http://www.escoladebolsa.com/sala/login.aspx?ReturnUrl=/sala/saladeaula.aspx";
		var src = "http://www.escoladebolsa.com/sala/login.aspx?ReturnUrl=%2fsala%2fsaladeaula.aspx";
		$.modal('<iframe src="' + src + '" height="350" width="550" style="border:0; overflow:hidden;">', {
		onShow: function (d) {
		d.wrap.css('overflow','hidden');
		var el = $('h1.cufon', d.data);
		Cufon.replace(el);
		},
		closeHTML:"",
		containerCss:{
		backgroundColor:"#fff",
		borderColor:"#fff",
		height:350,
		padding:0,
		width:550
	},
		overlayClose: true,
		});
		  return false;
	});
});
