/* ### !Default.js */
<!--
navgtr = 0;
function popup(theURL,winName,features) { //v3.0
navgtr = window.open(theURL,winName,features);
navgtr.focus();
}
//-->

function CheckForm()
{
    if(document.forms[0].email.value==''&&document.forms[0].tel.value=='') {
        alert('Пожалуйста заполните одно из полей `Телефон` или `E-mail`!');
        document.forms[0].email.focus();
        return false;
    }
}

function ShowImage (o,w,h)
{
	var href = String ( o.href );

	//if ( href.indexOf(url) != -1 ) { return true; }
	if ( !href || href=='undefined' ) { return true; }

	if(w=='') {w = 325;}
	if(h=='') {h = 485;}

	var pars = "dependent=yes,location=no";
	pars += ",width="+w+",height="+h;
	//pars += ",outerWidth="+w+",outerHeight="+h;
	pars += ",statusbar=no,menubar=no";
	pars += ",resizable=no";
	pars += ",scrollbars=no";
	//props += ",left=0,top=0";
	window.open(href, 'ShowImage', pars);

	return false;
}


/* ### CheckForm.js */
/*
* ============================================================================
* nnjsValidateForm.js - Universal HTML Form Validator JScript
*
* Copyright (C) 2002 by N-Networks. All Rights Reserved.
* http://www.dpsp-yes.com
*
* Modification history:
*
* Feb 21, 2002  v1.0.0   V.Bulatov     - initially created
* Mar 05, 2002  v1.0.1   V.Zakharychev - cleaned up some names and texts
* Aug 26, 2002  v1.1.0   V.Bulatov     - IsDate attribute added
*
*
* Sample usage: 
* <form .... OnSubmit="return nnjsValidateForm( this );">
*   or 
* <form .... OnSubmit="return nnjsValidateForm( this ) && SomeUsersFunction(....);">
* ....
* <input type=text IsRegex="^[abc]$"  .... IsRegexTxt="bla bla" >
* <input type=text IsNotEmpty IsDigit .... IsNotEmptyTxt="bla1" IsDigitTxt="bla2">
* <input type=text IsNotEmpty IsEmail .... CommonTxt="bla bla">
* ....
* </form>
*
* See nnjsValidateForm.html for more details
* ============================================================================
*
* *** IMPORTANT! THIS SCRIPT IS SHAREWARE ***
* If you find this script useful, please register at http://www.dpsp-yes.com
* to use it legally. This script can not be used for any purpose except
* evaluation without registration. Registered users are entitled to free email
* support and updates. They will also benefit from clean conscience and good
* karma.
*
* Any modifications to the script are expressly prohibited. Please do not
* change or remove any copyright notices and other text and/or functionality.
* If you miss some functionality, please email us and we will gladly implement
* it in the script (provided that you are registered user, that is).
* ============================================================================
*/

// you are free to change the values below to fit your style

var nnjsCommonTxt     = "Введено не верное значение";   // Generic error message
var nnjsIsNotEmptyTxt = "Поле не может быть пустым";    // Field is empty
var nnjsIsDigitTxt    = "Допускается числовое значение";       // Field is not numeric
var nnjsIsDateTxt     = "Не верный формат даты";    // Field is not a valid date
var nnjsIsEmailTxt    = "Адрес электронной почты указан неверно"; // Field is not a valid email address
var nnjsIsRegexTxt    = "Введенное значение не соотвествует требованиям"; // Field didn't match regexp

var nnjsIsDateFmt     = "MM/DD/YYYY"; // Default format for date value

// DO NOT CHANGE ANYTHING PAST THIS LINE!

function nnjsValidateFocus( item ){
// bring focus to the form item if it can have focus
  if( item.type == "text" ||
      item.type == "password" || 
      item.type == "checkbox" || 
      item.type == "select-one" ||
      item.type == "select-multiple" ||
      item.type == "button" ||
      item.type == "textarea"
    ){
    item.focus();
    return true;
    }
  else{
    return false;
    }
  }

