// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
//																								   //
//									WWW.YALLA.CO.IL												   //
//								   כל הזכויות שמורות											   //
//																								   //
//									@ אלמוג נחמיה @												   //
//																								   //
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //

function getIEVersionNumber()
{
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}


function getHTTPObject()
{
	var xmlhttp;
	
	if (getIEVersionNumber() >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	else
		xmlhttp = false;
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

// Flying Cart - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //

function addToCart(productId,storeId,getDo,getPage,info)
{
	if (document.getElementById('cartLoading'))
	{
		document.getElementById('cartLoading').style.display = 'block';
	}
	
	if	(getDo == 'addOne')
	{
		YallaFloatCart_OpenAndClose();
		
		if	(document.getElementById('productDiv_' + productId))
		{
			Fly2Cart(productId);
		}
	}
	
	http_cart.open("GET", "ajax.flyingCart.php?time=" + new Date().getTime() + "&id=" + productId + "&storeid=" + storeId + "&do=" + getDo + "&page=" + getPage + "&info=" + info, true);
	
	if	(getDo == 'addOne')
		http_cart.onreadystatechange = addToCart_HttpResponse_added;
	else
		http_cart.onreadystatechange = addToCart_HttpResponse;
	
	http_cart.send(null);
}

function addToCart_HttpResponse()
{
	if (http_cart.readyState == 4)
	{
		if	(document.getElementById('flyingCart'))
		{
			document.getElementById('flyingCart').innerHTML = http_cart.responseText;
		}
		
		if (document.getElementById('cartLoading'))
		{
			document.getElementById('cartLoading').style.display = 'none';
		}
	}
}

function addToCart_HttpResponse_added()
{
	if (http_cart.readyState == 4)
	{
		window.location='./?view=cart';
	}
}
 
var http_cart = getHTTPObject();


// Compere Products - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //

function addToCompere(productId,storeId,inComperePage)
{	
	http_compere.open("GET", "ajax.compere.php?time=" + new Date().getTime() + "&id=" + productId + "&storeid=" + storeId + "&inComperePage=" + inComperePage, true);
	http_compere.onreadystatechange = addToCompere_HttpResponse;
	http_compere.send(null);
}

function addToCompere_HttpResponse()
{
	if (http_compere.readyState == 4)
	{		
		if (http_compere.responseText == 'refresh')
		{
			location.reload(true);
		}
	}
}
 
var http_compere = getHTTPObject();
