
var OKCODE = "%OK_CODE%";
var xmlhttp;
var xmlhttpTab;
var currentTabSelected = "t1";
var currentSid = null;


function createAjax()
{ 
	try 
	{ 
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 
}

function createAjaxTab()
{ 
	try 
	{ 
		xmlhttpTab=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			xmlhttpTab=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttpTab && typeof XMLHttpRequest!='undefined') { xmlhttpTab=new XMLHttpRequest(); } 
}
function StateChangeTabProduct()
{
	if(xmlhttp.readyState == 4)
	{
		if(xmlhttp.status == 200)
		{
		 	document.getElementById('tabContainer').innerHTML = xmlhttp.responseText;
				document.getElementById("transSmall").style.display="none";
		}
		else
		{
			//alert("Código de error: "  + xmlhttp.status);
		}
	}
}
function StateChangeTab()
{
		
	if(xmlhttp.readyState == 4)
	{
		if(xmlhttp.status == 200)
		{
			 if (xmlhttp.responseText == 'ERROR_LOGIN')
				{
					 location.href = lang+"/login.php";
				}
				else
				{
			 	document.getElementById('tabContainer').innerHTML = xmlhttp.responseText;
				}
				
				document.getElementById("transSmall").style.display="none";
		}
		else
		{
			//alert("Código de error: "  + xmlhttp.status);
		}
	}
}

function getDataTabProduct(sid,tabDst,products_id)
{ 
 changeTabProduct(tabDst,products_id);
	text = 'Cargando datos. Por favor espere.';
	if (language == 'portugal') text = 'Loading data. Por favor aguarde.';
	
	currentSid = sid;
	var message="<br/><img src='./images/skins/Pink_v_2_0/validator/loading.gif' alt='Enviando'><br/><br/><span class='text'><b>"+text+"</b></span><br><br>";
		
	showMessageTransSmall(message);
	createAjax();
	var request = lang+'/product_info_ajax.php?action='+tabDst+"&"+sid+"&products_id="+products_id;
	xmlhttp.open( "GET", request , true );
	xmlhttp.onreadystatechange = StateChangeTabProduct;
	xmlhttp.send(null);	
}


function changeTabProduct(tabDst,products_id)
{
 createAjaxTab();
	var request = lang+'/header_products_tabs.php?action=change_tab&tab='+tabDst+'&'+currentSid+"&products_id="+products_id;
	xmlhttpTab.open( "GET", request , true );
	xmlhttpTab.onreadystatechange =function()
	{
		 if(xmlhttpTab.readyState == 4)
			{
				if(xmlhttpTab.status == 200)
				{
						document.getElementById("menuTabs").innerHTML = xmlhttpTab.responseText;
				}
				else
				{
					//alert("Código de error: "  + xmlhttpTab.status);
				}
			}
	}
	xmlhttpTab.send(null);
}