function nnjsValidateAlert( msg1, msg2, msg3, msg4 ){
// alert user using appropriate message
  if( msg1 ){ alert( msg1 ); }
  else{
    if( msg2 ){ alert( msg2 ); }
    else{
      if( msg3 ){ alert( msg3 ); }
      else{
        if( msg4 ){ alert( msg4 ); }
        }
      }
    }
  return true;
  }

function nnjsValidateDate( year, month, day ){
// validate date
// the full year, for example, 1976 (and not 76 for 1976)
// the month as an integer between 0 and 11 (January to December)
// the date as an integer between 1 and 31

  if( day < 1 || day > 31 || month < 0 || month > 11 || year < 0 )
    return false;
  if( day == 31 && ( month == 3 || month == 5 || month == 8 || month == 10 ))
    return false;
  if( day > 29 && month == 1 )
    return false;
  if( day == 29 && month == 1 && (( year % 4 != 0 ) || ( year % 100 == 0 && year % 400 != 0 )))
    return false;

  return true;
  }

function nnjsValidateForm( fm ){
// main validation routine
  for( i = 0; i < fm.elements.length; i++ ){
    var item = fm.elements.item(i);
    if( item && !item.disabled ){

      // check for NotEmpty
      if( item.getAttribute('IsNotEmpty') != null ){
        // check if item is filled/selected
        if(( item.value == "" ) ||
           ( item.type == "checkbox" && !item.checked )
          ){
          nnjsValidateFocus( item );
          nnjsValidateAlert(
            item.IsNotEmptyTxt,
            item.CommonTxt,
            nnjsIsNotEmptyTxt,
            nnjsCommonTxt
            );
          return false;
          }
        }

      // check if item is numeric
      if( item.getAttribute('IsDigit') != null ){
        var rex = /^-?\d+(\.\d+)?$/;
        if( item.IsDigit != "" ){
          if( item.IsDigit.search( /^-?([=z]?\d)|(z?\*)(\.([=z]?\d)|(z?\*))$/ ) == 0 ){
            //replacing rex with appropriate regexp
            }
          }
        if( item.value != "" && item.value.search( rex ) == -1 ){
          nnjsValidateFocus( item );
          nnjsValidateAlert(
            item.IsDigitTxt,
            item.CommonTxt,
            nnjsIsDigitTxt,
            nnjsCommonTxt
            );
          return false;
          }
        }

      // check if item is date
      if( item.getAttribute('IsDate') != null ){
        var fmt = item.getAttribute('IsDate');
        if( fmt == "" ) fmt = nnjsIsDateFmt;

        // determine order of date fields
        var mpos = fmt.search( /MM/ );
        var dpos = fmt.search( /DD/ );
        var ypos = fmt.search( /YYYY/ );
        var midx = 1, didx = 1, yidx = 1;
        if( mpos > dpos ) midx++;
        if( mpos > ypos ) midx++;
        if( dpos > mpos ) didx++;
        if( dpos > ypos ) didx++;
        if( ypos > mpos ) yidx++;
        if( ypos > dpos ) yidx++;

        // build regular expression according to date format
        fmt = fmt.replace( /\\/g, "\\\\" );
        fmt = fmt.replace( /MM/g, "(\\d{1,2})" );
        fmt = fmt.replace( /DD/g, "(\\d{1,2})" );
        fmt = fmt.replace( /YYYY/g, "(\\d{4})" );
        var rex = new RegExp( '^' + fmt + '$' );
        var sep = item.value.match( rex );

        if( item.value != "" &&
          ( sep == null || !nnjsValidateDate( sep[yidx], sep[midx]-1, sep[didx] ))){
          nnjsValidateFocus( item );
          nnjsValidateAlert(
            item.IsDateTxt,
            item.CommonTxt,
            nnjsIsDateTxt,
            nnjsCommonTxt
            );
          return false;
          }
        }

      // check if item is valid email address
      if( item.getAttribute('IsEmail') != null ){
        if( item.value != "" && item.value.search( /^[\w\.-_]+@[\w-_]+\.[\w\.-_]+$/ ) == -1 ){
          nnjsValidateFocus( item );
          nnjsValidateAlert(
            item.IsEmailTxt,
            item.CommonTxt,
            nnjsIsEmailTxt,
            nnjsCommonTxt
            );
          return false;
          }
        }

      // check if item matches the regular expression
      if( item.getAttribute('IsRegex') != null ){
        var rex = new RegExp( item.IsRegex );
        if( item.value != "" && item.value.search( rex ) == -1 ){
          nnjsValidateFocus( item );
          nnjsValidateAlert(
            item.IsRegexTxt,
            item.CommonTxt,
            nnjsIsRegexTxt,
            nnjsCommonTxt
            );
          return false;
          }
        }

      } // if
    } // for

  // all checks passed - form data is ok.
  return true;
  } // nnjsValidateForm

