BWCC = {
	getAbsolutePosition : function (o, stopElement) {
	    if (!o || typeof o != "object") {
	        return false;
	    }
	    if (!o.offsetParent) {
	        return false;
	    }
	    var position = new Object();
	    position["left"] = parseInt(o.offsetLeft);
	    position["top"] = parseInt(o.offsetTop);
	    while (o = o.offsetParent) {
			if (o == stopElement) {
				break;
			}
	        position["left"] += parseInt(o.offsetLeft);
	        position["top"] += parseInt(o.offsetTop);
	    }
	    return position;
	},
	
	//change this to take a parent
	//PASS THIS AN ELEMENT AND A STRING TO GET ALL ELEMENTS WITH THAT STRING IN THEIR CLASSNAME
	fuzzyClassName : function (tag,fClass)	{
		var el = (tag == "*" && document.all) ? document.all : document.getElementsByTagName(tag);
		var o=new Array();
		for (var i=0;i<el.length;i++)	{
			if (el[i].className.indexOf(fClass)!=-1)	{
				o.push(el[i]);
			}
		}
		return o;
	},
	
	toggleSelectBoxes : function (el) {
		if(window.ie && !window.ie7 ) {			
			var selects = $$("#"+ el + " select");
			for( var i = selects.length-1; i >= 0 ;i--) {
				selects[i].style.visibility = (selects[i].style.visibility == "hidden") ? "visible" : "hidden";
			}
		}
	},		
	/**
	 * @param {String} str
	 * @return {Object} width, height
	 */
	getScene7Dimensions : function (str) {
		var obj = {};
		if (str.indexOf('wid=') != -1) {		
			var dims = str.split('&');
			var dim
			for (i = dims.length-1; i >= 0; i--) {
				dim = dims[i].split("=");
				if (dim[0] == 'wid' || dim[0] == 'hei') {
					obj[dim[0]] = dim[1];
				}
			}		
		} 
		return obj;	
	}
}


if(!com){var com=new Object();}
if(typeof com.lbi=="undefined"){com.lbi=new Object();}
if(typeof com.lbi.utils=="undefined"){com.lbi.utils=new Object();}
if(typeof com.lbi.utils.DomUtils=="undefined"){com.lbi.utils.DomUtils=new Object();}

com.lbi.utils.DomUtils = function(){
}
/**
 * Injector{tag_name:String, attribute_maps:Object)
 * 
*/
com.lbi.utils.DomUtils.createAttributesInjector = function(tag_name, attribute_maps)
{
	return {tag_name:tag_name, attribute_maps:attribute_maps};
}
com.lbi.utils.DomUtils.createAttributeMap = function (attribute_name, map)
{
	return {attribute_name:attribute_name, map:map};
}
com.lbi.utils.DomUtils.getDefaultAttributes = function (allowed_attributes)
{
	var isInArray = com.lbi.utils.DomUtils.isInArray;
	var default_attributes = ["id", "src", "href", "class"];
	for(var i=0; i<allowed_attributes.length; i++){
		var attribute = allowed_attributes[i];
		if(!isInArray(attribute, default_attributes)){
			default_attributes.push(attribute);
		}
	}
	return default_attributes;
}
//TODO: provide full support for attributes
com.lbi.utils.DomUtils.innerHTML = function (src_obj, attributes_injectors, allowed_attributes)
{
	var InnerHTML = com.lbi.utils.DomUtils.innerHTML;
	var getNodeAttributes = com.lbi.utils.DomUtils.getNodeAttributes;
	var getInjectedAttributes = com.lbi.utils.DomUtils.getInjectedAttributes;
	var removeComments = com.lbi.utils.DomUtils.removeComments;
	var str_out='';
	
	var children=src_obj.childNodes;
	
	for (var i=children.length-1; i>=0; i--)
	{
		var c_node=children[i];
		
		
		if(c_node.nodeType==1) // element
		{
			var tag_name = c_node.tagName.toLowerCase();
			attr_str = "";
			//attr_str += c_node.getAttributeNode("id") ? getCarouselData(c_node.getAttributeNode("id").nodeValue) : "";
			attr_str += getNodeAttributes(c_node, allowed_attributes);
			var id = com.lbi.utils.DomUtils.getNodeAttribute(c_node, "id");
			if(attributes_injectors != null && id != null){
				var attr_inj_str = getInjectedAttributes(tag_name, id, attributes_injectors);
				attr_str += attr_inj_str;
			}
			str_out = 	'<' + tag_name + attr_str + '>' + InnerHTML(c_node, attributes_injectors, allowed_attributes) +  '</' + tag_name + '>' + str_out;
		}else if(c_node.nodeType==8) // comment
		{
		}else{// 3 = text
			str_out = c_node.nodeValue + str_out;			
		}
	}
	return str_out;
}

com.lbi.utils.DomUtils.getInjectorByTagName = function(tag_name, attributes_injectors)
{
	for(var i=0; i<attributes_injectors.length; i++)
	{
		var injector = attributes_injectors[i];
		if(injector.tag_name.toLowerCase() == tag_name.toLowerCase()) return injector;
	}
	return null;
}

