//Ajax manager
var managerShoppingCart = new AjaxManager('managerShoppingCart');

//from popup
var frompopup = 0;

//product type enumeration
var productType = new ProductType();

/* -------------------------------  */
/* HTML OBJECTS IDS					*/
/* -------------------------------  */
//Id of music price span
var spanMusicPrice = "spanMusicPrice";
//Id of the cd price span
var spanCdPrice = "spanCDPrice";

//Added to the sale of cards
//Id of the card price span
var spanCardPrice = "spanCardPrice";

//Indicates the type of button that should be drawn
var alternativeButtons = false; 

//Id of the shopping cart items count span
var spanShoppingCartCount = "spanShoppingCartCount";
//Id of the shopping cart value span
var spanShoppingCartValue = "spanShoppingCartValue";

//ajax url to add items
var addItemsUrl = "ajax/addToShoppingCart.aspx";

//ajax url to add artist playlist
var addPlaylistUrl = "ajax/addArtistPlaylistToShoppingCart.aspx";

var ids;
var types;
var alternatives;
var op;
var op2;
var st = 0;
var bol = false;
var url_cart;

//Retorna se é Highlights
var _isHighlight;

//shopping cart item
function ShoppingCartItem(id, price, type, isOnCart)
{
	this.id = id;
	this.price = price;
	this.type = type;
	this.isOnCart = isOnCart;
}

//Adds item to shopping cart
//ids - list of ids separated by comma
//types - list of types separated by comma
function addToShoppingCart(id, type, alternative)
{
	alternativeButtons = alternative;
	
	var url = addItemsUrl + "?ids=" + id + "&types=" + type;
	
	if(type == 3)
	{
		if(this.bol)
			drawCardPrice2("add", id);
		else
			drawCardPrice("add", id);
	}
	else
	{
		drawMusicPrice("add", id);
	}
	frompopup = 1;
	AjaxShoppingCart_Add(url);
}
function addToShoppingCart2(id, type, alternative)
{
	window.document.getElementById("id").value = id;
	window.document.getElementById("type").value = type;
	st = 1;
	alternativeButtons = alternative;
	var temp = new Object();
	temp.id = id;
	temp.type = type;
	temp.alternative = alternative;
	ids = id;
	types = type;
	alternatives = alternative;
	myManager.Add("ajax/getLoginXML.aspx?action=purchase", butComprarPlayer, null, null, null, temp);
}
function addToShoppingCart3(id, type, alternative)
{
	st = 2;
	alternativeButtons = alternative;
	var temp = new Object();
	temp.id = id;
	temp.type = type;
	temp.alternative = alternative;
	ids = id;
	types = type;
	alternatives = alternative;
	myManager.Add("ajax/getLoginXML.aspx?action=purchase", butComprarPlayer, null, null, null, temp);
}
function addToShoppingCart4(id, type, alternative, op)
{
	st = 3;
	op2 = op;
	alternativeButtons = alternative;
	var temp = new Object();
	temp.id = id;
	temp.type = type;
	temp.alternative = alternative;
	ids = id;
	types = type;
	alternatives = alternative;
	myManager.Add("ajax/getLoginXML.aspx?action=purchase", butComprarPlayer, null, null, null, temp);
	//alert(window.opener);
}
function butComprarPlayer()
{
	if(this.httpRequest.status == 200)
	{
		var html = this.httpRequest.responseText;
		var temp = this.parameters;
		
		if (html == "ok")
		{			
			var id; 
			id = ids;
			var type;
			type = types;
			var url = addItemsUrl + "?ids=" + id + "&types=" + type;
			
			if(this.type == 3)
			{
				if(this.bol)
					drawCardPrice2("add", id);
				else
					drawCardPrice("add", id);
			}
			else
			{
				drawMusicPrice2("add",id);
			}
			frompopup = 2;
			AjaxShoppingCart_Add(url);
		}
		else if(html == "deslogado")
		{
			//alert('not logged');
			var id; 
			id = ids;
			var type;
			type = types;
			var url = addItemsUrl + "?ids=" + id + "&types=" + type;
			
			
			var agt=navigator.userAgent.toLowerCase();
			if (agt.indexOf("msie") != -1)
			{
				try
				{
					window.opener.focus();
					//CreateCreditNotify2("Por favor efetue o Login.");*/
					if(this.type == 3)
					{
						if(this.bol)
							drawCardPrice2("add", id);
						else
							drawCardPrice("add", id);
					}
					else
					{
						drawMusicPrice2("add",id);
					}
					frompopup = 2;
					AjaxShoppingCart_Add(url);
				}
				catch(e) 
				{
					if(op == undefined)
					{
						var i = document.getElementById('urlP2').value;
						//op = window.open(i,"teste","width=589, height=337,resizable = no");
						op = window.open(i);
						void(0);
						if(this.type == 3)
						{
							if(this.bol)
								drawCardPrice2("add", id);
							else
								drawCardPrice("add", id);
						}
						else
						{
							drawMusicPrice2("add",id);
						}
						frompopup = 2;
						AjaxShoppingCart_Add(url);
						
						
					}
				}
			}
			if (navigator.appName.indexOf("Netscape") != -1)
			{
				try
				{
					if(window.opener == null)
					{
						if(op == undefined)
						{
							var i = document.getElementById('urlP2').value;
							op = window.open(i,"teste","status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes");
							void(0);
							if(this.type == 3)
							{
								if(this.bol)
									drawCardPrice2("add", id);
								else
									drawCardPrice("add", id);
							}
							else
							{
								drawMusicPrice2("add",id);
							}
							frompopup = 2;
							AjaxShoppingCart_Add(url);
						}
					}
					else
					{
						//alert(window.opener);
						/*window.opener.focus();
						CreateCreditNotify2("Por favor efetue o Login.");*/
						if(this.type == 3)
						{
							if(this.bol)
								drawCardPrice2("add", id);
							else
								drawCardPrice("add", id);
						}
						else
						{
							drawMusicPrice2("add",id);
						}
						frompopup = 2;
						AjaxShoppingCart_Add(url);
						
					}
				}
				catch (e) {}
			}
			//CreateCreditNotify("Por favor efetue o Login.")
		}
			
	}
	
}

