dom = (document.getElementById)?(true):(false);
ie = document.all;
ie4 = ie && !dom;
nn4 = document.layers;

visible = (nn4)?('show'):('visible');
hidden = (nn4)?('hide'):('hidden');

var elem = 0, timer = 0;


function mouseOver(id,a) {
	var open;
	if(!id) return;
	if(dom) open = document.getElementById(id); else return;

	if(!open)return;
	open = open.style;

	if(timer){
		clearTimeout(timer);
		timer=0;
	}

	if(elem && open!=elem) hideNow();
	if(a) {
//		open.left = menuLeft(id,a.offsetParent); 
//		open.top = menuTop(id,a) + 5;
	}

	open.visibility = visible;
	elem = open;
}

function mouseOut() {
	timer = setTimeout('hideNow()',200);
}

function hideNow() {
	if(elem) elem.visibility = hidden;
	elem = 0;
}

function menuLeft(id,a) 
{
	if(nn4) return 0; // document.layers['x'+id].pageX;
	else {
		var pos = a.offsetLeft;
		while (a.offsetParent != null) {
			a = a.offsetParent;
			pos += a.offsetLeft;
			if (a.tagName == 'BODY') break;
		} return pos;
	}
}
/*
function menuTop(id,a) 
{
	if(nn4) return document.layers['x'+id].pageY+25;
	else {
		var pos = a.offsetTop;
		while (a.offsetParent != null) {
			a = a.offsetParent;
			pos += a.offsetTop;
			if (a.tagName == 'BODY') break;
		} return pos+18;
	}
}
*/

function popunder(url, w, h)
{
	pu = window.open(url, "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, width=" + w + ", height=" + h);
	pu.blur();
	window.focus();
}





Pic1 = new Image(); Pic1.src = '/images/pic01.jpg';
Pic2 = new Image(); Pic2.src = '/images/pic02.jpg';
Pic3 = new Image(); Pic3.src = '/images/pic03.jpg';
Pic4 = new Image(); Pic4.src = '/images/pic04.jpg';
			

var Num=0, Page, Picture;

function ShowPic(numb){
	var i, Page, Picture;
	if((!dom)&&(!ie4))return;
	if(ie4){
		Picture=document.all('Pic');
	} else{
		Picture=document.getElementById('Pic');
	}
	Picture.src = eval('Pic'+numb).src;
}

function HidePic(numb){
	var i, Page, Pic;
	if((!dom)&&(!ie4))return;
	if(ie4){
		Picture=document.all('Pic');
	}else{
		Picture=document.getElementById('Pic');
	}
	Picture.src = eval('Pic1').src;
}



function isEmail(email) {
// ******************************************************************
// This function accepts a string variable and verifies if it is in
// the proper format for an e-mail address or not.

// The function returns true if the format is valid, false if not.
// ******************************************************************

    invalidChars = " ~\'^\`\"*+=\\|][(){}$&!#%/:,;";

    // Check for null
    if (email == "") {
        return false;
    }

    // Check for invalid characters as defined above
    for (i=0; i<invalidChars.length; i++) {
        badChar = invalidChars.charAt(i);
        if (email.indexOf(badChar,0) > -1) {
            return false;
        }
    }
    lengthOfEmail = email.length;
    if ((email.charAt(lengthOfEmail - 1) == ".") || (email.charAt(lengthOfEmail - 2) == ".")) {
        return false;
    }
    Pos = email.indexOf("@",1);
    if (email.charAt(Pos + 1) == ".") {
        return false;
    }
    while ((Pos < lengthOfEmail) && ( Pos != -1)) {
        Pos = email.indexOf(".",Pos);
        if (email.charAt(Pos + 1) == ".") {
            return false;
        }
        if (Pos != -1) {
            Pos++;
        }
    }

    // There must be at least one @ symbol
    atPos = email.indexOf("@",1);
    if (atPos == -1) {
        return false;
    }

    // But only ONE @ symbol
    if (email.indexOf("@",atPos+1) != -1) {
        return false;
    }

    // Also check for at least one period after the @ symbol
    periodPos = email.indexOf(".",atPos);
    if (periodPos == -1) {
        return false;
    }
    if (periodPos+3 > email.length) {
        return false;
    }
    return true;
}

function IsNumber(data){
 var NumStr="0123456789,.";
 var ch;
 var count=0;
 for(var i=0;i<data.length;i++){
   ch=data.substring(i,i+1);
   if(NumStr.indexOf(ch)!=-1)count++;
   }
 if(count==data.length)return true;
 else return false;
 }
 
function IsEmpty(data){
 if(data.length==0)return true;
 else return false;
 }


function CheckForm(){
//	return true;
var f = document.forms['global'];



 if(IsEmpty(f.elements['feedback_FIO'].value)){
        alert('Для отправки формы необходимо заполнить поле "Ваше ФИО"');
        f.elements['feedback_FIO'].focus();
        return false;
  }

 if(IsEmpty(f.elements['feedback_email'].value)){
        alert('Для отправки формы необходимо заполнить поле "Ваше e-mail"');
        f.elements['feedback_email'].focus();
        return false;
  }else {
	 if(!isEmail(f.elements['feedback_email'].value)){
	        alert('Неверный формат адреса электронной почты');
   	     f.elements['feedback_email'].focus();
   	     return false;
  	}
  }


 if(IsEmpty(f.elements['feedback_question'].value)){
        alert('Для отправки формы необходимо заполнить поле "Вопрос, который Вас интересует"');
        f.elements['feedback_question'].focus();
        return false;
  }

 return true;
 }



//*********************************************
//*           стандартные функции             *
//*********************************************

function checkmail(email)
{if (email == "") return(false);
 if (email.indexOf(".") == -1) return(false);
 dog = email.indexOf("@");
 if (dog == -1) return(false);
 if ( (dog < 1) || (dog > email.length - 5))return(false);
 if ((email.charAt(dog - 1) == '.') || (email.charAt(dog + 1) == '.')) return(false);
 if (email.charAt(email.length - 1) == '.') return(false);
 return true;
}


function startHint(nameid)
{
	if(stdHint)hideElem(stdHint);
	stdHint=nameid;
	moveElem(stdHint, stdMouseX+10, stdMouseY+10);
	showElem(stdHint);
}

function stopHint()
{
	hideElem(stdHint);
	stdHint="";
}

function openClose(elemId)
{
	var elem, img;
	if (dom || ie4) {
	    elem = (dom)?(document.getElementById(elemId)):(document.all[elemId]);
	}

	if (elem) {

		if (elem.style.display == 'none') { 
			elem.style.display='block'; 
		} else { 
			elem.style.display = 'none'; 
		}
	}
}

