Hi im trying to apply textures on my models but i cant get it working, ive been tracing some tutorials running around the net here is what i have:

my shaders are defined like this:
Code :
<script id="shader-fs" type="x-shader/x-fragment"> 
 
			#ifdef GL_ES
			precision highp float;
			#endif
 
 
			varying vec2 vTextureCoord;
 
 
			uniform sampler2D uSampler;
 
			void main(void) 
			{
				gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
			}
		</script> 
 
		<script id="shader-vs" type="x-shader/x-vertex"> 
			attribute vec3 aVertexPosition;
			attribute vec2 aTextureCoord;
 
			uniform mat4 uMVMatrix;
			uniform mat4 uPMatrix;
 
	                varying vec2 vTextureCoord;		
 
			void main(void) 
			{
				gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
				vTextureCoord = aTextureCoord;
			}
		</script>


in the function initGL which i call when i first start the page i have declared some functions so i can easy manipulate with the modelview matrix and with the drawing so here is how my initGL looks like:


Code :
function initGL(canvas) 
{
	try 
	{
		gl = canvas.getContext("experimental-webgl");
		gl.viewportWidth = canvas.width;
		gl.viewportHeight = canvas.height;
		gl.clearColor(0.0, 0.0, 0.0, 1.0);
		gl.enable(gl.DEPTH_TEST);
		mvMatrix = mat4.create();
		pMatrix = mat4.create();
		vertexBuffer = gl.createBuffer();
		textureBuffer = gl.createBuffer();
		colorsBuffer = gl.createBuffer();
		polygonMode = gl.LINE_STRIP;
 
		gl.scale = function (x, y, z)
		{
			mat4.scale(mvMatrix, [x, y, z]);
		}
 
		gl.rotate = function(degrees, x, y, z)
		{
			mat4.rotate(mvMatrix, degrees*Math.PI/180, [x, y, z]);
		}
 
		gl.translate = function(x, y, z)
		{
			mat4.translate(mvMatrix, [x, y, z]);
		}
 
		gl.pushMatrix = function()
		{
			var copy = mat4.create();
			mat4.set(mvMatrix, copy);
			matrixStack.push(copy);
		}
 
		gl.popMatrix = function()
		{
			if(matrixStack.length == 0) throw "Invalid popMatrix!";
			mvMatrix = matrixStack.pop();
		}
 
		gl.loadIdentity = function(mat)
		{
			mat4.identity(mat);
		}
 
		gl.lookAt = function(eyeX, eyeY, eyeZ, focusX, focusY, focusZ, upX, upY, upZ)
		{
			mat4.lookAt([eyeX, eyeY, eyeZ], [focusX, focusY, focusZ], [upX, upY, upZ], mvMatrix);
		}
 
		gl.flush = function(vertex, text)
		{
			gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
			gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertex), gl.STATIC_DRAW);
			vertexBuffer.itemSize = 3;
			vertexBuffer.itemCount = vertex.length/3;
			gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
 
			gl.bindBuffer(gl.ARRAY_BUFFER, textureBuffer);
			gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(text), gl.STATIC_DRAW);
			textureBuffer.itemSize = 2;
			textureBuffer.itemCount = vertex.length/3;
			gl.vertexAttribPointer(shaderProgram.textureCoordAttribute, textureBuffer.itemSize, gl.FLOAT, false, 0, 0);
 
			gl.activeTexture(gl.TEXTURE0);
			gl.bindTexture(gl.TEXTURE_2D, texture1);
			gl.uniform1i(shaderProgram.samplerUniform, 0);
 
			gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);
			gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);
			gl.drawArrays(polygonMode, 0, vertexBuffer.itemCount);
		}
 
		M4x4.makeFrustum(-1, 1, -1, 1, 1, 1000, pMatrix);
		initShaders();
	} 
	catch (e) 
	{
		alert("Could not initialise WebGL!");
	}

as you can see i try to get webGL near to openGL 2.1 cause i learned it at school so they gave us task for bonus points to make something in webGL, and i used external javascript for matrix ops. but i get those tight up in functions so i just call the functions later and those fix up the work for me ( want the display function clean) so as you can see the last method i define is flush (similar to openGL), which takes the vertex position buffer and texture coordinates buffer which i pass after i define the vertices and their texture coords, i have global var's named vertexBuffer and textureBuffer which you can see i use to set as gl buffers with call to createBuffer(), then in the flush i firstly bind the vertexBuffer, fill in the data that is sent as parameter set item size and item count (i.e. how many coords there is in the buffer) then i set the vertexAtributPointer for the vertexPosition in the shaderProgram to point to the vertexBuffer, after do nearly the same stuff to set pointer to the textureBuffer which previously i fill in with the text parameter (the actual texture coords i define in the functions which give coords to objects), here is one function that draws simple grid using 2 for loops..
Code :
function gridPlane(wSize, hSize, wSegments, hSegments)
{
	var vertex = [];
	var textCoords = [];
	gl.pushMatrix();
 
	gl.translate(-wSize/2, 0, -hSize/2);
 
	for(var j = 0; j < hSegments; j++)
	{
		for(var i = 0; i < wSegments; i++)
		{
			textCoords = textCoords.concat([0.0, 0.0]);
			vertex = vertex.concat([i*wSize/wSegments, 0, j*hSize/hSegments]);
			textCoords = textCoords.concat([1.0, 0.0]);
			vertex = vertex.concat([(i+1)*wSize/wSegments, 0, j*hSize/hSegments]);
			textCoords = textCoords.concat([1.0, 1.0]);
			vertex = vertex.concat([(i+1)*wSize/wSegments, 0, (j+1)*hSize/hSegments]);
			textCoords = textCoords.concat([0.0, 1.0]);
			vertex = vertex.concat([i*wSize/wSegments, 0, (j+1)*hSize/hSegments]);
		}	
	}
 
	gl.flush(vertex, textCoords);
	gl.popMatrix();
}

what i do here push the modelview matrix to the stack and then draw normally couple of coords in one temporary array called vertex, and also texture coords in one temporary array textCoords, then after that is finished right before i pop the matrix back i call flush with these parameters (i do this before pop cause i need the actual modelview matrix with the transforms or else it wont draw properly on spot) so after i do this i dont get anything drawn, before i tried to implement textures i used the same exact way to draw my object with one color, so before i tried to use textures my shaders had color variable and i did the same exact thing sending color array and the vertex array to flush and now i cant make it work i dont know where i do wrong, as i saw on the tutorial on the famous site for webgl tuts (not nehe) the dude uses drawElements call but i think i can draw with drawArrays too cause texture aint nothing but another color (right?) so i think this it should work with drawArrays call too, cause the shaderprogram do interpolation with the texture as well as the color ?, thanks!! if you need the full code i can upload it so you can help me out, thanks!!