function addToShoppingCartExtended(id, type, alternative)
{
	var temp = new Object();
	temp.id = id;
	temp.type = type;
	temp.alternative = alternative;
	myManager.Add("ajax/getLoginXML.aspx?action=purchase", shoppingParser, null, null, null, temp);
}
function addToShoppingCartExtended3(id, type, alternative)
{
	
	var temp = new Object();
	temp.id = id;
	temp.type = type;
	this.bol = true;
	myManager.Add("ajax/getLoginXML.aspx?action=purchase", shoppingParser, null, null, null, temp);
}
function shoppingParser()
{
	if(this.httpRequest.status == 200)
	{
		var html = this.httpRequest.responseText;
		var temp = this.parameters;
		
		if (html == "ok")
		{			
			//alert('logged');
			//alert(temp.id +' '+ temp.type +' '+ temp.alternative);
			addToShoppingCart(temp.id, temp.type, temp.alternative);
		}
		else if(html == "deslogado")
		{
			//alert('not logged');
			//CreateCreditNotify("Por favor efetue o Login.")
		}
			
	}
}

//Adds items to shopping cart
//ids - list of ids separated by comma
//types - list of types separated by comma
function addItemsToShoppingCart(ids, types, alternative)
{
	alternativeButtons = alternative;
	
	var idsString = ids.split(',');
	var url = addItemsUrl + "?ids=" + ids + "&types=" + types;
	
	for(var i = 0; i < idsString.length; i++)
	{
		drawMusicPrice("add", idsString[i]);
	}
	
	AjaxShoppingCart_Add(url);
}

function removeItemsFromShoppingCart()
{
	var ids = new Array(0);
	
	//gets all checked musics
	ids = ids.concat(getCheckBoxesValues(document.formShoppingCartItems.cds));
	ids = ids.concat(getCheckBoxesValues(document.formShoppingCartItems.musics));
	ids = ids.concat(getCheckBoxesValues(document.formShoppingCartItems.cards));
	
	if(ids.length > 0)
	{
		var url = "ajax/genericAjax.aspx";
		var post = "view=ShoppingCartItemsView&p1=remove&p2=" + ids.join(",") + "&p3=false";
		getAjaxContentNoCache("divShoppingCartItems", url, true, post);
	}
	var idsCD = new Array(0);
	var idsMUSIC = new Array(0);
	idsCD = ids.concat(getCheckBoxesValues(document.formShoppingCartItems.cds));
	idsMUSIC = ids.concat(getCheckBoxesValues(document.formShoppingCartItems.musics));
	if(verificaOpener())
	{
		if(idsCD.length > 0)
			alteraimgCd();
		if(idsMUSIC.length > 0)
			alteraimgMusic();
	}
			
}
function alteraimgCd(id)
{
	opener.UpdateImgCd(opener);
}
function alteraimgMusic()
{
	opener.UpdateImgMusic(opener);
}
function verificaOpener()
{
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("msie") != -1)
	{
		try
		{
			var val =  opener.document;
			return true;
		}
		catch(e) 
		{
			return false;
		}
	}
	if (navigator.appName.indexOf("Netscape") != -1)
	{
		try
		{
			if(window.opener == null)
			{
				return false;
			}
			else
			{
				return true;
			}
		}
		catch (e) {}
	}
}

