var LCImageMap_BaseImageX = 0;
var LCImageMap_BaseImageY = 0;
var LCImageMap_OutDelay = 300;

function LCImageMap_PrepareHottextActions(iNumber)
{
	var strNumber = String(LCLib_NumberFormat(iNumber, 4, "0"));
	var strLayerName = 'objLayerHottext' + strNumber;
	
	var objNewSequenceOver = new LCSequence();
	var objNewSequenceOut = new LCSequence();
	var objTempSequence = new LCSequence();
	
	for(var i = 0; i < Hotspots[iNumber].hottext.actions.length; i++)
	{
		strAction = Hotspots[iNumber].hottext.actions[i];
		
		Hotspots[i].hideTimeout = null;
		
		var objTempAction = null;
		var objAddActionOver = null;
		var objAddActionOut = null;
		
		if(strAction == 'fade')
		{
			objTempAction = new LCAction(0, 1, eval(strLayerName), 'fade', 100, 100);
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'fade', 100, 0);
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'fade', 0, 100);
		}		
		else if(strAction == 'move')
		{
			var startX, startY, endX, endY;
			endX = Hotspots[iNumber].hottext.x;
			endY = Hotspots[iNumber].hottext.y;
			startX = endX - (Hotspots[iNumber].hottext.width / 2);
			startY = endY - (Hotspots[iNumber].hottext.height / 2);
			
			objTempAction = new LCAction(0, 1, eval(strLayerName), 'moveFromTo', startX, startY, endX, endY);
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'moveFromTo', startX, startY, endX, endY);
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'moveFromTo', endX, endY, startX, startY);
		}
		else if(strAction.substr(0, 4) == 'glow')
		{
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'glow', 1, 20, '#' + strAction.substr(4));
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'glow', 20, 1, '#' + strAction.substr(4));
		}
		else if(strAction == 'motionblur')
		{
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'motionblur', 0, Hotspots[iNumber].hottext.width / 4, 315, true);


			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'motionblur', Hotspots[iNumber].hottext.width / 4, 0, 315, true);
		}
		else if(strAction == 'blur')
		{
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'blur', 20, 0, false, 0);
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'blur', 0, 20, false, 0);
		}
			
		if(objTempAction != null)
			objTempSequence.addAction(objTempAction);
		
		if(objAddActionOut != null)
			objNewSequenceOut.addAction(objAddActionOut);
			
		if(objAddActionOver != null)
			objNewSequenceOver.addAction(objAddActionOver);
	}
	
	objNewSequenceOver.addAction(new LCAction(0, 0, eval(strLayerName), 'show'));
	
	if(objNewSequenceOut.actions.length > 0)
		objNewSequenceOut.addAction(new LCAction(5, 5, eval(strLayerName), 'hide'));
	else
		objNewSequenceOut.addAction(new LCAction(0, 0, eval(strLayerName), 'hide'));
	
	if(typeof(Hotspots[iNumber].hottext) != 'undefined')
		Hotspots[iNumber].hottext.sequenceover = objNewSequenceOver;
		
	if(typeof(Hotspots[iNumber].hottext) != 'undefined')
		Hotspots[iNumber].hottext.sequenceout = objNewSequenceOut;
	
	objTempSequence.play();
}

