function ValidateBvbStocks(password, language)
{
	var simbol	=  document.getElementById('addSimbol');
	var tip =  document.getElementById('addTip');
	var tipSel = tip.selectedIndex;
	var myOrderType = tip.options[tipSel].text;

	var tipValabil =  document.getElementById('tip_valabilitate');
	var pret =  document.getElementById('addPrice');
	var cantitate =  document.getElementById('addCant');
	var piata = document.getElementById('addPiata');
	var observatii = document.getElementById('addObservatii');
	var valabil = document.getElementById('valabilitate');

	if(valabil.value != "")
	{
		var valabilitate = valabil.value;
	}
	else
	{
		if(language == "ro")
		{
			var valabilitate = 'zi';
		}
		else
		{
			var valabilitate = 'day';
		}
	}

	if(language == "ro")
	{
		if (pret.value == 0)
		{
			confirmMessage = "Ati introdus un ordin de " + myOrderType +  " pe simbolul: " + simbol.value + " la piata, cantitate: " + cantitate.value + ", valabilitate: "+ valabilitate + "    \nConfirmati introducerea acestui ordin?";
		} else {
			confirmMessage = "Ati introdus un ordin de " + myOrderType +  " pe simbolul: " + simbol.value + " in pretul de " + pret.value + ", cantitate: " + cantitate.value  + ", valabilitate: "+ valabilitate + "    \nConfirmati introducerea acestui ordin?";
		}
	}
	else
	{
		if(language == "en")
		{
			if (pret.value == 0)
			{
				confirmMessage = "You introduced a " + myOrderType +  " order, issuer: " + simbol.value + ", market, quantity: " + cantitate.value  + ", valability "+ valabilitate + "    \nDo you confirm this order?";
			} else {
				confirmMessage = "You introduced a " + myOrderType +  " order, issuer: " + simbol.value + ", price: " + pret.value + ", quantity: " + cantitate.value  + ", valability "+ valabilitate + "    \nDo you confirm this order?";
			}
		}
	}

	if (window.confirm(confirmMessage ))
	{
		document.getElementById('if_confirm').value = 1;
		document.getElementById('orderPass').value = password;
		document.getElementById('orders_bvb_add_form').submit();
	}
}

function ValidateBvbStocksP2(password, password2, language)
{
	var simbol	=  document.getElementById('addSimbol');
	var tip =  document.getElementById('addTip');
	var tipSel = tip.selectedIndex;
	var myOrderType = tip.options[tipSel].text

	var tipValabil =  document.getElementById('tip_valabilitate');
	var pret =  document.getElementById('addPrice');
	var cantitate =  document.getElementById('addCant');
	var piata = document.getElementById('addPiata');
	var observatii = document.getElementById('addObservatii');
	var valabil = document.getElementById('valabilitate');

	if(valabil.value != "")
	{
		var valabilitate = valabil.value;
	}
	else
	{
		if(language == "ro")
		{
			var valabilitate = 'zi';
		}
		else
		{
			var valabilitate = 'day';
		}
	}

	if(language == "ro")
	{
		if (pret.value == 0)
		{
			confirmMessage = "Ati introdus un ordin de " + myOrderType +  " pe simbolul: " + simbol.value + " la piata, cantitate: " + cantitate.value + ", valabilitate: "+ valabilitate + "    \nConfirmati introducerea acestui ordin?";
		} else {
			confirmMessage = "Ati introdus un ordin de " + myOrderType +  " pe simbolul: " + simbol.value + " in pretul de " + pret.value + ", cantitate: " + cantitate.value  + ", valabilitate: "+ valabilitate + "    \nConfirmati introducerea acestui ordin?";
		}
	}
	else
	{
		if(language == "en")
		{
			if (pret.value == 0)
			{
				confirmMessage = "You introduced a " + myOrderType +  " order, issuer: " + simbol.value + ", market, quantity: " + cantitate.value  + ", valability "+ valabilitate + "    \nDo you confirm this order?";
			} else {
				confirmMessage = "You introduced a " + myOrderType +  " order, issuer: " + simbol.value + ", price: " + pret.value + ", quantity: " + cantitate.value  + ", valability "+ valabilitate + "    \nDo you confirm this order?";
			}
		}
	}

	if (window.confirm(confirmMessage ))
	{
		document.getElementById('if_confirm').value = 1;
		document.getElementById('orderPass').value = password;
		document.getElementById('orderPass2').value = password2;
		document.getElementById('orders_bvb_add_form').submit();
	}
}