function ShowItemsCart()
{
		var url = "ajax/genericAjax.aspx";
		var post = "view=ShoppingCartItemsView&p1=&p2=&p3=true";
		getAjaxContentNoCache("divShoppingCartItems", url, true, post);
}

//draws price box (for music or cd)
function drawPriceBox(itemId, itemType, isOnCart, alternative, isLogged, albumPlayerCanSell, musicPlayerCanSell)
{
	var html = "";
	var spanId = "";
	var spanId = spanMusicPrice;
	

	
	if(itemType == productType.Cd)
	{
		spanId = spanCdPrice;
	}
	html += "<span id=\"" + spanId + itemId + "\">";

	//Checks if the music or album is on the cart
	if(isOnCart)
	{	//alert ("window.location()");	
		var image = (alternative) ? "bt_adicionado2.gif" : "bt_adicionado.gif";
		html += "<a href=\"javascript:;\" title=\"item adicionado: ver carrinho\"><img src=\"../image/" + image + "\" alt=\"Item adicionado\" /></a>";
	}
	else
	{
		var image = (alternative) ? "bt_comprar2.gif" : "bt_comprar.gif";
		if ( albumPlayerCanSell != null ){
			if (!albumPlayerCanSell)//if (albumPlayerCanSell != null && !albumPlayerCanSell)
				html += "";//"<img border=\"0\" src=\"../image/bt_comprar2.gif\" onmouseover=\" CreateCreditNotify('Não está disponível para venda!'); \" />";
			else			
				html += "<a href=\"javascript:;\" onclick=\"javascript:addToShoppingCart2(" + itemId + ", " + itemType + ", " + alternative + ");\" title=\"adicionar em meu carrinho\"><img src=\"../image/" + image + "\" alt=\"adicionar em meu carrinho\" /></a></div>";
				
		}
		if ( musicPlayerCanSell != null)
		{
			if (musicPlayerCanSell ){				
				html += "<a href=\"javascript:;\" onclick=\"javascript:addToShoppingCart2(" + itemId + ", " + itemType + ", " + alternative + ");\" title=\"adicionar em meu carrinho\"><img src=\"../image/" + image + "\" alt=\"adicionar em meu carrinho\" /></a></div>";				
			}else{
				html += "";
			}
		}

	}
	html += "</span>";

	/*if(!isLogged)
		html = "";*/
	return html;
}

//Draws Music Price span depending on the status
function drawMusicPrice(status, id, isSub)
{
	var span;
	if(st == 2){
		span = opener.document.getElementById(spanMusicPrice + id);
	}
	if(st == 3){
		span = op2.document.getElementById(spanMusicPrice + id);
	}
	if(st == 1){
		span = document.getElementById(spanMusicPrice + id);
	}
	if(st == 0){
		span = document.getElementById(spanMusicPrice + id);
	}
	
	if(span != null)
	{
		switch(status)
		{
			//button add clicked
			case "add":
				span.innerHTML = "aguarde";
				break;
			//item added
			case "added":
				var image = (alternativeButtons) ? "bt_adicionado2.gif" : "bt_adicionado.gif";
				if(isSub == 1) 
					/*image =  "bt_mini_adicionado.gif";*/
					image =  "bt_adicionado.gif";
				span.innerHTML = "<img src=\"../image/" + image + "\" alt=\"Item adicionado\" />";
				break;
			case "login": 
				span.innerHTML = "Por favor, faça o login.";
				break;
		}
	}
}