function LCImageMap_PrepareHotimageActions(iNumber)
{
	var strNumber = String(LCLib_NumberFormat(iNumber, 4, "0"));
	var strLayerName = 'objLayerHotimage' + strNumber;
	var strImageName = 'objImageHotimage' + strNumber;
	
	var objNewSequenceOver = new LCSequence();
	var objNewSequenceOut = new LCSequence();
	var objTempSequence = new LCSequence();
	
	for(var i = 0; i < Hotspots[iNumber].hotimage.actions.length; i++)
	{
		strAction = Hotspots[iNumber].hotimage.actions[i];
		
		var objTempAction = null;
		var objAddActionOver = null;
		var objAddActionOut = null;
		
		if(strAction == 'fade')
		{
			objTempAction = new LCAction(0, 1, eval(strLayerName), 'fade', 100, 100);
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'fade', 100, 0);
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'fade', 0, 100);
		}		
		else if(strAction == 'move')
		{
			var startX, startY, endX, endY;
			endX = Hotspots[iNumber].hotimage.x;
			endY = Hotspots[iNumber].hotimage.y;
			startX = endX - (Hotspots[iNumber].hotimage.width / 2);
			startY = endY - (Hotspots[iNumber].hotimage.height / 2);
			
			objTempAction = new LCAction(0, 1, eval(strLayerName), 'moveFromTo', startX, startY, endX, endY);
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'moveFromTo', startX, startY, endX, endY);
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'moveFromTo', endX, endY, startX, startY);
		}
		else if(strAction.substr(0, 4) == 'glow')
		{
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'glow', 1, 20, '#' + strAction.substr(4));
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'glow', 20, 1, '#' + strAction.substr(4));
		}
		else if(strAction == 'resize')
		{
			objTempAction = new LCAction(0, 1, eval(strImageName), 'resize', 0, 0, 0, 0);
			objAddActionOver = new LCAction(0, 5, eval(strImageName), 'resize',
						0, 0, Hotspots[iNumber].hotimage.width, Hotspots[iNumber].hotimage.height);
			objAddActionOut = new LCAction(0, 5, eval(strImageName), 'resize',
						Hotspots[iNumber].hotimage.width, Hotspots[iNumber].hotimage.height, 0, 0);
		}
		else if(strAction == 'motionblur')
		{
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'motionblur', 0, Hotspots[iNumber].hotimage.width / 4, 315, true);
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'motionblur', Hotspots[iNumber].hotimage.width / 4, 0, 315, true);


		}
		else if(strAction == 'blur')
		{
			objAddActionOver = new LCAction(0, 5, eval(strLayerName), 'blur', 20, 0, false, 0);
			objAddActionOut = new LCAction(0, 5, eval(strLayerName), 'blur', 0, 20, false, 0);
		}
			
		if(objTempAction != null)
			objTempSequence.addAction(objTempAction);
		
		if(objAddActionOut != null)
			objNewSequenceOut.addAction(objAddActionOut);
			
		if(objAddActionOver != null)
			objNewSequenceOver.addAction(objAddActionOver);
	}
	
	objNewSequenceOver.addAction(new LCAction(0, 0, eval(strLayerName), 'show'));
	
	if(objNewSequenceOut.actions.length > 0)
		objNewSequenceOut.addAction(new LCAction(5, 5, eval(strLayerName), 'hide'));
	else
		objNewSequenceOut.addAction(new LCAction(0, 0, eval(strLayerName), 'hide'));
	
	if(typeof(Hotspots[iNumber].hotimage) != 'undefined')
		Hotspots[iNumber].hotimage.sequenceover = objNewSequenceOver;
		
	if(typeof(Hotspots[iNumber].hotimage) != 'undefined')
		Hotspots[iNumber].hotimage.sequenceout = objNewSequenceOut;
	
	objTempSequence.play();
}

