<!--
FName_err = "Пожалуйста корректно введите Ваше полное имя (Ф.И.О.) !";
CityArea_err = "Пожалуйста корректно введите название Вашего города или области !";
EMail_err = "Пожалуйста корректно введите Ваш e-mail адрес !";
SkypeNik_err = "Пожалуйста корректно введите Ваш Skype - ник !";
PhoneNum_err = "Пожалуйста корректно введите номер Вашего телефона (желательно мобильный) !";
Contacts_err = "Хотя бы одно из полей для контактной связи с Вами должно быть заполненно !";
previousSiteType = 'MSG-null';
stWait = 0;


jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox({
loading_image : 'my_scripts/loading.gif',
close_image   : 'my_scripts/closelabel.gif'
}) 
}) 

/*jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox() 
})*/ 


function ClearMsg()
{
 $('#MSG-success').hide();
 setTimeout("ShowMsg1()", 1500);  
}

function ClearMsg1()
{
 $('#MSG-success').hide();
 setTimeout("ShowMsg2()", 1500);  
}

function ClearMsg2()
{
 $('#MSG-success').hide();
}

function ShowMsg2()
{
$('#MSG-success').show(); 
 setTimeout("ClearMsg2()", 80000);
}

function ShowMsg1()
{
$('#MSG-success').show(); 
 setTimeout("ClearMsg1()", 1500);
}

function ShowMsg()
{
$('#MSG-success').show(); 
 setTimeout("ClearMsg()", 1500);
}

function ClearErr()
{
 $('#MSG-error').hide();
 setTimeout("ShowErr1()", 1500);  
}

function ClearErr1()
{
 $('#MSG-error').hide();
 setTimeout("ShowErr2()", 1500);  
}

function ClearErr2()
{
 $('#MSG-error').hide();
}

function ShowErr2()
{
$('#MSG-error').show(); 
 setTimeout("ClearErr2()", 80000);
}

function ShowErr1()
{
$('#MSG-error').show(); 
 setTimeout("ClearErr1()", 1500);
}

function ShowErr()
{
$('#MSG-error').show(); 
 setTimeout("ClearErr()", 1500);
}

function ClearWarning()
{
 $('#MSG-waiting').hide();
 if(stWait != 10)
 { setTimeout("ShowWarning()", 20); }
}

function  ShowWarning()
{
$('#MSG-waiting').show(); 
 setTimeout("ClearWarning()", 20);
}

function ChSt()
{
//stOrderSend="<?php echo $stOrderSend; ?>";
 ShowWarning();
 
 if(stOrderSend) { stWait = 10; setTimeout("ShowMsg()", 2500); }
 else{ if(stWait == 10) { setTimeout("ShowErr()", 2500); return; } 
  stWait = stWait +1; setTimeout("ChSt()", 2500); 
 }
}

function isGraph(aChar)
   {
      myCharCode = aChar.charCodeAt(0);
   
      if((myCharCode > 32) && (myCharCode <  127))
      { 
         return true;
      }
   
      return false;
   }

function isDigit(aChar)
   {
      myCharCode = aChar.charCodeAt(0);
   
      if((myCharCode > 47) && (myCharCode <  58))
      {
         return true;
      }
   
      return false;
   }

function isAlpha(aChar)
   {
      myCharCode = aChar.charCodeAt(0);
   
      if(((myCharCode > 64) && (myCharCode <  91)) ||
         ((myCharCode > 96) && (myCharCode < 123))) // || и убрать 1 скобку
	     /* ((myCharCode > 1039) && (myCharCode < 1104))) Расскомментировать для поддержки кирилицы */
      {
         return true;
      }
   
      return false;
   }
   
function isAlnum(aChar)
   {
      return (isDigit(aChar) || isAlpha(aChar));
   }

function isPunct(aChar)
   {
      return (isGraph(aChar) && !(isAlnum(aChar)));
   }

function isSpace(aChar)
   {
      myCharCode = aChar.charCodeAt(0);
   
      if(((myCharCode >  8) && (myCharCode < 14)) ||
         (myCharCode == 32))
      {
         return true;
      }
   
      return false;
   }
   
 function isEmpty(Field)
   {
    var RealCH = 0;
	
	if(Field.length == 0)  { return true; }
	
    for(i = 0; i <= Field.length; i++)
	{
	 if(!isSpace(Field.charAt(i))) {
	   	RealCH = RealCH + 1;
	 }
	}

    if(RealCH == 0) { return true; }
	
	return false;
   }

