var curnav = 0;
//var curout = 0;
var loaded = 0;

function navhoveroff() {
	if (!loaded) {
		//addLoadEvent(navhoverclose);
		return;
	}

	//if (!curout) {
		navhoverclose();
	//	curout = setTimeout('navhoverclose()', 5);
	//}
}

function navhoverclose() {
	//if (curout) {
	//	clearTimeout(curout);
	//	curout = 0;
	//}
	
	if (curnav) {
		if (curnav < 990) {
			document.getElementById('nr' + curnav).style.backgroundColor = '#fff';
			var rod = document.getElementById('nri' + curnav);
			rod.style.color = '#000';
			rod.style.top = '0';
			rod.style.height = '32px';
			rod.style.borderBottom = '1px #000 solid';
			rod.style.borderTop = '0';
		}

		document.getElementById('nav_sub' + curnav).style.visibility = 'hidden';
		curnav = 0;
	}
	
	document.getElementById('curtain').style.display = 'none';
}

function navhoveron(id) {
	//if (curout) {
	//	clearTimeout(curout);
	//	navhoverclose();
	//	curout = 0;
	//}

	if (curnav == id) {
		return;
	} else if (curnav) {
		navhoverclose();
	}

	if (!loaded) {
		//addLoadEvent(function() { navhoveron(id); });
		return;
	}

	// move sub menu
	var bh = document.body.clientHeight;
	var dv = document.getElementById('nav_sub' + id);
	var dh = dv.clientHeight;
	var qq = 33; // nav_row height
	var of = 15;
	var by = 15;
	var bx = 0;
	
	if (id < 990) {
		var yx = 1;
		var yy = id - 1;
		var styler = document.getElementById('nav_cart').style;
		if (styler.display != 'none') {
			if (styler.backgroundColor.indexOf('rgb(255') >= 0) {
				yx = 2;
			}
			yy = id;
		}
		
		var sp = window.pageYOffset ? window.pageYOffset : document.body.scrollTop;
		var or = document.getElementById('navigation').offsetTop + qq * yy;
		of = or;
		
		var sb = (of + dh) - (sp + bh);
		if (sb > 0) {
			of -= qq * (1 + Math.floor(sb / qq));
			if (of < 15) {
				of = 15;
			}
		}
		by = or - of + 15;
		
		document.getElementById('nr' + id).style.backgroundColor = '#a1080a';
		var rod = document.getElementById('nri' + id);
		rod.style.color = '#fff';
		rod.style.top = id == 1 && yx == 1 ? '0' : '-1px';
		rod.style.height = '33px';
		rod.style.borderBottom = '0';
		rod.style.borderTop = id == 1 && yx == 1 ? '0' : '1px #fff solid';
	} else {
		var mn = document.getElementById('logo');
		var lf = parseInt(mn.style.left) < 300;
		var lt = mn.offsetTop;
		bx = 0; //lf ? 0 : 180;
		by = lt + 13;
		of = lt;
	}
	
	dv.style.top = of + 'px';
	dv.style.backgroundPosition = bx + 'px ' + by + 'px';				
	document.getElementById('curtain').style.display = 'block';
	dv.style.visibility = 'visible';

	curnav = id;
}

