function view_bid_disable(el, time, bid_id) {
	bd_click_highlight(bid_id);
	var elid = el.id;
	el.disabled = true;
	setTimeout("view_bid_undisable('" + elid + "')", time * 1000);
}
function view_bid_undisable(elid) {
	var el = document.getElementById(elid);
	el.disabled = false;
}

function showhide(id) {
	if (document.getElementById) {
		obj = document.getElementById(id);
		if (obj.style.display == "none") {
			obj.style.display = "";
		} else {
			obj.style.display = "none";
		}
	}
}

function openpopup1(popurl) {
	var winpops = window.open(popurl, "",
			"width=550,height=400,resizable,scrollbars")
}

function confirmation(msg_id, item_id) {
	var answer = confirm(window.locale.listing.MESSAGE_TO_REPORT_VIOLATION);
	if (answer) {
		var href = window.location.href;
		if (href.search("/transport/") != -1 && (href.search("bids=true") || href.search("view_bid"))) {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
			+ item_id + "&bids=true&report_msg=" + msg_id;
		}
		else {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
					+ item_id + "&report_msg=" + msg_id;
		}
	}
}

function confirmation2(item_id) {
	var answer = confirm(window.locale.listing.MESSAGE_TO_REPORT_VIOLATION);
	if (answer) {
		var href = window.location.href;
		if (href.search("/transport/") != -1 && (href.search("bids=true") || href.search("view_bid"))) {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
			+ item_id + "&bids=true&report_details_new=1";
		}
		else {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
					+ item_id + "&report_details_new=1";
		}
	}
}

function confirmation3(bid_id, item_id) {
	var answer = confirm(window.locale.listing.MESSAGE_TO_REPORT_VIOLATION);
	if (answer) {
		var href = window.location.href;
		if (href.search("/transport/") != -1 && (href.search("bids=true") || href.search("view_bid"))) {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
					+ item_id + "&report_bid=" + bid_id;
		}
		else {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
			+ item_id + "&bids=true&report_bid=" + bid_id;
		}
	}
}

function confirmation4(item_id, report_additional_details) {
	var answer = confirm(window.locale.listing.MESSAGE_TO_REPORT_VIOLATION);
	if (answer) {
		var href = window.location.href;
		if (href.search("/transport/") != -1 && (href.search("bids=true") || href.search("view_bid"))) {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
					+ item_id + "&report_additional_details="
					+ report_additional_details;
		}
		else {
			window.location = window.locale.baseUrl+"/listing.php?item_id="
			+ item_id + "&bids=true&report_additional_details="
			+ report_additional_details;
		}
	}
}

function gotobid() {
	window.location.href = "#bid";
}

maxKeys = 200;
var IE = (document.all) ? 1 : 0;
var DOM = 0;
if (parseInt(navigator.appVersion) >= 5) {
	DOM = 1
};

function txtshow(txt2show) {

	// Detect Browser

	if (DOM) {
		var viewer = document.getElementById("txtmsg");
		viewer.innerHTML = txt2show;
	} else if (IE) {
		document.all["txtmsg"].innerHTML = txt2show;
	}
}

function keyup(v, currency, ccode) {
	if (!currency) {
		currency = window.locale.currencySymbol;
	}
	if(!ccode) {
	  ccode = window.locale.language;
	}

	var bid = new String(v.value);
	switch (ccode) {
	case 'de':
		var fee = _deAmountIncVat(bid);
		break;
	case 'nl':
		var fee = _nlAmountIncVat(bid);
		break;
	default:
		var fee = _enAmountIncVat(bid);
		break;
	}
	var toyou = bid - fee;
	toyou = toyou.toFixed(2);

	if (toyou > 0) {
		var showstr = currency + toyou;
		txtshow(showstr);
		if (document.getElementById('txtmsg2').innerHTML != '-') {
			document.getElementById('txtmsg_between').style.display = 'inline-block';
			document.getElementById('txtmsg').style.display = 'inline-block';
			document.getElementById('txtmsg_and').style.display = 'inline-block';
			document.getElementById('txtmsg2').style.display = 'inline-block';
		} else {
			document.getElementById('txtmsg_between').style.display = 'none';
			document.getElementById('txtmsg').style.display = 'inline-block';
			document.getElementById('txtmsg_and').style.display = 'none';
			document.getElementById('txtmsg2').style.display = 'none';
		}
	} else {
		var showstr1 = "-";
		txtshow(showstr1);
		if (document.getElementById('txtmsg2').innerHTML != '-') {
			document.getElementById('txtmsg2').style.display = 'inline-block';
			document.getElementById('txtmsg').style.display = 'none';
		} else {
			document.getElementById('txtmsg2').style.display = 'none';
			document.getElementById('txtmsg').style.display = 'inline-block';
		}
		document.getElementById('txtmsg_between').style.display = 'none';
		document.getElementById('txtmsg_and').style.display = 'none';
	}
}

