function clear_me(field,default_value) {
	if (field) {
		if (field.value === default_value) {
			field.value = '';
		}
	}
}

function text_to_password(elm){
	if(elm.type!='password'){
		elm.type='password';
		elm.value='';		
	}
}

function submit_wrapping_form(form_id,product_id) {
	form = document.getElementById(form_id);
	product_field = document.getElementById('wrap_product_id');
	product_field.value = product_id;
	form.submit(); 
}


function submit_card_form(form_id,product_id) {
	form = document.getElementById(form_id);
	product_field = document.getElementById('card_product_id');
	product_field.value = product_id;
	form.submit(); 
}

function copyTo(fromFieldId,toFieldId) {
	from = document.getElementById(fromFieldId);
	to = document.getElementById(toFieldId);
	if (from && to) {
		to.value = from.value;
		return true;
	}
}

function switch_to_password(text_id, pass_id) {
	text = document.getElementById(text_id);
	pass = document.getElementById(pass_id);
	if (text && pass) {
		text.style.visibility = 'hidden';
		text.style.display = 'none';
		pass.style.visibility = 'visible';
		pass.style.display = 'inline';
		pass.focus();
	}
}
		


function submit_to_payment_window(formobj) {	
	var oHeight		= top.window.screen.availHeight;
	var oWidth		= top.window.screen.availWidth;
	var iHeight		= 370;
	var iWidth		= 390;
	var iLeft		= 0;
	var iTop		= 0;
	var targetname	= formobj.target;

	// Brug mindst en tredjedel af skærmen
	if (oHeight > 3 * iHeight) {
		iHeight = oHeight / 3;
	}
	if (oWidth > 3 * iWidth) {
		iWidth = oWidth / 3;
	}

	// Centrer det nye vindue
	if (oWidth > iWidth) {
		iLeft = (oWidth - iWidth) / 2;
	}
	if (oHeight > iHeight) {
		iTop = (oHeight - iHeight) / 2;
	}
	
	// Åbn vinduet
	window.open('about:blank', targetname, 'scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes,status=yes,width='
				+ iWidth + ',height=' + iHeight + ',left=' + iLeft + ',top=' +iTop +'dependent=yes');
	
	// Sørg for at opener er sat
	if ( ! newwin.opener) {
		newwin.opener = self;
	}
	
	// Og endeligt:
	formobj.submit();
}

function form_submit(form_id) {
	document.getElementById(form_id).submit();
}

function add_favorite(url, title) {
	if (url && title) {
		if (window.sidebar) { // Mozilla Firefox
			window.sidebar.addPanel(title, url,"");
		}
		else if(window.external) { // IE
			window.external.AddFavorite( url, title);
		}
	}
}
function selectCategory(form) {
	var category_id = form.value;
	if (category_id) {
		location.href = '/?page_label=category&category_id=' + category_id;
	}
} // End selectCategory()

function show_conditions(link) {
	newwin = window.open(link.href, 'conditions', 'resizable=yes,scrollbars=yes,status,width=930,height=800');	
	newwin.focus();
	return false;
}

function checkform() {
	if ( ! document.getElementById('conditions_confirmed').checked) {
		alert(document.getElementById('conditions_message').innerHTML);
		return false;
	}
	return true;
} // End checkform()

function cover_delivery_address() {
	var hider = document.getElementById('delivery_hider');
	if (hider) {
		hider.style.visibility = 'visible';
		hider.style.display = 'block';
	}
}

function uncover_delivery_address() {
	var hider = document.getElementById('delivery_hider');
	if (hider) {
		hider.style.visibility = 'hidden';
		hider.style.display = 'none';
	}
}

function delivery_hide_and_show() {
	// Fix størrelse af hider
	var container = document.getElementById('delivery_container');
	var hider = document.getElementById('delivery_hider');
	if (hider && container) {
		hider.style.width = container.offsetWidth + 'px';
		hider.style.height = container.offsetHeight + 'px';
	}
	var different_receiver = document.getElementById('delivery_address2');
	if (different_receiver && different_receiver.checked) {
		uncover_delivery_address();
	}
	else {
		cover_delivery_address();
	}
}





