/*
 =MONXTOOLS
*/

/*
	MonxTools for MooTools
	by Robert Slootjes - MediaMonks, www.mediamonks.com
	Copyright 2007

	version history:

	v1.11 (09/10/2007)
	- custom textarea changed, now its possible to make toggle the size with a custom image

	v1.1 : (08/10/2007)
	- custom dropdown
	- custom radiobutton is rewritten
	- custom checkbox is rewritten
	- custom textarea added

	v1.0 : (initial version, date unknown...)
	- user friendly popup; monxbox
	- custom radiobutton
	- custom checkbox

*/

/************************************************************************************************************
 *
 *	showMonxBox
 *
 *  usage:
 *	onclick="showMonxBox('http://www.mediamonks.com/', '800', '600');"
 *
************************************************************************************************************/
function showMonxBox(strUrl, intWidth, intHeight, strTitle, blnDisableClose)
{
	new Fx.Style($('ufoverlay'), 'opacity').start(0, 1);
	new Fx.Style($('ufoverlay1'), 'opacity').start(0, 0.75);
	var intPageWidth			= getWidth();
	var intPageHeight			= getHeight();
	var intPageScrollHeight		= getScrollHeight();
	var intScrollTop			= getScrollTop();

	intCloseHeight = 27;

	objDivContent = new Element('div');
	objDivContent.setProperty('id', 'overlay-page');
	objDivContent.setStyle('position', 'relative');
	objDivContent.setStyle('width', intWidth + 'px');
	if(blnDisableClose != false)
	{
		objDivContent.setStyle('height', (parseInt(intHeight) + parseInt(intCloseHeight)) + 'px');
	}
	else
	{
		objDivContent.setStyle('height', intHeight + 'px');
	}
	objDivContent.setStyle('left', ((intPageWidth / 2) - (intWidth / 2)) + 'px');
	objDivContent.setStyle('top', ((intScrollTop + (intPageHeight / 2)) - (intHeight / 2)) + 'px');
	objDivContent.setStyle('background-color', '#FFFFFF');
	objDivContent.setStyle('border', '1px solid #0F2235');
	objDivContent.injectInside($('ufoverlay'));

	if(blnDisableClose != false)
	{
		objHeader = new Element('div');
		objHeader.setStyle('position', 'relative');
		objHeader.setStyle('cursor', 'move');
		objHeader.setStyle('width', (intWidth - 10) + 'px');
		objHeader.setStyle('height', intCloseHeight + 'px');
		objHeader.setStyle('background-image', 'url(../images/admin/monxbog_bg.gif)');
		objHeader.setStyle('color', '#FFFFFF');
		objHeader.setStyle('padding', '10px 0px 0px 10px');

		objHeader.injectInside(objDivContent);

		objTitle = new Element('span');
		objTitle.setStyle('font-family', 'Verdana');
		objTitle.setStyle('font-size', '16px');
		objTitle.setStyle('font-weight', 'bold');
		objTitle.appendText(strTitle);
		objTitle.injectInside(objHeader);

		objImage = new Element('img');
		objImage.setProperty('src', 'images/admin/monxbox_close.gif');
		objImage.setStyle('cursor', 'pointer');
		objImage.setStyle('position', 'absolute');
		objImage.setStyle('top', '0px');
		objImage.setStyle('right', '3px');
		objImage.addEvent('click', function(){closeMonxBox()});
		objImage.injectInside(objHeader);

		var draggableOptions = {
		    handle:function()
		    {
		      $('objHeader');
		    }
		};

		objDivContent.makeDraggable(draggableOptions);
	}

	objIframe = new Element('iframe');
	objIframe.setProperty('src', strUrl);
	objIframe.setProperty('frameborder', '0');
	objIframe.setStyle('width', intWidth + 'px');
	objIframe.setStyle('height', intHeight + 'px');
	objIframe.injectInside(objDivContent);

}

function closeMonxBox()
{
	new Fx.Style($('ufoverlay'), 'opacity', {duration:500, onComplete: function(){ $('overlay-page').remove() } }).start(1, 0);
	new Fx.Style($('ufoverlay1') , 'opacity').start(0.75, 0);
}

function createMonxBox()
{
	var objBogus	= new Element('div');
	objBogus.setProperty('id', 'ufoverlay1');
	objBogus.setStyle('position', 'absolute');
	objBogus.setStyle('left', '0px');
	objBogus.setStyle('width', '100%');
	objBogus.setStyle('opacity', '0');
	objBogus.setStyle('z-index', '5');
	objBogus.setStyle('background-color', '#0F2235');
	objBogus.setStyles({top: '0px', height: getScrollHeight() +'px'});
	objBogus.injectInside(document.body);

	var objDivMain	= new Element('div');
	objDivMain.setProperty('id', 'ufoverlay');
	objDivMain.setStyle('position', 'absolute');
	objDivMain.setStyle('left', '0px');
	objDivMain.setStyle('width', '100%');
	objDivMain.setStyle('opacity', '0');
	objDivMain.setStyle('z-index', '15');
	objDivMain.setStyles({top: '0px', height: getScrollHeight() +'px'});
	objDivMain.injectInside(document.body);
}


/************************************************************************************************************
 *
 *	customCheckbox
 *
 *  usage:
 *	customCheckbox('CheckboxClass', 'check.png', 'delete.png' );
 *
************************************************************************************************************/
function customCheckbox(argInputClass, strCheckedImage, strUncheckedImage)
{
	$$('input.' + argInputClass).each(function(objCheckbox)
	{
		objCheckbox.setStyle('display', 'none');
		objCheckbox.objImage = new Element('img');

		if(objCheckbox.checked == true)
		{
			objCheckbox.objImage.src = strCheckedImage;
		}
		else
		{
			objCheckbox.objImage.src = strUncheckedImage;
		}

		objCheckbox.objImage.addEvent('click', function()
		{
			if(objCheckbox.checked == true)
			{
				objCheckbox.objImage.src				= strUncheckedImage;
				objCheckbox.checked			= false;
				objCheckbox.defaultChecked	= false;
			}
			else
			{
				objCheckbox.objImage.src				= strCheckedImage;
				objCheckbox.checked			= true;
				objCheckbox.defaultChecked	= true;
			}
		});

		objCheckbox.objImage.setStyle('cursor', 'pointer');
		objCheckbox.objImage.injectAfter(objCheckbox);
	}
	);
}

/************************************************************************************************************
 *
 *	customRadioButton
 *
 *  usage:
 *	customRadioButton('radioButtonClass', 'check.png', 'delete.png' );
 *
************************************************************************************************************/
function customRadioButton(argInputClass, strCheckedImage, strUncheckedImage)
{
	$$('input.' + argInputClass).each(function(objRadio)
	{
		objRadio.setStyle('display', 'none');
		objRadio.strName = objRadio.getProperty('name');
		objRadio.objImage = new Element('img');

		if(objRadio.checked == true)
		{
			objRadio.objImage.src = strCheckedImage;
		}
		else
		{
			objRadio.objImage.src = strUncheckedImage;
		}

		objRadio.objImage.addEvent('click', function()
		{
			$$('input[name$=' + objRadio.strName + ']').each(function(objRadio2)
			{
				objRadio2.checked = 'false';
				objRadio2.objImage.src = strUncheckedImage;
			});

			objRadio.objImage.src = strCheckedImage;
			objRadio.checked = true;
			objRadio.defaultChecked = true;

		});

		objRadio.objImage.setStyle('cursor', 'pointer');
		objRadio.objImage.injectAfter(objRadio);
	}
	);
}


/************************************************************************************************************
 *
 *	customDropdown
 *
 *  usage:
 *  customDropdown('class', 'base');
 *
************************************************************************************************************/
function customDropdown(argInputClass, argSetClass)
{
	$$('select.' + argInputClass).each(function(objSelect)
	{
		// hide the original select
		objSelect.setStyle('display', 'none');

		// open state
		objSelect.blnOpen = false;

		// function to open options
		objSelect.openOptions = function()
		{
			objCurrentOption.setStyle('z-index', '1');
			objFakeOptions.setStyle('display', 'block');
			objFakeOptions.setStyle('z-index', '999');
			objWrapper.setStyle('z-index', '100');
			objFakeOptions.setStyle('overflow', 'visible');
			objWrapper.addClass(argSetClass + '_open');
		}

		// function to close options
		objSelect.closeOptions = function()
		{
			objFakeOptions.setStyle('display', 'none');
			objFakeOptions.setStyle('overflow', 'hidden');
			objFakeOptions.setStyle('z-index', '1');
			objCurrentOption.setStyle('z-index', '999');
			objWrapper.setStyle('z-index', '1');
			objWrapper.removeClass(argSetClass + '_open');
		}

		objSelect.checkClose = function()
		{
			if(objSelect.blnOpen == false)
    		{
				objSelect.closeOptions();
			}
		}

		// get options
		var objOptions = objSelect.getElements('option');

		// create relative wrapper
		var objWrapper = new Element('div',
		{
			'events':
	    	{
				'click': function()
	        	{
	        		if('none' == objFakeOptions.getStyle('display') && false == objSelect.blnOpen)
	        		{
		        		objSelect.openOptions();
	        		}
	        		else
	        		{
	        			objSelect.closeOptions();
	        		}
	        	}
	    	},
	        'class': argSetClass
		}).injectBefore(objSelect)

		// create the current option and put it in the wrapper
		var objCurrentOption = new Element('div',
		{
		    'events':
	    	{
	        	'mouseleave': function()
	        	{
	        		objSelect.checkClose.delay(500);
	        	}
	    	},
	        'class': 'currentoption'
		}).setHTML(objOptions[objSelect.selectedIndex].innerHTML).injectInside(objWrapper);

		// create option wrapper and put them in the wrapper
		var objFakeOptions = new Element('div',
		{
		    'events':
	    	{
	        	'mouseleave': function()
	        	{
	        		objSelect.blnOpen = false;
	        		objSelect.checkClose.delay(500);
	        	}
	    	},
		    'class': 'options'
		}).injectInside(objWrapper);


		// add the options to the option wrapper
		var a = 1;
		objOptions.each(function(option)
		{
			var objItem = new Element('div',
			{
			    'events':
		    	{
					'mouseenter': function()
		        	{
		        		if(objItem.number == 1)
						{
							objItem.addClass('first_hover');
						}
						else if(objItem.number == objOptions.length)
						{
							objItem.addClass('last_hover');
						}
						else
						{
							objItem.addClass('item_hover');
						}

						objSelect.blnOpen = true;
		        	},
		        	'mouseleave': function()
		        	{
						if(objItem.number == 1)
						{
							objItem.removeClass('first_hover');
						}
						else if(objItem.number == objOptions.length)
						{
							objItem.removeClass('last_hover');
						}
						else
						{
							objItem.removeClass('item_hover');
						}
		        	},
		        	'click': function()
		        	{
		        		objSelect.value = option.value;
		        		objCurrentOption.setHTML(option.text);
		        		objSelect.closeOptions();
		        	}
			    },
		        'class': 'item'
			}).setHTML(option.text).injectInside(objFakeOptions);

			objItem.number = a;

			if(objItem.number == 1)
			{
				objItem.addClass('first');
			}
			else if(objItem.number == objOptions.length)
			{
				objItem.addClass('last');
			}

			a++;
		});

	});
}

function customTextarea(argInputClass, argResizeToWidth, argResizeToHeight, argMaximizeIcon, argMinimizeIcon, argImageWidth, argImageHeight)
{
	$$('textarea.' + argInputClass).each(function(objTextarea)
	{
		objTextarea.intStartHeight = objTextarea.getStyle('height');
		objTextarea.intStartWidth = objTextarea.getStyle('width');
		objTextarea.intStartBorder = objTextarea.getStyle('border');
		//objTextarea.intStartBackground = objTextarea.getStyle('background');
		objTextarea.intStartBackground = 'none';

		objTextarea.strName = objTextarea.getProperty('name');
		objTextarea.strId = objTextarea.getProperty('id');

		var objSizer = new Element('img', {'src': argMaximizeIcon});
		var intImageWidth = argImageWidth;
		var intImageHeight = argImageHeight;
		var intOffset = 4;

		// create a wrapper to hold the textarea
		var objTextareaWrapper = new Element('div',
		{
			'styles':
			{
		        'position': 'relative',
		        'width': parseInt(objTextarea.intStartWidth) - (intImageWidth) + 'px',
		        'height': objTextarea.intStartHeight,
		        'border': 'none',
		        'background': objTextarea.intStartBackground
		    }
		}).injectBefore(objTextarea);

		// create the textarea
		var objNewTextarea = new Element('textarea',
		{
			'name': objTextarea.strName,
			'id': objTextarea.strId,
			'styles':
			{
		        'position': 'absolute',
				'top': '0px',
				'left': '0px',
				'height': parseInt(objTextarea.intStartHeight) - intOffset + 'px',
				'width': parseInt(objTextarea.intStartWidth) - (intImageWidth + intOffset + 1) + 'px',
				'overflow' : 'auto',
				'z-index': '10'
		    }
		}).injectInside(objTextareaWrapper);

		objSizer.setStyles(
		{
			'position': 'absolute',
			'top': '1px',
			'right': '-' + (intImageWidth + intOffset) + 'px',
			'z-index': '999' ,
			'cursor': 'pointer'
		});

		objSizer.addEvent('click', function()
		{
			if(objTextareaWrapper.getStyle('height') == objTextarea.intStartHeight)
    		{
    			objSizer.setProperty('src', argMinimizeIcon);

    			new Fx.Styles(objTextareaWrapper, {duration: 200, transition: Fx.Transitions.linear}).start(
    			{
				    'height': argResizeToHeight,
				    'width': argResizeToWidth
				});

				new Fx.Styles(objNewTextarea, {duration: 200, transition: Fx.Transitions.linear}).start(
				{
				    'height': (argResizeToHeight - intOffset),
				    'width': (argResizeToWidth - intOffset)
				});

    		}
    		else
    		{
    			objSizer.setProperty('src', argMaximizeIcon);

    			new Fx.Styles(objTextareaWrapper, {duration: 200, transition: Fx.Transitions.linear}).start(
    			{
				    'height': objTextarea.intStartHeight,
				    'width': (parseInt(objTextarea.intStartWidth) - intImageWidth)
				});

				new Fx.Styles(objNewTextarea, {duration: 200, transition: Fx.Transitions.linear}).start(
				{
				    'height': (parseInt(objTextarea.intStartHeight) - intOffset),
				    'width': (parseInt(objTextarea.intStartWidth) - (intImageWidth + intOffset))
				});

    		}
		});

		objSizer.setProperty('name', objTextarea.strName);
		objSizer.setProperty('id', objTextarea.strId);

		objSizer.injectInside(objTextareaWrapper);

		objTextarea.remove();
	});

}

// autostart monxbox
window.addEvent('load', function() {createMonxBox()});

/*
	=SCRIPTS.JS
*/


window.addEvent('load', function()
{
	if($('language_state'))
	{
		// language selector fx
		if('true' == $('language_state').innerHTML)
		{
			objElement = $('language_selector');
			objElement.Fx = new Fx.Style(objElement, 'top', {duration:500, transition:Fx.Transitions.quintInOut});
			languageSlideOut.delay(1000, objElement);
		}

		$('language_selector').addEvent('mouseenter', languageSelectorIn);
		$('language_selector').addEvent('mouseleave', languageSelectorOut);
	}
});

function checkAll(argControl, argElement)
{
	var objControl = $(argControl);
	var arrElements = $$(argElement);

	arrElements.each(
		function(objElement)
		{
    	   	if(false == objControl.checked)
			{
    	       	objElement.checked = false;
			}
			else
			{
              	objElement.checked = true;
   			}
		}
	);
}

function delCheckedOrders(argType)
{
	if (confirm('Weet u zeker dat u alle geselecteerde items wilt verwijderen?'))
	{
        // init checked items array
		var arrCheckedItems = new Array();

        // fetch all checkboxes
		var arrCheckBox = $$('input.checkbox');

        var i = 0;

        // get values to fill array
		arrCheckBox.each(
			function(objElement)
			{
	    	   	if(true == objElement.checked)
				{
	    	       	arrCheckedItems[i] = objElement.value;
					++i;
				}
			}
		);

        //console.log(arrCheckedItems);

		var strUrl = strAjaxUrl + 'modules/Servers/common/common?type='+ argType +'&action=delete_checked_orders&items='+ arrCheckedItems +'&fix=' + Math.floor(Math.random() * 1000).toString(36);

		new Ajax(strUrl,
		{
			method: 'get',
			onComplete:function(responseText)
			{
                if ('1' === responseText)
				{
					arrCheckedItems.each(
                    	function(objElement)
						{
							// remove all, but the first (checkall box)
                            if (1 != objElement)
							{
								$('item.'+objElement).remove();
							}
						}
					);
				}
				else if ('2' === responseText)
				{
					document.location.href = document.location.href;
				}
			}
		}).request();
	}
}

function newsIn(objElement)
{
	var mainNavFx = new Fx.Styles(objElement, {duration:150, wait:false});
	mainNavFx.start({
		'padding-left': 30,
		'width': 375,
		'background-color': '#F2F2F2'
	});
}

function newsOut(objElement)
{
	var mainNavFx = new Fx.Styles(objElement, {duration:150, wait:false});
	mainNavFx.start({
		'padding-left': 25,
		'width': 375,
		'background-color': '#FFFFFF'
	});
}