//Added to the sale of cards
function drawCardPrice(status, id, isSub)
{
	
	var span = document.getElementById(spanCardPrice + id);
	
	if(span != null)
	{
		switch(status)
		{
			//button add clicked
			case "add":
				span.innerHTML = "aguarde";
				break;
			//item added
			case "added":
				var image = (alternativeButtons) ? "bt_adicionado2.gif" : "bt_adicionado.gif";
				if(isSub == 1) 
					image =  "bt_adicionado.gif";
				span.innerHTML = "<img src=\"../image/" + image + "\" alt=\"Item adicionado\" />";
				break;
			case "login": 
				span.innerHTML = "Por favor, faça o login.";
				break;
		}
	}
}
function drawCardPrice2(status, id, isSub)
{
	var span = document.getElementById(spanCardPrice + id);
	
	if(span != null)
	{
		switch(status)
		{
			//button add clicked
			case "add":
				span.innerHTML = "aguarde";
				break;
			//item added
			case "added":
				var image = (alternativeButtons) ? "bt_adicionado_vale.gif" : "bt_adicionado_vale.gif";
				if(isSub == 1) 
					image =  "bt_adicionado_vale.gif";
				span.innerHTML = "<img src=\"../image/" + image + "\" alt=\"Item adicionado\" />";
				break;
			case "login": 
				span.innerHTML = "Por favor, faça o login.";
				break;
		}
	}
}

//Draws Cd Price span depending on the status.
function drawCdPrice(status, idd, littleBox)
{
	var span;
	if(st == 2){
		span = opener.document.getElementById(spanCdPrice + idd);
	}
	if(st == 3){
		span = op2.document.getElementById(spanCdPrice + idd);
	}
	if(st == 1){
		span = document.getElementById(spanCdPrice + idd);
	}
	if(st == 0){
		span = document.getElementById(spanCdPrice + idd);
	}
	if(span != null)
	{
		switch(status)
		{
			//button add clicked
			case "add":
				span.innerHTML = "aguarde";
				break;
			//item added
			case "added":
				if (_isHighlight == '1'){
					var image = "bt_comprar_HomeHighliths.gif";
				}
				else{
					var image = (alternativeButtons) ? "bt_adicionado2.gif" : "bt_adicionado.gif";
				}
				
				span.innerHTML = "<img src=\"../image/" + image + "\" alt=\"Item adicionado\" />";
				break;
			case "login": 
				span.innerHTML = "Por favor, faça o login.";
				break;
		}
	}
}

//Draws shopping cart items count
function drawShoppingCart2(count, value)
{
	var spanCount;
	var spanValue;
	var spanImg;
	
	if(st == 2){
		spanCount = opener.document.getElementById(spanShoppingCartCount);
		spanValue = opener.document.getElementById(spanShoppingCartValue);
		spanImg = opener.document.getElementById("spanShoppingCartImg");
	}
	if(st == 3){
		spanCount = op2.document.getElementById(spanShoppingCartCount);
		spanValue = op2.document.getElementById(spanShoppingCartValue);
		spanImg = op2.document.getElementById("spanShoppingCartImg");
	}
	if(st == 1){
		try
		{
			spanCount = opener.document.getElementById(spanShoppingCartCount);
			spanValue = opener.document.getElementById(spanShoppingCartValue);
			spanImg = opener.document.getElementById("spanShoppingCartImg");
		}
		catch(e)
		{
			spanCount = op.document.getElementById(spanShoppingCartCount);
			spanValue = op.document.getElementById(spanShoppingCartValue);
			spanImg = op.document.getElementById("spanShoppingCartImg");
		}
	
	}	
	if(spanCount != null && spanValue != null)
	{
		/*if(count > 0)
			spanImg.innerHTML = "<img src=\"http://localhost/IgMusicStore/image/bt_carrinho_on.gif\" alt=\"Item adicionado\" />";
		else
			spanImg.innerHTML = "<img src=\"http://localhost/IgMusicStore/image/bt_carrinho_on.gif\" alt=\"Item adicionado\" />";*/
		if(count > 0)
			spanImg.innerHTML = "<img src='"+url_cart+"_on.gif' alt='Item adicionado' />";
		else
			spanImg.innerHTML = "<img src='"+url_cart+".gif' alt='Item adicionado' />";
		spanCount.innerHTML = count + " Itens no Carrinho";
		spanValue.innerHTML = "Valor " +  value;
	}
}
function  drawMusicPrice2(status,idsi)
{
	var ids = idsi;
	var span;
	if(st == 2){
		span = opener.document.getElementById(spanMusicPrice + idsi);
	}
	if(st == 3){
		span = op2.document.getElementById(spanMusicPrice + idsi);
	}
	if(st == 1){
		span = document.getElementById(spanMusicPrice + idsi);
	}
	
	if(span != null)
	{
		switch(status)
		{
			//button add clicked
			case "add":
				span.innerHTML = "aguarde";
				break;
			//item added
			case "added":
				var image = (alternativeButtons) ? "bt_adicionado2.gif" : "bt_adicionado.gif";
				if(isSub == 1) 
					/*image =  "bt_mini_adicionado.gif";*/
					image =  "bt_adicionado.gif";
				span.innerHTML = "<img src=\"../image/" + image + "\" alt=\"Item adicionado\" />";
				break;
			case "login": 
				span.innerHTML = "Por favor, faça o login.";
				break;
		}
	}
}
function drawShoppingCart(count, value)
{
	var spanCount = document.getElementById(spanShoppingCartCount);
	var spanValue = document.getElementById(spanShoppingCartValue);
	var spanImg = document.getElementById("spanShoppingCartImg");
	
	if(spanCount != null && spanValue != null)
	{
		if(count > 0)
			spanImg.innerHTML = "<img src='"+url_cart+"_on.gif' alt='Item adicionado' />";
		else
			spanImg.innerHTML = "<img src='"+url_cart+".gif' alt='Item adicionado' />";
		spanCount.innerHTML = count + " Itens no Carrinho";
		spanValue.innerHTML = "Valor " +  value;
	}
	
}