function LCImageMap_LCImageMapStart()
{
	objLayerBaseImage = new LCLayer("baseimagelayer", LCImageMap_BaseImageX, LCImageMap_BaseImageY, null, null, null, null, true, null, null, null, 0);
	objImageBaseImage = new LCImage("baseimageimage", "images/cold.jpg");
	objLayerBaseImage.addChild(objImageBaseImage);
	objLayerBaseImage.create();

	for(var i = 0; i < Hotspots.length; i++)
	{
		strNumber = String(LCLib_NumberFormat(i, 4, "0"));
		
		strLayer = 'objLayerHotspot' + strNumber + ' = new LCLayer("hotspot' + strNumber + 'layer", ' + Hotspots[i].x;
		strLayer += ', ' + Hotspots[i].y + ', null, null, null, null, false, null, null, null, 5';
		strLayer += ');';
		
		strLayerPixempty = 'objLayerHotspotPixempty' + strNumber + ' = new LCLayer("hotspotpixempty' + strNumber + 'layer", ' + Hotspots[i].x;
		strLayerPixempty += ', ' + Hotspots[i].y + ', null, null, null, null, true, null, null, null, 900';
		strLayerPixempty += ');';
		
		strImage = 'objImageHotspot' + strNumber + ' = new LCImage("hotspot' + strNumber + 'image", ';
		strImage += '"' + Hotspots[i].source + '", ' + Hotspots[i].width + ', ' + Hotspots[i].height + ');';
		
		strImagePixempty = 'objImageHotspotPixempty' + strNumber + ' = new LCImage("hotspotpixempty' + strNumber + 'image", ';
		strImagePixempty += '"pixempty.gif", ' + Hotspots[i].width + ', ' + Hotspots[i].height + ', ';
		strImagePixempty += '"' + Hotspots[i].tooltip + '", 0, "' + Hotspots[i].linkurl + '", "' + Hotspots[i].linktarget + '", "LCImageMap_onOverHotspot(\'' + i + '\');", "LCImageMap_onOutHotspot(\'' + i + '\')"';
		strImagePixempty += ');';
	
		strAddChild = 'objLayerHotspot' + strNumber + '.addChild(objImageHotspot' + strNumber + ');';
		strAddChildPixempty = 'objLayerHotspotPixempty' + strNumber + '.addChild(objImageHotspotPixempty' + strNumber + ');';
		
		strCreate = 'objLayerHotspot' + strNumber + '.create();';
		strCreatePixempty = 'objLayerHotspotPixempty' + strNumber + '.create();';
		
		
		eval(strLayer);
		eval(strLayerPixempty);
		eval(strImage);
		eval(strImagePixempty);
		eval(strAddChild);
		eval(strAddChildPixempty);
		eval(strCreate);
		eval(strCreatePixempty);
		
		if(typeof(Hotspots[i].hotimage) == 'object')
		{
			strLayerHotimage = 'objLayerHotimage' + strNumber + ' = new LCLayer("hotimage' + strNumber + 'layer", ' + Hotspots[i].hotimage.x;
			strLayerHotimage += ', ' + Hotspots[i].hotimage.y + ', null, null, null, null, false, null, null, null, 6, "LCImageMap_onOverHotImage(\'' + i + '\');", "LCImageMap_onOutHotImage(\'' + i + '\');"';
			strLayerHotimage += ');';
			strImageHotimage = 'objImageHotimage' + strNumber + ' = new LCImage("hotimage' + strNumber + 'image", ';
			strImageHotimage += '"' + Hotspots[i].hotimage.source + '", ' + Hotspots[i].hotimage.width + ', ' + Hotspots[i].hotimage.height + ');';
			strAddChildHotimage = 'objLayerHotimage' + strNumber + '.addChild(objImageHotimage' + strNumber + ');';
			strCreateHotimage = 'objLayerHotimage' + strNumber + '.create();';
			eval(strLayerHotimage);
			eval(strImageHotimage);
			eval(strAddChildHotimage);
			eval(strCreateHotimage);
			LCImageMap_PrepareHotimageActions(i);
		}
		
		if(typeof(Hotspots[i].hottext) == 'object')
		{
			strLayerHottext = 'objLayerHottext' + strNumber + ' = new LCLayer("hottext' + strNumber + 'layer", ' + Hotspots[i].hottext.x;
			strLayerHottext += ', ' + Hotspots[i].hottext.y + ', "' + Hotspots[i].hottext.text + '", ' + Hotspots[i].hottext.width;
			strLayerHottext += ', ' + Hotspots[i].hottext.height + ', "' + Hotspots[i].hottext.backgroundcolor;
			strLayerHottext += '", false, 2, "' + Hotspots[i].hottext.bordercolor + '", "solid", 6, "LCImageMap_onOverHotText(\'' + i + '\');", "LCImageMap_onOutHotText(\'' + i + '\');")';
			
			strCreateHottext = 'objLayerHottext' + strNumber + '.create();';
			
			strPaddingHottext = 'objLayerHottext' + strNumber + '.css.padding = "5px";';
			
			eval(strLayerHottext);
			eval(strCreateHottext);
			eval(strPaddingHottext);
			
			LCImageMap_PrepareHottextActions(i);
		}
	}
	
	for(i = 0; i < Texts.length; i++)
	{
		strNumber = String(LCLib_NumberFormat(i, 4, "0"));
		
		strBorderStyle = 'none';
		iBorderWidth = 0;
		strBorderColor = 'transparent';
		if(Texts[i].useborder == 1)
		{
			strBorderStyle = 'solid';
			iBorderWidth = 2;
			strBorderColor = Texts[i].bordercolor;
		}
		
		strBackgroundColor = 'transparent';
		if(Texts[i].usebackground == 1)
		{
			strBackgroundColor = Texts[i].backgroundcolor;
		}
		
		strLayerText = 'objLayerText' + strNumber + ' = new LCLayer("text' + strNumber + 'layer", ' + Texts[i].x;
		strLayerText += ', ' + Texts[i].y + ', "' + Texts[i].text + '", ' + Texts[i].width;
		strLayerText += ', ' + Texts[i].height + ', "' + strBackgroundColor;
		strLayerText += '", true, ' + iBorderWidth + ', "' + strBorderColor + '", "' + strBorderStyle + '", ' + (700+i) + ')';
		
		strCreateText = 'objLayerText' + strNumber + '.create()';
		
		strPaddingText = 'objLayerText' + strNumber + '.css.padding = "5px";';
	
		eval(strLayerText);
		eval(strCreateText);
		eval(strPaddingText);
	}
}

