

function getById(id)
{
  return document.getElementById?document.getElementById(id):(document.all?document.all(id):null);
}

function hideAll(test)
{
  return;
}

function getWidth()
{
	var w = 0;
	if (typeof(window.innerWidth) == 'number')
	  	w = window.innerWidth;
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		w = document.documentElement.clientWidth;
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
		w = document.body.clientWidth;
	return w;
}

function openWin(url)
{
	window.open(url, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=527,height=477,left=100,top=100');
}

var oldmany = 1;
var oldtype = 'parts';
var oldfactor = 1;

function change(ingredientcount, howmany, factor, type)
{
	if (howmany == 0)
		howmany = oldmany;
	else
		oldmany = howmany;
	if (factor == 0)
		factor = oldfactor;
	else
		oldfactor = factor;
	if (type == '')
		type = oldtype;
	else
		oldtype = type;

	for (var i=0; i<ingredientcount; i++)
	{
		eval("var amount = getById('recipe').v"+i+".value");
		if (amount == 1 && type == 'parts')
			getById('s'+i).innerHTML = '1 part';
		else if (type == 'parts')
			getById('s'+i).innerHTML = amount + ' ' + type;
		else
		{
			amount *= (factor * howmany);
			if (type == 'ml')
			{
//				amount = Math.round(amount/10)*10;
				if (amount % 10 < 3)
					amount = amount - (amount % 10);
				else if (amount % 10 < 8)
					amount = amount - (amount % 10) + 5;
				else
					amount = amount - (amount % 10) + 10;
			}
			else
			{
				amount *= 0.0338140226;
				amount = Math.round(amount*10);
				if (amount % 10 < 3)
					amount = Math.round(amount/10)*10;
				else if (amount % 10 < 8)
					amount = Math.round(amount/10)*10+5;
				else
					amount = amount + (10 - (amount % 10));
				amount /= 10;
			}
			getById('s'+i).innerHTML = amount + ' ' + type;
		}
	}
}


document.onmousemove = update;

var x = 500;
var y = 25;

var shown = 0;

function update(e)
{
	if (getById('ldadiv') && (getById('ldadiv').style.visibility != 'hidden'))
		return;

	if (!e)
		e = window.event;

	if (e)
	{
		if (e.pageX || e.pageY)
		{
			x = e.pageX;
			y = e.pageY;
	    	}
		else if (e.clientX || e.clientY)
		{
			x = e.clientX + document.body.scrollLeft;
			y = e.clientY + document.body.scrollTop;
		}
		if (shown == 2)
		{
			var tipw = parseInt(getById('tooltip').clientWidth, 10);
			var docw = parseInt(document.body.clientWidth, 10)-1;

			if ((docw-tipw) < (x-30))
			{
				var m = Math.min(tipw - (docw-x) - 5, tipw - 30);
				getById('bubble').style.marginLeft = m+'px';
				getById('tooltip').style.left = (docw-tipw)+'px';
				getById('tooltip').style.top = (y+20)+'px';
			}
			else
			{
				getById('bubble').style.marginLeft = '25px';
				getById('tooltip').style.left = (x-30)+'px';
				getById('tooltip').style.top = (y+20)+'px';
			}
		}
	}
}


function showToolTip(s, moveable)
{
	if (shown == 1)
		return true;

	shown = moveable + 1;

	update(window.event);

	if (shown == 1)
	{
		var docw = parseInt(document.body.clientWidth, 10);
		getById('tooltip').style.left = (240+docw/2)+'px';
		getById('tooltip').style.top = (66)+'px';
	}

	getById('tooltiptext').innerHTML = s;
	getById('tooltip').style.visibility = 'visible';

	return true;
}

function hideToolTip()
{
	shown = 0;

	getById('tooltip').style.visibility = 'hidden';

	return true;
}


function hoverbtn(id, img)
{
	getById(id).src = img;
}

function mobilePopUp()
{
  mobilePopUp = window.open("http://mobileguide.goldengekko.com/Mobile.aspx?site=Absolut","Mobile_Application","width=760,height=700,scrollbars=1,resizable=1,menubar=0");
  mobilePopUp.focus();
}


var stars = new Array(0,0,0,0,0,0);

var wait = 0;
function mouseoverstar(star, action)
{
	if (action == 1)
		stars[star] = 1;
	else
		stars[star] = 0;
	if (wait == 0)
	{
		wait = 1;
		setTimeout('updatestars()', 50)
	}
}

function updatestars()
{
	wait = 0;
	var star = 0;
	for(i=1; i<=5; i++) {
		if (stars[i] == 1)
			star = i;
	}
	for(i=1; i<=star; i++) {
		imgbase = getById('star'+i);
		imgbase.src = "/content/images/star_full.png";
	}
	for(i=star+1; i<=5; i++) {
		imgbase = getById('star'+i);
		imgbase.src = "/content/images/star_empty.png";
	}
}

/*function toggleRememberMe(white)
{
	var box = getById('rememberBox');
	var img = getById('rememberImg');
	box.value ^= 1;
	img.src = '/content/images/remember' + box.value + '.gif';
}*/

function competition()
{
	accesscomp = window.open("/members/access-competition-popup.aspx","access_competition","width=730,height=416,fullscreen=0,scrollbars=0,resizable=0,menubar=0,status=0,titlebar=1,toolbar=0");
	accesscomp.focus();
	log('Banner','Access Competition','LOG_PAGEVIEW','','');
}
