function blinkTitle()
{
	showHideTitle();
	setTimeout("blinkTitle()", 500);	
}

function showHideTitle()
{
	if(element = document.getElementById("blinktitle")) element.style.display = (element.style.display == 'none') ? 'block' : 'none';	
	if(element = document.getElementById("offerssmallstrap")) element.style.display = (element.style.display == 'none') ? 'block' : 'none';	
}

function scrollLargeOffers(variantid)
{	
	if(document.getElementById("offercontainer"))
	{
		var count = parseInt(document.getElementById("so_count").value);
		var offset = parseInt(document.getElementById("so_offset").value);
		
		if(count > 0)
		{		
			if(offset == 0)
			{
				setTimeout("var wait = true;", 6000);		
			}	
			
			fetchNewLargeOfferDetails(variantid);	
			setTimeout("scrollLargeOffers(" + variantid + ");", 6000);	
		}
	}
}

function scrollSmallOffers(variantid)
{	
	if(document.getElementById("smalloffercontainer"))
	{
		var count = parseInt(document.getElementById("so_count").value);
		var offset = parseInt(document.getElementById("so_offset").value);

		if(count > 1)
		{		
			if(offset == 0)
			{
				setTimeout("var wait = true;", 6000);		
			} 	
			
			fetchNewSmallOfferDetails(variantid);	
			setTimeout("scrollSmallOffers(" + variantid + ");", 6000);	
		}
	}
}

function updateOfferDetails()
{
	if (offerreq.readyState == 4) 	// only if req is "loaded"
	{ 
		if (offerreq.status == 200)		 // only if "OK"
		{
		  document.getElementById("offercontainer").innerHTML = offerreq.responseText;
    	}
    }	
}

function fetchNewLargeOfferDetails(variantid)
{	
	var count = parseInt(document.getElementById("so_count").value);
	var offset = parseInt(document.getElementById("so_offset").value);
	
	offset = parseInt(offset) + 1;	
	if(offset > (count - 1)) offset = 0;

   if (window.XMLHttpRequest)	// IE/Windows ActiveX version
   {
       offerreq = new XMLHttpRequest();
       offerreq.onreadystatechange = function() {updateOfferDetails();};
	   
       offerreq.open("GET", "/ajax/scroll_offers?offset=" + offset + "&variantid=" + variantid, true);
       offerreq.send(null);
   
   } else if (window.ActiveXObject)
   {
       offerreq = new ActiveXObject("Microsoft.XMLHTTP");
       if (offerreq)
	   {
           offerreq.onreadystatechange = function() {updateOfferDetails();};
           offerreq.open("GET", "/ajax/scroll_offers?offset=" + offset + "&variantid=" + variantid, true);
           offerreq.send();
       }
   } 		
}

function fetchNewSmallOfferDetails(variantid)
{	
	var count = parseInt(document.getElementById("so_count").value);
	var offset = parseInt(document.getElementById("so_offset").value);
	
	offset = parseInt(offset) + 1;	
	if(offset > (count - 1)) offset = 0;

   if (window.XMLHttpRequest)	// IE/Windows ActiveX version
   {
       offerreq = new XMLHttpRequest();
       offerreq.onreadystatechange = function() {updateSmallOfferDetails();};
	   
       offerreq.open("GET", "/ajax/scroll_small_offers?offset=" + offset + "&variantid=" + variantid, true);
       offerreq.send(null);
   
   } else if (window.ActiveXObject)
   {
       offerreq = new ActiveXObject("Microsoft.XMLHTTP");
       if (offerreq)
	   {
           offerreq.onreadystatechange = function() {updateSmallOfferDetails();};
           offerreq.open("GET", "/ajax/scroll_small_offers?offset=" + offset + "&variantid=" + variantid, true);
           offerreq.send();
       }
   } 		
}

function updateSmallOfferDetails()
{
	if (offerreq.readyState == 4) 	// only if req is "loaded"
	{ 
		if (offerreq.status == 200)		 // only if "OK"
		{
		  document.getElementById("smalloffercontainer").innerHTML = offerreq.responseText;
    	}
    }	
}