function adjust() {
	var bw = document.body.clientWidth;
	var bh = document.body.clientHeight;

	// move header & news
	/*if (bw >= 1200) {
		document.getElementById('center').style.width = '1200px';
		document.getElementById('navigation').style.top = '15px';
		document.getElementById('nav_sub999').style.marginLeft = '540px';
		document.getElementById('logo').style.left = '965px';
		document.getElementById('contact').style.left = '965px';
		document.getElementById('news').style.left = '965px';
		document.getElementById('news').style.top = '240px';
	} else {
		var cart = document.getElementById('nav_cart');
		document.getElementById('center').style.width = '975px';
		document.getElementById('navigation').style.top = '240px';
		document.getElementById('nav_sub999').style.marginLeft = '0';
		document.getElementById('logo').style.left = '15px';
		document.getElementById('contact').style.left = '15px';
		document.getElementById('news').style.left = '15px';
		document.getElementById('news').style.top = 783 + (cart.style.display != 'none' ? 33 : 0) + 'px';
	}*/

	// adjust zoom image
	if (zoom_link) {
		document.getElementById('zoom').style.lineHeight = bh + 'px';
		zoomUpdate();
	}

	// iphone
	bh = mobileHeight(bh, 1);
	
	// adjust bg image
	var img = document.getElementById('back_img');
	var iw = img.width;
	var ih = img.height;

	bw = Math.max(bw, 1200);
	bh = Math.max(bh, 800);
	var mul = bh / ih;
	if (Math.floor(mul * iw) < bw) {
		mul = bw / iw;
	}
	var tw = Math.round(mul * iw);
	var th = Math.round(mul * ih);
	var pl = (bw - tw) >> 1;
	var pt = (bh - th) >> 1;
	
	img.style.width = tw + 'px';
	img.style.height = th + 'px';
	img.style.left = pl + 'px';
	img.style.top = pt + 'px';
	
	window.onresize = adjust;
	//loaded = 1;
}

function prepareBackground(link, iw, ih) {
	var bw = Math.max(document.body.clientWidth, 1200);
	var bh = Math.max(document.body.clientHeight, 800);
	var mul = bh / ih;
	if (Math.floor(mul * iw) < bw) {
		mul = bw / iw;
	}
	var tw = Math.round(mul * iw);
	var th = Math.round(mul * ih);
	var pl = (bw - tw) >> 1;
	var pt = (bh - th) >> 1;
	var pi = document.getElementById('back_img');

	pi.style.width = tw + 'px';
	pi.style.height = th + 'px';
	pi.style.left = pl + 'px';
	pi.style.top = pt + 'px';
	pi.src = link;
}