function ValidateBvbStocksModify(password,language)
{
	var pret =  document.getElementById('modifyPrice');
	var cantitate =  document.getElementById('modifyCant');
	var piata = document.getElementById('modifyPiata');
	var orderID = document.getElementById('modifyorderID');
	var tip_valabilitate = document.getElementById('tip_valabilitate');
	var valabilitate = document.getElementById('valabilitate');
	var confirmMessage = "";
	
	if(language == "ro")
	{
		if(tip_valabilitate.value == "day")
		{
			tip_valabilitate = "zi";
		}
		else
		{
			if(tip_valabilitate.value == "gtd")
			{
				tip_valabilitate = "pana la";
			}
			else
				tip_valabilitate = "deschis";
		}
	}
	
	if(language == "ro")
	{
		if (pret.value == 0)
		{
			if(valabilitate.value != '')
			{
				confirmMessage = "Ati introdus un ordin de modificare: la piata, cantitate: " + cantitate.value + ", valabilitate: " + tip_valabilitate + ", data valabilitatii: " + valabilitate.value + "    \nConfirmati introducerea acestui ordin?";
			}
			else
				confirmMessage = "Ati introdus un ordin de modificare: la piata, cantitate: " + cantitate.value + ", valabilitate: " + tip_valabilitate + "    \nConfirmati introducerea acestui ordin?";
		} else {
			confirmMessage = "Ati introdus un ordin de modificare in pretul de " + pret.value + ", cantitate: " + cantitate.value + ", valabilitate: " + tip_valabilitate + ", data valabilitatii: " + valabilitate.value + "    \nConfirmati introducerea acestui ordin?";
		}
	}
	else
	{
		if(language == "en")
		{
			if (pret.value == 0)
			{
				if(valabilitate.value != '')
				{	
					confirmMessage = "You introduced a \" Modify \" order, market, quantity: " + cantitate.value + ", duration: " + tip_valabilitate.value + ", good till: " + valabilitate.value +"    \nDo you confirm this order?";
				}
				else
					confirmMessage = "You introduced a \" Modify \" order, market, quantity: " + cantitate.value + ", duration: " + tip_valabilitate.value + "    \nDo you confirm this order?";
			} else {
				confirmMessage = "You introduced a \" Modify \" order, price: " + pret.value + ", quantity: " + cantitate.value + ", duration: " + tip_valabilitate.value + ", good till: " + valabilitate.value +"    \nDo you confirm this order?";
			}
		}
	}

	if (window.confirm(confirmMessage ))
	{
		document.getElementById('if_confirm').value = 1;
		document.getElementById('orderPass').value = password;
		document.getElementById('orders_bvb_modify_form').submit();
	}
}

function ValidateBvbStocksModifyP2(password, password2, language)
{
	var pret =  document.getElementById('modifyPrice');
	var cantitate =  document.getElementById('modifyCant');
	var piata = document.getElementById('modifyPiata');
	var orderID = document.getElementById('modifyorderID');
	var tip_valabilitate = document.getElementById('tip_valabilitate');
	var valabilitate = document.getElementById('valabilitate');
	var confirmMessage = "";
	
	if(language == "ro")
	{
		if(tip_valabilitate.value == "day")
		{
			tip_valabilitate = "zi";
		}
		else
		{
			if(tip_valabilitate.value == "gtd")
			{
				tip_valabilitate = "pana la";
			}
			else
				tip_valabilitate = "deschis";
		}
	}
	
	if(language == "ro")
	{
		if (pret.value == 0)
		{
			if(valabilitate.value != '')
			{
				confirmMessage = "Ati introdus un ordin de modificare: la piata, cantitate: " + cantitate.value + ", valabilitate: " + tip_valabilitate + ", data valabilitatii: " + valabilitate.value + "    \nConfirmati introducerea acestui ordin?";
			}
			else
				confirmMessage = "Ati introdus un ordin de modificare: la piata, cantitate: " + cantitate.value + ", valabilitate: " + tip_valabilitate + "    \nConfirmati introducerea acestui ordin?";
		} else {
			confirmMessage = "Ati introdus un ordin de modificare in pretul de " + pret.value + ", cantitate: " + cantitate.value + ", valabilitate: " + tip_valabilitate + ", data valabilitatii: " + valabilitate.value + "    \nConfirmati introducerea acestui ordin?";
		}
	}
	else
	{
		if(language == "en")
		{
			if (pret.value == 0)
			{
				if(valabilitate.value != '')
				{	
					confirmMessage = "You introduced a \" Modify \" order, market, quantity: " + cantitate.value + ", duration: " + tip_valabilitate.value + ", good till: " + valabilitate.value +"    \nDo you confirm this order?";
				}
				else
					confirmMessage = "You introduced a \" Modify \" order, market, quantity: " + cantitate.value + ", duration: " + tip_valabilitate.value + "    \nDo you confirm this order?";
			} else {
				confirmMessage = "You introduced a \" Modify \" order, price: " + pret.value + ", quantity: " + cantitate.value + ", duration: " + tip_valabilitate.value + ", good till: " + valabilitate.value +"    \nDo you confirm this order?";
			}
		}
	}

	if (window.confirm(confirmMessage ))
	{
		document.getElementById('if_confirm').value = 1;
		document.getElementById('orderPass').value = password;
		document.getElementById('orderPass2').value = password2;
		document.getElementById('orders_bvb_modify_form').submit();
	}
}