com.lbi.utils.DomUtils.getInjectedAttributes = function(tag_name, id, attributes_injectors)
{
	var injector = com.lbi.utils.DomUtils.getInjectorByTagName(tag_name, attributes_injectors);
	if(injector == null) return "";
	var res = "";
	var attribute_maps = injector.attribute_maps;
	for(var i=0; i<attribute_maps.length; i++){
		var attribute_map = attribute_maps[i];
		var attribute_name = attribute_map.attribute_name;
		var attribute_value = attribute_map.map[id];
		//if(attribute_value == null) alert("can't find value for id:" + id + " tag_name:" + tag_name + " attribute_name:" + attribute_name);
		if(attribute_value != null)	res += " " + attribute_name + "='" + attribute_value + "'";
	}
	return res;
}

com.lbi.utils.DomUtils.getNodeAttribute = function($node, $attribute)
{
	var attributes = com.lbi.utils.DomUtils.getNodeAttributesArray($node);
	for(var i=0; i<attributes.length; i++){
		var attribute = attributes[i];
		if(attribute.nodeName.toLowerCase() == $attribute.toLowerCase()) return attribute.nodeValue;
	}
	return null;
}

com.lbi.utils.DomUtils.getNodeAttributesArray = function($node)
{
	return $node.attributes ? $node.attributes : $node.getAttributes();
}

com.lbi.utils.DomUtils.getNodeAttributes = function($node, allowed_attributes){
	var isInArray = com.lbi.utils.DomUtils.isInArray;
	//var allowed_tags = (allowed_attributes != null ? allowed_attributes : ["id", "src", "href", "class"]);
	var res = "";
	var arr = com.lbi.utils.DomUtils.getNodeAttributesArray($node);
	for(var j=0; j<arr.length; j++){
		var attr_node = arr[j];
		var attr_name = attr_node.nodeName.toLowerCase();
		if(allowed_attributes != null){
			if(isInArray (attr_name, allowed_attributes)){
				res += " " + attr_name + "='" + attr_node.nodeValue + "'";
			}
		}else{
			res += " " + attr_name + "='" + attr_node.nodeValue + "'";
		}
	}
	//alert(res);
	return res;
}
com.lbi.utils.DomUtils.isInArray = function ($element, $array){
	for(var i=0; i<$array.length; i++){
		if($array[i] == $element) return true;
	}
	return false;
}

// Cookies
function setCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function deleteCookie(name) {
    setCookie(name,"",-1);
}

//show all items that should be hidden when javascript is disabled
if (typeof jQuery != "undefined") {
	jQuery(document).ready(function(){
		jQuery('.jsHidden').show();
	});
}

var SiteLauncher = (function(jQuery){	
	if (!jQuery) {
		alert('jQuery is missing. This script required jQuery.');
		return null;
	}		
	return {	
		links: "",
		init: function() {		
			if (jQuery("#siteLauncher").size() > 0) {
				this.links = jQuery("#siteLauncherContainer");
				
				jQuery("#siteLauncherContainer").hide();
				
				jQuery("#showSiteLauncher").click(function() {
					SiteLauncher.links.slideDown('slow');
					jQuery("#showSiteLauncher").hide();
					jQuery("#hideSiteLauncher").show();
					if (cmEnabled) {
						SiteLauncher.sendCMData(launcherID);
					}
					return false;
				});
				
				jQuery("#hideSiteLauncher").click(function() {
					SiteLauncher.links.slideUp('fast');
					jQuery("#hideSiteLauncher").hide();
					jQuery("#showSiteLauncher").show();
					return false;
				});
				
				jQuery("#siteLauncherContainer").removeClass("hide");				
			}										
		},
		sendCMData: function(launcher) {
			cmCreatePageElementTag(launcher, launcher, "", "", "", "-_--_--_--_--_--_--_--_--_--_--_--_--_--_-");
		}
	}	
})(jQuery);

jQuery(document).ready(function() {
	SiteLauncher.init();
});

function payWithGiftVoucher() {
	if (!$('payWithGiftVoucher')) {return};
	$('payWithGiftVoucher').addEvent('click', function(e) {
	
		e = new Event(e).stop();
		
		TB_show('Online e-voucher',selectGiftVoucherURL+payWithGiftVoucherDimensions,'');
	});
}

function updateSmoothBoxContent(url) {
	new Request.HTML( {url:url,method: 'get',update: $("TB_ajaxContent")}).send();
}

window.addEvent('domready', function(){
	payWithGiftVoucher();
});

var search = { 
		field: null,
		fieldDefaultValue: null,
		init: function() {
			this.field = document.getElementById("q");
			if (this.field == null) return;
			this.fieldDefaultValue = this.field.defaultValue;
			this.field.onfocus = this.clearText;
			this.field.onblur = this.showDefaultText;
		},
		clearText: function() {
			if(search.field.value != search.fieldDefaultValue) return;
			search.field.value = "";
		},
		showDefaultText: function() {
			if (search.field.value != "") return;
			search.field.value = search.fieldDefaultValue;
		}	
	}

window.addEvent('domready', function(){	search.init(); });

/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.6
 * 
 * Requires: 1.2.2+
 */
(function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery)