function centerDiv(argStrDiv)
{
	maxheight = document.getElementById('wrapper').offsetHeight;
	maxwidth = document.getElementById('wrapper').offsetWidth;
	divheight = document.getElementById(argStrDiv).offsetHeight;
	divwidth = document.getElementById(argStrDiv).offsetWidth;
	topmargin = (maxheight-divheight)/2;
	leftmargin = (maxwidth-divwidth)/2;
	document.getElementById(argStrDiv).style.marginTop = topmargin + 'px';
	document.getElementById(argStrDiv).style.marginLeft = leftmargin + 'px';
	document.getElementById(argStrDiv).style.visibility = 'visible';
}

function setFocus(argElementId)
{
	document.getElementById(argElementId).focus();
}

function replace(string,text,by)
{
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;
	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;
	var newstr = string.substring(0,i) + by;
	if (i+txtLength < strLength)
	newstr += replace(string.substring(i+txtLength,strLength),text,by);
	return newstr;
}

function logOut()
{
	ht = document.getElementsByTagName("html");
	ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm('Weet u zeker dat u wilt uitloggen?'))
	{
		return true;
	}
	else
	{
		ht[0].style.filter = "";
		return false;
	}
}

function doClear(field)
{
	if (field.value == field.defaultValue)
	{
	 	field.value = "";
	}
}
function resetField(field)
{
	if (field.value == '')
	{
		field.value = field.defaultValue;
	}
}

function printPage()
{
	window.print();
}

function openPopup(argStrFile, argStrFrameName, argIntWidth, argIntHeight, argIntLeftStart, argIntTopStart, argIntScrollbars, argIntResizeable)
{
	if(argStrFrameName == '' || argStrFrameName == undefined)
	{
		argStrFrameName = 'popup';
	}
	if(argIntWidth == '' || argIntWidth == undefined)
	{
		argIntWidth = 530;
	}
	if(argIntHeight == '' || argIntHeight == undefined)
	{
		argIntHeight = 380;
	}
	if(argIntLeftStart == '' || argIntLeftStart == undefined)
	{
		argIntLeftStart = (screen.width/2) - (argIntWidth/2);
	}
	if(argIntTopStart == '' || argIntTopStart == undefined)
	{
		argIntTopStart = (screen.height/2) - (argIntHeight/2);
	}
	if(argIntScrollbars == '' || argIntScrollbars == undefined)
	{
		argIntScrollbars = 'no';
	}
	if(argIntResizeable == '' || argIntResizeable == undefined)
	{
		argIntResizeable = 'no';
	}

	var strProperties = "width=" + argIntWidth + ", height=" + argIntHeight + ", left=" + argIntLeftStart + ", top=" + argIntTopStart + ", toolbar=no, titlebar=no, title=0, location=no, scrollbars=" + argIntScrollbars + ", status=no, resizable=" + argIntResizeable;

	window.open(argStrFile, argStrFrameName, strProperties);
}

function trim(strValue)
{
	strValue = strValue.replace(/^\s+/,'');
	strValue = strValue.replace(/\s+$/,'');

	return strValue;
}

function insertKey(argField)
{
	$(argField).value = 'aNtIsPaMkEy!!11';
}

function languageSlideOut()
{
	objElement.Fx.start(-31);
}

function languageSelector()
{
	objElement = $('language_selector');

    if(!objElement.Fx)
    {
    	objElement.Fx = new Fx.Style(objElement, 'top', {duration:500, transition:Fx.Transitions.quintInOut});
    }

    if('-27px' == objElement.getStyle('top'))
	{
		objElement.Fx.start(0);
	}
	else
	{
		objElement.Fx.start(-27);
	}
}

function languageSelectorIn()
{
	objElement = $('language_selector');

    if(!objElement.Fx)
    {
    	objElement.Fx = new Fx.Style(objElement, 'top', {wait: true, duration:300, transition:Fx.Transitions.quintInOut});
    }

	objElement.Fx.start(0);
}

function languageSelectorOut()
{
	objElement.Fx.start(-39);
}

// handles the toggeling of component categories
var ComponentToggler = new Class({
	initialize:function()
	{
		// handles the toggeling of component categories
		$$('div.component_cat').each(function(objComponentWrapper)
		{
			// get arrow
			objComponentWrapper.objArrow = objComponentWrapper.getElements('div.arrow')[0];
			// get title
			objComponentWrapper.objTitle = objComponentWrapper.getElements('div.title')[0];
			// get wrapper
			objComponentWrapper.objComponents = objComponentWrapper.getElements('div.components')[0];
			// get current height
			objComponentWrapper.objComponents.intHeight = objComponentWrapper.objComponents.getStyle('height');
			// create fx object
			objComponentWrapper.objComponents.fxStyle  = new Fx.Style(objComponentWrapper.objComponents, 'height', {duration:500});
			// set wrapper to overflow hidden
			objComponentWrapper.objComponents.setStyle('overflow', 'hidden');
			// create onclick event
			objComponentWrapper.objTitle.addEvent('click', function()
			{
				// check the current state
				if('0px' == objComponentWrapper.objComponents.getStyle('height'))
				{
					// open the wrapper
					objComponentWrapper.objComponents.fxStyle.start(0, objComponentWrapper.objComponents.intHeight);
					// change the arrow icon
					objComponentWrapper.objArrow.setStyle('background-position', 'bottom left');
				}
				else
				{
					// close the wrapper
					objComponentWrapper.objComponents.fxStyle.start(objComponentWrapper.objComponents.intHeight, 0);
					// change the arrow icon
					objComponentWrapper.objArrow.setStyle('background-position', 'top left');
				}
			});
		});
	}
});