function init() {
	var img = document.getElementById('back_img');
	if (img.complete) {
		adjust();
	} else {
		img.onload = adjust;
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

var zoom_link = 0;
var zoom_href = 0;
var zoom_num = 0;
var zoom_img = 0;

function zoomIn(link) {
	zoom_link = link;
	zoom_href = link.href;
	zoom_num = parseInt(zoom_link.name.substr(3));
	link.href = 'javascript:void(0);';

	document.getElementById('zoom_img').title = zoom_link.rel;
	document.getElementById('zoom_bg').style.display = 'block';
	document.getElementById('zoom').style.lineHeight = mobileHeight(document.body.clientHeight, 0) + 'px';
	document.getElementById('zoom').style.display = 'block';
	
	zoom_img = new Image();
	zoom_img.onload = zoomNow;
	zoom_img.src = zoom_href;
}

function zoomUpdate() {
	var rh = mobileHeight(document.body.clientHeight, 0);
	var bw = Math.max(Math.min(document.body.clientWidth - 100, 1920), 600);
	var bh = Math.max(Math.min(rh - 100, 1200), 400);
	var iw = zoom_img.width;
	var ih = zoom_img.height;
	var mul = bh / ih;
	if (Math.floor(mul * iw) > bw) {
		mul = bw / iw;
	}
	if (mul > 1) {
		mul = 1;
	}

	var img = document.getElementById('zoom_img');
	var tw = Math.round(mul * iw);
	var th = Math.round(mul * ih);
	img.style.width = tw + 'px';
	img.style.height = th + 'px';

	tw = Math.max(tw, 400);
	
	var ctrl = document.getElementById('zoom_control');
	ctrl.style.width = tw + 'px';
	ctrl.style.height = th + 'px';
	ctrl.style.left = ((document.body.clientWidth - tw - 30) >> 1) + 'px';
	ctrl.style.top = ((rh - th - 30) >> 1) + 'px';
}

function zoomNow() {
	document.getElementById('zoom_img').src = zoom_img.src;
	zoomUpdate();
	
	document.getElementById('zoom_next').style.display = document.getElementsByName('gal' + (zoom_num + 1)).length ? 'block' : 'none';
	document.getElementById('zoom_last').style.display = document.getElementsByName('gal' + (zoom_num - 1)).length ? 'block' : 'none';
	document.getElementById('zoom_control').style.display = 'block';	
}

function zoomOther(dir) {
	document.getElementById('zoom_control').style.display = 'none';

	zoom_link.href = zoom_href;
	zoom_num += dir;
	
	var link = document.getElementsByName('gal' + zoom_num)[0];

	zoom_link = link;
	zoom_href = link.href;
	link.href = '#';

	zoom_img = new Image();
	zoom_img.onload = zoomNow;
	zoom_img.src = zoom_href;
}

function zoomNext() {
	zoomOther(1);
}

function zoomLast() {
	zoomOther(-1);
}

function zoomOut() {
	zoom_img.onload = null;
	zoom_link.href = zoom_href;
	zoom_link = 0;
	
	document.getElementById('zoom').style.display = 'none';
	document.getElementById('zoom_control').style.display = 'none';
	document.getElementById('zoom_bg').style.display = 'none';
}

function setCookie(name, value, minutes) {
	var expires = '';
	if (minutes) {
		var date = new Date();
		date.setTime(date.getTime() + minutes * 60000);
		expires = '; expires=' + date.toGMTString();
	}
	document.cookie = name + '=' + value + expires + '; path=/';
}

function getCookie(name) {
	name += '=';
	var arr = document.cookie.split(';');
	for (var i = 0; i < arr.length; i++) {
		var c = arr[i].replace(/^\s+|\s+$/g, '');
		if (!c.indexOf(name)) {
			return c.substring(name.length, c.length);
		}
	}
	return 0;
}

function delCookie(name) {
	setCookie(name, '', -1);
}

var xmlHttpReqBuffer = 0;

function xmlHttpPost(url, query, target) {
	var xmlHttpReq = 0;

	if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();						// Mozilla/Safari
	} else if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');	// IE
	}

	xmlHttpReqBuffer = xmlHttpReq;
	xmlHttpReq.open('POST', url, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			target();
		}
	}
	xmlHttpReq.send(query);
}

function ajaxBuy(product, size, color) {
	if (ajaxLock) { return; } ajaxLock = 1;

	document.getElementById('buy_button_real').style.display = 'none';	
	document.getElementById('buy_loader').style.display = 'block';
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppinp=1&wppcart=add&buyid=' + product + '&sizeid=' + size + '&colorid=' + color, ajaxBuyBack);
}

function ajaxBuyBack() {
	//if (cartTimer) {
	//	clearTimeout(cartTimer);
	//	cartTimer = 0;
	//}

	var cart = document.getElementById('nav_cart');
	if (cart.style.display != 'block') {
		//if (document.body.clientWidth < 1200) {
		//	document.getElementById('news').style.top = '816px';
		//}
		cart.style.display = 'block';
	}

	document.getElementById('buy_loader').style.display = 'none';
	document.getElementById('buy_button_real').style.display = 'block';	
	ajaxPCBack();
}

function ajaxCmpAdd(pid) {
	if (ajaxLock) { return; } ajaxLock = 1;
	setCookie('compare-list', getCookie('compare-list') + ',' + pid, 0);
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppcmpmode=1&wppseeslides[]=' + prv_pol + '&wppseeslides[]=' + prv_pos, ajaxCmdRemoveBack);
}

function ajaxCmpRemove(pid) {
	if (ajaxLock) { return; } ajaxLock = 1;
	var old = getCookie('compare-list').split(',');
	for (var i = 0; i < old.length; i++) {
		if (old[i] == pid) {
			old.splice(i, 1);
			break;
		}
	}
	setCookie('compare-list', old.join(','), old.length ? 0 : -60);
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppcmpmode=1&wppseeslides[]=' + prv_pol + '&wppseeslides[]=' + prv_pos, ajaxCmdRemoveBack);
}

