//-----------------------------------------------------------------------------
//
// Check fields correct filling
//
function CheckForm()
{
 var Obj, ObjFile, Obj2;

 // проверить корректность заполнения полей
 FPhone = document.getElementById("f_phone");
 FEmail = document.getElementById("f_email");
 FZip   = document.getElementById("f_zip");

 FNeed  = document.getElementById("f_need"); // type of job
 FArea  = document.getElementById("f_area"); // type of job

 if (FPhone && FEmail)
   {
    if (FPhone.value == '' && FEmail.value == '') { alert('Please fill in the details marked with a "*"'); return false; }
   }
 else
   {
    if (FPhone)
      {
       if (FPhone.value == '') { alert('Please fill in the details marked with a "*"'); return false; }
      }

    if (FEmail)
      {
       if (FEmail.value == '') { alert('Please fill in the details marked with a "*"'); return false; }
      }
   }

 if (FZip)
   {
    if (FZip.value   == '') { alert('Please fill in the details marked with a "*"'); return false; }
   }
 
 var subm_form = document.getElementById('F1');
 if (subm_form)
   {
    subm_form.submit();
   }
 else 
   {
    ;
   }

/*
 Obj.value = trim(Obj.value);
 if (Obj.value == '') { alert('Заполните поле: "Название документа"'); Obj.focus(); return; }
 // Проверим на :файл:
 Obj     = document.getElementById("doc_tmpl");
 ObjFile = document.getElementById("user_file");
 if (ObjFile) 
   { 
    if (ObjFile.value == '') { alert('Выберите файл для документа.');ObjFile.focus(); return; }    
    else 
      { // доступные расширения проверить
       var str=ObjFile.value;
       var reg=/.jpg$|.doc$|.docx$|.xls$|.xlsx$|.pdf$/i;
       var result = reg.test(str);
       if (result == false){ alert('Выберите файл который соответсвует разрешенному типу: JPG, XLS(X), DOC(X), PDF ');ObjFile.focus(); return; }
      }
   }
 else if  (Obj)
   {
   }
 else
   { 
    alert('Выберите шаблон документа.'); return; 
   }
 // спрятать...
 Obj = document.getElementById("DocxArea0");    if (Obj){ Obj.style.display = "none"; }
 Obj = document.getElementById("DocxArea");     if (Obj){ Obj.style.display = "none"; }
 Obj = document.getElementById("DocxAreaBtns"); if (Obj){ Obj.style.display = "none"; }
 // Выполнить сохранение все дополнительные поля в type=hidden
 doLoad("../ajax/ajNewDocx.php"+"?step=docfinal", "workform", "DocxResultArea", "", true, 1); 
 */
 return true;
}
//-----------------------------------------------------------------------------



//-----------------------------------------------------------------------------
//
// Показать окно
//
function Video_Show()
{
 var WObj = document.getElementById('video');
 if (!WObj) return;

 WObj.style.visibility = 'visible';
}
//-----------------------------------------------------------------------------
//
// Спрятать окно
//
function Video_Close()
{
 var WObj = document.getElementById('video');
 if (!WObj) return;

 WObj.style.visibility = 'hidden';

 var WObj2 = document.getElementById('container');
 if (!WObj2) return;
 WObj2.innerHTML = '';
}
//-----------------------------------------------------------------------------



function Video_Show2(FileVideo, FileImage)
{
 var WObj = document.getElementById('video');
 if (!WObj) return;

 var s1 = new SWFObject("player.swf","ply","525","330","9","#FFFFFF");
 s1.addParam("allowfullscreen","true");
 s1.addParam("allowscriptaccess","always");
 s1.addParam("flashvars","file=userfiles/video/"+FileVideo+"&image="+FileImage);
 s1.write("container");


 WObj.style.visibility = 'visible';
}
//-----------------------------------------------------------------------------



/*
//
// Подругзить список моделей
//
function Win1_ajModel(IdBrand)
{
 doLoad("ajax/ajModelList.php"+"?idbrand="+IdBrand, "ajForm", "automark", "", true, 1);
}
//-----------------------------------------------------------------------------
//
// Подругзить список типоа к моделе
//
function Win1_ajType(IdBrand, IdModel)
{
 doLoad("ajax/ajModelTypeList.php"+"?idbrand="+IdBrand+"&idmodel="+IdModel, "ajForm", "automark", "", true, 1);
}
//-----------------------------------------------------------------------------
*/





//-----------------------------------------------------------------------------
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
//-----------------------------------------------------------------------------



















