
// JavaScript Document
if (window.attachEvent) window.attachEvent("onload", setup_page);
else window.addEventListener("DOMContentLoaded", setup_page, false);

function setup_page()
{
	gel('bnav1').href='javascript:void(0);';
	gel('bnav2').href='javascript:void(0);';
}

function juggle_ads(direc)
{
	$imgl=Array("http://shop.zappies.com/toys/laq/","http://shop.zappies.com/nintendo/","http://shop.zappies.com/top-gear/","http://shop.zappies.com/toys/my-little-sandbox/","http://shop.zappies.com/gadgets/wowwee/rovio.html","http://shop.zappies.com/toys/zhu-zhu/");
	$imgi=Array("http://shop.zappies.com/images/laq.png","http://shop.zappies.com/images/nintendo.png","http://shop.zappies.com/images/topgear.png","http://shop.zappies.com/images/sandbox.png","http://shop.zappies.com/images/right-160-banner/rovio.png","http://shop.zappies.com/images/right-160-banner/zuzuhamp.jpg");
	i=0;
	while(!(gel('rbanl').href==$imgl[i])&&i<5)
	{
		i++;
	}
	if(direc==1)
	{
		i--;
		if(i<0){i=5; }
		gel('rbanl').href=$imgl[i];
		gel('rbani').src=$imgi[i];
	}
	else if(direc==2)
	{
		i++;
		if(i>5){i=0; }
		gel('rbanl').href=$imgl[i];
		gel('rbani').src=$imgi[i];
	}
}

function movesheet(direc)
{
	if(direc==0)
	{
		//next sheet
		ml.val=0;
		movetotop();
	}
	else if(direc==1)
	{
		ml.val=0;
		movefromtop();
		//previous sheet
	}
}

function movetotop()
{
	ml.val=ml.val-1;
	gel('sheet'+cursheet.val).style.marginTop=ml.val+'px';
	if(ml.val>-40)
	{
		setTimeout("movetotop();",10);
	}
	else
	{
		ml.val=-40;
		gel('sheet'+cursheet.val).style.display='none';
		cursheet.val=cursheet.val+1;
		if(cursheet.val>4)
		{
			cursheet.val=1;
		}
		ajaxRemeSheet(cursheet.val);
		gel('sheet'+cursheet.val).style.display='block';
		movetotopb();
	}
}

function movetotopb()
{
	ml.val=ml.val+1;
	gel('sheet'+cursheet.val).style.marginTop=ml.val+'px';
	if(ml.val<0)
	{
		setTimeout("movetotopb();",10);
	}
}

function movefromtop()
{
	ml.val=ml.val-1;
	gel('sheet'+cursheet.val).style.marginTop=ml.val+'px';
	if(ml.val>-40)
	{
		setTimeout("movefromtop();",10);
	}
	else
	{
		ml.val=-40;
		gel('sheet'+cursheet.val).style.display='none';
		cursheet.val=cursheet.val-1;
		if(cursheet.val<1)
		{
			cursheet.val=4;
		}
		ajaxRemeSheet(cursheet.val);
		gel('sheet'+cursheet.val).style.display='block';
		movefromtopb();
	}
}

function movefromtopb()
{
	ml.val=ml.val+1;
	gel('sheet'+cursheet.val).style.marginTop=ml.val+'px';
	if(ml.val<0)
	{
		setTimeout("movefromtopb();",10);
	}
}

function public_var(variin)
{
	this.val=variin;
}
var ml = new public_var(0);
var cursheet = new public_var(1);

function gel(rabies)
{
	return document.getElementById(rabies);
}

if (window.attachEvent) window.attachEvent("onload", prep_feedback);
else window.addEventListener("DOMContentLoaded", prep_feedback, false);

function prep_feedback()
{
	//feedback
	gel('feedback').href='javascript: void(0);';
	gel('feedback_cancel').href='javascript: void(0);';	
}

function feedback_open()
{
	gel('newbg').style.display='block';
	gel('feedback_box').style.display='block';
}

function cancel_feedback()
{
	gel('feedback_box').style.display='none';
	gel('newbg').style.display='none';
}
// ---------------------------------------------
// --- Name:    Easy DHTML Treeview           --
// --- Author:  D.D. de Kerf                  --
// --- Version: 0.1           Date: 6-6-2001  --
// ---------------------------------------------
function Toggle(node)
{
	// Unfold the branch if it isn't visible
	if (node.nextSibling.style.display == 'none')
	{
		// Change the image (if there is an image)
		if (node.children.length > 0)
		{
			if (node.children.item(0).tagName == "IMG")
			{
				node.children.item(0).src = "/js/treeIcon/minus.gif";
			}
		}

		node.nextSibling.style.display = '';
	}
	// Collapse the branch if it IS visible
	else
	{
		// Change the image (if there is an image)
		if (node.children.length > 0)
		{
			if (node.children.item(0).tagName == "IMG")
			{
				node.children.item(0).src = "/js/treeIcon/plus.gif";
			}
		}

		node.nextSibling.style.display = 'none';
	}

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////

function ajaxRemeSheet(sheetNo)
{
	url = 'http://shop.zappies.com/js/reme_sheet.php?id='+sheetNo;
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
}