function HaveDigit(Field)
   {
    for(i = 0; i <= Field.length; i++)
	{
	 if(isDigit(Field.charAt(i))) {	return true; }
	}

	return false;
   }
   
   function HaveATAbstract(Field)
   {
    for(i = 0; i <= Field.length; i++)
	{
	 if((Field.charCodeAt(i) == 64) && i > 0 && i < (Field.length - 2)) 
	 { 
	   if(!isPunct(Field.charAt(i - 1)) && !isPunct(Field.charAt(i + 1)))
	   { return true; }
	 }
	}

	return false;
   }
   
   function HaveAT(Field)
   {
    for(i = 0; i <= Field.length; i++)
	{
	 if(Field.charCodeAt(i) == 64) return true; 
	}

	return false;
   }
   

 function HavePoint(Field)
   {
    for(i = 0; i <= Field.length; i++)
	{
	 if(Field.charCodeAt(i) == 46) return true; 
	}

	return false;
   }

function HaveSpaceAbstract(Field)
   {
    for(i = 0; i <= Field.length; i++)
	{
	 if(isSpace(Field.charAt(i))) {
	   	if(i > 1 && i < (Field.length - 2)) return true;
	 }
	}

	return false;
   }
   
   

function HaveSpace(Field)
   {
    for(i = 0; i <= Field.length; i++)
	{
	 if(isSpace(Field.charAt(i))) {
	   	return true;
	 }
	}

	return false;
   }

function eContactsAllowedLetters(Field)
{
  if(HaveSpace(Field)) return false;

  for(i = 0; i <= Field.length; i++)
	{
	 if(isPunct(Field.charAt(i))) 
	 {
	  switch(Field.charCodeAt(i)) {
		case 45:
		case 46:
	    case 64:
		case 95:
	   case 173:
 		
		break;
		default:
		return false;
	  }
	 }
     
	 if((Field.charCodeAt(i) > 1039) && (Field.charCodeAt(i) < 1104)) return false;
    }

 return true;
}

function PhoneSymbolsOnly(Field)
{
  var DigitCount = 0;
  
  if(Field.length < 2) return false;
  
  for(i = 0; i <= Field.length; i++)
	{
	 if(isPunct(Field.charAt(i))) 
	 {
	  switch(Field.charCodeAt(i)) {
		case 40:
		case 41:
		case 43:
		case 45:
		case 46:
		case 47:
		case 92:
	   case 173:
 		
		break;
		default:
		return false;
	  }
	 }
     
	 if((Field.charCodeAt(i) > 1039) && (Field.charCodeAt(i) < 1104)) return false;
 	 if(isAlpha(Field.charAt(i))) return false;
	 
	 if(isDigit(Field.charAt(i))) DigitCount = DigitCount + 1;
    }

 if(DigitCount < 2) return false;

 return true;
}

function SetSign(idSign, State)
{
 var SignTrue, SignFalse;

 if(idSign != null) {
 SignTrue = idSign + 'Correct';
 SignFalse = idSign + 'InCorrect';
 }

 if(State != null && State == false) {
 document.getElementById(SignTrue).style.visibility = 'hidden';
 document.getElementById(SignFalse).style.visibility = 'visible';
 }else if(State != null && State == true) {
 document.getElementById(SignFalse).style.visibility = 'hidden';
 document.getElementById(SignTrue).style.visibility = 'visible';
 }	
}

function ClearSign(idSign)
{
 var SignTrue, SignFalse;

 if(idSign != null) {
 SignTrue = idSign + 'Correct';
 SignFalse = idSign + 'InCorrect';
 }

 document.getElementById(SignTrue).style.visibility = 'hidden';
 document.getElementById(SignFalse).style.visibility = 'hidden';
}

function MSGBox(MSG)
{

document.getElementById('idInfo').innerHTML = MSG;
  jQuery("#idMSGLink").click();
}

