// JavaScript Document
function nuevoAjax()
{ 
	var xmlhttp=false;
	try
	{
		xmlhttp=new ("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
				xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}

function menu_language(l,page)
{
	var _ajax = nuevoAjax();
		 
	var _selectDestino = document.getElementById('menu_language');
		 
	_ajax.open("GET", "menu_language.php?l="+l+"&page="+page+"&noCache="+Math.random(), true);

	_ajax.onreadystatechange=function()
	{
		if (_ajax.readyState==4)
		{
			_selectDestino.innerHTML = _ajax.responseText;
		}
	}
	_ajax.send(null);
}

function page_on_load(l,page)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('page_on_load');
		 
	ajax.open("GET", "page_on_load.php?l="+l+"&page="+page+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function page_on_load_surf(l,page,pageNum_paginas,pageNum_paginas2,totalRows_paginas2)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('page_on_load');
		 
	ajax.open("GET", "page_on_load.php?l="+l+"&page="+page+"&pageNum_paginas="+pageNum_paginas+"&pageNum_paginas2="+pageNum_paginas2+"&totalRows_paginas2="+totalRows_paginas2+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function page_on_load_surf2(l,page,pageNum_paginas2,totalRows_paginas2,pageNum_paginas)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('page_on_load');
		 
	ajax.open("GET", "page_on_load.php?l="+l+"&page="+page+"&pageNum_paginas2="+pageNum_paginas2+"&totalRows_paginas2="+totalRows_paginas2+"&pageNum_paginas="+pageNum_paginas+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function buscar_series(id_marca,id_ambiente,id_estilo)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "php_procesar_series3.php?Marca="+id_marca+"&Ambiente="+id_ambiente+"&Estilo="+id_estilo+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function buscar_series2(id_ambiente,id_estilo)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "php_procesar_series4.php?Ambiente="+id_ambiente+"&Estilo="+id_estilo+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}


function buscar_series_in(marca,pageNum_Recordset1,totalPages_Recordset1)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "php_procesar_series.php?Marca="+marca+"&pageNum_Recordset1="+pageNum_Recordset1+"&totalPages_Recordset1="+totalPages_Recordset1+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function buscar_series_in2(marca,pageNum_Recordset1,totalPages_Recordset1,ambiente,estilo)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "php_procesar_series3.php?Marca="+marca+"&Ambiente="+ambiente+"&Estilo="+estilo+"&pageNum_Recordset1="+pageNum_Recordset1+"&totalPages_Recordset1="+totalPages_Recordset1+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function buscar_series_in4(pageNum_Recordset1,totalPages_Recordset1,ambiente,estilo)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "php_procesar_series4.php?Ambiente="+ambiente+"&Estilo="+estilo+"&pageNum_Recordset1="+pageNum_Recordset1+"&totalPages_Recordset1="+totalPages_Recordset1+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function buscar_ext(valor)
{
	var id_marca ;
	id_marca = get_marca();
	
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "php_busqueda_ext.php?Marca="+id_marca+"&valor="+valor+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function buscar_series_in3(valor2,pageNum_Recordset1,totalPages_Recordset1)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
	
	//valor = new String (valor2);
		 
	ajax.open("GET", "php_busqueda_ext.php?valor="+valor2.toString()+"&pageNum_Recordset1="+pageNum_Recordset1+"&totalPages_Recordset1="+totalPages_Recordset1+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}



function cargar_lateral(id,id_serie,Marca,Ambiente,Estilo,Coordinado,busqueda)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('serie_fondo');
		 
	ajax.open("GET", "php_lateral.php?id_producto="+id+"&series_id="+id_serie+"&Marca="+Marca+"&Ambiente="+Ambiente+"&Estilo="+Estilo+"&coordinado="+Coordinado+"&busqueda="+busqueda+"&noCache="+Math.random(), true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);	
}

function cargar_lateral2(id_serie,pageNum_Recordset4,totalRows_Recordset4)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('piezas');
		 
	ajax.open("GET", "php_lateral_2.php?id_serie="+id_serie+"&pageNum_Recordset4="+pageNum_Recordset4+"&totalRows_Recordset4="+totalRows_Recordset4+"&noCache="+Math.random(), true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);	
}

function cargar_lateral3(id,id_serie)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('serie_fondo');
		 
	ajax.open("GET", "php_lateral3.php?id_producto="+id+"&series_id="+id_serie+"&noCache="+Math.random(), true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
			
		}
	}
	ajax.send(null);	
}

function cambiar_imagenes_ext(id_marca)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('marcas');
		 
	ajax.open("GET", "php_cambiar_marca.php?Marca="+id_marca+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}


function cambiar_ambiente_ext(id_marca)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('ambientes');
		 
	ajax.open("GET", "php_cambiar_ambiente.php?Marca="+id_marca+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cambiar_ambiente2()
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('ambientes');
		 
	ajax.open("GET", "php_cambiar_ambiente2.php?noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cambiar_estilo_ext(id_marca,id_ambiente)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('estilos');
		 
	ajax.open("GET", "php_cambiar_estilo.php?Marca="+id_marca+"&Ambiente="+id_ambiente+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cambiar_estilo_ext2(id_ambiente)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('estilos');
		 
	ajax.open("GET", "php_cambiar_estilo2.php?Ambiente="+id_ambiente+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cambiar_estilo_ext3(id_marca)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('estilos');
		 
	ajax.open("GET", "php_cambiar_estilo3.php?Marca="+id_marca+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cargar_coordinados(series_id,coordinated_id,marca,ambiente,estilo,busqueda)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "php_cambiar_producto_serie.php?series_id="+series_id+"&coordinated_id="+coordinated_id+"&Marca="+marca+"&Ambiente="+ambiente+"&Estilo="+estilo+"&busqueda="+busqueda+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
			recargar_scroll_producto_serie();
		}
	}
	ajax.send(null);
}

function procesar_productos(series_id,marca,ambiente,estilo,busqueda)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "procesar_producto_serie.php?series_id="+series_id+"&Marca="+marca+"&Ambiente="+ambiente+"&Estilo="+estilo+"&busqueda="+busqueda+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
			recargar_scroll_producto_serie();
		}
	}
	ajax.send(null);
}

