
//Calculate prices
function taxiTransferPrice()
{
	if(priceSafer()){
		var count = 1;
		if($("#TransportCarnum").get().length > 0 && $("#TransportCarnum").val() != "")
		{
			count = parseInt($("#TransportCarnum").val());
		}
		$.each($("#TransportCityPrice").val().split(";"), function(i, val)
		{
			if(val.split(":")[0]  == $("#TransportCity").val())
			{
				price = parseInt(val.split(":")[1]);

				if($("#TransportExtraPrice").get().length > 0 && $("#ExtraExtra").get().length > 0){
					$.each($("#TransportExtraPrice").val().split(";"), function(i, val)
					{
						if($("#ExtraExtra").val() != null && $.inArray(val.split(":")[0], $("#ExtraExtra").val()) != -1){
							price += parseInt(val.split(":")[1]);
						}
					});
				}
				
				if($("#priceField").get().length > 0)
					$("#priceField").html((price * count) + " Ft");
				$("#TransportPrice").val(price * count);
			}
		});
	}
}

function priceSafer()
{
	if($("#TransportPriceSafer").get().length > 0 && $("#TransportPriceSafer").val() == 1)
	{
		return false;
	}
	return true;
}

function changeSaferState()
{
	if($("#TransportPriceSafer").get().length > 0)
	{
		if($("#TransportPriceSafer").val() == 1){
			$("#TransportPriceSafer").val(0);
			$("#saferIMG").attr("src","/img/lock_unlock.png");
		} else {
			$("#TransportPriceSafer").val(1);
			$("#saferIMG").attr("src","/img/lock.png");
		}
	}
}

function clearExtras()
{
	$("#ExtraExtra").val(null);
	taxiTransferPrice();
}
//end Calculate prices

//Menu
function CustomMenu(id, classtoParent) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.links = this.menu.getElementsByTagName("a");
	this.toParent = classtoParent;
}

CustomMenu.prototype.init = function() {

	var mainInstance = this;
	for (var i = 0; i < this.links.length; i++){
		if(this.toParent){
			if (document.location.href == this.links[i].href) {
				this.links[i].parentNode.className = "active";
			}
		}else{
			if (document.location.href.indexOf(this.links[i].href) == 0) {
				this.links[i].className = "active";
			}
		}
	}
};

function adClassToId(id)
{
	$("#"+id).attr('class','active');
}

//end Menu