function ajaxCmdRemoveBack() {
	document.getElementById('cmp_container').innerHTML = xmlHttpReqBuffer.responseText;
	ajaxLock = 0;
}

function ajaxPCRefresh(product, size, color, count) {
	if (parseInt(count) == 0) {
		ajaxPCRemove(product, size, color, 0);
		return;
	}
	
	if (ajaxLock) { return; } ajaxLock = 1;
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppinp=1&wppcart=upd&refresh=1&buyid=' + product + '&sizeid=' + size + '&colorid=' + color + '&count=' + count, ajaxPCBack);
}

function ajaxPCRemove(product, size, color, item) {
	if (ajaxLock) { return; } ajaxLock = 1;
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppinp=1&wppcart=del&refresh=1&buyid=' + product + '&sizeid=' + size + '&colorid=' + color, ajaxPCBack);
}

function ajaxPCBack() {
	var ret = xmlHttpReqBuffer.responseText;
	if (ret.indexOf('<!-- empty') >= 0) {
		var cart = document.getElementById('nav_cart');
		if (cart.style.display != 'none') {
			//if (document.body.clientWidth < 1200) {
			//	document.getElementById('news').style.top = '783px';
			//}
			cart.style.display = 'none';
		}
	} else {
		cartHoverOn();
		cartTimer = setTimeout(cartHoverOff, 1500);
	}
	document.getElementById('prod_in_cart').innerHTML = xmlHttpReqBuffer.responseText;
	ajaxLock = 0;
}

function ajaxRefresh(product, size, color, count) {
	if (parseInt(count) == 0) {
		ajaxRemove(product, size, color, 0);
		return;
	}
	
	if (ajaxLock) { return; } ajaxLock = 1;
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppcart=upd&refresh=1&buyid=' + product + '&sizeid=' + size + '&colorid=' + color + '&count=' + count, ajaxRemoveBack);
}

function ajaxRemove(product, size, color, item) {
	if (ajaxLock) { return; } ajaxLock = 1;
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppcart=del&refresh=1&buyid=' + product + '&sizeid=' + size + '&colorid=' + color, ajaxRemoveBack);
}

function ajaxCartClear() {
	if (ajaxLock) { return; } ajaxLock = 1;
	document.getElementById('cart_loader').style.display = 'block';
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&wppcart=nul&refresh=1', ajaxRemoveBack);
}

function ajaxRemoveBack() {
	var ret = xmlHttpReqBuffer.responseText;
	if (ret.indexOf('<!-- empty') >= 0) {
		location.href = ajaxHost + '/checkout/';
	} else {
		var r = ret.split('%PRICE%');
		//document.getElementById('cart_price').innerHTML = r[1];
		document.getElementById('cartilein').innerHTML = r[0];
		//document.getElementById('cartibuy').innerHTML = r[1];
		cartPrice = parseFloat(r[1]);
		resetShipping();
		setPrice();
	}
	
	ajaxLock = 0;
}

function ajaxSlide(slider, ids, pos, dir, dst) {
	ajaxSlide(slider, ids, pos, dir, dst, 0, 0);
}