function procesar_productos1(series_id,marca,ambiente,estilo,busqueda)
{
	var ajax = nuevoAjax();
		 
	var selectDestino = document.getElementById('contenido');
		 
	ajax.open("GET", "procesar_producto_serie1.php?series_id="+series_id+"&Marca="+marca+"&Ambiente="+ambiente+"&Estilo="+estilo+"&busqueda="+busqueda+"&noCache="+Math.random(), true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function buscar_tiendas(value)
{
	var ajax = nuevoAjax();
	var selectDestino = document.getElementById('tmp');
	
	ajax.open("GET", "buscar_tiendas.php?value="+value, true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function habilitar2(ciudad)
{
	var ajax = nuevoAjax();
	
	var pais = document.getElementById('pais');
	
	if ((pais.value != 199) || (ciudad == -1))
	{
		var selectDestino = document.getElementById('ciudad2');
		
		ajax.open("GET", "ciudad2.php", true);
		
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState == 4)
			{
				selectDestino.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
	else
	{
		var selectDestino = document.getElementById('ciudad2');
		
		ajax.open("GET", "ciudad.php?ciudad="+ciudad, true);
		
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState == 4)
			{
				selectDestino.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}	
}

function buscar_tiendas2()
{
	var ajax = nuevoAjax();
	var selectDestino = document.getElementById('lista_tiendas');
	
	var pais = document.getElementById('pais');
	
	if (pais.value == 199)
	{
		var ciudad = document.getElementById('ciudad');
		
		ajax.open("GET", "buscar_spain.php?pais="+pais.value+"&ciudad="+ciudad.value, true);
		
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState == 4)
			{
				selectDestino.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
	else
	{
		ajax.open("GET", "buscar.php?pais="+pais.value, true);
		
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState == 4)
			{
				selectDestino.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);
	}
}

function buscar_paises(own,l)
{
	var ajax = nuevoAjax();
	var selectDestino = document.getElementById('pais');
	
	ajax.open("GET", "buscar_pais.php?own="+own+"&l="+l, true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 4)
		{
			selectDestino.parentNode.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cargar_imagenes(pageNum_imagenes_noticia,totalRows_imagenes_noticia,NEWS_ID)
{
	var ajax = nuevoAjax();
	var selectDestino = document.getElementById('img_carrusel_interno');
	
	ajax.open("GET", "cargar_imagenes.php?pageNum_imagenes_noticia="+pageNum_imagenes_noticia+"&totalRows_imagenes_noticia="+totalRows_imagenes_noticia+"&NEWS_ID="+NEWS_ID, true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cargar_imagenes2(pageNum_campanyas_pictures,totalRows_campanyas_pictures,CAMPAIGN_ID)
{
	var ajax = nuevoAjax();
	var selectDestino = document.getElementById('carrusel');
	
	ajax.open("GET", "cargar_imagenes2.php?pageNum_campanyas_pictures="+pageNum_campanyas_pictures+"&totalRows_campanyas_pictures="+totalRows_campanyas_pictures+"&CAMPAIGN_ID="+CAMPAIGN_ID, true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function cargar_imagenes3(pageNum_images_proyectos,totalRows_images_proyectos,PROJECT_ID)
{
	var ajax = nuevoAjax();
	var selectDestino = document.getElementById('img_carrusel_interno');
	
	ajax.open("GET", "cargar_imagenes3.php?pageNum_images_proyectos="+pageNum_images_proyectos+"&totalRows_images_proyectos="+totalRows_images_proyectos+"&PROJECT_ID="+PROJECT_ID, true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}

function recargar_scroll_producto_serie()
{
	borrar_scrolls();
	var scr=crear_scroll('contenido','lista_series',false,'lista_series','before');
	
}

function update_in_use(l, page_id, page, num, pageNum_paginas, pageNum_paginas2, totalRows_paginas2)
{
	var ajax = nuevoAjax();
	var selectDestino = document.getElementById('in');
	
	var _t = document.getElementById('in_use');
	var pos;
	if ( _t.checked )
		pos = 1;
	else
		pos = 0;

	ajax.open("GET","guardar_contenido_pagina_in_use.php?in_use="+pos+"&l="+l+"&page_id="+page_id+"&page="+page+"&pageNum_paginas="+pageNum_paginas+"&pageNum_paginas2="+pageNum_paginas2+"&totalRows_paginas2="+totalRows_paginas2, true);
	
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 4)
		{
			selectDestino.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null);
}