function SendOF()
{
var tmp = null;
var ContactStatus = false;
var ContactError = false;

document.getElementById('idOrder').action = '/my_scripts/order.php';

if(isEmpty(document.getElementById('idFname').value) || HaveDigit(document.getElementById('idFname').value)) 
{ MSGBox(FName_err); SetSign('idFname', false); return;}

if(!HaveSpaceAbstract(document.getElementById('idFname').value)) 
{ MSGBox(FName_err); SetSign('idFname', false); return; } 
else { SetSign('idFname', true); }

tmp = document.getElementById('idCityArea').value;
if(isEmpty(tmp) || (tmp.length < 2) || HaveDigit(tmp))
{ MSGBox(CityArea_err); SetSign('idCityArea', false); return; }
else { SetSign('idCityArea', true); }

ClearSign('idEMail');
ClearSign('idSkypeNik');
ClearSign('idPhoneNum');

tmp = document.getElementById('idEMail').value;

if(!isEmpty(tmp)) 
{  

 if(HaveATAbstract(tmp) && eContactsAllowedLetters(tmp) && HavePoint(tmp)) 
 { SetSign('idEMail', true); ContactStatus = true; } 
 else { MSGBox(EMail_err); SetSign('idEMail', false); ContactError = true; }
} 

tmp = document.getElementById('idSkypeNik').value;

if(!isEmpty(tmp)) 
{  
 if(eContactsAllowedLetters(tmp) && !HaveAT(tmp)) 
 { SetSign('idSkypeNik', true); ContactStatus = true; } 
 else { MSGBox(SkypeNik_err); SetSign('idSkypeNik', false); ContactError = true; }
} 

tmp = document.getElementById('idPhoneNum').value;

if(!isEmpty(tmp)) 
{  
 if(PhoneSymbolsOnly(tmp)) 
 { SetSign('idPhoneNum', true); ContactStatus = true; } 
 else { MSGBox(PhoneNum_err); SetSign('idPhoneNum', false); ContactError = true; }
}

if(ContactStatus)
{ document.getElementById('idOrder').submit(); ChSt(); }
else { if(!ContactError) MSGBox(Contacts_err); }

//document.getElementById('idOrder').submit(); 
}

function MessageProcessing(SType)
{
var sType;

sType = '#' + SType;

/* $(document).ready(function(){
    
    // Using multiple unit types within one animation.
      if($(sType).is(':visible')) {
      $(sType).show();
      $(sType).animate({"opacity": "toggle", "height": "toggle"}, {"duration": "slow"});  
	  }else{
      $(sType).animate({"opacity": "toggle", "height": "toggle"}, {"duration": "slow"});  
	  }
     //slideToggle("slow");
	  //animate({"opacity": "100%", "height": "slideToggle"}, {"duration": "slow"});
 }); */

jQuery(document).ready(function(){
    
    // Using multiple unit types within one animation.
      if( jQuery(sType).is(':visible')) {
      jQuery(sType).show();
      jQuery(sType).animate({"opacity": "toggle", "height": "toggle"}, {"duration": "slow"});  
	  }else{
      jQuery(sType).animate({"opacity": "toggle", "height": "toggle"}, {"duration": "slow"});  
	  }
     //slideToggle("slow");
	  //animate({"opacity": "100%", "height": "slideToggle"}, {"duration": "slow"});
 }); 


}

function STChange()
{
var SiteType;

SiteType = "MSG-" + document.getElementById('idSType').value;

if(previousSiteType != 'MSG-null') { MessageProcessing(previousSiteType); } 
if(previousSiteType == 'MSG-flash') {
document.getElementById('IdEconom').disabled = false; 
document.getElementById('IdLEconom').style.color = '#AAD3E9';
}

switch(SiteType) {
case 'MSG-visiting-card':
  case 'MSG-e-corporate':
     case 'MSG-e-portal':
       case 'MSG-e-shop':
	  MessageProcessing(SiteType);
	  previousSiteType = SiteType;	
break;
        case 'MSG-flash':
	  MessageProcessing(SiteType);
	  previousSiteType = SiteType;	
	  document.getElementById('IdEconom').disabled = true;
	  document.getElementById('IdLEconom').style.color = '#F1F3EF';
break;

case 'MSG-null':
    default:
    //if(previousSiteType != 'MSG-null') { MessageProcessing(previousSiteType); } 
	previousSiteType = 'MSG-null';	
 }
}
-->