function ajaxSlide(slider, ids, pos, dir, dst, brand, incomp) {
	if ((dir < 0 && pos <= 0) || (dir > 0 && pos + 3 >= ids.length)) {
		return pos;
	}

	if (ajaxLock) {
		return pos;
	}
	ajaxLock = 1;

	var but = slider.children[dir > 0 ? 1 : 0];
	but.className = 'product_wait ' + (dir > 0 ? 'fright' : 'fleft');
	but.innerHTML = '<img style="vertical-align: top; margin-top: 13px;" src="' + ajaxloader + '" alt="" />';

	var slides = 3;
	var m = Math.min(slides, dir > 0 ? ids.length - (pos + 3) : pos);
	
	var l = m * 175;
	var o = document.getElementById(dst);
	var w = parseInt(o.style.width);
	var x = parseInt(o.style.left);
	if ((dir > 0 && x + w >= 525 + l) || (dir < 0 && x <= -l)) {
		var d = x - dir * l;
		var s = 4 * m;
		pos += dir * m;

		slidePos = 0;
		slideInt = setInterval(function() { slideIn(s, slider, ids, pos, o, x, d); }, 50);

		return pos;
	}

	// wieviele slides fehlen?
	var f = (dir > 0 ? 525 + l - (x + w) : l + x) / 175;
	//alert('pos='+pos+' es fehlen ' + f);
	
	var dif = m - f;
	var nps = pos + (dir > 0 ? 3 + dif : -1 - dif);
	var pid = new Array();
	for (var fi = 0; fi < f; fi++) {
		if (nps < 0 || nps >= ids.length) {
			break;
		}
		pid.push(ids[nps]);
		nps += dir;
	}
	
	if (pid.length < f && dir > 0) {
		pid.push(0);
	}
	
	f = pid.length;
	pos += dir * m;
	
	xmlHttpPost(ajaxHost, 'bmx_request_uri=' + ajaxURI + '&' + (incomp ? 'wppincmp=' + incomp + '&' : '') + (brand ? 'wppbrand=' + brand + '&' : '') + 'bmxclusive_ajax_action=true&wppslide[]=' + pid.join('&wppslide[]=') + '&wppsee[]=' + prv_see.join('&wppsee[]='), function() { ajaxSlideAdd(slider, ids, pos, dir, dst, m, f); });
	return pos;
}

function ajaxSlideFix(slider, ids, pos) {
	var bul = slider.children[0];
	var bur = slider.children[1];
	bul.innerHTML = '&laquo;';
	bur.innerHTML = '&raquo;';
	bul.className = 'fleft product_slider_' + (pos > 0 ? 'go' : 'nogo');
	bur.className = 'fright product_slider_' + (pos + 3 < ids.length ? 'go' : 'nogo');
}

function ajaxSlideAdd(slider, ids, pos, dir, dst, slides, loaded) {
	var r = xmlHttpReqBuffer.responseText;
	var o = document.getElementById(dst);
	var a = dir > 0 ? parseInt(o.style.left) : -slides * 175;
	var b = dir > 0 ? (a - slides * 175) : 0;
	var s = slides * 4;
	
	o.style.width = (parseInt(o.style.width) + loaded * 175) + 'px';
	o.innerHTML = dir > 0 ? o.innerHTML + r : r + o.innerHTML;
	o.style.left = a + 'px';
	
	for (var i = 0; i < pc_num; i++) {
		var obj = document.getElementById('compid_' + pc_ids[i]);
		if (obj != null) {
			obj.checked = true;
		}
	}
	
	slidePos = 0;
	slideInt = setInterval(function() { slideIn(s, slider, ids, pos, o, a, b); }, 50);
}

var slidePos = 0;
var slideInt = 0;

function slideIn(steps, slider, ids, pos, obj, off, dst) {
	slidePos++;
	var p = off + ((dst - off) * slidePos) / steps;
	obj.style.left = p + 'px';
	if (slidePos == steps) {
		clearInterval(slideInt);
		slideInt = 0;
		
		ajaxSlideFix(slider, ids, pos);
		ajaxLock = 0;
	}
}

var mailreg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

function newsLetterCheck() {
	var inp = document.getElementById('newsletter_input').value;
	if (mailreg.test(inp)) {
		return true;
	} else {
		document.getElementById('newsletter_input').style.borderColor = '#f0000c';
		return false;
	}
}

