function DrawToolbar(in_currWizardID, in_currPageIndex)
{		
	if(swfobject.hasFlashPlayerVersion("6.0.0"))
	{		
		var fn = function() 
		{
			var c = document.getElementById("toolbar");
			if (!c) 
			{
				var d = document.createElement("div");
				d.setAttribute("id", "toolbar");
				document.getElementById("toolbar_container").appendChild(d);
			}
				
			var flashvars = {oldPageIndex: LAST_selected_page};			
			if(in_currWizardID >= 0 && in_currPageIndex >= 0)		
			{
				flashvars = {oldPageIndex: LAST_selected_page, currWizardID: in_currWizardID, currPageIndex: in_currPageIndex};								
			}							
			var params = {};
			var attributes = { id: "toolbar", name: "toolbar" }; 		
			swfobject.embedSWF("toolbar.swf", "toolbar", "160", "246", "8", false, flashvars, params, attributes);								
		}
		swfobject.addDomLoadEvent(fn);
	};	
	
	LAST_selected_page = in_currPageIndex;		
}
// ===============================================================================================
	

function KikToolbar()
{
	var obj = swfobject.getObjectById("toolbar");
	if(obj) 
	{
		swfobject.removeSWF("toolbar");
	}					
}
// ===============================================================================================


function AlignOverlay()
{
	document.all["wizard_container"].style.top = 0;
	document.all["wizard_container"].style.left = (window.document.body.clientWidth - 800) / 2;
}
// ===============================================================================================

function ShowFlashLayers(style_name)
{
	var hide_layers = new Array("toolbar_layer", "banner_layer", "offers_layer", "content_layer", "exchange_banner");	 
	for(var i = 0; i<hide_layers.length; i++)
	{
		var this_layer = document.getElementById(hide_layers[i]);				
		if(this_layer != null)
		{						
			this_layer.className = style_name;					
		}	
		if(style_name == '')
		{
			this_layer.style.visibility = 'visible';			
		}
	}						
}
// ===============================================================================================


function PositionShadow()
{	
	var shadow_layer = document.getElementById("shadow_layer");
	
	shadow_layer.style.width = (window.document.body.clientWidth);	
	shadow_layer.style.height = (window.document.body.clientHeight);				
	
	if(shadow_layer.style.visibility == "visible")
	{		
      	shadow_layer.style.top = document.body.scrollTop;
      	shadow_layer.style.left = document.body.scrollLeft;
	}		
}
// ===============================================================================================


function ShowShadowLayer()
{
	AlignOverlay();		
		
	ShowFlashLayers("hidden_layer");	
		
	
	var shadow_layer = document.getElementById("shadow_layer");	
	shadow_layer.style.visibility = "visible";		
	PositionShadow();		
}
// ===============================================================================================


function HideShadowLayer()
{
	ShowFlashLayers("");	
									
	//DrawToolbar(newWizardID, newPageIndex);				
	
	var shadow_layer = document.getElementById("shadow_layer");	
	shadow_layer.style.visibility = "hidden";
}	
// ===============================================================================================


function ActivateWizard(currWizardID, PageIndex)
{	
	// Show notepad	
	var c = document.getElementById("wizard");
	if (!c) 
	{
		var d = document.createElement("div");
		d.setAttribute("id", "wizard");
		document.getElementById("wizard_container").appendChild(d);
	}			
	
	var att = { data:"wizard.swf", width:"800", height:"610" };	
	var par = { flashvars: "currWizardID=" + currWizardID + "&currPageIndex=" + PageIndex};
	var id = "wizard";	
	swfobject.createSWF(att, par, id);	
	
	KikToolbar();
		
	// Show shadow & hide all flash items		
	ShowShadowLayer()			
}
// ===============================================================================================

function DeactivateWizard(newWizardID, newPageIndex, forwardUrl)
{					
	// Save wizard bookmark
	var url = "utils/save_wizard.php?currWizardID=" + newWizardID + "&currPageIndex="  + newPageIndex;	
	document.getElementById("save_wizard_layer").src = url;	
	alert(url);
	
	// Redirect, if requested
	if(forwardUrl != "")
	{
		document.location.href = forwardUrl;
		exit;
	}
	
	// Remove notepad		
	var obj1 = swfobject.getObjectById("wizard");
	if(obj1) 
	{
		swfobject.removeSWF("wizard");
	}	
	
	DrawToolbar(newWizardID, newPageIndex);	
	
	// Hide shadow & show all hidden elements
	HideShadowLayer();		
}
// ===============================================================================================


function ShowSplashScreen()
{	
	// Show notepad	
	var c = document.getElementById("wizard");
	if (!c) 
	{
		var d = document.createElement("div");
		d.setAttribute("id", "wizard");
		document.getElementById("wizard_container").appendChild(d);
	}				
	var att = { data:"flash/splash.swf", width:"800", height:"610" };	
	var par = { }; // flashvars: "currWizardID=" + currWizardID + "&currPageIndex=" + PageIndex};
	var id = "wizard";	
	swfobject.createSWF(att, par, id);	
	
	
	ShowShadowLayer();
}
// ===============================================================================================


function HideSplashScreen()
{
	var obj1 = swfobject.getObjectById("wizard");
	if(obj1) 
	{
		swfobject.removeSWF("wizard");
	}		
	HideShadowLayer(-1, -1);	
}
// ===============================================================================================

