var bln = true;
var count = 0;
var t;

var newcount = 0;
var ld = true;
var loader = "";

var str = "<style> .black_overlay { display: none; position: absolute; top: 0px; left: 0px; width: " + (screen.width - 20) + "px; height: 1500px; background-color: #000;  z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80);} </style>";
			
document.write(str);


function appear_box(pos) {

	if(count == 5)
	{
		bln = false;
	}
		
	popupbox = document.getElementById("snapshot" + pos);
	popupbox.style.display='block';
	
	width = screen.width;
	width = (width - 650)/2;
	document.getElementById("snapshot" + pos).style.left = Number(width) + "px";
	
	height = findscrollpos();
	document.getElementById("snapshot" + pos).style.top = Number(height + 20) + "px";

	
	
	//document.getElementById("fade").style.display="block";
	
	t = setTimeout("appear_box(" + pos + ")", 1000);
	num = 0;
	count++;

}

function snap_addtocart(pos)
{
	/*	ld=true;
		newcount = 0;
		document.getElementById("snapshot" + pos).style.display = "block";
		loading(pos);
		window.floatingframe.document.location.reload();*/
		//document.location.href = "http://www.supercuffs.com";
		document.getElementById("message" + pos).innerHTML = "<img src='http://site.supercuffs.com/newstore/images/loading.gif'><br>Adding product(s) to Cart...";
		newcount = 0;
		snap_addtocart_message(pos);	

}

function snap_addtocart_message(pos)
{
		if(newcount < 7)
		{
			t = setTimeout("snap_addtocart_message(" + pos + ")",2000);

		}
		else
		{
			document.getElementById("message" + pos).innerHTML = "";
			document.getElementById("shopframe").innerHTML = "<iframe src='https://p7.secure.hostingprod.com/@supercuffs.com/ssl/newstore/scripts/cookieget.html' width='80' allowtransparency='100%' height='20' frameborder='0' style='margin-top: 3px;' name='flotingframe'  id='flotingframe'></iframe>";
			clearTimeout(t);
		}
		newcount++;
}


function snap_start(pos)
{
	ld = true;
	newcount = 0;
	loading(pos);
}

function loading(pos)
{
		count = 0;
		
		
		bln = true;
		if(ld == true)
		{
			if(newcount == 0)
			{
				setIntDn = setInterval("dissolve_in()",100);
			}
			popupbox = document.getElementById("loading");
			
			width = screen.width;
			width = (width - 400)/2;
			document.getElementById("loading").style.left = Number(width) + "px";
			
			height = findscrollpos();
			document.getElementById("loading").style.top = Number(height + 20) + "px";
			
			
			popupbox.style.display='block';
			//document.getElementById("fade").style.display="block";
			t = setTimeout("loading(" + pos + ")", 1000);
			num = 0;

		}
		else
		{
			clearTimeout(t);
			document.getElementById("loading").style.display = 'none';
			appear_box(pos);
		}
	
		newcount++;
		if(newcount == 5)
		{
			ld = false;
		}
}
	
function dissolve_in(){
	popupbox.style.opacity = num/100;
	//popupbox.style.filter='alpha(opacity='+num+')';
	if(num < 110){num=num+15;}
	else{clearInterval(setIntDn);}
}

function temp(pos)
{
	document.getElementById('snapshot' + pos).style.display='none';
	//document.getElementById('fade').style.display='none';
	clearInterval(t);
	ld=true;
	newcount = 0;
}



function findscrollpos()
{
	var ScrollTop = document.body.scrollTop;

 

	if (ScrollTop == 0)

	{

	    if (window.pageYOffset)

    	    ScrollTop = window.pageYOffset;
	
	    else

    	    ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;

	}
	return ScrollTop;
}