function LCImageMap_onOverHotspot(iNumber)
{
	for(i = 0; i < Hotspots.length; i++)
	{
		if(i != iNumber && Hotspots[i].hideTimeout != null)
		{
			clearInterval(Hotspots[i].hideTimeout);
			Hotspots[i].hideTimeout = null;
			LCImageMap_realOutHotspot(i);
		}
	}
	
	if(Hotspots[iNumber].hideTimeout != null)
	{
		clearInterval(Hotspots[iNumber].hideTimeout);
		Hotspots[iNumber].hideTimeout = null;		
		
		return;
	}
	
	strNumber = String(LCLib_NumberFormat(iNumber, 4, "0"));

	strShowLayer = 'objLayerHotspot' + strNumber + '.show();';
	eval(strShowLayer);

	if(typeof(Hotspots[iNumber].hotimage) != 'undefined' && Hotspots[iNumber].hotimage.runningsequence != null)
	{
		Hotspots[iNumber].hotimage.runningsequence.stop();
	}
		
	if(typeof(Hotspots[iNumber].hottext) != 'undefined' && Hotspots[iNumber].hottext.runningsequence != null)
	{
		Hotspots[iNumber].hottext.runningsequence.stop();
	}
		
	if(typeof(Hotspots[iNumber].hotimage) != 'undefined')
	{
		Hotspots[iNumber].hotimage.sequenceover.play();
	}
		
	if(typeof(Hotspots[iNumber].hottext) != 'undefined')
	{
		Hotspots[iNumber].hottext.sequenceover.play();
	}
		
	if(typeof(Hotspots[iNumber].hotimage) != 'undefined')
	{
		Hotspots[iNumber].hotimage.runningsequence = Hotspots[iNumber].hotimage.sequenceover;
	}
		
	if(typeof(Hotspots[iNumber].hottext) != 'undefined')
	{
		Hotspots[iNumber].hottext.runningsequence = Hotspots[iNumber].hottext.sequenceover;
	}
}

function LCImageMap_realOutHotspot(iNumber)
{
	if(Hotspots[iNumber].hideTimeout != null)
	{
		clearInterval(Hotspots[iNumber].hideTimeout);
		Hotspots[iNumber].hideTimeout = null;
	}	
	
	strNumber = String(LCLib_NumberFormat(iNumber, 4, "0"));
	
	strHideLayer = 'objLayerHotspot' + strNumber + '.hide();';
	eval(strHideLayer);
	
	if(typeof(Hotspots[iNumber].hotimage) != 'undefined' && Hotspots[iNumber].hotimage.runningsequence != null)
	{
		Hotspots[iNumber].hotimage.runningsequence.stop();
	}
		
	if(typeof(Hotspots[iNumber].hottext) != 'undefined' && Hotspots[iNumber].hottext.runningsequence != null)
	{
		Hotspots[iNumber].hottext.runningsequence.stop();
	}
		
	if(typeof(Hotspots[iNumber].hotimage) != 'undefined')
	{
		Hotspots[iNumber].hotimage.sequenceout.play();
	}
		
	if(typeof(Hotspots[iNumber].hottext) != 'undefined')
	{
		Hotspots[iNumber].hottext.sequenceout.play();
	}
	
	if(typeof(Hotspots[iNumber].hotimage) != 'undefined')
	{
		Hotspots[iNumber].hotimage.runningsequence = Hotspots[iNumber].hotimage.sequenceout;
	}
		
	if(typeof(Hotspots[iNumber].hottext) != 'undefined')
	{
		Hotspots[iNumber].hottext.runningsequence = Hotspots[iNumber].hottext.sequenceout;
	}
}

function LCImageMap_onOutHotspot(iNumber)
{
	Hotspots[iNumber].hideTimeout = setInterval('LCImageMap_realOutHotspot(' + iNumber + ');', LCImageMap_OutDelay);
}

function LCImageMap_onOverHotImage(iNumber)
{
	if(Hotspots[iNumber].hideTimeout != null)
	{
		clearInterval(Hotspots[iNumber].hideTimeout);
		Hotspots[iNumber].hideTimeout = null;
	}
}

function LCImageMap_onOutHotImage(iNumber)
{
	Hotspots[iNumber].hideTimeout = setInterval('LCImageMap_realOutHotspot(' + iNumber + ');', LCImageMap_OutDelay);
}

function LCImageMap_onOverHotText(iNumber)
{
	if(Hotspots[iNumber].hideTimeout != null)
	{
		clearInterval(Hotspots[iNumber].hideTimeout);
		Hotspots[iNumber].hideTimeout = null;
	}
}

function LCImageMap_onOutHotText(iNumber)
{
	Hotspots[iNumber].hideTimeout = setInterval('LCImageMap_realOutHotspot(' + iNumber + ');', LCImageMap_OutDelay);
}