//Adds item to shopping cart
function AjaxShoppingCart_Add(url)
{
	managerShoppingCart.Add(url, AjaxShoppingCart_Parse);	
}

//Parses add to cart xml result
function AjaxShoppingCart_Parse()
{
	if(this.httpRequest.status == 200)
	{
		// XML loaded properly, parses it
		var xml = this.httpRequest.responseXML;
			
		// Gets the root node
		var root = this.tools.SelectSingleNode(xml,'xml');
			
		// Looks for status Node
		var statusNode = this.tools.SelectSingleNode(this.tools.SelectSingleNode(root,'status'), 'status');
		
		//Gets return status
		var status = parseInt(this.tools.GetNodeValue(statusNode));
		
		var cdNodes = this.tools.SelectNodes(root,'cd');
		var musicNodes = this.tools.SelectNodes(root,'music');
		
		//Added to the sale of cards
		var cardNodes = this.tools.SelectNodes(root,'card');
		
		var cartNode = this.tools.SelectSingleNode(root,'shoppingCart');

		var isSubNode = this.tools.SelectSingleNode(this.tools.SelectSingleNode(root,'IsSub'), 'IsSub');
		
		var preco = this.tools.SelectSingleNode(this.tools.SelectSingleNode(root,'status'), 'preco');
		preco = this.tools.GetNodeValue(preco)
		var total = this.tools.SelectSingleNode(this.tools.SelectSingleNode(root,'status'), 'total');
		total = parseInt(this.tools.GetNodeValue(total))
		url_cart = this.tools.SelectSingleNode(this.tools.SelectSingleNode(root,'status'), 'url_cart');
		url_cart = this.tools.GetNodeValue(url_cart)
		
		isSub = parseInt(this.tools.GetNodeValue(isSubNode));
		if(frompopup == 2){
			
			//drawShoppingCart(total, preco);
			/*if(cdNodes.length > 0)
				UpdatePlaylist();
					
			if(musicNodes.length > 0)
				UpdatePlaylist2();*/
				
			if(cdNodes.length > 0)
			{
					if(st == 2){
						opener.UpdatePlaylist();
						isSub = 0;
					}
					if(st == 3){
						op2.UpdatePlaylist();
						isSub = 0;
					}
					if(st == 1){
						UpdatePlaylist();
						isSub = 0;
					}
			}		
			if(musicNodes.length > 0)
			{
				if(st == 2){
					opener.UpdatePlaylist2();
					isSub = 0;
				}
				if(st == 3){
					op2.UpdatePlaylist2();
					isSub = 0;
				}
				if(st == 1){
					UpdatePlaylist2();
					isSub = 0;
				}
			}
			drawShoppingCart2(total, preco);
		}
		
		
		if(status == -2)
		{
			//document.getElementById("spanCDPrice22").innerHTML = 
			alert("Por favor efetue o login.");
		}	
		else if(status == 0)
		{
			var i = 0;
			
			if(cdNodes != null)
			{
				
			
				for(i = 0; i < cdNodes.length; i++)
				{
					//If there are Cd nodes, an entire CD was added
					AjaxShoppingCart_ParseCd("added", cdNodes[i], this.tools);
				}
			}
			if(musicNodes != null)
			{
				
					
				for(i = 0; i < musicNodes.length; i++)
				{
					AjaxShoppingCart_ParseMusic("added", musicNodes[i], this.tools, isSub);
				}
			}
			
			//Added to the sale of cards
			if(cardNodes != null)
			{
				for(i = 0; i < cardNodes.length; i++)
				{
					AjaxShoppingCart_ParseBatchCard("added", cardNodes[i], this.tools, isSub);
				}
			}
			
			//Updates cart count
			AjaxShoppingCart_ParseCart(cartNode, this.tools);
			
		}		
		//drawShoppingCart(total, preco);
	}
}