/* ### Content_ShotsBlock.js */

var ShotWidth = 300;
var ShotHeight = 450;

function ShowShot (o,w,h)
{
	if ( !Number(w) ) { w = ShotWidth; }
	if ( !Number(h) ) { h = ShotHeight; }
	w += 20;
	h += 30;
	return ShowImage(o,w,h);
}
/* ### MenuBar.js */

var _XBug = '';
function _View (s)
{
	var win = window.open('_View.htm','_View');
	win.document.forms.View.Text.value = s;
}

function showXBug ()
{
	_View(_XBug);
}

if ( document.layers ) { document.all = document.layers; }

function getObjectPos (layer)
{
	var a = new Array ();
	a[0] = a[1] = 0;
	if ( String(layer.x) == 'undefined' ) {
		var p = layer;
		while ( p ) {
			a[0] += p.offsetLeft;
			a[1] += p.offsetTop;
			p = p.offsetParent;
		}
	} else {
		a[0] = layer.x;
		a[1] = layer.y;
	}
	return a;
}

function moveObject (layer, x, y)
{
	if ( layer.moveTo ) {
		layer.moveTo(x,y);
	}
	else if ( String(layer.style.left) != 'undefined' ) {
		layer.style.left = x;
		layer.style.top  = y;
	}
}

function getObject (objId)
{
	var obj = 0;
	if ( document.getElementById ) {
		obj = document.getElementById(objId);
	}
	else {
		obj = document.all[objId];
	}
	return obj;
}

function showObject (obj) { if ( obj && obj.style ) { obj.style.display = 'block'; } }
function hideObject (obj) { if ( obj && obj.style ) { obj.style.display = 'none'; } }

var CurrSubMenuId = '';
var ClosingSubMenu = '';
//var goToCloseSubMenuFlag = 0;
//var waitForCloseSubMenu = 0;
var SubMenuStatus = new Array ();

function getSubMenuId (o)
{
	var name = String ( o.id );
	var id = name.substring(name.indexOf('_')+1);
	return id;
}

function posSubMenu (id)
{
	var anchorId = 'MenuAnchor_'+id;
	var subId = 'MenuSub_'+id;

	var anchor = document.images[anchorId];
	var apos = getObjectPos(anchor);
	var x = apos[0];
	var y = apos[1];
	x -= 1;
	y += 14;

	var obj = getObject(subId);
	moveObject(obj,x,y);
}

function lowlightSubMenuItem (id)
{
	var itemId = 'MenuItem_'+id;
	var itemObj = getObject(itemId);
	if ( itemObj && itemObj.className ) { itemObj.className = 'MenuItem'; }
}

function highlightSubMenuItem (id)
{
	var itemId = 'MenuItem_'+id;
	var itemObj = getObject(itemId);
	if ( itemObj && itemObj.className ) { itemObj.className = 'MenuItemSel'; }
}