function _deAmountIncVat(v) {
	v = parseInt(v);
	var fee = 0;
	if (v <= 150) {
		var fee = v / 100;
		fee = fee * 9.9;
		fee = fee.toFixed(2);
		if (fee < 6.00) {
			fee = 6.00;
		}
	}
	if (v <= 350 & v > 150) {
		var fee = v - 150;
		fee = fee / 100;
		fee = fee * 7.9;
		fee = fee + 14.85;
		fee = fee.toFixed(2);
	}
	if (v <= 1000 & v > 350) {
		var fee = v - 350;
		fee = fee / 100;
		fee = fee * 5.9;
		fee = fee + 15.8 + 14.85;
		fee = fee.toFixed(2);
	}
	if (v > 1000) {
		var fee = v - 1000;
		fee = fee / 100;
		fee = fee * 3.9;
		fee = fee + 15.8 + 14.85 + 38.35;
		fee = fee.toFixed(2);
	}
	fee = fee / 100;
	fee = fee * 100;
	return fee;
}

function _enAmountIncVat(v) {
	v = parseInt(v);
	var fee = 0;
	if (v <= 150) {
		var fee = v / 100;
		fee = fee * 9.9;
		fee = fee.toFixed(2);
		if (fee < 6.00) {
			fee = 6.00;
		}
	}
	if (v <= 350 & v > 150) {
		var fee = v - 150;
		fee = fee / 100;
		fee = fee * 7.9;
		fee = fee + 14.85;
		fee = fee.toFixed(2);
	}
	if (v <= 1000 & v > 350) {
		var fee = v - 350;
		fee = fee / 100;
		fee = fee * 5.9;
		fee = fee + 15.8 + 14.85;
		fee = fee.toFixed(2);
	}
	if (v > 1000) {
		var fee = v - 1000;
		fee = fee / 100;
		fee = fee * 3.9;
		fee = fee + 15.8 + 14.85 + 38.35;
		fee = fee.toFixed(2);
	}
	fee = fee / 100;
	fee = fee * 117.5;
	return fee;
}

function _nlAmountIncVat(v) {
	v = parseInt(v);
	var fee = 0;
	if (v <= 150) {
		var fee = v / 100;
		fee = fee * 9.9;
		fee = fee.toFixed(2);
		if (fee < 6.00) {
			fee = 6.00;
		}
	}
	if (v <= 350 & v > 150) {
		var fee = v - 150;
		fee = fee / 100;
		fee = fee * 7.9;
		fee = fee + 14.85;
		fee = fee.toFixed(2);
	}
	if (v <= 1000 & v > 350) {
		var fee = v - 350;
		fee = fee / 100;
		fee = fee * 5.9;
		fee = fee + 15.8 + 14.85;
		fee = fee.toFixed(2);
	}
	if (v > 1000) {
		var fee = v - 1000;
		fee = fee / 100;
		fee = fee * 3.9;
		fee = fee + 15.8 + 14.85 + 38.35;
		fee = fee.toFixed(2);
	}
	fee = fee / 100;
	fee = fee * 117.5;
	return fee;
}

function min_bid_amount_to_you(v, currency, ccode) {
	if (!currency) {
		currency = window.locale.currencySymbol;
	}
	if(!ccode) {
	  ccode = window.locale.language;
	}

	var bid = new String(v.value);
	switch (ccode) {
	case 'de':
		var fee = _deAmountIncVat(bid);
		break;
	case 'nl':
		var fee = _nlAmountIncVat(bid);
		break;
	default:
		var fee = _enAmountIncVat(bid);
		break;
	}
	var toyou = bid - fee;
	toyou = toyou.toFixed(2);
	if (toyou > 0) {
		var showstr = currency + toyou;
		if (document.getElementById('txtmsg').innerHTML != '-') {
			document.getElementById('txtmsg_between').style.display = 'inline-block';
			document.getElementById('txtmsg').style.display = 'inline-block';
			document.getElementById('txtmsg_and').style.display = 'inline-block';
			document.getElementById('txtmsg2').style.display = 'inline-block';
		} else {
			document.getElementById('txtmsg_between').style.display = 'none';
			document.getElementById('txtmsg').style.display = 'none';
			document.getElementById('txtmsg_and').style.display = 'none';
			document.getElementById('txtmsg2').style.display = 'inline-block';
		}
		document.getElementById('txtmsg2').innerHTML = showstr;
	} else {
		document.getElementById('txtmsg_between').style.display = 'none';
		document.getElementById('txtmsg').style.display = 'inline-block';
		document.getElementById('txtmsg_and').style.display = 'none';
		document.getElementById('txtmsg2').style.display = 'none';
		document.getElementById('txtmsg2').innerHTML = "-";
	}
}