function ValidateBvbStocksCancel(password,language)
{
	var orderID = document.getElementById('cancelorderID');
	
	if(language == "ro")
	{
		confirmMessage = "Ati introdus un ordin de anulare. \nConfirmati introducerea acestui ordin?";
	}
	else
	{
		if(language == "en")
		{
			confirmMessage = "You introduced a \" Cancel \" order. \nDo you confirm this order?";
		}
	}

	if (window.confirm(confirmMessage ))
	{
		document.getElementById('if_confirm').value = 1;
		document.getElementById('orderPass').value = password;
		document.getElementById('orders_bvb_cancel_form').submit();
	}
}

function ValidateBvbStocksCancelP2(password, password2, language)
{
	var orderID = document.getElementById('cancelorderID');
	
	if(language == "ro")
	{
		confirmMessage = "Ati introdus un ordin de anulare. \nConfirmati introducerea acestui ordin?";
	}
	else
	{
		if(language == "en")
		{
			confirmMessage = "You introduced a \" Cancel \" order. \nDo you confirm this order?";
		}
	}

	if (window.confirm(confirmMessage ))
	{
		document.getElementById('if_confirm').value = 1;
		document.getElementById('orderPass').value = password;
		document.getElementById('orderPass2').value = password2;
		document.getElementById('orders_bvb_cancel_form').submit();
	}
}

function getDate(targetDate, numberOfDays)
{
	var oneMinute = 60 * 1000;
	var oneHour = oneMinute * 60;
	var oneDay = oneHour * 24;

	var dateInMs = targetDate.getTime();
	dateInMs += numberOfDays * oneDay;

	targetDate.setTime(dateInMs);

	var day = new String(targetDate.getDate());
	if (day.length == 1)	day = "0"+day;
	var month = new String(targetDate.getMonth() + 1);
	if (month.length == 1)	month = "0"+month;
	var year = new String(targetDate.getFullYear());

	var formatDate = new String (day+"."+month+"."+year);
	
	return formatDate;
}

function setValabilDate(tipValabilRadio, valabilitateID)
{
	var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	var tipValabilValue = "";

	for ( i = 0; i < tipValabilRadio.length; i++ )
		if ( tipValabilRadio[i].checked )			
			tipValabilValue = tipValabilRadio[i].value;

	var dataValue = new Date();

	if ( tipValabilValue != "gtd")
	{
		if ( tipValabilValue == "open")
		{	
			document.getElementById(valabilitateID).value = getDate(dataValue, 62);
		}
		else
			document.getElementById(valabilitateID).value = "";
		
		document.getElementById(valabilitateID).disabled = true;
	}
	else
	{	
		document.getElementById(valabilitateID).value = "";
		document.getElementById(valabilitateID).disabled = false;
	}

	return true;
}

function change_status(control)
{
	if (control.disabled == false)
	{
		control.value = '';
		control.disabled = true;
	}
	else
		control.disabled = false;
}

//toggle order type