function checkContact() {
	var frm = document.forms['contact_frm'];
	var err = false;
	if (frm.cname.value.replace(/^\s+|\s+$/g, '') != '') {
		document.getElementById('contact_err_name').style.visibility = 'hidden';
	} else {
		document.getElementById('contact_err_name').style.visibility = 'visible';
		err = true;
	}
	if (mailreg.test(frm.mail.value)) {
		document.getElementById('contact_err_mail').style.visibility = 'hidden';
	} else {
		document.getElementById('contact_err_mail').style.visibility = 'visible';
		err = true;
	}
	if (frm.msg.value.replace(/^\s+|\s+$/g, '') != '') {
		document.getElementById('contact_err_msg').style.visibility = 'hidden';
	} else {
		document.getElementById('contact_err_msg').style.visibility = 'visible';
		err = true;
	}
	return !err;
}

function nsearchOver() {
	var hs = document.getElementById('hide_search');
	if (hs.style.height.indexOf('0') != 0) {
		hs.style.backgroundColor = '#a1080a';
		hs.style.borderColor = '#fff';
		hs.style.color = '#fff';
		
		hs.style.top = '-1px';
		hs.style.borderTop = '1px #fff solid';
	
		hs = document.getElementById('nav_search');
		hs.style.backgroundColor = '#a1080a';
		hs.style.cursor = 'pointer';
	} else {
		hs.style.borderColor = '#000';
	}
}

function nsearchOut() {
	var hs = document.getElementById('hide_search');
	hs.style.top = '0';
	hs.style.borderTop = '0';
	
	if (hs.style.height.indexOf('0') != 0) {
		hs.style.backgroundColor = '#fff';
		hs.style.borderColor = '#000';
		hs.style.color = '#ccc';

		hs = document.getElementById('nav_search');
		hs.style.backgroundColor = '#fff';
		hs.style.cursor = 'default';
	}
}

function nsearchClick() {
	var hs = document.getElementById('nav_search');
	hs.style.backgroundColor = '#fff';
	hs.style.cursor = 'default';
	
	hs = document.getElementById('hide_search');
	hs.style.borderColor = '#000';
	hs.style.height = '0';
	
	document.forms['search'].s.focus();
}

var riderId = 0;

function riderSave(save) {
	delCookie('riderId');
	if (save) {
		setCookie('riderId', riderId, 365 * 24 * 60);
	}
}

function riderNext(dir) {
	if (ajaxLock) {
		return;
	}
	ajaxLock = 1;
	
	//var r3 = document.getElementById('rpc_check');
	//r3.checked = false;
	//delCookie('riderId');
	
	var r1 = document.getElementById('rpc_active');
	var r2 = document.getElementById('rpc_loading');
	r2.style.display = 'block';
	r1.style.display = 'none';

	var ri = riderId;
	var rl = riderList.length;
	var rp = 0;
	for (; rp < rl; rp++) {
		if (riderList[rp] == ri) {
			var ro = rp + dir;
			if (ro < 0) {
				ro = rl - 1;
			} else if (ro >= rl) {
				ro = 0;
			}
			ri = riderList[ro];
			break;
		}
	}
	
	xmlHttpPost(ajaxHost, 'bmxclusive_ajax_action=true&riderid=' + ri, ajaxRiderBack);
}

function ajaxRiderUpdate(rid, pad, chk) {
	var r3 = document.getElementById('rider_pad_info');
	var r4 = document.getElementById('has_bichk');
	r3.innerHTML = pad;
	r4.innerHTML = chk;

	var r5 = document.getElementById('rpc_check');
	r5.checked = rid == getCookie('riderId');
	
	var r1 = document.getElementById('rpc_active');
	var r2 = document.getElementById('rpc_loading');
	r1.style.display = 'block';
	r2.style.display = 'none';

	riderId = rid;
	ajaxLock = 0;
}