function show(id) {
	if (document.getElementById) {
		obj = document.getElementById(id);
		if (obj.style.display == "none") {
			obj.style.display = "";
		}
	}
}

function hide(id) {
	if (document.getElementById) {
		obj = document.getElementById(id);
		if (obj.style.display == "") {
			obj.style.display = "none";
		}
	}
}

function Activate() {
	if (document.test.pickup.value == 'select') {
		hide('box1');
		hide('box2');
		return false;
	}
	if (document.test.pickup.value == 'on') {
		show('box1');
		hide('box2');
		document.test.pu_date1.focus();
		document.test.pu_date1.select();
		return true;
	}
	if (document.test.pickup.value == 'before') {
		show('box1');
		hide('box2');
		document.test.pu_date1.focus();
		document.test.pu_date1.select();
		return true;
	}
	if (document.test.pickup.value == 'between') {
		show('box1');
		show('box2');
		document.test.pu_date1.focus();
		document.test.pu_date1.select();
		return true;
	}
}

function Activate2() {
	if (document.test.delivery.value == 'select') {
		hide('dbox1');
		hide('dbox2');
		return false;
	}
	if (document.test.delivery.value == 'on') {
		show('dbox1');
		hide('dbox2');
		document.test.del_date1.focus();
		document.test.del_date1.select();
		return true;
	}
	if (document.test.delivery.value == 'before') {
		show('dbox1');
		hide('dbox2');
		document.test.del_date1.focus();
		document.test.del_date1.select();
		return true;
	}
	if (document.test.delivery.value == 'between') {
		show('dbox1');
		show('dbox2');
		document.test.del_date1.focus();
		document.test.del_date1.select();
		return true;
	}
}

function bid_rule_activate(v, id) {
	if (v == 'select') {
		hide('listing_' + id + '_box1');
		hide('listing_' + id + '_box2');
		return false;
	}
	if (v == 'on') {
		show('listing_' + id + '_box1');
		hide('listing_' + id + '_box2');
		document.forms['listing_' + id + '_bid_form'].pu_date1.focus();
		document.forms['listing_' + id + '_bid_form'].pu_date1.select();
		return true;
	}
	if (v == 'before') {
		show('listing_' + id + '_box1');
		hide('listing_' + id + '_box2');
		document.forms['listing_' + id + '_bid_form'].pu_date1.focus();
		document.forms['listing_' + id + '_bid_form'].pu_date1.select();
		return true;
	}
	if (v == 'between') {
		show('listing_' + id + '_box1');
		show('listing_' + id + '_box2');
		document.forms['listing_' + id + '_bid_form'].pu_date1.focus();
		document.forms['listing_' + id + '_bid_form'].pu_date1.select();
		return true;
	}
}

function bid_rule_activate2(v, id) {
	if (v == 'select') {
		hide('listing_' + id + '_dbox1');
		hide('listing_' + id + '_dbox2');
		return false;
	}
	if (v == 'on') {
		show('listing_' + id + '_dbox1');
		hide('listing_' + id + '_dbox2');
		document.forms['listing_' + id + '_bid_form'].del_date1.focus();
		document.forms['listing_' + id + '_bid_form'].del_date1.select();
		return true;
	}
	if (v == 'before') {
		show('listing_' + id + '_dbox1');
		hide('listing_' + id + '_dbox2');
		document.forms['listing_' + id + '_bid_form'].del_date1.focus();
		document.forms['listing_' + id + '_bid_form'].del_date1.select();
		return true;
	}
	if (v == 'between') {
		show('listing_' + id + '_dbox1');
		show('listing_' + id + '_dbox2');
		document.forms['listing_' + id + '_bid_form'].del_date1.focus();
		document.forms['listing_' + id + '_bid_form'].del_date1.select();
		return true;
	}
}