﻿//javascript - Englsh

var msgFirstLastName = "Please fill First & Last Names";
var msgEmail= "Please fill the Email";
var msgStreet= "Please fill the Address";
var msgCity= "Please fill the City";
var msgHouseNumber= "Please fill the House Number";
var msgPhone= "Please fill the Phone";
var msgMobile= "Please fill the Mobile Phone";
var msgCardNumber= "Please fill the Card Number";
var msgCardNumberInvalid= "Card Number is invalid";
var msgCardHolder= "Please fill the Card onwer full name";
var msgIDNumber= "Please fill the ID Number";
var L_Empty = 'Заполните обозначенное поле.';
var L_Invalid ='Неправильный формат введенного поля.';
var Len_Invalid = 'Должен быть 8 символов.';
var L_NotMatch = 'Пароль пользователя не совпадает';
var msgOutOfStock = 'Продукт в данный момент отсутствует на складе.';
var msgLimitStock = 'Вы можете заказать максимум xxx ед. товара.';
var msgHasCrossProds = "Этот товар имеет сопутствующие товары со специальной ценой. \nУдаление этого товара отменяет специальную цену сопутствующих товаров. \nВы желаете удалить этот товар?";
var msgZeroQuantity="Кол-во одного из товаров в корзине = 0.\nИзмениете кол-во единиц товара или очистите корзину."
var msgEmptyBasket = 'Очистить корзину?';

function CheckLogin()
{
   //alert(window.location.href);
   var sStr="";
   if (document.all.uname.value==""  && document.all.uname.value.length==0)
    {
                
      			
      			
      		document.all.uname.style.background="#EFD000" ;
              document.all.errmsg.value = "Введите логин."
      			
      	document.all.uname.focus();
      	return false;
      }
      else
		document.all.uname.style.background="white" ;
      if (document.all.upwd.value==""  && document.all.upwd.value.length==0)
      {
                
      			
      			
      		document.all.upwd.style.background="#EFD000" ;
              document.all.errmsg.value = "Введите пароль."
      			
      	document.all.upwd.focus();
      	return false;
      }
   //   var x = window.location;
   //var t = ['Property - Typeof - Value',
   //         'window.location - ' + (typeof x) + ' - ' + x ];
   //for (var prop in x){
   //  t.push(prop + ' - ' + (typeof x[prop]) + ' - ' +  (x[prop] || 'n/a'));
   //}
   //alert(t.join('\n'));
   //alert(window.location.pathname);
   //	alert(window.location.search);
	 //document.method="post";
	 //document.login_details.action="CheckLogin.asp?lin=1&lout=0&uname="+document.all.uname.value + "&upwd=" + document.all.upwd.value + "&url=" + window.location.pathname +"&sstr=;;;" + window.location.search + ""
	 //alert(document.all("Hidden3"));
	 if (document.all.Hidden1)
		sStr="&SupplierID=" + document.all.Hidden1.value;
	if (document.all.Hidden3)	
		sStr=sStr +"&shopSearch=" + document.all.Hidden3.value;
		
		//alert(sStr);
     document.location.href="CheckLogin.asp?lin=1&lout=0&uname="+document.all.uname.value + "&upwd=" + document.all.upwd.value + "&url=" + window.location.pathname +"&sstr=;;;" + window.location.search + "" +sStr;
     //document.login_details.submit();
}

function CheckLogout()
{  
     document.location.href="CheckLogin.asp?lin=0&lout=1&url=" + window.location.pathname +"&sstr=;;;" + window.location.search + ""
}

function ShowCompanyDiv(sValue)
{
	if (sValue=="personal_order")
	   document.all("CompanyDiv").style.display="none";
	else
	   document.all("CompanyDiv").style.display="block";
	   
}

function OpenPaymentDiv(id)
{
	if (document.all("CC"))
	   document.all("CC").style.display="none";
	if (document.all("MM"))
	   document.all("MM").style.display="none";
	if (document.all("WM"))
	   document.all("WM").style.display="none";
	if (document.all("YM"))
	   document.all("YM").style.display="none";	
	switch(id)
	{
		case "credit_card":
			 document.all("CC").style.display="block";	
		     break;	
		case "money_mail":
			 document.all("MM").style.display="block";	
		     break;
		case "web_money":
			 document.all("WM").style.display="block";	
		     break;
		case "yandex":
			 document.all("YM").style.display="block";	
		     break;
	}
}

function CitySelect(objCity,objMetro)
  {
	//alert(objCity.value);
	if (objCity.value==133)
	   objMetro.disabled=false;
	else
	{
	   objMetro.disabled=true;
	   objMetro.selectedIndex=0;
	   }
	document.all.sCity.value=objCity.options[objCity.selectedIndex].text;
  }
  
  function MetroSelect(objMetro)
  {
	document.all.sMetro.value=objMetro.options[objMetro.selectedIndex].text;
  }
  
  function CheckPersonType()
{
	
	if (document.all.CompanyDiv)
	{
		if (document.all.PersonType_opt(1).checked)
		   document.all.CompanyDiv.style.display='block';
		else
		   document.all.CompanyDiv.style.display='none';
			   
		if (document.all("CC"))
		   document.all("CC").style.display="none";
		if (document.all("MM"))
		   document.all("MM").style.display="none";
		if (document.all("WM"))
		   document.all("WM").style.display="none";
		if (document.all("YM"))
		   document.all("YM").style.display="none";	
		for(var i=0;i<document.all["pay_opt"].length;i++)
        {
             if(document.all["pay_opt"][i].checked)
             {
					switch(document.all["pay_opt"][i].value)
					{
						case "credit_card":
							 document.all("CC").style.display="block";	
						     break;	
						case "money_mail":
							 document.all("MM").style.display="block";	
						     break;
						case "web_money":
							 document.all("WM").style.display="block";	
						     break;
						case "yandex":
							 document.all("YM").style.display="block";	
						     break;
					}
             }
        }	   
	}
	
}

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}