function displaySubMenu (id)
{
	//_XBug += 'DisplaySubMenu '+id+'\n';
	highlightSubMenuItem(id);
	if ( CurrSubMenuId != '' ) {
		closeSubMenu(CurrSubMenuId);
	}
	CurrSubMenuId = id;
	var subId = 'MenuSub_'+id;
	var subObj = getObject(subId);
	if ( !subObj ) {
		return;
	}
	if ( String(SubMenuStatus[id]) == 'undefined' ) {	
		posSubMenu(id);
		SubMenuStatus[id] = 1;
	}
	showObject(subObj);
}

function closeSubMenu (id)
{
	//_XBug += 'CloseSubMenu '+id+'\n';
	lowlightSubMenuItem(id);
	ClosingSubMenu = '';
	CurrSubMenuId = '';
	var subId = 'MenuSub_'+id;
	var subObj = getObject(subId);
	if ( !subObj ) {
		return;
	}
	hideObject(subObj);
}

function checkClose (id,CloseId)
{
	if ( ClosingSubMenu ) {
		//_XBug += 'CheckClose ('+CloseId+'/'+CloseCount+':'+ClosingSubMenu+','+CurrSubMenuId+' vs '+id+')\n';
		closeSubMenu(ClosingSubMenu);
	}
}

var CloseCount = 0;

function goToCloseSubMenu (id)
{
	//if ( ClosingSubMenu != '' && ClosingSubMenu==CurrSubMenuId ) {
		//closeSubMenu(CurrSubMenuId);
	//}
	CloseCount++;
	//_XBug += 'GoToCloseSubMenu '+id+' ('+CloseCount+')\n';
	ClosingSubMenu = id;
	setTimeout('checkClose("'+id+'",'+CloseCount+')', 750);
}

function MenuItemOver (o)
{
	ClosingSubMenu = '';
	var id = getSubMenuId(o);
	//_XBug += 'MenuItemOver '+id+'\n';
	if ( CurrSubMenuId != id ) { 
		displaySubMenu(id);
	}
}
function MenuItemOut (o)
{
	var id = getSubMenuId(o);
	//_XBug += 'MenuItemOut '+id+'\n';
	if ( CurrSubMenuId == id ) { 
		goToCloseSubMenu(id);
	}
}

function MenuSubOver (o)
{
	var id = getSubMenuId(o);
	//_XBug += 'MenuSubOver '+id+'\n';
	ClosingSubMenu = '';
}

function MenuSubOut (o)
{
	var id = getSubMenuId(o);
	//_XBug += 'MenuSubOut '+id+'\n';
	if ( CurrSubMenuId == id ) { 
		goToCloseSubMenu(id);
	}
}

function MenuSubItemOver (o)
{
	if ( o && o.className ) { o.className = 'MenuItemSel'; }
}

function MenuSubItemOut (o)
{
	if ( o && o.className ) { o.className = 'MenuItem'; }
}

/*
function MenuItemClick (o)
{
	//var oo=o; var ss=''; for ( var kk in oo ) { ss+=kk+' '; } alert(ss);
	//if ( ! o || !o.all || ! o.all[1] || ! o.all[1].tagName || ! o.all[1].href ) { return true; }
	var anchor = 0;
	if ( o.getElementsByTagName ) {
		anchor = o.getElementsByTagName('A')[0];
	}
	else if ( o.all ) {
		for ( var i=0; i<o.all.length; i++ ) {
			var tagName = String ( o.all[i].tagName );
			if ( tagName != 'A' ) { continue; }
			anchor = o.all[i];
			break;
		}
	}
	if ( anchor ) {
		//alert(anchor.href);
		//if ( event && anchor.handleEvent ) {
			alert(anchor);
			anchor.handleEvent();
		//}
		//alert(event);
		//anchor.onClick();
		//var oo=anchor.Methods; var ss=''; for ( var kk in oo ) { ss+=kk+' '; } alert(ss);
	}
	return false;
	if ( tagName != 'A' && tagName != 'a' ) { return true; }
	var href = String ( anchor.href );
	if ( ! href || ! href.length || href == 'undefined' ) { return true; }
	//alert(tagName+': '+href);
	window.location.href = href;
	return false;
}
*/


