function ajaxRequest(url, method, postData) {
	    //validation start
	    if (url == undefined) return false;
	    this.method = method == undefined ? "GET" : method.toUpperCase();
	    if (this.method != "GET" && this.method != "POST") return false;
	    if (url == undefined || url == "") return false;
	    //validation end
	    this.url = url + ((url.indexOf('?') > 0) ? "&ajts" : "?ajts") + new Date().getTime();
	    var mainCls = this;
        this.inProgress = false;
	    this.xmlHttpObj = null;
	    this.postData = postData;
	    this.toString = function() { return "Ajax by Sanal"; }
	    this.abort = function() {
	        if (mainCls.inProgress) {
            mainCls.xmlHttpObj.abort();
	            mainCls.inProgress = false;
	            mainCls.xmlHttpObj = null;
	        }
	    }
	    this.execute = function(statusChangeFunction) {
	        try {
	            // Firefox, Opera 8.0+, Safari
	            mainCls.xmlHttpObj = new XMLHttpRequest();
	        }
	        catch (e) {
	            // Internet Explorer
	            try {
	                mainCls.xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
	            }
	            catch (e) {
	                try {
	                    mainCls.xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
	                }
	                catch (e) {
	 
	                    return false; //No support for AJAX
	                }
	            }
	        }
	 
	        mainCls.xmlHttpObj.onreadystatechange = function() {
	            if (statusChangeFunction) {
	                statusChangeFunction(mainCls.xmlHttpObj.readyState, typeof (mainCls.xmlHttpObj.responseText) == "unknown" ? null : mainCls.xmlHttpObj.responseText, typeof (mainCls.xmlHttpObj.responseXML) == "unknown" ? null : mainCls.xmlHttpObj.responseXML, mainCls.xmlHttpObj.readyState==4 ? mainCls.xmlHttpObj.status : null);
	            }
	            if (mainCls.xmlHttpObj.readyState == 4) {
	                mainCls.inProgress = false;
	                mainCls.xmlHttpObj = null;
	            }
	        }
	 
	        mainCls.xmlHttpObj.open(mainCls.method, mainCls.url, true);
	        if (mainCls.method == "POST") {
	            mainCls.xmlHttpObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	            mainCls.xmlHttpObj.setRequestHeader("Content-Length", mainCls.postData.length);
	        }
	        mainCls.inProgress = true;
	        mainCls.xmlHttpObj.send(mainCls.method == "POST" ? mainCls.postData : null);
	        return true;
	    }
	}


function get_provincias(id_pais) {
	            var myAjaxRequest = new ajaxRequest("index.php?modulo=llamadas_background&funcion_llamada=get_provincias&id_pais="+id_pais);
	            myAjaxRequest.execute(muestra_provincias);
	            myAjaxRequest = null;
	        }

function muestra_provincias(readyState, responseText) {           
	            if (readyState == 1)//loaded
	                document.getElementById("id_provincia_ajax").innerHTML = "Loading...";
	            else if (readyState == 4)//complete
	                document.getElementById("id_provincia_ajax").innerHTML = responseText;           
	        }    


function valida_codigo(codigo) {				
				document.getElementById("idloading").innerHTML = "";
	            var myAjaxRequest = new ajaxRequest("index.php?modulo=llamadas_background&funcion_llamada=valida_codigo&codigo="+codigo);
	            myAjaxRequest.execute(actualiza_carrito);
	            myAjaxRequest = null;
	        }

function actualiza_carrito(readyState, responseText) {           
        if (readyState == 1)//loaded
            document.getElementById("idloading").innerHTML = "Loading...";
        else if (readyState == 4){//complete        	
            document.getElementById("carritoIzq").innerHTML = responseText;
            document.getElementById("idloading").innerHTML = "";            
        }
            
                   
} 


function muestra_importe_tarjeta_regalo(precio){
var contenedor;  	       	  		
contenedor = document.getElementById('precio_tarjeta');	    	        	 
contenedor.innerHTML = precio + '&euro;';						   	  
}

function precio_talla(valor, precio,cadena){
var contenedor;  	 
  document.getElementById('talla').value=valor;
  //document.getElementById('talla_seleccion').innerHTML='<div class="selected"><a href="#">'+cadena+'</a></div>';
  document.getElementById('talla_seleccion').innerHTML=cadena;
  document.getElementById("listaTallas").style.display = "none";  
  if (valor > 44){	  		
	    contenedor = document.getElementById('precio');	    	    
	    precio += parseInt(10);	    	    	 
		contenedor.innerHTML = precio + '&euro;';		
		document.getElementById('talla_grande').value=1;				
  }  
  else{
  		contenedor = document.getElementById('precio');	    	    	    	    	    	
		contenedor.innerHTML = precio + '&euro;';		
		document.getElementById('talla_grande').value=0
  }   
	  
}

function selecciona_color(fichero, nombre,id){   
	var contenedor,id_color_selecionado_old;      	  
	contenedor = document.getElementById('imagen_color_escogido');
	id_color_selecionado_old=document.getElementById('id_color').value;
	//contenedor.innerHTML = "<a href='img/colores/GRAND_"+fichero+"' title='' class='ampliarSimple'> <img src='img/colores/"+fichero+"'></a>";
	contenedor.innerHTML = "<img class='activo' src='img/colores/"+fichero+"'><br /><span class='nombreColor' id='nombre_color_escogido' >"+nombre+"</span> </div>";
	document.getElementById('color_'+id).className="activo";			
	document.getElementById('id_color').value=id;	  		  
	document.getElementById('color_'+id_color_selecionado_old).className="";
}


//UTILIDADES
function marcar_todos(){
	for (i=0;i<document.usuarioview.elements.length;i++)
	if( (document.usuarioview.elements[i].type == 'checkbox') && (document.usuarioview.elements[i].name !='aceptar_condiciones'))
		document.usuarioview.elements[i].checked=1
} 

function desmarcar_todos(){
	for (i=0;i<document.usuarioview.elements.length;i++)
	if( (document.usuarioview.elements[i].type == 'checkbox') && (document.usuarioview.elements[i].name !='aceptar_condiciones'))
		document.usuarioview.elements[i].checked=0
} 
function logueate_aqui(){
    document.getElementById('id_input_login').focus();
    document.getElementById('id_input_login').style.borderBottom='2px solid red';
    document.getElementById('id_input_password').style.borderBottom='2px solid red';
}
