/**
*Procedimientos y funciones de uso general
*
*/
var nav4 = window.event ? true : false;
var opts = {
		align: 'top',
		size: 80,
		labels: true,
		distance: 100
			};
	
jQuery( document ).ready(function(){
	

	 //solo numeros
	$( "input.onlynumber" ).keypress(function( evt ){
		var key = nav4 ? evt.keyCode : evt.which;
		return /[\d]/.test( String.fromCharCode( key ) );
	});
	
	//monetario
	$( "input.money" ).keyup(function(){
		this.value = number_format( this.value );
	});
	
	//solo letras
	$( "input.onlyword" ).keypress(function(){
		var key = nav4 ? evt.keyCode : evt.which;
		return /[\w]/.test( String.fromCharCode( key ) );
	});
	
	$( "form.formvalida" ).submit(function(){ 
		 return EvaluaReg( this );
	});
	
	//Enviar forularios intocable
	$(".EnviaForm").click(function(){
		$( "#" + $(this).attr("rel") ).submit();
		return false;
	});
	
	//Enviar forularios intocable
	$(".btnBanner").click(function(){
		$( "#imgPrincipal").attr({ 
							  src: $(this).attr("rel"),
							  alt: $(this).attr("title")
							});
		return false;
	});
	
	
	
	//addNotify();
	/*
	$( "#volatilnotif" ).html( "Items Borrados!" );

	setTimeout( function(){$( "#volatilnotif" ).fadeOut( "slow" )} , 600 );
	*/
	
	$('#menuDock').jqDock(opts);
	
	
	//Para eliminar agencias a los clientes listagencias listagenciascliente
	$( ".get_page" ).click(function(){
		$( ".tabs li" ).removeClass("selected");
		$(this).parent().addClass("selected" );	
		window.location.hash = $(this).attr("id");
		return get_page( $(this) );
	});
	
	
	$( "#buscador" ).click(function(){
		$(this).val("");
	});
	
});

function addNotify()
{
	if( !window.contactonotify )
	{
		window.contactonotify = $( '<div id="volatilnotif" class="mensaje_notify info_notify"><img border=0 src=\"assets/imgs/ajax-loader.gif\"</div>' )
					.css({ 
							"position":"absolute",
							"top" : "419px",
							"left" : "650px",
							"width" : "300px"
				}).get();
				
		$( document.body ).append( window.contactonotify );
	}
	else
		$( window.contactonotify ).show();
	
	setTimeout( function(){$( "#volatilnotif" ).fadeOut( "slow" )} , 600 );
		
}


function get_page( obj, offset )
{
	//var myforminputs = $( "div#contactos input" ).get();
	var params = {};
	var tmpname = "";
	var strOffset = "";
	if( offset > 0 )
		strOffset = "&offset=" + offset;
		
	var myfield;
	var idseccion = obj.attr("rel");
	var url = obj.attr("href") + "?ids=" + idseccion + strOffset;

	//params[ "context" ] = context;
	
	//return false;
	jQuery.ajax( {
		"type" : "GET",
		"data" : params,
		//"dataType" : "json",
		"url" : url ,
		
		"beforeSend" : function(){
			addNotify();
		},
		 
		"success" : function( data ){
			
			$( ".home-marca" ).html(data);
			
			

			setTimeout( function(){
				$( "#volatilnotif" ).fadeOut( "slow" );
			} , 700);

		}
	});
	
	
	return false;
}

