function onOver(name,new_img) 
{
	filename = document.images[name].src;
	document.images[name].src = "/media/1/" + new_img;
}
		
function onOut(name,new_img) 
{
	filename = document.images[name].src;
	document.images[name].src = "/media/1/" + new_img;
}
function Over(hover_color)
{
	lmnt = window.event.srcElement;
	if (lmnt.tagName.toUpperCase() == 'TABLE')
	return;
	while (lmnt.tagName.toUpperCase() !='TD') 
	lmnt = lmnt.parentElement;
	lmnt.style.background = hover_color;
}

function Out(color)
{
	lmnt = window.event.srcElement;
	if (lmnt.tagName.toUpperCase() == 'TABLE')
	return;
	while (lmnt.tagName.toUpperCase() !='TD') 
	lmnt = lmnt.parentElement;
	lmnt.style.background =color;
}

function addColliToBasket(item_id,id)
{
	newURL = '/?id='+id+'&action=addKolliToBasket&itemId='+item_id;

	window.location=newURL;
}
function addToBasket(itemId,item_number,id,item_note,warning)
{
    if (warning != undefined)
        alert(warning);
    if (item_note != undefined)
        newURL = '/?id='+id+'&action=addToBasket&itemId='+itemId+'&itemNumber='+item_number+"&item_note="+item_note;
    else
        newURL = '/?id='+id+'&action=addToBasket&itemId='+itemId+'&itemNumber='+item_number;
        if (document.getElementById('variant_id') != null) {
            if(document.getElementById('variant_id').value != "0")
            {
                    //itemSize = document.getElementById('variant_id').options[document.getElementById('variant_id').selectedIndex].text;
                    val = document.getElementById('variant_id').value;

                    newURL = newURL+'&variantId='+val;

                    window.location.href=newURL;
                    return;
            }
	}
	$.get(newURL);
	
	$("body").append('<div id="divBasketStatus" align="center" style="border:1px solid #000;background:#99aaff;padding:10px;"></div>');
	$("#divBasketStatus").hide();
	var dbst = $(window).scrollTop()+200;
	$("#divBasketStatus").css({width:'30%',position:'absolute',left:'35%',top:dbst});
	$("#divBasketStatus").append('<h1>Produktet er nu i kurven</h1><p>Vil du forsætte med at shoppe, eller se din indkøbskurv?</p><br /><br /><br />')
	$("#divBasketStatus").append('<span style="float:left"><input type="button" value="Kig i kurv" id="btnBasket" style="font-size:14pt;background:#69c;color:#fff;border:1px solid #369" /></span>');
	$("#divBasketStatus").append('<span style="float:right"><input type="button" value="Shop videre" id="btnShop" style="font-size:14pt;background:#69c;color:#fff;border:1px solid #369" /></span>');
	
	$("#btnShop").click(function() { $("#divBasketStatus").remove() });
	$("#btnBasket").click(function() { document.location.href='/?id='+id });
	$("#divBasketStatus").show();
	return false;
}

function changeColorSize(item_id,item_number,id,type)
{
	newURL = '/?id='+id+'&recordid='+item_id;

	if(type == 'size')
	{
		if(document.getElementById('size_'+item_number))
		{
			itemSize = document.getElementById('size_'+item_number).options[document.getElementById('size_'+item_number).selectedIndex].value;
				newURL = newURL+'&amp;itemSize='+itemSize;
		}
	
		if(document.getElementById('color_'+item_number))
		{
			itemColor = document.getElementById('color_'+item_number).options[document.getElementById('color_'+item_number).selectedIndex].value;
				newURL = newURL+'&amp;itemColor='+itemColor;
		}
	}
	else
	{
		if(document.getElementById('color_'+item_number))
		{
			itemColor = document.getElementById('color_'+item_number).options[document.getElementById('color_'+item_number).selectedIndex].value;
				newURL = newURL+'&amp;itemColor='+itemColor;
		}
		
		if(document.getElementById('size_'+item_number))
		{
			itemSize = document.getElementById('size_'+item_number).options[document.getElementById('size_'+item_number).selectedIndex].value;
				newURL = newURL+'&amp;itemSize='+itemSize;
		}
	}
	
	window.location=newURL;
}

// var fields = new Array('name','familyName','address','zipcode','city','phone','mobile')
// <SPAN id="msgname">*</SPAN>
function submitForm(fields)
{
	var x
	var doSubmit = true
	var focusField
	
	for(x in fields)
	{
		if(document.getElementById) {
			ref = document.getElementById(fields[x])
		}
		if(ref){
			if(window.document.getElementById(fields[x]).value == "")
			{
				if(doSubmit == true)
				{
					focusField = fields[x];
				}
				
				doSubmit = false
				window.document.getElementById('msg'+fields[x]).style.color = "#FF0000";
			}else{
				window.document.getElementById('msg'+fields[x]).style.color = "#000000";
			}
		}
	}
	
	if(doSubmit)
	{
		document.form.submit();
	}else{
	
		alert('Udfyld venligst alle felter med *');
		window.scrollTo(0, 0);
		
		function focusL()
		{
                	document.getElementById(focusField).focus();
		}
		window.onReadyState=focusL();
	}
}