window.addEvent('load', function()
{
	// handles the toggeling of component categories
	if($('product_list'))
	{
		$$('div.product_selection div.product a').each(function(elNode)
		{
			elNode.removeEvents();
			elNode.addEvent('click', function(e)
			{
				new Event(e).stop();
				showConfirmation(this.href, 400, 80, 'Weet u zeker dat u een ander product wilt kiezen?<br />Uw huidige instellingen worden niet opgeslagen.', 'Doorgaan', 'Annuleren');

				return false;
			}.bind(elNode));
		});

		// handles the product selection box
		intSelectionProducts = $$('div.product_selection div.product').length;
		intSelectionFx = new Fx.Style('product_list', 'left', {duration:500});
		intSelectionProductWidth = parseInt($('product_list').getElements('div.product')[0].getStyle('width'));
	}


	// handles the toggeling of component categories
	new ComponentToggler();


	// handles the toggeling of right info blocks
	$$('div.block_wrapper').each(function(objBlockWrapper)
	{
		// get arrow
		objBlockWrapper.objArrow = objBlockWrapper.getElements('div.arrow')[0];
		// get title
		objBlockWrapper.objTitle = objBlockWrapper.getElements('div.title')[0];
		// get wrapper
		objBlockWrapper.objComponents = objBlockWrapper.getElements('div.data')[0];
		// get current height
		objBlockWrapper.objComponents.intHeight = objBlockWrapper.objComponents.getStyle('height');
		// create fx object
		objBlockWrapper.objComponents.fxStyle  = new Fx.Style(objBlockWrapper.objComponents, 'height', {duration:500});
		// set wrapper to overflow hidden
		objBlockWrapper.objComponents.setStyle('overflow', 'hidden');
		// create onclick event
		objBlockWrapper.objTitle.addEvent('click', function()
		{
			// check the current state
			if('0px' == objBlockWrapper.objComponents.getStyle('height'))
			{
				// open the wrapper
	   			objBlockWrapper.objComponents.fxStyle.start(0, objBlockWrapper.objComponents.intHeight);
	   			// change the arrow icon
	   			objBlockWrapper.objArrow.setStyle('background-position', 'bottom left');
			}
			else
			{
				// get height again, it may be different
				objBlockWrapper.objComponents.intHeight = objBlockWrapper.objComponents.getStyle('height');
				// close the wrapper
				objBlockWrapper.objComponents.fxStyle.start(objBlockWrapper.objComponents.intHeight, 0);
				// change the arrow icon
				objBlockWrapper.objArrow.setStyle('background-position', 'top left');
			}
		});

		if(objBlockWrapper.hasClass('closed'))
		{
			// close the wrapper
			objBlockWrapper.objComponents.fxStyle.start(objBlockWrapper.objComponents.intHeight, 0);
			// change the arrow icon
			objBlockWrapper.objArrow.setStyle('background-position', 'top left');
		}
	});

	// handles the realtime pricing of radio buttons
	$$('div.component_cat ul.radio').each(function(objList)
	{
		//console.log( objList );

		// get all items from the current ul
		objList.objListItems = objList.getElements('li');

		// special mient-jan code
		objList.getElements('li ul li').each(function(elSubLi){
			objList.objListItems.each(function(elLi, intI){
				if( elSubLi == elLi )
				{
					delete(objList.objListItems[intI]);
				}
			});

		});

		// loop trough the items of the current ul
		objList.objListItems.each(function(objListItem)
		{
			if(objListItem)
			{

			// get elements in the item
			objListItem.objInput = objListItem.getElements('input')[0];
			objListItem.objPrice = objListItem.getElements('span.price_normal')[0];
			objListItem.objPriceSpecial = objListItem.getElements('span.price_sale')[0];
			objListItem.objDifference = objListItem.getElements('span.difference_normal')[0];
			objListItem.objDifferenceSpecial = objListItem.getElements('span.difference_sale')[0];
            objListItem.strName = objListItem.getElements('span.name')[0].innerHTML;
			objListItem.intCatId = objListItem.getElements('span.catid')[0].innerHTML;
			// check if its dsl product
			if(true == objListItem.hasClass('dsl'))
			{
				objListItem.blnIsDsl = true;
				objListItem.strDslComponent = objListItem.objInput.name;
			}
			else
			{
				objListItem.blnIsDsl = false;
			}

			// check if its setup fee instead of month price
			if(true == objListItem.hasClass('setup'))
			{
				objListItem.blnIsSetup = true;
			}
			else
			{
				objListItem.blnIsSetup = false;
			}

			// check if its setup fee instead of month price
			if(true == objListItem.hasClass('percentage'))
			{
				objListItem.blnIsPercentage = true;
			}
			else
			{
				objListItem.blnIsPercentage = false;
			}

			// check if the current input is checked
			if(objListItem.objInput.checked == true)
			{
				// check if product is on sale
				if(objListItem.objPriceSpecial)
				{
					// product is on sale, use the sale price
					objList.fltCurrentPrice = objListItem.objPriceSpecial.innerHTML;
				}
				else
				{
					// product is not on sale, use normal price
					objList.fltCurrentPrice = objListItem.objPrice.innerHTML;
				}
				// copy the price
				objList.fltTmp = objList.fltCurrentPrice;
			}

			// get product price
			if(objListItem.objPriceSpecial)
			{
				objListItem.fltPrice = objListItem.objPriceSpecial.innerHTML;
			}
			else
			{
				objListItem.fltPrice = 0; // objListItem.objPrice.innerHTML;
			}

			// set onclick event handler on the radio button
			objListItem.addEvent('click', function()
			{
				// check if its a dsl item
				if(true == objListItem.blnIsDsl)
				{
					var fltCurrentPrice = parseFloat(objListItem.getElements('span.price_normal')[0].innerHTML).toFixed(2);

					// update dsl prices
					switch(objListItem.strDslComponent)
					{
						case 'specs[speed]':
						{
							// update ratio prices
							var intCurrentSpeed = objListItem.objInput.value;
							var arrUpdateElements = $$('li.overboeking div.info');

							arrUpdateElements.each(function(objUpdatePrice)
							{
								// get current overboeking
								var strCurrent = objUpdatePrice.getElements('span.name')[0].innerHTML;
								var objPrice = objUpdatePrice.getElements('span.price_normal')[0];
								var objDifference = objUpdatePrice.getElements('span.difference_normal')[0];
								strCurrentOverboeking = strCurrent;

								if(objRecData.data[intCurrentSpeed][strCurrentOverboeking])
								{
									if("1" == objRecData.data[intCurrentSpeed][strCurrentOverboeking] )
									{
										objUpdatePrice.addClass('recommended');
									}
									else
									{
										objUpdatePrice.removeClass('recommended');
									}
								}
								else
								{
									objUpdatePrice.removeClass('recommended');
								}

								if(objSaleData .data[intCurrentSpeed][strCurrentOverboeking])
								{
									if("1" == objSaleData .data[intCurrentSpeed][strCurrentOverboeking] )
									{
										objUpdatePrice.addClass('sale');
									}
									else
									{
										objUpdatePrice.removeClass('sale');
									}
								}
								else
								{
									objUpdatePrice.removeClass('sale');
								}


								if(objPriceData.data[intCurrentSpeed][strCurrentOverboeking])
								{
									var fltNewPrice = objPriceData.data[intCurrentSpeed][strCurrentOverboeking];

									if('0.00' != fltNewPrice)
									{
										var fltDifference = parseFloat(fltNewPrice - fltCurrentPrice).toFixed(2);
										var strOperator = '+';

										// check if the difference is negative
										if(fltDifference < 0)
										{
											fltDifference = (fltDifference * - 1).toFixed(2);
											strOperator = '-';
										}

										if(fltDifference != '0.00')
										{
											objDifference.innerHTML = '(' + strOperator + ' &euro;' + formatPrice(fltDifference) + ')';
										}
										else
										{
											objDifference.innerHTML = '';
										}

										objPrice.innerHTML = fltNewPrice;
									}
									else
									{
										objDifference.innerHTML = strNotAvailable;
										objPrice.innerHTML = fltNewPrice;
									}
								}
							});

							// update speed prices
							if($('right_value_overboeking'))
							{
								var strCurrentOverboeking = $('right_value_overboeking').innerHTML;
								var arrUpdateElements = $$('li.speed div.info');

								arrUpdateElements.each(function(objUpdatePrice)
								{
									// get current overboeking
									var strCurrent = objUpdatePrice.getElements('span.name')[0].innerHTML;
									var objPrice = objUpdatePrice.getElements('span.price_normal')[0];
									var objDifference = objUpdatePrice.getElements('span.difference_normal')[0];
									intCurrentSpeed = strCurrent;

									if(objRecData.data[intCurrentSpeed][strCurrentOverboeking])
									{
										if("1" ==objRecData.data[intCurrentSpeed][strCurrentOverboeking] )
										{
											objUpdatePrice.addClass('recommended');
										}
										else
										{
											objUpdatePrice.removeClass('recommended');
										}
									}
									else
									{
										objUpdatePrice.removeClass('recommended');
									}

									if(objSaleData .data[intCurrentSpeed][strCurrentOverboeking])
									{
										if("1" == objSaleData .data[intCurrentSpeed][strCurrentOverboeking] )
										{
											objUpdatePrice.addClass('sale');
										}
										else
										{
											objUpdatePrice.removeClass('sale');
										}
									}
									else
									{
										objUpdatePrice.removeClass('sale');
									}


									if(objPriceData.data[intCurrentSpeed][strCurrentOverboeking])
									{
										var fltNewPrice = objPriceData.data[intCurrentSpeed][strCurrentOverboeking];

										if('0.00' != fltNewPrice)
										{
											var fltDifference = parseFloat(fltNewPrice - fltCurrentPrice).toFixed(2);
											var strOperator = '+';

											var strCurrentPrice = $('total_price_hidden').innerHTML;



											// check if the difference is negative
											if(fltDifference < 0)
											{
												fltDifference = (fltDifference * - 1).toFixed(2);
												strOperator = '-';
											}

											if(fltDifference != '0.00')
											{
												objDifference.innerHTML = '(' + strOperator + ' &euro;' + formatPrice(fltDifference) + ')';
											}
											else
											{
												objDifference.innerHTML = '';
											}

											objPrice.innerHTML = fltNewPrice;
										}
										else
										{
											objDifference.innerHTML = strNotAvailable;
											objPrice.innerHTML = fltNewPrice;
										}
									}
								});
							}

							break;
						}
						case 'specs[overboeking]':
						{
							// update speed prices
							var strCurrentOverboeking = objListItem.objInput.value;
							var arrUpdateElements = $$('li.speed div.info');

							arrUpdateElements.each(function(objUpdatePrice)
							{
								// get current overboeking
								var strCurrent = objUpdatePrice.getElements('span.name')[0].innerHTML;
								var objPrice = objUpdatePrice.getElements('span.price_normal')[0];
								var objDifference = objUpdatePrice.getElements('span.difference_normal')[0];
								intCurrentSpeed = strCurrent;

								if(objRecData.data[intCurrentSpeed][strCurrentOverboeking])
								{
									if("1" ==objRecData.data[intCurrentSpeed][strCurrentOverboeking] )
									{
										objUpdatePrice.addClass('recommended');
									}
									else
									{
										objUpdatePrice.removeClass('recommended');
									}
								}
								else
								{
									objUpdatePrice.removeClass('recommended');
								}

								if(objSaleData .data[intCurrentSpeed][strCurrentOverboeking])
								{
									if("1" == objSaleData .data[intCurrentSpeed][strCurrentOverboeking] )
									{
										objUpdatePrice.addClass('sale');
									}
									else
									{
										objUpdatePrice.removeClass('sale');
									}
								}
								else
								{
									objUpdatePrice.removeClass('sale');
								}

								if(objPriceData.data[intCurrentSpeed][strCurrentOverboeking])
								{
									var fltNewPrice = objPriceData.data[intCurrentSpeed][strCurrentOverboeking];

									if('0.00' != fltNewPrice)
									{
										var fltDifference = parseFloat(fltNewPrice - fltCurrentPrice).toFixed(2);
										var strOperator = '+';

										var strCurrentPrice = $('total_price_hidden').innerHTML;

										// check if the difference is negative
										if(fltDifference < 0)
										{
											fltDifference = (fltDifference * - 1).toFixed(2);
											strOperator = '-';
										}

										if(fltDifference != '0.00')
										{
											objDifference.innerHTML = '(' + strOperator + ' &euro;' + formatPrice(fltDifference) + ')';
										}
										else
										{
											objDifference.innerHTML = '';
										}

										objPrice.innerHTML = fltNewPrice;
									}
									else
									{
										objDifference.innerHTML = strNotAvailable;
										objPrice.innerHTML = fltNewPrice;
									}
								}
							});

							// update ratio prices
							if($('right_value_overboeking'))
							{
								var arrUpdateElements = $$('li.overboeking div.info');
								var intCurrentSpeed = $('right_value_speed').innerHTML;

								// update prices
								arrUpdateElements.each(function(objUpdatePrice)
								{
									// get current overboeking
									var strCurrent = objUpdatePrice.getElements('span.name')[0].innerHTML;
									var objPrice = objUpdatePrice.getElements('span.price_normal')[0];
									var objDifference = objUpdatePrice.getElements('span.difference_normal')[0];
									strCurrentOverboeking = strCurrent;

									if(objRecData.data[intCurrentSpeed][strCurrentOverboeking])
									{
										if("1" ==objRecData.data[intCurrentSpeed][strCurrentOverboeking] )
										{
											objUpdatePrice.addClass('recommended');
										}
										else
										{
											objUpdatePrice.removeClass('recommended');
										}
									}
									else
									{
										objUpdatePrice.removeClass('recommended');
									}

									if(objSaleData .data[intCurrentSpeed][strCurrentOverboeking])
									{
										if("1" == objSaleData .data[intCurrentSpeed][strCurrentOverboeking] )
										{
											objUpdatePrice.addClass('sale');
										}
										else
										{
											objUpdatePrice.removeClass('sale');
										}
									}
									else
									{
										objUpdatePrice.removeClass('sale');
									}

									if(objPriceData.data[intCurrentSpeed][strCurrentOverboeking])
									{
										var fltNewPrice = objPriceData.data[intCurrentSpeed][strCurrentOverboeking];

										if('0.00' != fltNewPrice)
										{
											var fltDifference = parseFloat(fltNewPrice - fltCurrentPrice).toFixed(2);
											var strOperator = '+';

											// check if the difference is negative
											if(fltDifference < 0)
											{
												fltDifference = (fltDifference * - 1).toFixed(2);
												strOperator = '-';
											}

											if(fltDifference != '0.00')
											{
												objDifference.innerHTML = '(' + strOperator + ' &euro;' + formatPrice(fltDifference) + ')';
											}
											else
											{
												objDifference.innerHTML = '';
											}

											objPrice.innerHTML = fltNewPrice;
										}
										else
										{
											objDifference.innerHTML = strNotAvailable;
											objPrice.innerHTML = fltNewPrice;
										}
									}
								});
							}

							break;
						}
					}
				}

				// dont change the differences if its a percentage
				if(false == objListItem.blnIsPercentage)
				{
					// loop trough all list items
					objList.objListItems.each(function(objExtListItem)
					{
						// calculate the new price differences
						if( objExtListItem )
						{

							// get normal price
							objExtListItem.fltPrice = objExtListItem.getElements('span.price_normal')[0].innerHTML;

							// check if there is a sale price
							if(objExtListItem.getElements('span.price_sale')[0])
							{
								objExtListItem.fltPriceSpecial = objExtListItem.getElements('span.price_sale')[0].innerHTML;
							}

							// check if the selected product is on sale
							//if(parseFloat(objListItem.fltPriceSpecial) <= parseFloat(objListItem.fltPrice))
							//if(objExtListItem.fltPriceSpecial)
							if(objListItem.objPriceSpecial)
							{
								// selected product is on sale, use the special price to calculate the difference
								objExtListItem.fltDifference = (Math.round((objExtListItem.fltPrice - objListItem.objPriceSpecial.innerHTML) * 100) / 100).toFixed(2);
								objExtListItem.fltDifferenceSpecial = (Math.round((objExtListItem.fltPriceSpecial - objListItem.objPriceSpecial.innerHTML) * 100) / 100).toFixed(2);
								objExtListItem.strDifferenceOperator = '+';
							}
							else
							{
								// selected product is not on sale, use the normal price to calculate the difference
								objExtListItem.fltDifference = (Math.round((objExtListItem.fltPrice - objListItem.objPrice.innerHTML) * 100) / 100).toFixed(2);
								objExtListItem.fltDifferenceSpecial = (Math.round((objExtListItem.fltPriceSpecial - objListItem.objPrice.innerHTML) * 100) / 100).toFixed(2);
								objExtListItem.strDifferenceOperator = '+';
							}

							// check if the difference is negative
							if(objExtListItem.fltDifference < 0)
							{
								objExtListItem.fltDifference = (objExtListItem.fltDifference * - 1).toFixed(2);
								objExtListItem.fltDifferenceSpecial = (objExtListItem.fltDifferenceSpecial * - 1).toFixed(2);
								objExtListItem.strDifferenceOperator = '-';
							}

							// update price difference

							// only update the sale difference if there is a sale price
							if(objExtListItem.getElements('span.difference_sale')[0])
							{
								// sale price
								objExtListItem.getElements('span.difference_normal')[0].innerHTML = '<strike>(' +  objExtListItem.strDifferenceOperator +  ' &euro;' + formatPrice(objExtListItem.fltDifference) + ')<\/strike>';
								objExtListItem.getElements('span.difference_sale')[0].innerHTML = '(' +  objExtListItem.strDifferenceOperator +  ' &euro;' + formatPrice(objExtListItem.fltDifferenceSpecial) + ')';
							}
							else
							{
								// no sale price
								objExtListItem.getElements('span.difference_normal')[0].innerHTML = '(' +  objExtListItem.strDifferenceOperator +  ' &euro;' + formatPrice(objExtListItem.fltDifference) + ')';
							}

							if(true == objListItem.blnIsDsl)
							{
								var strPrice = objListItem.getElements('span.price_normal')[0].innerHTML;

								// bug
								if(objExtListItem.fltDifference == strPrice)
								{
									// difference is the same as current price so the product is 0.00 because its not available
									//objExtListItem.getElements('span.difference_normal')[0].innerHTML = strNotAvailable;
								}
							}

							// set all inputs to false
							objExtListItem.objInput = objExtListItem.getElements('input')[0];
							objExtListItem.objInput.checked = false;
						}
					});

					// override difference
					objListItem.objDifference.innerHTML = '';
					if(objListItem.objDifferenceSpecial)
					{
						objListItem.objDifferenceSpecial.innerHTML = '';
					}

				}


				// set the item as checked
				objListItem.objInput.checked = true;


				// update total price
				var strCurrentPrice = $('total_price_hidden').innerHTML;
				var fltNewPrice1 = parseFloat(strCurrentPrice - objList.fltCurrentPrice);

				if(false == objListItem.blnIsPercentage)
				{
					// check if the selected product is on sale
					if(parseFloat(objListItem.fltPriceSpecial) <= parseFloat(objListItem.fltPrice))
					{
						// selected product is on sale, set the sale price
						objList.fltTmpPrice = objListItem.fltPriceSpecial;
						var fltNewPrice2 = parseFloat(fltNewPrice1 + parseFloat(objListItem.fltPriceSpecial));
					}
					else
					{
						// selected product is not on sale, set the normal price
						objList.fltTmpPrice = objListItem.fltPrice;
						var fltNewPrice2 = parseFloat(fltNewPrice1 + parseFloat(objListItem.fltPrice));
					}
				}


				// update value in the right block
				if($('right_value_' + objListItem.intCatId))
				{
					// get
					var strName = objListItem.strName;

					// strip image
					myregexp = new RegExp(/<img(.*)>/);
					strName = strName.replace(myregexp, '');

					myregexp = /<IMG(.*)>/;
					strName = strName.replace(myregexp, '');

					// trim value
					strName = trim(strName);

					//console.log(strName);

                    //console.log('objListItem.blnIsSetup:' + objListItem.blnIsSetup, 'objListItem.blnIsPercentage:' + objListItem.blnIsPercentage);

					// show price if its a setup fee item
					if(true == objListItem.blnIsSetup)
					{
						// add category name
						var strCatName = objListItem.getParent().getParent().getParent().getParent().getElements('div.title')[0].innerHTML;

						// strip div
						myregexp = new RegExp(/<div(.*)>/);
						strCatName = strCatName.replace(myregexp, '');

						myregexp = /<DIV(.*)>/;
						strCatName = strCatName.replace(myregexp, '');

						strCatName = trim(strCatName);

						$('right_value_' + objListItem.intCatId).innerHTML = strCatName + ': ' + strName + ' (+ &euro; ' + formatPrice(objList.fltTmpPrice) + ')';
					}
					else if(true == objListItem.blnIsPercentage)
					{
						var intPercentage = objListItem.objPrice.innerHTML;
						$('right_value_' + objListItem.intCatId).innerHTML = strName;
						$('right_value_' + objListItem.intCatId + '_discount').innerHTML = intPercentage;
					}
					else
					{
						$('right_value_' + objListItem.intCatId).innerHTML = strName;
					}

					// color it of it is changes
					$('right_value_' + objListItem.intCatId).getParent().addClass('highlight');
				}

				if(true == objListItem.blnIsDsl)
				{
					// dsl

					// get price of this item
					var strPrice = objListItem.getElements('span.price_normal')[0].innerHTML;

					if('0.00' == strPrice)
					{
						// not available
						showDslError();

						// set price of the item
						$('total_price_hidden').innerHTML = strPrice;
						$('total').innerHTML = '&euro;' + formatPrice(strPrice);
					}
					else
					{
						removeDslError();

						// set price of the item
						$('total_price_hidden').innerHTML = strPrice;
						$('total').innerHTML = '&euro;' + formatPrice(strPrice);
					}
				}
				else if(true == objListItem.blnIsPercentage)
				{
					// get percentage
					var strPrice = $('total_price_hidden').innerHTML;
					var intPercentage = objListItem.objPrice.innerHTML;
					var fltPriceDiscount = (((100 - intPercentage) / 100) * strPrice).toFixed(2);
					var intCurrentPercentage = intPercentage;

					// console.log(strPrice, intPercentage, fltPriceDiscount, intCurrentPercentage);

					// change current price
					//console.log('huidige prijs: ' + strPrice);
					//console.log('kortingpercentage: ' + intPercentage);
					//console.log('nieuwe prijs: ' + fltPriceDiscount);
				}
				else
				{
					if(true == objListItem.blnIsSetup)
					{
						// do nothing...
					}
					else
					{
						var strPrice = fltNewPrice2.toFixed(2);

						// percentage
						var fltPriceDiscount = (((100 - intCurrentPercentage) / 100) * strPrice).toFixed(2);

						//console.log(fltPriceDiscount);

						// normal
						$('total_price_hidden').innerHTML = strPrice;
						$('total').innerHTML = '&euro;' + formatPrice(strPrice);

						// override the current price
						objList.fltCurrentPrice = objList.fltTmpPrice;
					}

				}



			});
			}
		});
	});


	// handles the realtime pricing of checkboxes
	$$('div.component_cat ul.checkbox').each(function(objList)
	{
		// get all items from the current ul
		objList.objListItems = objList.getElements('li');

		// loop trough the items of the current ul
		objList.objListItems.each(function(objListItem)
		{
			if( objListItem )
			{

				// get elements in the item
				objListItem.objInput = objListItem.getElements('input')[0];
				objListItem.objPrice = objListItem.getElements('span.price_normal')[0];
				objListItem.objPriceSpecial = objListItem.getElements('span.price_sale')[0];
				objListItem.objSelect = objListItem.getElements('select')[0];
				objListItem.objDifference = objListItem.getElements('span.difference_normal')[0];
				objListItem.objDifferenceSpecial = objListItem.getElements('span.difference_sale')[0];
				objListItem.strName = objListItem.getElements('span.name')[0].innerHTML;
				objListItem.objCatId = objListItem.getElements('span.catid')[0].innerHTML;

				// get price
				if(objListItem.objPriceSpecial)
				{
					// use sale price if set
					objListItem.fltItemPrice = objListItem.objPriceSpecial.innerHTML;
				}
				else
				{
					// use normal price
					objListItem.fltItemPrice = objListItem.objPrice.innerHTML;
				}

				if(objListItem.objSelect)
				{
					// set change event handler on the select
					objListItem.objSelect.addEvent('change', function()
					{
						// calculate new price of this item
						var fltNewPrice = objListItem.objSelect.value * parseFloat(objListItem.fltItemPrice);

						// insert new price in the difference element
						objListItem.objDifference.innerHTML = '(+ &euro;' + formatPrice(parseFloat(fltNewPrice).toFixed(2)) + ')';
					});
				}

				// set onclick event handler on the radio button
				objListItem.objInput.addEvent('click', function()
				{
					// update total price
					var strCurrentPrice = $('total_price_hidden').innerHTML;
					var fltNewPrice1 = parseFloat(strCurrentPrice);

					// check if there is a select in this
					if(objListItem.objSelect)
					{
						// calculate the price according to the select value
						var fltNewPrice = objListItem.objSelect.value * parseFloat(objListItem.fltItemPrice);
					}
					else
					{
						// normal price
						var fltNewPrice = objListItem.fltItemPrice;
					}


					// check if item is checked
					if(false == objListItem.objInput.checked)
					{
						// item is checked
						var fltNewPrice2 = fltNewPrice1 - parseFloat(fltNewPrice);

						// enable select if there is one
						if(objListItem.objSelect)
						{
							objListItem.objSelect.disabled = false;
						}

						// remove from right block if it exists
						if($('right_value_' + objListItem.objInput.value))
						{
							$('right_value_' + objListItem.objInput.value).remove();
						}
					}
					else
					{
						// item is not checked
						var fltNewPrice2 = fltNewPrice1 + parseFloat(fltNewPrice);

						// disable select if there is one
						if(objListItem.objSelect)
						{
							objListItem.objSelect.disabled = true;
						}



						// add to right block if it doesnt exist
						if(!$('right_value_' + objListItem.objInput.value))
						{
							objElement = new Element('li', {
											'id': 'right_value_' + objListItem.objInput.value,
											'class': 'highlight'
										}).setHTML(objListItem.strName);

							objElement.injectInside('extras_right');
						}

					}

					// make pretty var
					var strPrice = formatPrice(fltNewPrice2.toFixed(2));

					// update prices
					$('total_price_hidden').innerHTML = fltNewPrice2.toFixed(2);
					$('total').innerHTML = '&euro;' + formatPrice(strPrice);
				});

			}
		});
	});


});

function formatPrice(fltPrice)
{
	var strPrice = fltPrice.toString();
	strPrice = strPrice.replace('.', ',');

	return strPrice;
}


function productSelectRight()
{
	if(intCurrentProduct <= (intSelectionProducts - 4))
	{
		intMove = intCurrentProduct * intSelectionProductWidth;
		intSelectionFx.start($('product_list').getStyle('left'), (intMove - (intMove * 2)));
		intCurrentProduct += 1;
	}
}

function productSelectLeft()
{
	if(intCurrentProduct > 1)
	{
		intCur = parseInt($('product_list').getStyle('left'));
		intSelectionFx.start(intCur, (intCur + intSelectionProductWidth));
		intCurrentProduct -= 1;
	}
}

function setValue(strElement, strValue, blnPost, strForm)
{
	$(strElement).value = strValue;

	if(true == blnPost)
	{
		$(strForm).submit();
	}
}

function copyValue(strValue, strElement)
{
	$(strElement).value = strValue;
}

function hideTopElements()
{

}

function showTopElements()
{

}

function customizePage(intShowDiv)
{
	//
	$$('div.cutomize_block').each(function(objBlock){objBlock.setStyle('display', 'none');});
	$$('div.page_type h5').each(function(objHeader){objHeader.addClass('inactive');});
	$$('a#conf_backlink').setStyle('display', 'none');

	if($('component_list_' + intShowDiv)){$('component_list_' + intShowDiv).setStyle('display', 'block');}
	if($('config_header_' + intShowDiv)){$('config_header_' + intShowDiv).removeClass('inactive');}

	if (2 == intShowDiv)
	{
    	$$('a#conf_backlink').setStyle('display', 'block');
	}
	else
	{
    	$$('a#conf_backlink').setStyle('display', 'none');
	}

	// handles the toggeling of component categories
	new ComponentToggler();
}


function showDslError()
{
	// hide continue button
	$('submit_wrapper').setStyle('visibility', 'hidden');

	// hide price
	$('order_total').setStyle('display', 'none');

	// show error
	$('order_error').setStyle('display', 'block');
}

function removeDslError()
{
	// show continue button
	$('submit_wrapper').setStyle('visibility', 'visible');

	// hide error
	$('order_error').setStyle('display', 'none');

	// show price
	$('order_total').setStyle('display', 'block');

}

function showOrderIncludingVat()
{
	var objExcl = $('vat_ex_details');
    var objIncl = $('vat_details');

    if ('none' == objIncl.getStyle('display'))
	{
    	objExcl.setStyle('display', 'none');
        objIncl.setStyle('display', 'block');
	}
	else
	{
    	objExcl.setStyle('display', 'block');
        objIncl.setStyle('display', 'none');
	}

    /*
	var objVatFx = new Fx.Style('vat_details', 'height', {duration:500});
	var intHeight = $('vat_details').getStyle('height');

	if('0px' == $('vat_details').getStyle('height'))
	{
		objVatFx.start(0, 50);
	}
	else
	{
		objVatFx.start(50, 0);
	}
	*/
}