//Pares Cd information and redraws cd price span and its musics price spans
function AjaxShoppingCart_ParseCd(status, cdNode, tools)
{
	var idCd = parseInt(tools.GetNodeValue(tools.SelectSingleNode(cdNode, "id")));
	
	//Draws Cd
	drawCdPrice(status, idCd);
	
	//Gets music nodes
	var musicNodes = tools.SelectNodes(cdNode, 'music');
	
	for(var i = 0; i < musicNodes.length; i++)
	{
		//Draws music
		AjaxShoppingCart_ParseMusic(status, musicNodes[i], tools);
	}
}

//Pares Music information and redraws music price span
function AjaxShoppingCart_ParseMusic(status, musicNode, tools, isSub)
{
	var idMusic = parseInt(tools.GetNodeValue(tools.SelectSingleNode(musicNode, "id")));
	//Draws Music
	drawMusicPrice(status, idMusic, isSub);
}

//Added to the sale of cards
//Pares Card information and redraws cart count span
function AjaxShoppingCart_ParseBatchCard(status, cardNode, tools, isSub)
{
	var idCard = parseInt(tools.GetNodeValue(tools.SelectSingleNode(cardNode, "id")));
	drawCardPrice2(status, idCard, isSub);
	
}

//Pares Shopping cart information and redraws cart count span
function AjaxShoppingCart_ParseCart(cartNode, tools)
{
	var count = parseInt(tools.GetNodeValue(tools.SelectSingleNode(cartNode, "count")));
	
	var value = tools.GetNodeValue(tools.SelectSingleNode(cartNode, "value"));
	
	//Draws cart items
	drawShoppingCart(count, value);
}


function shoppingParser()
{
	if(this.httpRequest.status == 200)
	{
		var html = this.httpRequest.responseText;
		var temp = this.parameters;
		
		if (html == "ok")
		{			
			//alert('logged');
			//alert(temp.id +' '+ temp.type +' '+ temp.alternative);
			addToShoppingCart(temp.id, temp.type, temp.alternative);
		}
		else if(html == "deslogado")
		{
			//alert('not logged');
			//CreateCreditNotify("Por favor efetue o Login.")
			addToShoppingCart(temp.id, temp.type, temp.alternative);
		}
			
	}
}

function addToShoppingCartExtended2(id,value)
{
	var value = document.getElementById("Qtd"+value).value;
	var post = "id=" + id + "&qtd=" + value;
	
	myManager.Add("ajax/getValidaCartao.aspx", AjaxAddQtd_Parse, null, null, null, null, post);
}

function AjaxAddQtd_Parse()
{
	if(this.httpRequest.status == 200)
	{
		// XML loaded properly, parses it
		var xml = this.httpRequest.responseXML;
		var root = this.tools.SelectSingleNode(xml,'xml');
		var card = this.tools.SelectSingleNode(root,'card');
		var id = parseInt(this.tools.GetNodeValue(this.tools.SelectSingleNode(card,'id')));
		var status = parseInt(this.tools.GetNodeValue(this.tools.SelectSingleNode(card,'status')));
		var preco = this.tools.GetNodeValue(this.tools.SelectSingleNode(card,'preco'));
		var items = parseInt(this.tools.GetNodeValue(this.tools.SelectSingleNode(card,'items')));
		
		if(id > 0 && status == 1)
		{
			CreateLoginNotify("Quantidade maior que a Disponível!");
		}else{
			drawShoppingCart(items, preco);
			var price = document.getElementById("price");
			price.innerHTML = "Total:  " +  preco;
		}
	}
}

//Função que retorna uma flag para saber se vem de "Highlights" afim de manter o botão Adicionar
function getIsHighlight(isHighlights)
{
	_isHighlight = isHighlights;
}