dragStatus = false;
d = document;
/////////////////////////////////////////////////////////
function gid(id){
return d.getElementById(id)
}
/////////////////////////////////////////////////////////
function isEmail(sEmail){
if(/([^@]+)@(.+)\.(.+)/.test(sEmail)){ return(1) } else { return(0) }
}
/////////////////////////////////////////////////////////
function isNumber(sNum){
if(/[^(1|2|3|4|5|6|7|8|9|0|\.)]/.test(sNum)){
return false
} else {
return true
}
}
/////////////////////////////////////////////////////////
function isPassword(str){
if(str.length < 8 || /[^(a-z0-9)]/i.test(str)){
return false
} else {
return true
}
}
/////////////////////////////////////////////////////////
function checkInt(obj,title){
obj.value = obj.value.replace(/\.{2,}/g,'.');
if(!isNumber(obj.value)){
obj.value = obj.value.replace(/[^(0-9|\.)]/g,'');
baloon('ОШИБКА','В поле «'+ title +'» должно быть цифровое значение');
};
}
/////////////////////////////////////////////////////////
function checkLatin(obj,title){
var text,regexp;
text = obj.value;
regexp = /[^(a-z0-9\s_\-)]/ig ;
if(regexp.test(text)){
obj.value = text.replace(regexp,'');
baloon('ОШИБКА','В поле «'+ title +'» могут быть только латинские буквы',5000);
}
}
/////////////////////////////////////////////////////////
function nowDate(incDays){
var nowDate, hours, minutes, seconds, day, month, year;
nowDate = new Date();
if(incDays){ nowDate.setDate(nowDate.getDate() + incDays) };
hours = nowDate.getHours();
minutes = nowDate.getMinutes();
seconds = nowDate.getSeconds();
day = nowDate.getDate();
month = eval(nowDate.getMonth() + 1);
year = nowDate.getFullYear();
time = nowDate.getTime();
gmt = nowDate.toGMTString();
if(hours < 10){ hours = '0' + hours }
if(minutes < 10){ minutes = '0' + minutes }
if(day < 10){ day = '0' + day }
if(month < 10){ month = '0' + month }
return {hours:hours, minutes:minutes, seconds:seconds, day:day, month:month, year:year, time:time, gmt:gmt}
}
/////////////////////////////////////////////////////////
function symCount(field_id,counter_id,maxNum){
var field = document.getElementById(field_id);
var counter = document.getElementById(counter_id);
counter.innerHTML = field.value.length + '/' + maxNum;
if(field.value.length > maxNum){field.value = field.value.substr(0,maxNum)}
}
/////////////////////////////////////////////////////////
function fade(id,i_start,i_finish,bRemove,speed){
if(gid(id)){
var step = 8, // %
speed = 1, // ms
obj = document.getElementById(id),
op = (navigator.appName.indexOf('Microsoft') >= 0) ?
((obj.style.filter) ? parseInt(obj.style.filter.match(/opacity=([0-9]+)/)[1]) : i_start) :
((obj.style.opacity) ? parseFloat(obj.style.opacity * 100) : i_start);
if(i_start < i_finish){
if(op < i_finish){
if(typeof(OUTTIMER) == 'number'){ clearTimeout(OUTTIMER) }
op = Math.round(op) + step;
obj.style.opacity = op/100
obj.style.filter = 'alpha(opacity='+ op +')'
INTIMER = setTimeout("fade('"+id+"',"+i_start+","+i_finish+")",speed)
}
} else {
if(op > i_finish){
if(typeof(INTIMER) == 'number'){ clearTimeout(INTIMER) }
op = Math.round(op) - step;
obj.style.opacity = op/100
obj.style.filter = 'alpha(opacity='+ op +')'
OUTTIMER = setTimeout("fade('"+id+"',"+i_start+","+i_finish+")",speed)
} else if(bRemove){
obj.parentNode.removeChild(obj)
}
}
}
}
/////////////////////////////////////////////////////////
function isChecked(oContainer,sCheckName,table){
if(oContainer){
var i,inputList,checkedList = new Array();
inputList = oContainer.getElementsByTagName('input');
for(i = 0; i < inputList.length; i++){
if(inputList[i].checked == true && inputList[i].name == sCheckName){
checkedList.push([inputList[i].value,inputList[i].getAttribute('table'),inputList[i].getAttribute('delete')])
}
}
return checkedList
}
}
/////////////////////////////////////////////////////////
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i";
} catch(e) {
// Error. Do nothing.
}
}
/////////////////////////////////////////////////////////
function send_form(uuid,title){
var dialogTitle, dialogCode, dialogButtons;
dialogCode = ''
+ '
'
+ ' '
+ ' '
+ ' '
+ ' '
+ ' ';
dialogButtons = [
'',
''
];
dialogTitle = (title) ? title : 'Отправка сообщения';
dialog(dialogTitle,dialogCode,dialogButtons);
ten();
document.forms['nov_form'].kName1.style.display = 'none';
document.forms['nov_form'].kName2.style.display = 'none';
document.forms['nov_form'].kName3.style.display = 'none';
document.forms['nov_form'].kName4.style.display = 'none';
}
/////////////////////////////////////////////////////////
function checkFill(form){
if(!form.fName.value){
alert('Введите Ваше имя','5000');
form.fName.focus();
} else if(!form.fText.value){
alert('Введите текст сообщения','5000');
form.fText.focus();
} else if(!form.fContacts.value) {
alert('Введите Вашу контактную информацию','5000');
form.fContacts.focus();
} else {
form.submit();
}
}
/////////////////////////////////////////////////////////
function _blank(){
var aList = document.getElementsByTagName('a')
for(var i = 0; i < aList.length; i++){
if(aList[i].className.indexOf('_blank') >= 0 && !aList[i].onclick){
aList[i].onclick = function(){ window.open(this.href); return false }
}
}
}
/////////////////////////////////////////////////////////
function removeOverlay(){
var baloon = gid('baloon'),
nov = gid('nov'),
fon = gid('fon');
if(nov){
nov.parentNode.removeChild(nov)
}
if(baloon){
baloon.parentNode.removeChild(baloon)
}
if(fon){
if(1 == 1){ //if(nofade || navigator.appName.indexOf('Microsoft')>=0)
document.body.removeChild(fon)
} else {
fade('fon',65,0)
}
}
var selectList = document.getElementsByTagName("SELECT");
for(var i = 0; i=0){
// tenList[i].innerHTML='' +
// '' +
// //тень
// ''+ tenList[i].innerHTML +'' +
// //текст
// ''+ tenList[i].innerHTML +'' +
// ''
// tenList[i].className='';
// }
// }
}
/////////////////////////////////////////////////////////
function initDrag(event,obj){
layer = obj;
mouse_x_0 = event.clientX;
mouse_y_0 = event.clientY;
obj_x_0 = absPos(obj).x;
obj_y_0 = absPos(obj).y;
dragStatus = true;
if(navigator.appName.indexOf('Microsoft') >= 0){
document.body.setAttribute("onmousemove",function(){ doDrag(event) });
document.body.setAttribute("onmouseup",function(){ stopDrag() });
} else {
document.body.setAttribute("onmousemove","doDrag(event)");
document.body.setAttribute("onmouseup","stopDrag()");
}
}
/////////////////////////////////////////////////////////
function doDrag(event){
if(dragStatus){
obj = layer;
obj.style.position = 'absolute';
obj.style.cursor = 'move';
var posLeft, posTop, posRight, posBottom, leftSide, rightSide, topSide, bottomSide;
posLeft = obj_x_0 + event.clientX - mouse_x_0 - document.body.scrollLeft;
posTop = obj_y_0 + event.clientY - mouse_y_0 - document.body.scrollTop;
posRight = posLeft + obj.clientWidth;
posBottom = posTop + obj.clientHeight;
rightSide = document.body.clientWidth;
bottomSide = document.body.clientHeight;
if(posRight > rightSide - 30){
// прилипает вправо
obj.style.left = rightSide - obj.clientWidth + 'px';
} else if(posLeft < 30){
// прилипает влево
obj.style.left = 0 + 'px';
} else {
obj.style.left = posLeft + 'px';
}
if(posBottom > bottomSide - 30){
// прилипает вниз
obj.style.top = bottomSide - obj.clientHeight + 'px';
} else if(posTop < 30){
// прилипает вверх
obj.style.top = '0px';
} else {
obj.style.top = posTop + 'px';
}
}
}
/////////////////////////////////////////////////////////
function stopDrag(){
if(dragStatus){
layer.style.cursor = 'auto';
dragStatus = false;
}
}
/////////////////////////////////////////////////////////
function ajax(params){
var req = false;
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if(window.ActiveXObject){
try{
req = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e){}
try{
req = new ActiveXObject('Microsoft.XMLHTTP');
} catch(e){}
}
if(req){
req.onreadystatechange = function(){
if(req.readyState == 4 && req.status == 200){
params.func(req.responseText)
}
};
if(params.params){
req.open('POST', params.url, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.send(params.params);
} else {
req.open('GET', params.url, true);
req.send(null);
}
} else {
alert("Браузер не поддерживает AJAX");
}
return false;
}
/////////////////////////////////////////////////////////
function getScript(params){
var newEl = document.createElement('script');
newEl.type = 'text/javascript';
newEl.src = params.url + '?rnd=' + Math.random();
if(params.func){
// IE
newEl.onreadystatechange = function(){
if(newEl.readyState == 'complete' || newEl.readyState == 'loaded'){
params.func()
}
}
// FF
newEl.onload = function(){
params.func()
}
}
document.body.appendChild(newEl);
return false
}
/////////////////////////////////////////////////////////
function getStyle(url){
var newEl = document.createElement('link');
newEl.rel = 'stylesheet';
newEl.type = 'text/css';
newEl.href = url;
document.body.appendChild(newEl);
return false
}
/////////////////////////////////////////////////////////
function checkForm(aParams){
var f = d.forms[aParams.form],
bal = (typeof(baloon) == 'function') ? 1 : 0,
err;
for(var i = 0; i < aParams.fields.length; i++){
var aField = aParams.fields[i];
var oField = f.elements[aField[1]];
if(aField[2] == 'email' && !isEmail(oField.value)){
(bal) ? baloon(getLangVal.err,'Введите корректный e-mail в поле «' + aField[0] + '»',5000) : alert('Введите корректный e-mail в поле "' + aField[0] + '"');
oField.focus();
err = 1;
break;
}
if(aField[2] == 'checkbox' && !isChecked(gid(aField[1]),aField[3]).length){
(bal) ? baloon(getLangVal.err,'Выберите что-нибудь в поле «' + aField[0] + '»',5000) : alert('Выберите что-нибудь в поле "' + aField[0] + '"');
err = 1;
break;
}
if(aField[2] == 'string' && oField.disabled == false && (!oField.value || oField.value == ' ' || oField.value == aField[3])){
(bal) ? baloon(getLangVal.err,'Заполните поле «' + aField[0] + '»',5000) : alert('Заполните поле "' + aField[0] + '"');
oField.focus();
err = 1;
break;
}
if(aField[2] == 'password' && !isPassword(oField.value)){
(bal) ? baloon(getLangVal.err,'Поле «' + aField[0] + '» должно быть длиной не менее 8 символов и содержать только латинские символы и цифры',5000) : alert('Поле "' + aField[0] + '" должно быть длиной не менее 8 символов и содержать только латинские символы и цифры');
oField.focus();
err = 1;
break;
}
if(aField[2] == 'phone' && (oField.value.length < 6 || oField.value.length > 150 || /[^(0-9\-\s\(\)\,\.\;\:)]/.test(oField.value))){
(bal) ? baloon(getLangVal.err,'Поле «' + aField[0] + '» должно быть длиной не менее 6 символов и не содержать букв',5000) : alert('Поле "' + aField[0] + '" должно быть длиной не менее 6 символов и не содержать букв');
oField.focus();
err = 1;
break;
}
if(aField[2] == 'select' && (!oField.options[oField.selectedIndex].innerHTML || oField.options[oField.selectedIndex].innerHTML == aField[3] || !oField.options[oField.selectedIndex].value || oField.options[oField.selectedIndex].value == aField[3])){
(bal) ? baloon(getLangVal.err,'Выберите что-нибудь в поле «' + aField[0] + '»',5000) : alert('Выберите что-нибудь в поле "' + aField[0] + '"');
err = 1;
break;
}
if(aField[2] == 'number' && (oField.value == '' || !isNumber(oField.value))){
(bal) ? baloon(getLangVal.err,'В поле «' + aField[0] + '» должно быть цифровое значение',5000) : alert('В поле "' + aField[0] + '" должно быть цифровое значение');
oField.focus();
err = 1;
break;
}
if(aField[2] == 'file' && oField.disabled == false && (!oField.value || oField.value == ' ' || oField.value == aField[3])){
(bal) ? baloon(getLangVal.err,'Выберите файл в поле «' + aField[0] + '»',5000) : alert('Выберите файл в поле «' + aField[0] + '»');
oField.focus();
err = 1;
break;
}
if(aField[2] == 'check'){
var list = d.getElementsByTagName('input'),
i2 = 0,
errCheck = 1;
for(i2; i2 < list.length; i2++){
if((list[i2].type == 'checkbox' || list[i2].type == 'radio') && list[i2].name == aField[1]){
if(list[i2].checked == true){
errCheck = 0;
}
}
}
if(errCheck){
(bal) ? baloon(getLangVal.err,'Выберите что-нибудь из «' + aField[0] + '»',5000) : alert('Выберите что-нибудь из "' + aField[0] + '"');
err = 1;
break;
}
}
}
if(!err){ aParams.func() };
return false
}
//var userEntry = '123s11d'
//var oneChar
//for (var i = 0; i < userEntry.length; i++) {
// oneChar = userEntry.charAt(i)
// if (oneChar < "0" || oneChar > "9") {
// alert(oneChar + " The entry must be numerals only.")
// }
//}
/////////////////////////////////////////////////////////
function slidein(id,step){
if(typeof(slide) == 'number'){ clearTimeout(slide); }
var obj = gid(id),
diff = obj.scrollHeight - obj.offsetHeight;
obj.style.display = 'block';
if(obj.offsetHeight < obj.scrollHeight){
h = obj.offsetHeight + (diff < step ? diff : step);
obj.style.height = h + 'px';
slide = setTimeout("slidein('" + id + "'," + step + ")",1);
}
return false;
}
/////////////////////////////////////////////////////////
function slideout(id,step){
if(typeof(slide) == 'number'){ clearTimeout(slide); }
var obj = gid(id);
if(obj.offsetHeight > 1){
h = obj.offsetHeight - (obj.offsetHeight < step ? obj.offsetHeight - 1 : step);
obj.style.height = h + 'px';
slide = setTimeout("slideout('" + id + "'," + step + ")",1);
} else {
obj.style.display = 'none';
}
return false;
}
/////////////////////////////////////////////////////////
function addHandler(object,event,handler){
if (typeof object.addEventListener != 'undefined')
object.addEventListener(event, handler, false);
else if (typeof object.attachEvent != 'undefined')
object.attachEvent('on' + event, handler);
else
throw "Incompatible browser";
}
/////////////////////////////////////////////////////////
function removeHandler(object,event,handler){
if (typeof object.removeEventListener != 'undefined')
object.removeEventListener(event, handler, false);
else if (typeof object.detachEvent != 'undefined')
object.detachEvent('on' + event, handler);
else
throw "Incompatible browser";
}
/////////////////////////////////////////////////////////
function search(searchString){
if(searchString.length >= 2 && getCookie('searchString') != searchString){
setTimeout(function(){
setCookie('searchValue',searchString);
ajax({
url:'/include/classes/search.html?search=' + searchString,
func:function(resp){
var searchResults = gid('searchResults'),
i = 0,
resp = eval("(" + resp + ")").results,
cookieSearchTime = getCookie('searchTime'),
nowTime = nowDate().time,
text = '';
if(typeof(resp) != 'undefined'){
if(!cookieSearchTime || cookieSearchTime <= nowTime){
setCookie('searchTime',nowTime);
searchResults.innerHTML = '';
gid('pageContent').style.display = 'none';
searchResults.style.display = 'block';
for(i; i < resp.id.length; i++){
text = resp.text[i].replace(/(.*?)<\/style>/gi, '');
text = text.replace(/(.*?)<\/script>/gi, '');
text = text.replace(/\^(.*?)\[\]/g, '');
text = text.replace(/<.*?>/g, '…');
text = text.replace(/\.\.\.{2,}/g, '…');
text = text.substr(0,150);
text = text.replace(/(.+)\b.+$/g, '$1'); //обрезка по словам
text = text.replace(/(\.\.\.(\ \;|\s)?){2,}/g, '…');
text = text.replace(/\ (\;)?\b/g, '');
text = text.replace(/<|>/g, '');
if(text.length <= 150 && text.substr(text.length-3) != '…'){
text += '…'
}
searchResults.innerHTML += ' \
' + resp.full_title[i] + '
\
\
' + text + ' \
\
'
}
}
} else {
gid('pageContent').style.display = 'none';
searchResults.style.display = 'block';
searchResults.innerHTML = 'Результатов нет'
}
}
})
},500)
}
}
/////////////////////////////////////////////////////////
function setCookie(name, value, expires, path, domain, secure) {
// name - имя cookie
// value - значение cookie
// [expires] - дата окончания действия cookie (по умолчанию - до конца сессии)
// [path] - путь, для которого cookie действительно (по умолчанию - документ, в котором значение было установлено)
// [domain] - домен, для которого cookie действительно (по умолчанию - домен, в котором значение было установлено)
// [secure] - логическое значение, показывающее требуется ли защищенная передача значения cookie
var caution
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie
else
if (confirm("Cookie превышает 4KB и будет вырезан !"))
document.cookie = curCookie
}
/////////////////////////////////////////////////////////
function getCookie(name) {
var source = document.cookie
var prefix = name + "="
var cookieStartIndex = source.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = source.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = source.length
return unescape(source.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
/////////////////////////////////////////////////////////
function fixPNG(element,margin){
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if ((version >= 5.5) && (version < 8) && (document.body.filters)){
if(element.tagName=='IMG'){
element.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ element.src +"',sizingMethod=scale)"
element.src = "/include/images/null.gif"
element.style.width = element.width+"px"
element.style.height = element.height+"px"
} else {
var backimg = element.style.backgroundImage
var regexp = /url\((.+)\)/
var url = backimg.match(regexp)
element.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ url[1] +"',sizingMethod=scale)"
element.style.backgroundImage = ''
}
if(margin){ element.style.marginTop = "3px" }
}
}
/////////////////////////////////////////////////////////
function absPos(obj) {
var x = y = 0;
while(obj) {
x += obj.offsetLeft;
y += obj.offsetTop;
obj = obj.offsetParent;
}
return {x:x, y:y};
}