function showAnswer(argId)
{
	if('none' == $('answer_' + argId).getStyle('display'))
	{
		$('answer_' + argId).setStyle('display', 'block');
	}
	else
	{
		$('answer_' + argId).setStyle('display', 'none');
	}
}

var first_can_not_be_zero = 'First can not be zero digit';

function isIntiger(e)
{

    if(document.all)
    {
		var key_index = window.event.keyCode;
	}
 	else
 	{
		var key_index = e.which;
 	}

    if((key_index>47 && key_index<58) || key_index==8 || key_index==127|| key_index==9 || key_index==0)
	{
		return true;
	}
	else
	{
		return false;
	}
}


//	Class tabber
//	 - easy tab creator
//	 - By Mient-jan Stelling

var Tabber = new Class(
{
	initialize:function(argArrTab,argArrItem,argIntMakeActive)
	{
		if( argIntMakeActive == undefined ) argIntMakeActive = 0;

		this.arrTab = argArrTab;
		this.arrItem = argArrItem;
		this.intMakeActive = argIntMakeActive;

		this.arrTab.each(function(elNode,intI)
		{
			elNode.rel = intI;
			elNode._parent = this;
			elNode.addEvent('click',function()
			{
				this._parent.switchItem(this);
                sIFR.replace(is_rc, {
					selector: 'div.yourcart_widget_tabber h3',
					css: [
							'.sIFR-root { font-weight:normal;font-size:24px;color:#FFFFFF;background: transparent; }'
						],
					wmode: 'transparent'
				});
			});
			if( intI != this.intMakeActive )
			{
				elNode.removeClass('active');
			}
			else
			{
				elNode.addClass('active');
			}
		}.bind(this));

		this.arrItem.each(function(elNode,intI)
		{
			if( intI != this.intMakeActive ) elNode.style.display = 'none';
		}.bind(this));


	},

	switchItem:function( argElTabNode )
	{
		var intCurrent = 0;

		this.arrTab.each(function(elNode,intI)
		{
			if( argElTabNode != elNode )
			{
				elNode.removeClass('active');
			}
			else if( argElTabNode == elNode )
			{
				elNode.addClass('active');
				intCurrent = intI;
			}
		}.bind(this));

		this.arrItem.each(function(elNode,intI)
		{
			if( intCurrent != intI )
			{
				elNode.style.display = 'none';
			}
			else if( intCurrent == intI )
			{
				elNode.style.display = 'block';
			}
		}.bind(this));
	}
});


//	Class klapper
//	 - easy tab creator
//	 - By Mient-jan Stelling

var Klapper = new Class(
{
	initialize:function(argArrBlock,argStrHeaderClassName,argStrHeaderPlusTekenName,argStrContentClassName)
	{
		this.arrBlock = argArrBlock;
		this.strHeaderClassName = argStrHeaderClassName;
		this.strContentClassName = argStrContentClassName;
		this.strHeaderPlusTekenName = argStrHeaderPlusTekenName;

		this.arrBlock.each(function(elNode,intI)
		{
			elHeader = elNode.getElement( this.strHeaderClassName );
			elHeader.elContent = elNode.getElement( this.strContentClassName ).setStyle('display', 'none');
			elHeader.elHeaderPlusTeken = elNode.getElement( this.strHeaderPlusTekenName );
			elHeader._parent = this;

			elHeader.objFxStyle = new Fx.Styles(elHeader, {duration:200,wait:false});

			elHeader.addEvent('mouseover',function()
												   {
				if( !this._parent.isOpen(this.elContent) )
				{
					this.objFxStyle.start({
						'background-color':'#DEE1E5',
						'padding-left':'10px'
					});
				}
			});

			elHeader.addEvent('mouseout',function(){
				if( !this._parent.isOpen(this.elContent) )
				{
					this.objFxStyle.start({
						'background-color':'#FFFFFF',
						'padding-left':'0px'
					});
				}
			});

			elHeader.addEvent('click',function()
			{
				if( !this._parent.isOpen(this.elContent) )
				{
					this.objFxStyle.start({
						'background-color':'#FFFFFF',
						'padding-left':'0px'
					});
					this.elHeaderPlusTeken.innerHTML = '-';
				}
				else
				{
					this.elHeaderPlusTeken.innerHTML = '+';
				}
				this._parent.switchItem( this.elContent );
			});
		}.bind(this));
	},

	isOpen:function( argElContentNode )
	{
		if( argElContentNode.style.display == 'none')
		{
			return false;
		} else {
			return true;
		}
	},

	switchItem:function( argElContentNode )
	{
		if( !this.isOpen(argElContentNode) )
		{
			argElContentNode.setStyle('display', 'block');
		} else {
			argElContentNode.setStyle('display', 'none');
		}
	}
});


//	Class NewsRollOver
//	 - easy rollover creator
//	 - By Mient-jan Stelling

var NewsRollOver = new Class(
{
	initialize:function( argArrBlock, argStrMarginElement)
	{
		this.arrBlock = argArrBlock;
		this.strMarginElement = argStrMarginElement;

		this.arrBlock.each(function(elNode,intI)
		{
			elNode._parent = this;
			elNode.objFxStyle = new Fx.Styles(elNode, {duration:500,wait:false});

			elNode.addEvent('mouseover',function()
			{
				this.objFxStyle.start({
					'background-color':'#DEE1E5',
					'padding-left':'10px'
				});
			});

			elNode.addEvent('mouseout',function(){
				this.objFxStyle.start({
					'background-color':'#FFFFFF',
					'padding-left':'0px'
				});
			});

		}.bind(this));
	}
});



//	Class Overlay
//	 - easy Overlay creator
//	 - By Mient-jan Stelling

var Overlay = new Class(
{
	width:'490',
	height:'400',

	Close:function(){
		this.elCurrentDiv.Close();
	},

	Show:function( argStrHtml, argStrClass )
	{

		var elDiv = new Element('div',{
			'class':argStrClass,
			'styles':{
				'width':this.width.toInt() + 'px',
				//'height':this.height.toInt() + 'px',

				//'background-color':'#FFFFFF',
				//'padding':'8px',
				//'position':'absolute',

				'z-index':'999'
			}
		});
		elDiv.innerHTML = argStrHtml;
		var elBody = $$('body')[0];

		// Close
		elDiv.Close = function()
		{
			$(this).empty();
			if( this.elOverlay ) $(this.elOverlay).remove();
			$(this).remove();
		};

		// Move to center
		elDiv.moveToCenter = function()
		{
			this.objFx.stop();

			this.objSize = this.getSize();
			this.objWindowSize = window.getSize();

			var left = ( (this.objWindowSize.size.x / 2) - (this.objSize.size.x / 2) );
			var top = this.objWindowSize.scroll.y + ( (this.objWindowSize.size.y / 2) - (this.objSize.size.y / 2) );

			this.objFx.set({
				'left':left,'top':top
			});
		};
		elDiv.addEvent('mouseleave',function(event){ this.Close(); });

		// Enter
		elDiv.show = function()
		{
			this.objFx.stop();
			var objWindowSize = window.getSize();

			this.removeEvents();

			this.elOverlay = new Element('div',{'styles':{'background-color':'#000000','position':'absolute','z-index':'998'} });
			this.elOverlay.setStyles({
				'width':objWindowSize.scrollSize.x,
				'height':objWindowSize.scrollSize.y,
				'left':0,
				'top':0,
				'opacity':0.5
			});

			this.elOverlay.addEvent('click',function(){
				this.Close();
			}.bind(this));

			elBody.appendChild( this.elOverlay );

			delete( objWindowSize );

			// move Shit To Zenter
			this.moveToCenter();
		}

		elDiv.objFx = new Fx.Styles(elDiv,{duration:1,transition:Fx.Transitions.Elastic.easeOut});

		elBody.appendChild( elDiv );

		elDiv.show();
		this.elCurrentDiv = elDiv;

		objCord = '';
	}
});


//	Location extender
//	 - easy tab creator
//	 - By Mient-jan Stelling

objGet = {};
var arrGet = location.search.split('?').join('').split('&');
arrGet.each(function(node,i){
	var arrSub = node.split('=');
	var key = (arrSub[0].split('[]').join(''));

	if(arrSub[0].indexOf('[]') > 0)
	{
		if($type(objGet[key]) != "array"){ objGet[key] = Array(); }
		objGet[key].push(arrSub[1]);
	}
	else
	{
		objGet[key] = arrSub[1];
	}
});

Object.extend(location,
{
	get:objGet,
	requesturi:( location.href.split( location.search).join('') ),
	arrrequesturi:( location.href.split(location.search).join('').split('//').join('/').split('/') ),
	changeSwitch:function()
	{
		var objA = arguments[0];
		var objB = arguments[1];

		objChange = Object();

		for( i in objA )
		{
			if(location.get[i] == objA[i])
			{
				objChange[i] = objB[i];
			}
			else
			{
				objChange[i] = objA[i];
			}
		}

		this.change( objChange );
	},

	change:function(){
		if( arguments.length < 2 )
		{
			var objChange = arguments[0];
			var strBaseUrl = location.requesturi;
			if( strBaseUrl.indexOf('#') > 0 )
			{
				var strBaseUrl = strBaseUrl.substr(0,strBaseUrl.lastIndexOf('#'));
			}
		}
		else
		{
			var strBaseUrl = arguments[0];
			var objChange = arguments[1];
		}

		if( objChange != undefined )
		{
			var arrUrl = Array();
			for( i in location.get )
			{
				if( objChange[i] != undefined ){
					if( $type(objChange[i]) != "array" )
					{
						arrUrl.push(i + '=' + objChange[i] );
					}
					else
					{
						objChange[i].each(function(node){
							arrUrl.push(i + '[]=' + node );
						});
					}
					delete(objChange[i]);
					continue;
				}

				if( $type(location.get[i]) != "array" )
				{
					if( location.get[i] != undefined || i != '' ) arrUrl.push(i + '=' + location.get[i] );
				}
				else
				{
					location.get[i].each(function(node){
						arrUrl.push(i + '[]=' + node );
					});
				}
			}

			for( i in objChange )
			{
				if( $type(objChange[i]) != "array" )
				{
					arrUrl.push(i + '=' + objChange[i] );
				}
				else
				{
					objChange[i].each(function(node){
						arrUrl.push(i + '[]=' + node );
					});
				}
			}


			if( strBaseUrl.substr( (strBaseUrl.length-1) ) != '/' )
			{
				strBaseUrl = strBaseUrl + '/';
			}
			location.href = strBaseUrl + '?' + arrUrl.join('&');
		}
	}
});


//	TooltipOverlayer

//	to use is create a

//	<TagName class="extraInfoComp">
//	<TagName class="extraInfoComp">Text You Want To Show</TagName>

//	popupDetails


var TooltipOverlayer = new Class({

	strClass:'popupDetails',

	initialize:function( argStrCssQuery )
	{
		this.arrEl = $$( argStrCssQuery );

		if( this.arrEl.length >= 2 )
		{

			this.arrEl.each(function(elNode, intI)
			{
				if( ((intI+1) % 2) == 1 )
				{
					var strClass = this.strClass;

					elNode.elOverlay = this.arrEl[(intI+1)];
					elNode.addEvent('click',function()
					{
						var strHtml = this.elOverlay.innerHTML;

						var elOverlayOpmaak = $('overlayOpmaak');
						strHtml = strHtml.replace("&quot;", '\"', "g");
						strHtml = strHtml.replace('%22', '' , "g");
						elOverlayOpmaak.getElement('.innerHTML').innerHTML = strHtml;

						objOverlay.Show(elOverlayOpmaak.innerHTML,strClass);

						sIFR.replace(is_rc, {
							selector: 'h3',
							css: [
								'.sIFR-root { font-weight:normal;font-size:24px;color:#003366;background: transparent; }'
							],
							wmode: 'transparent'
						});
					});
				}
			}.bind(this));

		}
	}
});
if(!objOverlay)
{
	var objOverlay = new Overlay();
}

window.addEvent('load',function()
{

	var objTooltipOverlayer = new TooltipOverlayer('.TooltipOverlay');

		if(!objOverlay)
	{
		var objOverlay = new Overlay();
	}

	$$('.toolTip').each(function(elNode)
	{
		elNode.strTitleText = elNode.getProperty('title');


		// elNode.elOverlay = arrExtraInfoComp[(intI+1)];
		elNode.addEvent('click',function(){
			objOverlay.Show(this.strTitleText,'popupDetails')

			sIFR.replace(is_rc, {
				selector: 'h3',
				css: [
					'.sIFR-root { font-weight:normal;font-size:24px;color:#003366;background: transparent; }'
				],
				wmode: 'transparent'
			});
		});
	});

});


/*
	if($('tooltip'))
	{
    	// create effect
		var objToolTipFx = new Fx.Style('tooltip', 'opacity', {wait: false, duration:500});
		// set opacity to 0
		objToolTipFx.set(0);
		// make element visible
		$('tooltip').setStyle('visibility', 'visible');

		// handles the tooltip
		$$('.toolTip').each(function(elNode)
		{
			// get data from title
			elNode.strTitleText = elNode.getProperty('title');

			// remove title attribute
			elNode.removeAttribute('title');

			// add mouseenter event
			elNode.addEvent('mouseenter', function(e)
			{
				// set tooltip text in the tooltip content
				$('tooltip_content').innerHTML = unescape(elNode.strTitleText);

				// get new tooltip size
				objTooltipSize = $('tooltip').getSize();
				// get pixels scrolled from top of the page
				intScrollTop = getScrollTop();

				// set position of the tooltip element
				$('tooltip').setStyle('top', (e.page.y - objTooltipSize['size']['y'] - 10) + 'px');
				$('tooltip').setStyle('left', (e.page.x - 65) + 'px');

				// show the tooltip
				objToolTipFx.start(0, 1);
			});

			// add mouseleave event
			elNode.addEvent('mouseleave', function(e)
			{
				// hide the tooltip
				objToolTipFx.start(1, 0);
			});
		});
	}
*/

/*
	=AJAX.JS
*/

// update the quantity of the product
function changeQuantity(argIntItemId, argIntNewQuantity)
{
	// update client side
		$('cart_ajax').setStyle('display', 'block');
		new Fx.Style('cart_ajax', 'opacity').start(0,1);
		$('item.' + argIntItemId + '.quantity').value = argIntNewQuantity;

	if(1 > argIntNewQuantity)
	{
		// ask user if the product should be removed
		var blnAnswer = confirm('Wilt u dit product verwijderen uit uw winkelwagen?')
		if (true == blnAnswer)
		{
			// verwijder product
			argIntNewQuantity = 0;
			$('item.' + argIntItemId).remove();
		}
		else
		{
			// zet product op 1
			$('item.' + argIntItemId + '.quantity').value = 1;
			new Fx.Style('cart_ajax', 'opacity').start(1,0);
			return false;
		}
	}

	// update serverside
		// create the url
		var strUrl = strSiteUrl + strCurrentLanguage + '/ajax/?func=quantity&id=' + argIntItemId + '&quantity=' + argIntNewQuantity + '&r=' + Math.floor(Math.random() * 1000).toString(36);

		// do the call
		new Ajax(strUrl, {method: 'get', onComplete: quantityCallback }).request();

	return true;
}

function quantityCallback(responseText, responseXML)
{
	// get values
	var arrValues = responseText.split(';');

	// update client side
	$('cartoverview.subtotal').innerHTML 	= arrValues[0];
	$('cartoverview.btw').innerHTML 		= arrValues[1];
	$('cartoverview.total').innerHTML 		= arrValues[2];

	// hide loading screen
	new Fx.Style('cart_ajax', 'opacity').start(1,0);

}

function deleteItem(strTable, strPrefix, intId)
{
	// create the url
	var strUrl = strSiteUrl + strCurrentLanguage + '/ajax/?func=deleteitem&table=' + strTable + '&prefix=' + strPrefix + '&id=' + intId + '&r=' + Math.floor(Math.random() * 1000).toString(36);

	// do the call
	new Ajax(strUrl, {method: 'get', onComplete: deleteItemCallback }).request();
}

function deleteItemCallback(responseText, responseXML)
{
	var arrValues = responseText.split(';');

	if('1' == arrValues[0])
	{
		$(arrValues[1]).remove();
	}
}

