// JavaScript Document

$().ready(function() {
						   
	$('#rightbanner').myposition();					   
	// Collapse everything but the first menu:
	
	mytoggleslide = function (v){
		//$(v).slideToggle("fast");
		$(v).find("+ ul").slideToggle("fast");
		return false;
	}
	
	myhidemenu = function(v){
	
	$(v).each(
			function(){
				$(this).find("ul").slideToggle("fast");
				
				/*$(this).click(function(){
						mytoggleslide(v + ' > a');
					}
				);*/
				myhidemenu(v + ' > li');
				}
			);
	}
	
	myhidemenu("#menuright > li");
	
	

	/*
	$("#menuright li  ")
		.each(function(){
					$(this).click(function(){
									//alert('qui');
									if($(this).attr('href')=='#'){
										$(this).find("ul").slideToggle("fast");
										return false;
										//alert('qui');
									}else{
										return true;
									}
								}
								);
						}
				);

*/
	/*
	$("#menuright > li > a").children().click(function() {
		$(this).find("+ ul").slideToggle("fast");
	});	
*/
	/*
	$("#menuright > li > a, #menuright > li > ul > li> a, #menuright > li > ul > li> ul > li> a ").find("+ ul").slideUp(1);	
*/	// Expand or collapse:
	$("#menuright > li > a, #menuright > li > ul > li> a, #menuright > li > ul > li> ul > li> a").click(function() {
		$(this).find(" + ul").slideToggle("fast");
	});
	
	myValidateform = function(nameform){
		var containererror = $('div#msgerror');
		// validate the form when it is submitted
		$("#"+nameform).validate({
			errorContainer: containererror,
			errorLabelContainer: "div#msgerror",
			wrapper: 'ul li',
			meta: "validate",
			event: "submit",
			onclick: false,
			onblur:false,
			onfocus:false,
			onkeyup:false,
			showErrors: function(errorMap, errorList) {
				$("div#msgerror").html("Your form contains " + this.numberOfInvalids() + " errors, see details below.");
				this.defaultShowErrors();
			}
		});
	}
	if($("#frm-login").lenght>0){
		$("#frm-login").validate({
			meta: "validate",
			event: "submit",
			onclick: false,
			onblur:false,
			onfocus:false,
			onkeyup:false
								});
	}
	mySetsubmit = function (container,nameform){
		myValidateform(nameform);
		$('#'+container).one("click",function(nameform){	
			//alert(nameform);
			$('div#msgerror').show();
			$("#"+nameform).submit();		
		});
		
	}
	mydelform = function(v){
		if (confirm("Are you sure you want to delete")) {
			return true;
		}
		return false;
	}
	$('#divloading').hide();

	
});