function ajaxRiderBack() {
	var ret = xmlHttpReqBuffer.responseText;
	var inf = ret.split('#');

	var img = new Image();
	img.src = inf[2];

	prepareBackground(inf[2], inf[3], inf[4]);

	if (img.complete) {
		ajaxRiderUpdate(inf[0], inf[5], inf[1]);
	} else {
		img.onload = function() {
			ajaxRiderUpdate(inf[0], inf[5], inf[1]);
		}
	}
}

var cartTimer = 0;

function cartHoverOn() {
	if (cartTimer) {
		clearTimeout(cartTimer);
		cartTimer = 0;
	}

	var c1 = document.getElementById('nav_cart');
	var c2 = c1.childNodes[0];
	
	c1.style.backgroundColor = '#a1080a';
	c2.style.backgroundColor = '#a1080a';
	c2.style.borderColor = '#a1080a';
	c2.style.color = '#fff';
}

function cartHoverOff() {
	var c1 = document.getElementById('nav_cart');
	var c2 = c1.childNodes[0];

	c1.style.backgroundColor = '#fff';
	c2.style.backgroundColor = '#fff';
	c2.style.borderColor = '#000';
	c2.style.color = '#ccc';
}

/*function cartHide() {
	var cart = document.getElementById('nav_cart');
	if (cart.style.display != 'none') {
		cart.style.display = 'none';
	}
}*/

/*function miniSetup() {
	for (var i = 0; i < mini_img.length; i++) {
		mini_img[i] = new Image();
		mini_img[i].src = mini_buf[i]['image'][0];
		mini_buf[i]['title'] = unescape(mini_buf[i]['title']);
	}
}

function miniLast() {
	miniChange(1);
}

function miniNext() {
	miniChange(-1);
}

function miniChange(dir) {
	mini_cur += dir;
	document.getElementById('mini_news_img').src = mini_img[mini_cur].src;
	document.getElementById('mini_news_link').href = mini_buf[mini_cur]['link'];
	document.getElementById('mini_news_link').title = mini_buf[mini_cur]['title'];
	document.getElementById('mini_news_title').children[0].href = mini_buf[mini_cur]['link'];
	document.getElementById('mini_news_title').children[0].innerHTML = mini_buf[mini_cur]['title'];
	document.getElementById('mini_news_next').onclick = mini_cur > 0 ? miniNext : null;
	document.getElementById('mini_news_next').innerHTML = mini_cur > 0 ? '&raquo;' : '';
	document.getElementById('mini_news_last').onclick = mini_cur < mini_buf.length - 1 ? miniLast : null;
	document.getElementById('mini_news_last').innerHTML = mini_cur < mini_buf.length - 1 ? '&laquo;' : '';
}*/

function loadBrand() {
	var bs = document.getElementById('brand_selector');
	document.getElementById('beyond_brand').innerHTML = bs.options[bs.selectedIndex].innerHTML.replace(/&nbsp;/g, '');
	document.location.href = bs.options[bs.selectedIndex].value;
}

var pc_max = 4;
var pc_num = 0;
var pc_ids = new Array();

function prodCompare(pid, cb) {
	var add = true;
	if (cb) {
		add = cb.checked;
		document.getElementById('lpcn_' + pid).className = add ? 'list_product_wait' : 'list_product_compare';
	} else {
		document.getElementById('compid_' + pid).checked = true;
		document.getElementById('lpcn_' + pid).className = 'list_product_wait';
	}
	var i = 0;
	for (; i < pc_ids.length; i++) {
		if (pc_ids[i] == pid) {
			if (!add) {
				pc_ids.splice(i, 1);
				pc_num--;
				//return;
			}
			break;
		}
	}
	if (add && i >= pc_ids.length && pc_num < pc_max) {
		pc_ids.push(pid);
		pc_num++;
	}
	if (pc_num == pc_max || !cb) {
		setCookie('compare-list', pc_ids.join(','), 0);
		location.href = ajaxHost + '/compare/';
	}
}
