
$( function() {
	// Ajustamos el formato de columnas ( en caso de que exista )
	if( $( '#content div:first' ).hasClass( 'col_left' ) ){ fAjustarColumnas(); }
} );



function fAjustarColumnas(){
	
	var bgColX = parseInt( $( '#content div.col_left:first' ).css( 'width' ) ) + parseInt( $( '#content div.col_left:first' ).css( 'padding-left' ) ) + parseInt( $( '#content div.col_left:first' ).css( 'padding-right' ) );
	
	// ajustamos la posición del fondo
	$( '#content' ).css( { 'background-position' : bgColX + 'px top', 'background-color' : '#DADADA' } );
	// Ajustamos la posición de la columna izquierda ( y le quitamos el padding )
	$( '#content div.col_left:first' ).css( {
			'margin-left' : ( parseInt( $( '#content div.col_left:first' ).css( 'padding-left' ) ) - parseInt( $( '#content' ).css( 'padding-left' ) ) ) + 'px',
			'margin-top' : ( parseInt( $( '#content div.col_left:first' ).css( 'padding-top' ) ) - parseInt( $( '#content' ).css( 'padding-top' ) ) ) + 'px',
			'padding' : '0px' } );
	// Ajustamos el ancho de la columna derecha
	$( '#content div.col_right:first' ).css( { 'width' : ( parseInt( $( '#content' ).css( 'width' ) ) - bgColX ) + 'px' } );
	
}

function fFormatearForm ( idForm, activarPrimero ){
	$( '#' + idForm + ' :text, #' + idForm + ' textarea' )
		.each( function(){
							$( this ).addClass( 'texto' )
									 .focus( function(){ $( this ).addClass( 'txtFocus' );
														 // $( this ).parent().css( 'font-weight', 'bold' );
														} )
									 .blur( function(){ $( this ).removeClass( 'txtFocus' );
														// $( this ).parent().css( 'font-weight', 'normal' );
														} )
						} );
	if( activarPrimero ){
		$( '#' + idForm + ' :text:first' ).focus();
	}
	
}

function fAjax( obj ){
	
	if( window.XMLHttpRequest ){
		obj.xhr = new XMLHttpRequest();
	} else
	if( window.ActiveXObject ){
		obj.xhr = new ActiveXObject( "Microsoft.XMLHTTP" );
	} else {
		// alert( "Error" );
	}
	
	if( obj.xhr ){
		obj.xhr.onreadystatechange = obj.func;
		obj.xhr.open( "GET", String( obj.doc ), true );
		obj.xhr.send( null );
	}
}

// Función para leer valores del URI
function fLeerURI( v ){
	
	var sRE = "[&?]" + v + "=([^&]+)";
	var oRE = new RegExp( sRE );
	
	if( oRE.test( location.search ) ){
		return RegExp.$1;
	} else {
		return null;
	}
}