/*
	=SWFOBJECT.JS
*/
/**
 * SWFObject v1.4.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.createElement || !document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for (var i=3; axo!=null; i++) {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				PlayerVersion = new deconcept.PlayerVersion([i,0,0]);
			}
		}catch(e){}
		if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
		// this only does the minor rev lookup if the user's major version
		// is not 6 or we are checking for a specific minor or revision number
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
			try{
				PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			}catch(e){}
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = parseInt(arrVersion[0]) != null ? parseInt(arrVersion[0]) : 0;
	this.minor = parseInt(arrVersion[1]) || 0;
	this.rev = parseInt(arrVersion[2]) || 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param){
		var q = document.location.search || document.location.hash;
		if(q){
			var startIndex = q.indexOf(param +"=");
			var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
			if (q.length > 1 && startIndex > -1) {
				return q.substring(q.indexOf("=", startIndex)+1, endIndex);
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i=0; i < objects.length; i++) {
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = null;
			}
		}
	}
}
if (typeof window.onunload == 'function') {
	var oldunload = window.onunload;
		window.onunload = function() {
		deconcept.SWFObjectUtil.cleanupSWFs();
		oldunload();
	}
} else {
	window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

/*
	=AUTOFILLFIX
*/
// disables google bar autofill functionality

  if(window.attachEvent) window.attachEvent("onload",setListeners);

  function setListeners()
  {
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++)
    {
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++)
    {
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles()
  {
    if(event.srcElement.style.backgroundColor != "") event.srcElement.style.backgroundColor = "";
  }

/*
	=MONXBOX_FRONTEND.JS
*/

/*
	Monxbox for MooTools v1.00
	by Robert Slootjes - MediaMonks, www.mediamonks.com
	Copyright 2007

	Usage:
	onclick="showmonxbox('http://www.mediamonks.com/', '800', '600');"

*/

function showmonxbox(strUrl, intWidth, intHeight, strTitle, blnDisableClose)
{
	showMonxBox(strUrl, intWidth, intHeight, strTitle, blnDisableClose)
}
/************************************************************************************************************
 *
 *	showMonxBox
 *
 *  usage:
 *	onclick="showMonxBox('http://www.mediamonks.com/', '800', '600');"
 *
************************************************************************************************************/
function showMonxBox(strUrl, intWidth, intHeight, strTitle, blnDisableClose)
{
	var strPageHeight = getScrollHeight();
	$('ufoverlay').setStyle('height', strPageHeight);
	$('ufoverlay1').setStyle('height', strPageHeight);

	new Fx.Style($('ufoverlay'), 'opacity').start(0, 1);
	new Fx.Style($('ufoverlay1'), 'opacity').start(0, 0.75);
	var intPageWidth			= getWidth();
	var intPageHeight			= getHeight();
	var intPageScrollHeight		= getScrollHeight();
	var intScrollTop			= getScrollTop();

	intCloseHeight = 27;

	objDivContent = new Element('div');
	objDivContent.setProperty('id', 'overlay-page');
	objDivContent.setStyle('position', 'relative');
	objDivContent.setStyle('width', intWidth + 'px');
	if(blnDisableClose != false)
	{
		objDivContent.setStyle('height', (parseInt(intHeight) + parseInt(intCloseHeight)) + 'px');
	}
	else
	{
		objDivContent.setStyle('height', intHeight + 'px');
	}
	objDivContent.setStyle('left', ((intPageWidth / 2) - (intWidth / 2)) + 'px');
	objDivContent.setStyle('top', ((intScrollTop + (intPageHeight / 2)) - (intHeight / 2)) + 'px');
	objDivContent.setStyle('background-color', '#FFFFFF');
	objDivContent.setStyle('border', '1px solid #0F2235');
	objDivContent.injectInside($('ufoverlay'));

	if(blnDisableClose != false)
	{
		objHeader = new Element('div');
		objHeader.setStyle('position', 'relative');
		objHeader.setStyle('cursor', 'move');
		objHeader.setStyle('width', (intWidth - 10) + 'px');
		objHeader.setStyle('height', intCloseHeight + 'px');
		objHeader.setStyle('background-image', 'url(../images/admin/monxbog_bg.gif)');
		objHeader.setStyle('color', '#FFFFFF');
		objHeader.setStyle('padding', '10px 0px 0px 10px');

		objHeader.injectInside(objDivContent);

		objTitle = new Element('span');
		objTitle.setStyle('font-family', 'Verdana');
		objTitle.setStyle('font-size', '16px');
		objTitle.setStyle('font-weight', 'bold');
		objTitle.appendText(strTitle);
		objTitle.injectInside(objHeader);

		objImage = new Element('img');
		objImage.setProperty('src', 'images/admin/monxbox_close.gif');
		objImage.setStyle('cursor', 'pointer');
		objImage.setStyle('position', 'absolute');
		objImage.setStyle('top', '0px');
		objImage.setStyle('right', '3px');
		objImage.addEvent('click', function(){closeMonxBox()});
		objImage.injectInside(objHeader);

		var draggableOptions = {
		    handle:function()
		    {
		      $('objHeader');
		    }
		};

		objDivContent.makeDraggable(draggableOptions);
	}

	objIframe = new Element('iframe');
	objIframe.setProperty('src', strUrl);
	objIframe.setProperty('frameborder', '0');
	objIframe.setStyle('width', intWidth + 'px');
	objIframe.setStyle('height', intHeight + 'px');
	objIframe.injectInside(objDivContent);

}

function showConfirmation(strLink, intWidth, intHeight, strText, strConfirm, strCancel)
{
	var strPageHeight = getScrollHeight();
	$('ufoverlay').setStyle('height', strPageHeight);
	$('ufoverlay1').setStyle('height', strPageHeight);

	new Fx.Style($('ufoverlay'), 'opacity').start(0, 1);
	new Fx.Style($('ufoverlay1'), 'opacity').start(0, 0.5);
	var intPageWidth			= getWidth();
	var intPageHeight			= getHeight();
	var intPageScrollHeight		= getScrollHeight();
	var intScrollTop			= getScrollTop();
	var intButtonHeight			= 30;

	objDivContent = new Element('div');
	objDivContent.setProperty('id', 'overlay-page');
	objDivContent.setStyle('position', 'relative');
	objDivContent.setStyle('width', intWidth + 'px');
	objDivContent.setStyle('height', (intHeight + intButtonHeight) + 'px');

	objDivContent.setStyle('left', ((intPageWidth / 2) - (intWidth / 2)) + 'px');
	objDivContent.setStyle('top', ((intScrollTop + (intPageHeight / 2)) - (intHeight / 2)) + 'px');
	objDivContent.setStyle('background-color', '#FFFFFF');
	objDivContent.setStyle('border', '1px solid #5C677F');
	objDivContent.injectInside($('ufoverlay'));

	var strInsert = '<div class="image"><img src="images/about.gif" alt="" /></div><div class="text">' + strText + '</div>';

	objConfirmation = new Element('div');
	objConfirmation.setStyle('width', intWidth + 'px');
	objConfirmation.setStyle('height', (intHeight + 30) + 'px');
	objConfirmation.setStyle('background-color', '#E9F2FE');
	objConfirmation.setStyle('color', '#666666');
	objConfirmation.injectInside(objDivContent);

	objWrapper1 = new Element('div');
	objWrapper1.setStyle('width', intWidth + 'px');
	objWrapper1.setStyle('height', intHeight + 'px');
	objWrapper1.injectInside(objConfirmation);

	objConfirmationImage = new Element('div');
	objConfirmationImage.setStyle('width', '60px');
	objConfirmationImage.setStyle('height', '70px');
	objConfirmationImage.setStyle('padding-top', '30px');
	objConfirmationImage.setStyle('text-align', 'center');
	objConfirmationImage.setStyle('float', 'left');
	objConfirmationImage.setHTML('<img src="images/about.gif" alt="" />');
	objConfirmationImage.injectInside(objWrapper1);

	objConfirmationText = new Element('div');
	objConfirmationText.setStyle('width', (intWidth - 60) + 'px');
	objConfirmationText.setStyle('height', (intHeight - 30) + 'px');
	objConfirmationText.setStyle('padding-top', '30px');
	objConfirmationText.setStyle('text-align', 'left');
	objConfirmationText.setStyle('float', 'left');
	objConfirmationText.setHTML(strText);
	objConfirmationText.injectInside(objWrapper1);

	objWrapper2 = new Element('div');
	objWrapper2.setStyle('width', (intWidth - 60) + 'px');
	objWrapper2.setStyle('height', '30px');
	objWrapper2.setStyle('padding-left', '60px');
	objWrapper2.injectInside(objConfirmation);

	objButton1 = new Element('div');
	objButton1.setStyle('width', '100px');
	objButton1.setStyle('height', '20px');
	objButton1.setStyle('padding', '5px 0px 0px 20px');
	objButton1.setStyle('float', 'left');
	objButton1.setStyle('background-image', 'url(images/check.gif)');
	objButton1.setStyle('background-repeat', 'no-repeat');
	objButton1.setStyle('background-position', '0px 4px');
	objButton1.setStyle('cursor', 'pointer');
	objButton1.addEvent('click', function(){ window.location =  strLink });
	objButton1.setHTML(strConfirm);
	objButton1.injectInside(objWrapper2);

	objButton2 = new Element('div');
	objButton2.setStyle('width', '100px');
	objButton2.setStyle('height', '20px');
	objButton2.setStyle('padding', '5px 0px 0px 20px');
	objButton2.setStyle('float', 'left');
	objButton2.setStyle('background-image', 'url(images/delete.gif)');
	objButton2.setStyle('background-repeat', 'no-repeat');
	objButton2.setStyle('background-position', '0px 4px');
	objButton2.setStyle('cursor', 'pointer');
	objButton2.addEvent('click', function(){closeMonxBox()});
	objButton2.setHTML(strCancel);
	objButton2.injectInside(objWrapper2);

}

function closeMonxBox()
{
	new Fx.Style($('ufoverlay'), 'opacity', {duration:500, onComplete: function(){ $('overlay-page').remove() } }).start(1, 0);
	new Fx.Style($('ufoverlay1') , 'opacity').start(0.5, 0);
}

function createMonxBox()
{
	var intPageHeight = getScrollHeight() + 'px';

	var objBogus = new Element('div');
	objBogus.setProperty('id', 'ufoverlay1');
	objBogus.setStyle('position', 'absolute');
	objBogus.setStyle('left', '0px');
	objBogus.setStyle('width', '100%');
	objBogus.setStyle('opacity', '0');
	objBogus.setStyle('background-color', '#CCCCCC');
	objBogus.setStyle('z-index', '995');
	objBogus.setStyle('top', '0px');
	objBogus.injectInside(document.body);
	//objBogus.setStyle('height', intPageHeight);

	var objDivMain = new Element('div');
	objDivMain.setProperty('id', 'ufoverlay');
	objDivMain.setStyle('position', 'absolute');
	objDivMain.setStyle('left', '0px');
	objDivMain.setStyle('width', '100%');
	objDivMain.setStyle('opacity', '0');
	objDivMain.setStyle('z-index', '999');
	objDivMain.setStyle('top', '0px');
	objDivMain.injectInside(document.body);
	//objDivMain.setStyle('height', intPageHeight);
}

window.addEvent('load', function()
{
	createMonxBox();
});

/*
	=SIFR.JS
*/
/*=:project
		parseSelector 2.0

	=:description
		Provides an extensible way of parsing CSS selectors against a DOM in
		JavaScript.

  =:file
  	Copyright: 2006 Mark Wubben.
  	Author: Mark Wubben, <http://novemberborn.net/>

	=:license
		This software is licensed and provided under the CC-GNU LGPL.
		See <http://creativecommons.org/licenses/LGPL/2.1/>

	=:support
	  parseSelector supports the following user agents:
	    * Internet Explorer 6 and above
	    * Firefox 1.0 and above, and equivalent Gecko engine versions
	    * Safari 2.0 and above
	    * Opera 8.0 and above
	    * Konqueror 3.5.5 and above
	  It might work in other browsers and versions, but there are no guarantees. There is
	  no verification made when parseSelector is run to ascertain the browser is supported.

	=:notes
		The parsing of CSS selectors as streams has been based on Dean Edwards
		excellent work with cssQuery. See <http://dean.edwards.name/my/cssQuery/>
		for more info.
*/

var parseSelector = (function() {
	var SEPERATOR       = /\s*,\s*/
	var WHITESPACE      = /\s*([\s>+~(),]|^|$)\s*/g;
	var IMPLIED_ALL     = /([\s>+~,]|[^(]\+|^)([#.:@])/g;
	var STANDARD_SELECT = /^[^\s>+~]/;
	var STREAM          = /[\s#.:>+~()@]|[^\s#.:>+~()@]+/g;

	function parseSelector(selector, node) {
		node = node || document.documentElement;
		var argSelectors = selector.split(SEPERATOR), result = [];

		for(var i = 0; i < argSelectors.length; i++) {
			var nodes = [node], stream = toStream(argSelectors[i]);
			for(var j = 0; j < stream.length;) {
				var token = stream[j++], filter = stream[j++], args = '';
				if(stream[j] == '(') {
					while(stream[j++] != ')' && j < stream.length) args += stream[j];
					args = args.slice(0, -1);
				}
				nodes = select(nodes, token, filter, args);
			}
			result = result.concat(nodes);
		}

		return result;
	}

	function toStream(selector) {
		var stream = selector.replace(WHITESPACE, '$1').replace(IMPLIED_ALL, '$1*$2');
		if(STANDARD_SELECT.test(stream)) stream = ' ' + stream;
    return stream.match(STREAM) || [];
	}

	function select(nodes, token, filter, args) {
		return (selectors[token]) ? selectors[token](nodes, filter, args) : [];
	}

	var util = {
		toArray: function(enumerable) {
			var a = [];
			for(var i = 0; i < enumerable.length; i++) a.push(enumerable[i]);
			return a;
		}
	};

	var dom = {
		isTag: function(node, tag) {
			return (tag == '*') || (tag.toLowerCase() == node.nodeName.toLowerCase());
		},

		previousSiblingElement: function(node) {
			do node = node.previousSibling; while(node && node.nodeType != 1);
			return node;
		},

		nextSiblingElement: function(node) {
			do node = node.nextSibling; while(node && node.nodeType != 1);
			return node;
		},

		hasClass: function(name, node) {
			return (node.className || '').match('(^|\\s)'+name+'(\\s|$)');
		},

		getByTag: function(tag, node) {
			return node.getElementsByTagName(tag);
		}
	};

	var selectors = {
		'#': function(nodes, filter) {
			for(var i = 0; i < nodes.length; i++) {
				if(nodes[i].getAttribute('id') == filter) return [nodes[i]];
			}
			return [];
		},

		' ': function(nodes, filter) {
			var result = [];
			for(var i = 0; i < nodes.length; i++) {
				result = result.concat(util.toArray(dom.getByTag(filter, nodes[i])));
			}
			return result;
		},

		'>': function(nodes, filter) {
			var result = [];
			for(var i = 0, node; i < nodes.length; i++) {
				node = nodes[i];
				for(var j = 0, child; j < node.childNodes.length; j++) {
					child = node.childNodes[j];
					if(child.nodeType == 1 && dom.isTag(child, filter)) result.push(child);
				}
			}
			return result;
		},

		'.': function(nodes, filter) {
			var result = [];
			for(var i = 0, node; i < nodes.length; i++) {
				node = nodes[i];
				if(dom.hasClass([filter], node)) result.push(node);
			}
			return result;
		},

		':': function(nodes, filter, args) {
			return (pseudoClasses[filter]) ? pseudoClasses[filter](nodes, args) : [];
		}

	};

	parseSelector.selectors			= selectors;
	parseSelector.pseudoClasses = {};
	parseSelector.util 				  = util;
	parseSelector.dom 				  = dom;

	return parseSelector;
})();

/*=:project
    scalable Inman Flash Replacement (sIFR) version 3.

  =:file
    Copyright: 2006 Mark Wubben.
    Author: Mark Wubben, <http://novemberborn.net/>

  =:history
    * IFR: Shaun Inman
    * sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
    * sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben

  =:documentation
    See <http://wiki.novemberborn.net/sifr3>

  =:license
    This software is licensed and provided under the CC-GNU LGPL.
    See <http://creativecommons.org/licenses/LGPL/2.1/>
*/

var sIFR = new function() {
  //=:private Constant reference to the Singleton instance
  var SIFR = this;

  var CSS_ACTIVE           = 'sIFR-active';
  var CSS_REPLACED         = 'sIFR-replaced';
  var CSS_FLASH            = 'sIFR-flash';
  var CSS_IGNORE           = 'sIFR-ignore';
  var CSS_ALTERNATE        = 'sIFR-alternate';
  var CSS_CLASS            = 'sIFR-class';
  var CSS_LAYOUT           = 'sIFR-layout';
  var CSS_FIX_FOCUS        = 'sIFR-fixfocus'
  var CSS_DUMMY            = 'sIFR-dummy';
  var MIN_FONT_SIZE        = 6;
  var MAX_FONT_SIZE        = 126;
  var MIN_FLASH_VERSION    = 8;
  var PREFETCH_COOKIE      = 'SIFR-PREFETCHED';
  //= Whitespace string each whitespace character is replaced with, as per `preserveSingleWhitespace`.
  var DEFAULT_RATIOS       = [];
  var FLASH_PADDING_BOTTOM = 5;
  var VERSION              = '340';

  this.isActive                 = false;
  this.isEnabled                = true;
  this.hideElements             = true;
  this.preserveSingleWhitespace = false;
  this.fixWrap                  = true;
  this.fixHover                 = true;
  this.registerEvents           = true;
  this.setPrefetchCookie        = true;
  this.cookiePath               = '/';
  this.domains                  = [];
  this.fromLocal                = false;
  this.forceClear               = false;
  this.forceWidth               = false;
  this.fitExactly               = false;
  this.forceTextTransform       = true;
  this.useDomLoaded             = true;
  this.useStyleCheck            = false;
  this.hasFlashClassSet         = false;
  this.repaintOnResize          = true;
  this.callbacks                = [];

  var elementCount = 0; // The number of replaced elements.
  var hasPrefetched = false, isInitialized = false;

  var dom = new function() {
    var XHTML_NS = 'http://www.w3.org/1999/xhtml';

    this.getBody = function() {
      var nodes = document.getElementsByTagName('body');
      if(nodes.length == 1) return nodes[0];
      return null;
    };

    this.addClass = function(name, node) {
      if(node) node.className = ((node.className || '') == '' ? '' : node.className + ' ') + name;
    };

    this.removeClass = function(name, node) {
      if(node) node.className = node.className.replace(new RegExp('(^|\\s)' + name + '(\\s|$)'), '').replace(/^\s+|(\s)\s+/g, '$1');
    };

    this.hasClass = function(name, node) {
      return new RegExp('(^|\\s)' + name + '(\\s|$)').test(node.className);
    };

    this.hasOneOfClassses = function(names, node) {
      for(var i = 0; i < names.length; i++) {
        if(this.hasClass(names[i], node)) return true;
      }
      return false;
    };

    this.create = function(name) {
      if(document.createElementNS) return document.createElementNS(XHTML_NS, name);
      return document.createElement(name);
    };

    this.setInnerHtml = function(node, html) {
      if(ua.innerHtmlSupport) node.innerHTML = html;
      else if(ua.xhtmlSupport){
        html = ['<root xmlns="', XHTML_NS, '">', html, '</root>'].join('');
        var xml = (new DOMParser()).parseFromString(html, 'text/xml');
        xml = document.importNode(xml.documentElement, true);
        while(node.firstChild) node.removeChild(node.firstChild);
        while(xml.firstChild)  node.appendChild(xml.firstChild);
      }
    };

    this.nodeFromHtml = function(html) {
      var temp = this.create('div');
      temp.innerHTML = html;
      return temp.firstChild;
    };

    this.getComputedStyle = function(node, property) {
      var result;
      if(document.defaultView && document.defaultView.getComputedStyle) {
        result = document.defaultView.getComputedStyle(node, null)[property];
      } else if(node.currentStyle) result = node.currentStyle[property];
      return result || ''; // Ensuring a string.
    };

    this.getStyleAsInt = function(node, property, requirePx) {
      var value = this.getComputedStyle(node, property);
      if(requirePx && !/px$/.test(value)) return 0;

      value = parseInt(value);
      return isNaN(value) ? 0 : value;
    };

    this.getWidthFromStyle = function(node) {
      var width = this.getStyleAsInt(node, 'width', ua.ie);
      if(width == 0) {
        var paddingRight  = this.getStyleAsInt(node, 'paddingRight', true);
        var paddingLeft   = this.getStyleAsInt(node, 'paddingLeft', true);
        var borderRight   = this.getStyleAsInt(node, 'borderRightWidth', true);
        var borderLeft    = this.getStyleAsInt(node, 'borderLeftWidth', true);
        width = node.offsetWidth - paddingLeft - paddingRight - borderLeft - borderRight;
      }
      return width;
    };

    this.getZoom = function() {
      return hacks.zoom.getLatest();
    };

    this.blurElement = function(element) {
      if (ua.gecko) {
        // This can only be done in Gecko
        element.blur();
        return;
      }

      // Move the focus to an input element, and then destroy it.
      var input = dom.create('input');
      input.style.width = '0px';
      input.style.height = '0px';
      element.parentNode.appendChild(input);
      input.focus();
      input.blur();
      input.parentNode.removeChild(input);
    };

    this.getDimensions = function(node) {
      var width = node.offsetWidth;
      var height = node.offsetHeight;

      if(width == 0 || height == 0) {
        for(var i = 0; i < node.childNodes.length; i++) {
          var child = node.childNodes[i];
          if(child.nodeType != 1) continue;
          width = Math.max(width, child.offsetWidth);
          height = Math.max(height, child.offsetHeight);
        }
      }

      return {width: width, height: height};
    };

    this.contentIsLink = function(node) {
      var linkFound = false;
      for(var i = 0; i < node.childNodes.length; i++) {
        var child = node.childNodes[i];
        if(child.nodeType == 3 && !child.nodeValue.match(/^\s*$/)) return false;
        else if(child.nodeType != 1) continue;

        var isLink = child.nodeName.toLowerCase() == 'a';
        if(!isLink) return false;
        else linkFound = true;
      }
      return linkFound;
    };
  };
  this.dom = dom;

  var ua = new function() {
    var ua                = navigator.userAgent.toLowerCase();
    var product           = (navigator.product || '').toLowerCase();

    this.macintosh        = ua.indexOf('mac') > -1;
    this.windows          = ua.indexOf('windows') > -1;
    this.quicktime        = false;

    this.opera            = ua.indexOf('opera') > -1;
    this.konqueror        = product.indexOf('konqueror') > -1;
    this.ie               = false/*@cc_on || true @*/;
    this.ieSupported      = this.ie && !/ppc|smartphone|iemobile|msie\s5\.5/.test(ua)/*@cc_on && @_jscript_version >= 5.5 @*/
    this.ieWin            = this.ie && this.windows/*@cc_on && @_jscript_version >= 5.1 @*/;
    this.windows          = this.windows && (!this.ie || this.ieWin);
    this.ieMac            = this.ie && this.macintosh/*@cc_on && @_jscript_version < 5.1 @*/;
    this.macintosh        = this.macintosh && (!this.ie || this.ieMac);
    this.safari           = ua.indexOf('safari') > -1;
    this.webkit           = ua.indexOf('applewebkit') > -1 && !this.konqueror;
    this.khtml            = this.webkit || this.konqueror;
    this.gecko            = !this.webkit && product == 'gecko';

    this.operaVersion     = this.opera     && /.*opera(\s|\/)(\d+\.\d+)/.exec(ua) ? parseFloat(RegExp.$2) : 0;
    this.webkitVersion    = this.webkit    && /.*applewebkit\/(\d+).*/.exec(ua)   ? parseFloat(RegExp.$1) : 0;
    this.geckoBuildDate   = this.gecko     && /.*gecko\/(\d{8}).*/.exec(ua)       ? parseFloat(RegExp.$1) : 0;
    this.konquerorMajor   = this.konqueror && /.*konqueror\/(\d).*/.exec(ua)      ? parseFloat(RegExp.$1) : 0;
    this.konquerorMinor   = this.konqueror && /.*khtml\/\d\.(\d).*/.exec(ua)      ? parseFloat(RegExp.$1) : 0;
    this.konquerorSmall   = this.konqueror && /.*khtml\/\d\.\d\.(\d).*/.exec(ua)  ? parseFloat(RegExp.$1) : 0;

    this.flashVersion     = 0;
    if(this.ieWin) {
      var axo;
      var stop = false;
      try {
        axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
      } catch(e) {
        // In case the Flash 7 registry key does not exist, we need to test for specific
        // Flash 6 installs before we can use the general key.
        // See also <http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/>.
        // Many thanks to Geoff Stearns and Bobby van der Sluis for clarifying the problem and providing
        // examples of non-crashing code.
        try {
          axo                   = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
          this.flashVersion     = 6;
          axo.AllowScriptAccess = 'always';
        } catch(e) { stop = this.flashVersion == 6; }

        if(!stop) try { axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); } catch(e) {}
      }

      if(!stop && axo) this.flashVersion = parseFloat(/([\d,?]+)/.exec(axo.GetVariable('$version'))[1].replace(/,/g, '.'));
    } else if(navigator.plugins && navigator.plugins['Shockwave Flash']) {
      var flashPlugin = navigator.plugins['Shockwave Flash'];
      this.flashVersion = parseFloat(/(\d+\.?\d*)/.exec(flashPlugin.description)[1]);

      // Watch out for QuickTime, which could be stealing the Flash handling!
      var i = 0;
      while(this.flashVersion >= MIN_FLASH_VERSION && i < navigator.mimeTypes.length) {
        var mime = navigator.mimeTypes[i];
        if(mime.type == 'application/x-shockwave-flash' && mime.enabledPlugin.description.toLowerCase().indexOf('quicktime') > -1) {
          this.flashVersion = 0;
          this.quicktime = true;
        }
        i++;
      }
    }

    this.flash = this.flashVersion >= MIN_FLASH_VERSION;

    // There are other conditions, but these are ruled out in `computedStyledSupport` or `supported`.
    this.transparencySupport  = this.macintosh || this.windows;

    this.computedStyleSupport = this.ie || document.defaultView && document.defaultView.getComputedStyle
      && (!this.gecko || this.geckoBuildDate >= 20030624); // Older Geckos have trouble with `getComputedStyle()`

    this.xhtmlSupport = !!window.DOMParser && !!document.importNode;
    try {
      var n = dom.create('span');
      if(!this.ieMac) n.innerHTML = 'x'; // Need to test for IE/Mac, since the code will still be executed in IE/Mac.
      this.innerHtmlSupport = n.innerHTML == 'x';
    } catch (e) { this.innerHtmlSupport = false; }

    this.zoomSupport       = !!(this.opera && document.documentElement);
    this.geckoXml          = this.gecko && (document.contentType || '').indexOf('xml') > -1;

    this.requiresPrefetch  = this.ieWin || this.khtml;
    this.fixFocus          = this.gecko && this.windows && this.geckoBuildDate > 20061206;
    this.nativeDomLoaded   = this.gecko || this.webkit && this.webkitVersion >= 525
                                        || this.konqueror && this.konquerorMajor > 3 || this.opera;
    this.mustCheckStyle    = this.khtml || this.opera;
    this.forcePageLoad     = this.webkit && this.webkit < 523; // Fine in Konqueror 3.5.8, which is required for support.

    this.supported         = this.flash && (!this.ie || this.ieSupported)
      && (!this.opera/* || this.operaVersion >= 8*/) && (!this.webkit || this.webkitVersion >= 412)
      && (!this.konqueror/* || this.konquerorMajor > 3 || this.konquerorMajor == 3 && (this.konquerorMinor > 5 || this.konquerorMinor == 5 & this.konquerorSmall > 7)*/)
      && this.computedStyleSupport && (this.innerHtmlSupport || !this.khtml && this.xhtmlSupport)
      && (!this.gecko || this.geckoBuildDate > 20040804); // Had a few reports about Netscape 7.2 crashing, therefore
                                                          // now requiring a newer Gecko version.

  };
  this.ua = ua;

  var util = new function() {
    var UNIT_REMOVAL_PROPERTIES = {leading: true, 'margin-left': true, 'margin-right': true, 'text-indent': true};
    var SINGLE_WHITESPACE = ' ';

    function capitalize($) {
      return $.toUpperCase();
    }

    this.normalize = function(str) {
      if(SIFR.preserveSingleWhitespace) return str.replace(/\s/g, SINGLE_WHITESPACE);
      // Replace linebreaks by whitespace, then normalize and make sure no nbsp characters are
      // preserved as Flash doesn't seem to support them.
      return str.replace(/(\n|\r)+/g, SINGLE_WHITESPACE).replace(/(\s)\s+/g, '$1').replace(/\xA0/, SINGLE_WHITESPACE);
    };

    this.textTransform = function(type, str) {
      switch(type) {
        case 'uppercase':
          str = str.toUpperCase();
          break;

        case 'lowercase':
          str = str.toLowerCase();
          break;

        case 'capitalize':
          var strCopy = str;
          str = str.replace(/^\w|\s\w/g, capitalize);
          if(str.indexOf('function capitalize') != -1) {
            var substrs = strCopy.replace(/(^|\s)(\w)/g, '$1$1$2$2').split(/^\w|\s\w/g);
            str = '';
            for(var i = 0; i < substrs.length; i++) str += substrs[i].charAt(0).toUpperCase() + substrs[i].substring(1);
          }
          break;
      }

      return str;
    };

    this.toHexString = function(str) {
      if(typeof(str) != 'string' || !str.charAt(0) == '#' || str.length != 4 && str.length != 7) return str;

      str = str.replace(/#/, '');
      if(str.length == 3) str = str.replace(/(.)(.)(.)/, '$1$1$2$2$3$3');

      return '0x' + str;
    };

    this.toJson = function(obj) {
      var json = '';

      switch(typeof(obj)) {
        case 'string':
          json = '"' + obj + '"';
          break;
        case 'number':
        case 'boolean':
          json = obj.toString();
          break;
        case 'object':
          json = [];
          for(var prop in obj) {
            if(obj[prop] == Object.prototype[prop]) continue;
            json.push('"' + prop + '":' + util.toJson(obj[prop]));
          }
          json = '{' + json.join(',') + '}';
          break;
      }

      return json;
    };

    this.convertCssArg = function(arg) {
      if(!arg) return {};
      if(typeof(arg) == 'object') {
        if(arg.constructor == Array) arg = arg.join('');
        else return arg;
      }

      var obj = {};
      var rules = arg.split('}');

      for(var i = 0; i < rules.length; i++) {
        var $ = rules[i].match(/([^\s{]+)\s*\{(.+)\s*;?\s*/);
        if(!$ || $.length != 3) continue;

        if(!obj[$[1]]) obj[$[1]] = {};

        var properties = $[2].split(';');
        for(var j = 0; j < properties.length; j++) {
          var $2 = properties[j].match(/\s*([^:\s]+)\s*\:\s*([^;]+)/);
          if(!$2 || $2.length != 3) continue;
          obj[$[1]][$2[1]] = $2[2].replace(/\s+$/, '');
        }
      }

      return obj;
    };

    this.extractFromCss = function(css, selector, property, remove) {
      var value = null;

      if(css && css[selector] && css[selector][property]) {
        value = css[selector][property];
        if(remove) delete css[selector][property];
      }

      return value;
    };

    this.cssToString = function(arg) {
      var css = [];
      for(var selector in arg) {
        var rule = arg[selector];
        if(rule == Object.prototype[selector]) continue;

        css.push(selector, '{');
        for(var property in rule) {
          if(rule[property] == Object.prototype[property]) continue;
          var value = rule[property];
          if(UNIT_REMOVAL_PROPERTIES[property]) value = parseInt(value, 10);
          css.push(property, ':', value, ';');
        }
        css.push('}');
      }

      return css.join('');
    };

    this.bind = function(scope, method) {
      return function() {
        scope[method].apply(scope, arguments);
      };
    };

    this.escape = function(str) {
      return escape(str).replace(/\+/g, '%2B');
    };

    this.copyProperties = function(from, to) {
      for(var property in from) {
        if(to[property] === undefined) to[property] = from[property];
      }
      return to;
    };

    this.domain = function() {
      var domain = '';
      try { // When trying to access document.domain on a Google-translated page with Firebug, I got an exception.
        domain = document.domain;
      } catch(e) {};
      return domain;
    };

    this.domainMatches = function(domain, match) {
      if(match == '*' || match == domain) return true;

      var wildcard = match.lastIndexOf('*');
      if(wildcard > -1) {
        match = match.substr(wildcard + 1);
        var matchPosition = domain.lastIndexOf(match);
        if(matchPosition > -1 && (matchPosition + match.length) == domain.length) return true;
      }

      return false;
    };

    this.uriEncode = function(s) {
      return encodeURI(decodeURIComponent(s));  // Decode first, in case the URI was already encoded.
    }
  };
  this.util = util;

  var hacks = {};
  hacks.fragmentIdentifier = new function() {
    this.fix = true;

    var cachedTitle;
    this.cache = function() {
      cachedTitle = document.title;
    };

    function doFix() {
      document.title = cachedTitle;
    }

    this.restore = function() {
      if(this.fix) setTimeout(doFix, 0);
    };
  };
  this.hacks = {fragmentIdentifier: hacks.fragmentIdentifier};

  // The zoom hack needs to be run before replace(). The synchronizer can be
  // used to ensure this.
  hacks.synchronizer = new function() {
    this.isBlocked = false;

    this.block = function() {
      this.isBlocked = true;
    };

    this.unblock = function() {
      this.isBlocked = false;
      blockedReplaceKwargsStore.replaceAll();
    };
  };

  // Detect the page zoom in Opera. Adapted from <http://virtuelvis.com/archives/2005/05/opera-measure-zoom>.
  hacks.zoom = new function() {
    // Latest zoom, assume 100
    var latestZoom = 100;

    this.getLatest = function() {
      return latestZoom;
    }

    if(ua.zoomSupport && ua.opera) {
      // Create the DOM element used to calculate the zoom.
      var node = document.createElement('div');
      node.style.position = 'fixed';
      node.style.left = '-65536px';
      node.style.top = '0';
      node.style.height = '100%';
      node.style.width = '1px';
      node.style.zIndex = '-32';
      document.documentElement.appendChild(node);

      function updateZoom() {
        if(!node) return;

        var zoom = window.innerHeight / node.offsetHeight;

        var correction = Math.round(zoom * 100) % 10;
        if(correction > 5) zoom = Math.round(zoom * 100) + 10 - correction;
        else zoom = Math.round(zoom * 100) - correction;

        latestZoom = isNaN(zoom) ? 100 : zoom;
        hacks.synchronizer.unblock();

        document.documentElement.removeChild(node);
        node = null;
      }

      hacks.synchronizer.block();

      // We need to wait a few ms before Opera the offsetHeight of the node
      // becomes available.
      setTimeout(updateZoom, 54);
    }
  };

  hacks.pageLoad = new function() {
    var dummy = null;

    function pollLoad() {
      try {
        // IE hack courtesy of Diego Perini – <http://javascript.nwbox.com/IEContentLoaded/>.
        // Merged polling taken from jQuery – <http://dev.jquery.com/browser/trunk/jquery/src/event.js>
        if(ua.ie || document.readyState != 'loaded' && document.readyState != 'complete') {
          document.documentElement.doScroll('left');
        }
      } catch(e) {
        return setTimeout(pollLoad, 10);
      }
      afterDomLoad();
    };

    function afterDomLoad() {
      if(SIFR.useStyleCheck) checkStyle();
      else if(!ua.mustCheckStyle) fire(null, true);
    };

    function checkStyle() {
      dummy           = dom.create("div");
      dummy.className = CSS_DUMMY;
      dom.getBody().appendChild(dummy);
      pollStyle();
    };

    function pollStyle() {
      if(dom.getComputedStyle(dummy, 'marginLeft') == '42px') afterStyle();
      else setTimeout(pollStyle, 10);
    };

    function afterStyle() {
      if(dummy && dummy.parentNode) dummy.parentNode.removeChild(dummy);
      dummy = null;
      fire(null, true);
    };

    function fire(evt, preserveReplacements) {
      SIFR.initialize(preserveReplacements);

      // Remove handlers to prevent memory leak in Firefox 1.5, but only after onload.
      if(evt && evt.type == 'load') {
        if(document.removeEventListener) document.removeEventListener('DOMContentLoaded', fire, false);
        if(window.removeEventListener) window.removeEventListener('load', fire, false);
      }
    };

    this.attach = function() {
      if(window.addEventListener) window.addEventListener('load', fire, false);
      else window.attachEvent('onload', fire);

      if(!SIFR.useDomLoaded || ua.forcePageLoad) return;

      if(ua.nativeDomLoaded) {
        document.addEventListener('DOMContentLoaded', afterDomLoad, false);
      } else if(ua.ie || ua.khtml) {
        pollLoad();
      }
    };
  };

  this.errors = {
    isFile: 'sIFR: Did not activate because the page is being loaded from the filesystem.',
    getSource: 'sIFR: Could not determine appropriate source'
  };

  var replaceKwargsStore = {
    kwargs: [],
    replaceAll:  function(preserve) {
      for(var i = 0; i < this.kwargs.length; i++) SIFR.replace(this.kwargs[i]);
      if(!preserve) this.kwargs = [];
    }
  };

  var blockedReplaceKwargsStore = {
    kwargs: [],
    replaceAll: replaceKwargsStore.replaceAll
  };

  // The goal here is not to prevent usage of the Flash movie, but running sIFR on possibly translated pages
  function isValidDomain() {
    if(SIFR.domains.length == 0) return true;

    var domain = util.domain();

    for(var i = 0; i < SIFR.domains.length; i++) {
      var match = SIFR.domains[i];
      if(util.domainMatches(domain, match)) return true;
    }

    return false;
  }

  function isFile() {
    if(!SIFR.fromLocal && document.location.protocol == 'file:') {
      if(SIFR.debug) throw new Error(SIFR.errors.isFile);
      return true;
    }
    return false;
  }

  function resize() {
    var viewport = resize.viewport;
    resize.viewport = {
      width: window.innerWidth || document.documentElement.clientWidth || dom.getBody().clientWidth,
      height: window.innerHeight || document.documentElement.clientHeight || dom.getBody().clientHeight
    };

    if(viewport && resize.viewport.width == viewport.width && resize.viewport.height == viewport.height) {
      return;
    }

    if (resize.timer) clearTimeout(resize.timer);
    resize.timer = setTimeout(function() {
      delete resize.timer;
      for(var i = 0; i < SIFR.callbacks.length; i++) SIFR.callbacks[i].resize();
    }, 200);
  }

  this.activate = function(/* … */) {
    if(!ua.supported || !this.isEnabled || this.isActive || !isValidDomain() || isFile()) return;
    if(arguments.length > 0) this.prefetch.apply(this, arguments);

    this.isActive = true;
    if(this.hideElements) this.setFlashClass();

    hacks.fragmentIdentifier.fix = ua.ieWin && hacks.fragmentIdentifier.fix && window.location.hash != ''
    if(hacks.fragmentIdentifier.fix) hacks.fragmentIdentifier.cache();

    if(!this.registerEvents) return;

    hacks.pageLoad.attach();
  };

  this.setFlashClass = function() {
    if(this.hasFlashClassSet) return;

    dom.addClass(CSS_ACTIVE, dom.getBody() || document.documentElement);
    this.hasFlashClassSet = true;
  };

  this.removeFlashClass = function() {
    if(!this.hasFlashClassSet) return;

    dom.removeClass(CSS_ACTIVE, dom.getBody());
    dom.removeClass(CSS_ACTIVE, document.documentElement);
    this.hasFlashClassSet = false;
  }

  this.initialize = function(preserveReplacements) {
    if(!this.isActive || !this.isEnabled) return;
    if(isInitialized) {
      if(!preserveReplacements) replaceKwargsStore.replaceAll(false);
      return;
    }

    isInitialized = true;
    replaceKwargsStore.replaceAll(preserveReplacements);
    if(SIFR.repaintOnResize) {
      if(window.addEventListener) window.addEventListener('resize', resize, false);
      else window.attachEvent('onresize', resize);
    }
    clearPrefetch();
  };

  function getSource(src) {
    if(typeof(src) != 'string') {
      // This is a niciety to allow you to create general configuration objects
      // for the prefetch as well as the replacement. You could create constructs
      // like `{src: {src: { /*....*/ }}}`, but that's not really a problem.
      if(src.src) src = src.src;

      // It might be a string now...
      if(typeof(src) != 'string') {
        var versions = [];
        for(var version in src) if(src[version] != Object.prototype[version]) versions.push(version);
        versions.sort().reverse();

        var result = '';
        var i = -1;
        while(!result && ++i < versions.length) {
          if(parseFloat(versions[i]) <= ua.flashVersion) result = src[versions[i]];
        }

        src = result;
      }
    }

    if(!src && SIFR.debug) throw new Error(SIFR.errors.getSource);

    // Some IE installs refuse to show the Flash unless it gets the really absolute
    // URI of the file. I haven't been able to reproduce this behavior but let's
    // ensure a full URI none the less. This turns `/foo.swf` in `http://example.com/foo.swf`.
    if(ua.ie && src.charAt(0) == '/') {
      src = window.location.toString().replace(/([^:]+)(:\/?\/?)([^\/]+).*/, '$1$2$3') + src;
    }

    return src;
  }

  this.prefetch = function(/* … */) {
    if((!ua.requiresPrefetch && !this.isActive) || !ua.supported || !this.isEnabled || !isValidDomain()) return;
    if(this.setPrefetchCookie && new RegExp(';?' + PREFETCH_COOKIE + '=true;?').test(document.cookie)) return;

    try { // We don't know which DOM actions the user agent will allow
      hasPrefetched = true;

      if(ua.ieWin) prefetchIexplore(arguments);
      else prefetchLight(arguments);

      if(this.setPrefetchCookie) document.cookie = PREFETCH_COOKIE + '=true;path=' + this.cookiePath;
    } catch(e) { if(SIFR.debug) throw e; }
  };

  function prefetchIexplore(args) {
    for(var i = 0; i < args.length; i++) {
      document.write('<script defer type="sifr/prefetch" src="' + getSource(args[i]) + '"></script>');
    }
  }

  function prefetchLight(args) {
    for(var i = 0; i < args.length; i++) new Image().src = getSource(args[i]);
  }

  function clearPrefetch() {
    if(!ua.ieWin || !hasPrefetched) return;

    try {
      var nodes = document.getElementsByTagName('script');
      for(var i = nodes.length - 1; i >= 0; i--) {
        var node = nodes[i];
        if(node.type == 'sifr/prefetch') node.parentNode.removeChild(node);
      }
    } catch(e) {}
  }

  // Gives a font-size to required vertical space ratio
  function getRatio(size, ratios) {
    for(var i = 0; i < ratios.length; i += 2) {
      if(size <= ratios[i]) return ratios[i + 1];
    }
    return ratios[ratios.length - 1] || 1;
  }

  function getFilters(obj) {
    var filters = [];
    for(var filter in obj) {
      if(obj[filter] == Object.prototype[filter]) continue;

      var properties = obj[filter];
      filter = [filter.replace(/filter/i, '') + 'Filter'];

      for(var property in properties) {
        if(properties[property] == Object.prototype[property]) continue;
        filter.push(property + ':' + util.escape(util.toJson(util.toHexString(properties[property]))));
      }

      filters.push(filter.join(','));
    }

    return util.escape(filters.join(';'));
  }

  function calculate(node) {
    var lineHeight, lines;
    if(!ua.ie) { //:=todo Only do once for each selector?
      lineHeight = dom.getStyleAsInt(node, 'lineHeight');
      lines = Math.floor(dom.getStyleAsInt(node, 'height') / lineHeight);
    } else if(ua.ie) {
      // IE returs computed style in the original units, which is quite useless.
      // Therefore we'll only use the fontSize if it's in pixel units, otherwise we'll approximate.
      var fontSize = dom.getComputedStyle(node, 'fontSize');
      if(fontSize.indexOf('px') > 0) {
        lineHeight = parseInt(fontSize);
      } else {
        var html = node.innerHTML;

        // Without these settings, we won't be able to get the rects properly. getClientRects()
        // won't work on elements having layout or that are hidden.
        node.style.visibility  = 'visible';
        node.style.overflow    = 'visible';
        node.style.position    = 'static';
        node.style.zoom        = 'normal';
        node.style.writingMode = 'lr-tb';
        node.style.width       = node.style.height = 'auto';
        node.style.maxWidth    = node.style.maxHeight = node.style.styleFloat  = 'none';

        var rectNode = node;
        var hasLayout = node.currentStyle.hasLayout;
        if(hasLayout) {
          dom.setInnerHtml(node, '<div class="' + CSS_LAYOUT + '">X<br />X<br />X</div>');
          rectNode = node.firstChild;
        } else dom.setInnerHtml(node, 'X<br />X<br />X');

        var rects = rectNode.getClientRects();
        lineHeight = rects[1].bottom - rects[1].top;

        // In IE, the lineHeight is about 1.25 times the height in other browsers.
        lineHeight = Math.ceil(lineHeight * 0.8);

        if(hasLayout) {
          dom.setInnerHtml(node, '<div class="' + CSS_LAYOUT + '">' + html + '</div>');
          rectNode = node.firstChild;
        } else dom.setInnerHtml(node, html);
        rects = rectNode.getClientRects();
        lines = rects.length;

        if(hasLayout) dom.setInnerHtml(node, html);

        // By setting an empty string, the values will fall back to those in the (non-inline) CSS.
        // When that CSS changes, the changes are reflected here. Setting explicit values would break
        // that behaviour.
        node.style.visibility = node.style.width = node.style.height = node.style.maxWidth
                              = node.style.maxHeight = node.style.overflow = node.style.styleFloat
                              = node.style.position = node.style.zoom = node.style.writingMode
                              = '';
      }
    }

    return {lineHeight: lineHeight, lines: lines};
  }

  this.replace = function(kwargs, mergeKwargs) {
    if(!ua.supported) return;

    // This lets you specify to kwarg objects so you don't have to repeat common settings.
    // The first object will be merged with the second, while properties in the second
    // object have priority over those in the first. The first object is unmodified
    // for further use, the resulting second object will be used in the replacement.
    if(mergeKwargs) kwargs = util.copyProperties(kwargs, mergeKwargs);

    if(!isInitialized) return replaceKwargsStore.kwargs.push(kwargs);
    if(hacks.synchronizer.isBlocked) return blockedReplaceKwargsStore.kwargs.push(kwargs);

    if(SIFR.onReplacementStart) SIFR.onReplacementStart(kwargs);

    var nodes = kwargs.elements;
    if(!nodes && parseSelector) nodes = parseSelector(kwargs.selector);
    if(nodes.length == 0) return;

    this.setFlashClass();

    var src = getSource(kwargs.src);
    var css = util.convertCssArg(kwargs.css);
    var filters = getFilters(kwargs.filters);

    var forceClear      = (kwargs.forceClear == null) ? SIFR.forceClear : kwargs.forceClear;
    var fitExactly      = (kwargs.fitExactly == null) ? SIFR.fitExactly : kwargs.fitExactly;
    var forceWidth      = fitExactly || (kwargs.forceWidth == null ? SIFR.forceWidth : kwargs.forceWidth);
    var preventWrap     = !!(kwargs.preventWrap && !kwargs.forceSingleLine);

    var leading         = parseInt(util.extractFromCss(css, '.sIFR-root', 'leading')) || 0;
    var fontSize        = util.extractFromCss(css, '.sIFR-root', 'font-size', true) || 0;
    var backgroundColor = util.extractFromCss(css, '.sIFR-root', 'background-color', true) || '#FFFFFF';
    var kerning         = util.extractFromCss(css, '.sIFR-root', 'kerning', true) || '';
    var gridFitType     = kwargs.gridFitType || util.extractFromCss(css, '.sIFR-root', 'text-align') == 'right' ? 'subpixel' : 'pixel';
    var textTransform   = SIFR.forceTextTransform ? util.extractFromCss(css, '.sIFR-root', 'text-transform', true) || 'none' : 'none';
    var opacity         = util.extractFromCss(css, '.sIFR-root', 'opacity', true) || '100';
    var cursor          = util.extractFromCss(css, '.sIFR-root', 'cursor', true) || 'default';
    var pixelFont       = kwargs.pixelFont || false;
    var ratios          = kwargs.ratios || DEFAULT_RATIOS;
    var tuneHeight      = parseInt(kwargs.tuneHeight) || 0;
    var events          = !!kwargs.onRelease || !!kwargs.onRollOver || !!kwargs.onRollOut;

    if(parseInt(fontSize).toString() != fontSize && fontSize.indexOf('px') == -1) fontSize = 0; // We only support pixel sizes
    else fontSize = parseInt(fontSize);
    if(parseFloat(opacity) < 1) opacity = 100 * parseFloat(opacity); // Make sure to support percentages and decimals

    var cssText = '';
    // Alignment is handled by the browser in this case.
    if(fitExactly) util.extractFromCss(css, '.sIFR-root', 'text-align', true);
    if(!kwargs.modifyCss) cssText = util.cssToString(css);

    var wmode = kwargs.wmode || '';
    if(!wmode) {
      if(kwargs.transparent) wmode = 'transparent';
      else if(kwargs.opaque) wmode = 'opaque';
    }
    if(wmode == 'transparent') {
      if(!ua.transparencySupport) wmode = 'opaque';
      else backgroundColor = 'transparent';
    }


    for(var i = 0; i < nodes.length; i++) {
      var node = nodes[i];

      if(dom.hasOneOfClassses([CSS_REPLACED, CSS_IGNORE, CSS_ALTERNATE], node)) continue;

      // Opera does not allow communication with hidden Flash movies. Visibility is tackled by sIFR itself, but
      // `display:none` isn't. Additionally, WebKit does not return computed style information for elements with
      // `display:none`. We'll prevent elements which have `display:none` or are contained in such an element from
      // being replaced. It's a bit hard to detect this, but we'll check for the dimensions of the element and it's
      // `display` property.

      var dimensions = dom.getDimensions(node);
      var height     = dimensions.height;
      var width      = dimensions.width;
      var display    = dom.getComputedStyle(node, 'display');

      if(!height || !width || display == null || display == 'none') continue;

      if(forceClear && ua.gecko) node.style.clear = 'both';

      // If the text doesn't wrap nicely, the width becomes too large and Flash
      // can't adjust for it. By setting the text to just "X" we can be sure
      // we get the correct width.
      var html = null;
      if(SIFR.fixWrap && ua.ie && display == 'block') {
        html = node.innerHTML;
        dom.setInnerHtml(node, 'X');
      }

      // Get the width (again to approximate the final size). The computed width
      // may not be a pixel unit in IE, in which case we try to calculate using
      // padding and borders and the offsetWidth.
      width = dom.getWidthFromStyle(node);

      if(html && SIFR.fixWrap && ua.ie) dom.setInnerHtml(node, html);

      var lineHeight, lines;
      if(!fontSize) {
        var calculation = calculate(node);
        lineHeight      = Math.min(MAX_FONT_SIZE, Math.max(MIN_FONT_SIZE, calculation.lineHeight));
        if(pixelFont) lineHeight = Math.max(8, 8 * Math.round(lineHeight / 8));

        lines = calculation.lines;
        if(isNaN(lines) || !isFinite(lines) || lines == 0) lines = 1;

        if(lines > 1 && leading) height += Math.round((lines - 1) * leading);
      } else {
        lineHeight = fontSize;
        lines      = 1;
      }

      height = Math.round(lines * lineHeight);

      // We have all the info we need, reset the display setting now.
      if(forceClear && ua.gecko) node.style.clear = '';

      // I wanted to use `noembed` here, but unfortunately FlashBlock only works with `span.sIFR-alternate`
      var alternate = dom.create('span');
      alternate.className = CSS_ALTERNATE;

      // Clone the original content to the alternate element.
      var contentNode = node.cloneNode(true);
      // Temporarily append the contentNode to the document, to get around IE problems with resolved hrefs
      node.parentNode.appendChild(contentNode);

      for(var j = 0, l = contentNode.childNodes.length; j < l; j++) {
        alternate.appendChild(contentNode.childNodes[j].cloneNode(true));
      }

      // Allow the sIFR content to be modified
      if(kwargs.modifyContent) kwargs.modifyContent(contentNode, kwargs.selector);
      if(kwargs.modifyCss) cssText = kwargs.modifyCss(css, contentNode, kwargs.selector);

      var fixHover = SIFR.fixHover && dom.contentIsLink(contentNode);
      var content = handleContent(contentNode, textTransform, kwargs.uriEncode);

var mifr = kwargs.mifr || '';
if(mifr == 'menu')
{
	// mifr menu
	sContent = trim(contentNode.innerHTML);

	// remove newlines, returns, tabs and white spaces
	sContent = replace(sContent,"\n","");
	sContent = replace(sContent,"\r","");
	sContent = replace(sContent,"\t","");
	sContent = replace(sContent,"  ","");
	sContent = replace(sContent, strSiteUrl,"");
	sContent = replace(sContent,'class=process_nav','class="process_nav"');
	sContent = replace(sContent,'class=last','class="last"');
	sContent = replace(sContent,'class=first','class="first"');
	sContent = replace(sContent,'class=selected','class="selected"');
	sContent = replace(sContent,"<OL","<ol");
	sContent = replace(sContent,"</OL>","</ol>");
	sContent = replace(sContent," <LI"," <li");
	sContent = replace(sContent,"<LI>","<li>");
	sContent = replace(sContent,"</LI>","</li>");
	sContent = replace(sContent,"<A ","<a ");
	sContent = replace(sContent,"</A>","</a>");
	sContent = replace(sContent,"<SPAN>","<span>");
	sContent = replace(sContent,"<SPAN ","<span ");
	sContent = replace(sContent,"</SPAN> ","</span>");
	sContent = replace(sContent,"</a> ","</a>");

	//sContent = '<ol class="process_nav"><li><a href="products/shared-hosting/" class="first">OVERVIEW</a></li><li><a href="products/shared-hosting/packages/" class="selected">PACKAGES</a></li><li><a href="products/shared-hosting/compare/" class="last">COMPARE PACKAGES</a></li></ol>';
	//sContentTmp = escape(sContent);
	//$('debug').setHTML(sContentTmp);
	//alert(sContentTmp);
	//alert(sContent);

	contentNode.parentNode.removeChild(contentNode);

	var vars = ['txt=' + escape(sContent), 'antialiastype=' + (kwargs.antiAliasType || ''),
                  'width=' + width, 'height=' + height, 'fitexactly=' + fitExactly,
                  'tunewidth=' + (kwargs.tuneWidth || 0), 'tuneheight=' + tuneHeight,
                  'offsetleft=' + (kwargs.offsetLeft || ''), 'offsettop=' + (kwargs.offsetTop || ''),
                  'thickness=' + (kwargs.thickness || ''), 'sharpness=' + (kwargs.sharpness || ''),
                  'kerning=' + kerning, 'gridfittype=' + gridFitType, 'zoomsupport=' + ua.zoomSupport,
                  'flashfilters=' + filters, 'opacity=' + opacity, 'blendmode=' + (kwargs.blendMode || ''),
                  'size=' + lineHeight, 'zoom=' + dom.getZoom(), 'css=' + util.escape(cssText),
                  'selectable=' + (kwargs.selectable == null ? 'true' : kwargs.selectable),
                  'fixhover=' + fixHover, 'preventwrap=' + preventWrap, 'forcesingleline=' + (kwargs.forceSingleLine === true),
                  'link=' + util.escape(content.primaryLink[0] || ''), 'target=' + util.escape(content.primaryLink[1] || ''),
                  'events=' + events, 'cursor=' + cursor, 'version=' + VERSION];
}
else
{
	// normal sifr

	// Remove the contentNode again
	contentNode.parentNode.removeChild(contentNode);
	if(kwargs.modifyContentString) content.text = kwargs.modifyContentString(content.text, kwargs.selector);
	if(content.text == '') continue;

	var vars = ['content=' + util.escape(content.text), 'antialiastype=' + (kwargs.antiAliasType || ''),
                  'width=' + width, 'height=' + height, 'fitexactly=' + fitExactly,
                  'tunewidth=' + (kwargs.tuneWidth || 0), 'tuneheight=' + tuneHeight,
                  'offsetleft=' + (kwargs.offsetLeft || ''), 'offsettop=' + (kwargs.offsetTop || ''),
                  'thickness=' + (kwargs.thickness || ''), 'sharpness=' + (kwargs.sharpness || ''),
                  'kerning=' + kerning, 'gridfittype=' + gridFitType, 'zoomsupport=' + ua.zoomSupport,
                  'flashfilters=' + filters, 'opacity=' + opacity, 'blendmode=' + (kwargs.blendMode || ''),
                  'size=' + lineHeight, 'zoom=' + dom.getZoom(), 'css=' + util.escape(cssText),
                  'selectable=' + (kwargs.selectable == null ? 'true' : kwargs.selectable),
                  'fixhover=' + fixHover, 'preventwrap=' + preventWrap, 'forcesingleline=' + (kwargs.forceSingleLine === true),
                  'link=' + util.escape(content.primaryLink[0] || ''), 'target=' + util.escape(content.primaryLink[1] || ''),
                  'events=' + events, 'cursor=' + cursor, 'version=' + VERSION];
}

	 var encodedVars = encodeVars(vars);
      var callbackName = 'sIFR_callback_' + elementCount++;
      var callbackInfo = new CallbackInfo(callbackName, vars, {
        onReplacement: kwargs.onReplacement,
        onRollOver: kwargs.onRollOver,
        onRollOut: kwargs.onRollOut,
        onRelease: kwargs.onRelease
      });
      window[callbackName + '_DoFSCommand'] = (function(callbackInfo) {
        return function(info, arg) {
          callbackInfo.handle(info, arg);
        }
      })(callbackInfo);
      alternate.setAttribute('id', callbackName + '_alternate');

      // Approximate the final height to avoid annoying movements of the page
      height = Math.round(lines * getRatio(lineHeight, ratios) * lineHeight) + FLASH_PADDING_BOTTOM + tuneHeight;

      var forcedWidth = forceWidth ? width : '100%';

      var flash;
      if(ua.ie) {
        flash = [
          '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="', callbackName,
           '" sifr="true" width="', forcedWidth, '" height="', height, '" class="', CSS_FLASH, '">',
            '<param name="movie" value="', src, '"></param>',
            '<param name="flashvars" value="', encodedVars, '"></param>',
            '<param name="allowScriptAccess" value="always"></param>',
            '<param name="quality" value="best"></param>',
            '<param name="wmode" value="', wmode, '"></param>',
            '<param name="bgcolor" value="', backgroundColor, '"></param>',
            '<param name="name" value="', callbackName, '"></param>',
          '</object>',
          // Load in the callback code. Keep the <script> line exactly the same!!! (Yes, IE is that crappy)
          // Thanks to Tom Lee for the tip: <http://tom-lee.blogspot.com/2006/04/dynamically-inserting-fscommand.html>
          '<scr', 'ipt event=FSCommand(info,args) for=', callbackName, '>',
            callbackName, '_DoFSCommand(info, args);',
          '</', 'script>' // End like this to prevent syntax error in IE/Mac.
        ].join('');
      } else {
        flash = [
          '<embed type="application/x-shockwave-flash" class="' + CSS_FLASH + '" src="', src,
          '" quality="best" flashvars="', encodedVars, '" width="', forcedWidth, '" height="', height,
          '" wmode="', wmode, '" bgcolor="', backgroundColor, '" name="', callbackName, '" id="', callbackName,
          '" allowScriptAccess="always" sifr="true"></embed>'
        ].join('');
      }

      var insert = ua.fixFocus && kwargs.fixFocus ? '<div class="' + CSS_FIX_FOCUS + '">' + flash + '</div>' : flash;
      dom.setInnerHtml(node, insert);
      callbackInfo.html = flash;
      SIFR.callbacks.push(callbackInfo);
      if(kwargs.selector) {
        if(!SIFR.callbacks[kwargs.selector]) SIFR.callbacks[kwargs.selector] = [callbackInfo];
        else SIFR.callbacks[kwargs.selector].push(callbackInfo);
      }
      node.appendChild(alternate);
      dom.addClass(CSS_REPLACED, node);
    }

    hacks.fragmentIdentifier.restore();
  };

  this.getCallbackByFlashElement = function(node) {
    for(var i = 0; i < SIFR.callbacks.length; i++) {
      if(SIFR.callbacks[i].id == node.getAttribute('id')) return SIFR.callbacks[i];
    }
  };

  this.redraw = function() {
    for(var i = 0; i < SIFR.callbacks.length; i++) SIFR.callbacks[i].resetMovie();
  };

  function encodeVars(vars) {
    return vars.join('&amp;').replace(/%/g, '%25');
  }

  /*=:private
    Walks through the childNodes of `source`. Generates a text representation of these childNodes.

    Returns:
    * string: the text representation.

    Notes:
    * A number of items are still to do. See the individual comments for that.
    * This method does not recursion because it'll be necessary to keep a
      count of all links and their URIs. This is easier without recursion.
  */
  function handleContent(source, textTransform, uriEncode) {
    uriEncode = uriEncode || util.uriEncode;
    var stack = [], content = [], primaryLink = [];
    var nodes = source.childNodes;

    var i = 0;
    while(i < nodes.length) {
      var node = nodes[i];

      if(node.nodeType == 3) {
        var text = util.normalize(node.nodeValue);
        text = util.textTransform(textTransform, text);
        // Escape < characters because they'll mess with the HTML rendering inside Flash.
        text = text.replace(/</g, '&lt;');
        content.push(text);
      }

      if(node.nodeType == 1) {
        var attributes = [];
        var nodeName = node.nodeName.toLowerCase();

        var className = node.className || '';
        // If there are multiple classes, look for the specified sIFR class
        if(/\s+/.test(className)) {
          if(className.indexOf(CSS_CLASS) > -1) className = className.match('(\\s|^)' + CSS_CLASS + '-([^\\s$]*)(\\s|$)')[2];
          // or use the first class
          else className = className.match(/^([^\s]+)/)[1];
        }
        if(className != '') attributes.push('class="' + className + '"');

        if(nodeName == 'a') {
          var href = uriEncode(node.getAttribute('href') || '');
          var target = node.getAttribute('target') || '';
          attributes.push('href="' + href + '"', 'target="' + target + '"');

          if(primaryLink.length == 0) primaryLink = [href, target];
        }

        content.push('<' + nodeName + (attributes.length > 0 ? ' ' : '') + attributes.join(' ') + '>');

        if(node.hasChildNodes()) {
          // Push the current index to the stack and prepare to iterate
          // over the childNodes.
          stack.push(i);
          i = 0;
          nodes = node.childNodes;
          continue;
        } else if(!/^(br|img)$/i.test(node.nodeName)) content.push('</', node.nodeName.toLowerCase(), '>');
      }

      if(stack.length > 0 && !node.nextSibling) {
        // Iterating the childNodes has been completed. Go back to the position
        // before we started the iteration. If that position was the last child,
        // go back even further.
        do {
          i = stack.pop();
          nodes = node.parentNode.parentNode.childNodes;
          node = nodes[i];
          if(node) content.push('</', node.nodeName.toLowerCase(), '>');
        } while(i == nodes.length - 1 && stack.length > 0);
      }

      i++;
    }

    return {text: content.join('').replace(/\n|\r/g, ''), primaryLink: primaryLink};
  }

  function CallbackInfo(id, vars, events) {
    this.id         = id;
    this.vars       = vars;

    this._events                = events;
    this._firedReplacementEvent = !(events.onReplacement != null);
    this.html                   = '';
  }

  CallbackInfo.prototype.getFlashElement = function() {
    return document.getElementById(this.id);
  };

  CallbackInfo.prototype.available = function() {
    var flashNode = this.getFlashElement();
    return flashNode && flashNode.parentNode;
  };

  CallbackInfo.prototype.handle = function(info, arg) {
    if(!this.available()) return;

    if(/(FSCommand\:)?resize/.test(info)) {
      var flashNode = this.getFlashElement();

      var $ = arg.split(/\:|,/);
      flashNode.setAttribute($[0], $[1]);
      if($.length > 2) flashNode.style[$[2]] = $[3] + 'px';

      // Here comes another story!
      //
      // Good old Safari (saw this in 2.0.3) does not see the resizing
      // of the Flash movie as requiring a repaint of the document. Because
      // of this, the movie won't be resized unless Safari is forced to.
      // This is done by requesting the `offsetHeight` on the Flash node.
      //
      // Just to be sure this hack is applied to all browsers which
      // implement the KHTML engine.
      if(ua.khtml) var repaint = flashNode.offsetHeight;

      if(!this._firedReplacementEvent) {
        this._events.onReplacement(this);
        this._firedReplacementEvent = true;
      }
    } else if(/(FSCommand\:)?resetmovie/.test(info)) {
      this.resetMovie();
    } else if(/(FSCommand\:)?blur/.test(info)) {
      dom.blurElement(this.getFlashElement());
    } else if(/(FSCommand\:)?event/.test(info)) {
      if (this._events[arg]) this._events[arg](this);
    } else if(this.debugHandler && /(FSCommand\:)?debug/.test(info)) {
      this.debugHandler(info, arg);
    }
  };

  CallbackInfo.prototype.call = function(type, value) {
    if(!this.available()) return false;

    var flashNode = this.getFlashElement();
    try {
      flashNode.SetVariable('callbackType', type);
      flashNode.SetVariable('callbackValue', value);
      flashNode.SetVariable('callbackTrigger', true);
    } catch(e) {
      return false;
    }

    return true;
  };

  // `content` must not be util.escaped.
  CallbackInfo.prototype.replaceText = function(content) {
    var escapedContent = util.escape(content);
    this.injectVars('content', escapedContent);
    if(this.call('replacetext', escapedContent)) {
      dom.setInnerHtml(this.getAlternate(), content);
      return true;
    }
    return false;
  };

  CallbackInfo.prototype.injectVars = function(name, value) {
    for(var i = 0; i < this.vars.length; i++) {
      if (this.vars[i].split('=')[0] == name)
      {
        this.vars[i] = name + '=' + value;
        break;
      }
    }
    this.html = this.html.replace(/(flashvars(=|\"\svalue=)\")[^\"]+/, '$1' + encodeVars(this.vars));
  }

  CallbackInfo.prototype.resetMovie = function() {
    if(!this.available()) return;

    var flashNode = this.getFlashElement();
    var node = flashNode.parentNode;
    // Not using outerHTML because the Flash vars will be lost.
    node.replaceChild(dom.nodeFromHtml(this.html), flashNode);
  };

  CallbackInfo.prototype.resize = function() {
    if(!this.available()) return;

    var flashNode      = this.getFlashElement();
    var ancestor       = flashNode.parentNode;
    var originalWidth  = dom.getComputedStyle(flashNode, 'width');
    var originalHeight = dom.getComputedStyle(flashNode, 'height');

    // Remove Flash movie from flow
    flashNode.style.width = '0px';
    flashNode.style.height = '0px';

    // Set a minimal height on the flashNode's parent, to stop a reflow
    flashNode.parentNode.style.minHeight = originalHeight;

    // Restore original content
    var nodes = this.getAlternate().childNodes;
    var clones = [];
    for(var i = 0; i < nodes.length; i++) {
      var node = nodes[i].cloneNode(true);
      clones.push(node);
      ancestor.appendChild(node);
    }

    // Calculate width
    var width = dom.getWidthFromStyle(ancestor);

    // Remove original content again
    for(var i = 0; i < clones.length; i++) ancestor.removeChild(clones[i]);

    // Reset Flash movie flow
    flashNode.style.width                = originalWidth;
    flashNode.style.height               = originalHeight;
    flashNode.parentNode.style.minHeight = '';

    // Resize!
    if(width != parseInt(originalWidth)) this.call('resize', width);
  };

  CallbackInfo.prototype.changeCSS = function(css) {
    css = util.escape(util.cssToString(util.convertCssArg(css)));
    this.injectVars('css', css);
    return this.call('changecss', css);
  };

  CallbackInfo.prototype.getAlternate = function() {
    return document.getElementById(this.id + '_alternate');
  };
};

/*
	=SIFT-CONFIG.JS
*/

var is_light = {src: 'js/interstate_light_3.swf'};
var is_rc = {src: 'js/interstate_regularcompressed_3.swf'};
var menu = {src: 'js/progressmenu.swf'};

sIFR.prefetch(is_light, is_rc, menu);
sIFR.activate(is_light, is_rc, menu);

sIFR.replace(is_light, {
	selector: 'h2',
	css: [
		'.sIFR-root { font-weight:normal;font-size:18px;color:#566077;background: transparent; }'
    ],
    wmode: 'transparent'
});

sIFR.replace(is_rc, {
	selector: 'div.yourcart_widget h3',
	css: [
		'.sIFR-root { font-weight:normal;font-size:24px;color:#FFFFFF;background: transparent; }'
	],
	wmode: 'transparent'
});

sIFR.replace(is_rc, {
	selector: 'div.yourcart_widget_tabber h3',
	css: [
		'.sIFR-root { font-weight:normal;font-size:24px;color:#FFFFFF;background: transparent; }'
	],
	wmode: 'transparent'
});

sIFR.replace(is_rc, {
	selector: 'div.yourcart_widget_blue h3',
	css: [
		'.sIFR-root { font-weight:normal;font-size:24px;color:#FFFFFF;background: transparent; }'
	],
	wmode: 'transparent'
});

sIFR.replace(is_rc, {
	selector: 'h3',
	css: [
		'.sIFR-root { font-weight:normal;font-size:24px;color:#003366;background: transparent; }'
	],
	wmode: 'transparent'
});

sIFR.replace(is_rc, {
	selector: 'h4',
	css: [
		'.sIFR-root { font-weight:normal;font-size:24px;color:#7F8B9D;background: transparent; }'
	],
	wmode: 'transparent'
});


sIFR.replace(menu, {
	selector: 'div.progress_nav_wrapper',
	wmode: 'transparent',
	mifr: 'menu'
});
