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){
	targetname=formobj.target;
	newwin = window.open ('about:blank' , targetname,'status,width=390,height=350');
	if (!newwin.opener) {
		newwin.opener = self;
	}
	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 switchMainImage(url) {
	var list_pattern = /\/(thumb)\//
	main_url = url.replace(list_pattern, '/main/');
	images = document.getElementsByName('main_image');
	if (images.length > 0) {
		images[0].src = main_url;
	}
}

function hide_price_change() {
	// Opdater checkbox value
	if(document.settings_form.cms_module_customer_page__extra1.value == 1) {
		document.settings_form.cms_module_customer_page__extra1.value = 0;
	}
	else {
		document.settings_form.cms_module_customer_page__extra1.value = 1;
	}
}

function update_price_change() {
	// Sæt checkbox checked afhængig af value
	if(document.settings_form.cms_module_customer_page__extra1.value == 1) {
		document.settings_form.cms_module_customer_page__extra1.checked = true;
	}
	else {
		document.settings_form.cms_module_customer_page__extra1.checked = false;
	}
}

// Vis produktets pris
function show_price() {
	document.getElementById('netto_pris').style.display = 'table-row';
	document.getElementById('brutto_pris').style.display = 'table-row';
	document.getElementById('depos').style.display = 'table-row';
	document.getElementById('vis_pris').style.display = 'none';
}

function init_product_price() {
	if (document.getElementById('extra1').value == '1') {
		document.getElementById('vis_pris').style.display = 'table-row';
		document.getElementById('netto_pris').style.display = 'none';
		document.getElementById('brutto_pris').style.display = 'none';
		document.getElementById('depos').style.display = 'none';
	}
	else {
		document.getElementById('netto_pris').style.display = 'table-row';
		document.getElementById('brutto_pris').style.display = 'table-row';
		document.getElementById('depos').style.display = 'table-row';
	}
}

