function openmap(bigmap_id)
{
var d=document.getElementById(bigmap_id);
d.style.position='absolute';
d.style.marginLeft='290'+'px';
d.style.display=='block' ? d.style.display='none' : d.style.display='block';
}




function change_foto_bg (obj, bg_img)
{
var src='url(/images/continent_id' + bg_img + '.gif)';
obj.style.backgroundImage=src;
obj.childNodes[2].getAttribute('name')=='country' ? obj.childNodes[2].style.color="#ffffff" : obj.childNodes[1].style.color="#ffffff";
}

function change_foto_bg2 (obj)
{
obj.style.backgroundImage='url(/images/foto_bg.gif)';
obj.childNodes[2].getAttribute('name')=='country' ? obj.childNodes[2].style.color="#514949" : obj.childNodes[1].style.color="#514949";
}

var current_block_id='start_block'

function change_bigfoto(img)
{
block_id='block_' + img.id;
// Выключаем текущий блок
document.getElementById(current_block_id).style.display="none";
// Включаем выбранный блок
document.getElementById(block_id).style.display="block";
// Присваиваем значение текущего блока
current_block_id=block_id;
}


function leftpreviews(obj, tabIndex)
{
width=tabIndex*140; // Ширина картинок
posLeft=document.getElementById('previews').style.posLeft;
posRight=posLeft+width;
if (posRight > 560)
	{
	posLeft=posLeft-571;
	document.getElementById('previews').style.left=posLeft;
	}
}

function rightpreviews(obj, tabIndex)
{
width=tabIndex*140; // Ширина картинок
posLeft=document.getElementById('previews').style.posLeft;
posRight=posLeft+width;
if (posLeft < 0)
	{
	posLeft=posLeft+571;
	document.getElementById('previews').style.left=posLeft;
	}
}

function previews_hover(img, color)
{
color=='red' ? img.src="images/arr-red-lt.jpg" : img.src="images/arr-grey-lt.gif";
}

function previews_hover2(img, color)
{
color=='red' ? img.src="images/arr-red-rt.jpg" : img.src="images/arr-grey-rt.gif";
}





function bigimage(right_block_id, big_image_src)
{
img='<p><img src="' + big_image_src + '" alt=""/></p>'
document.getElementById(right_block_id).innerHTML=img
}



function opensubmenu(submenuN)
{
var d=document.getElementById(submenuN);
d.style.display=='block' ? d.style.display='none' : d.style.display='block'
}

function closesubmenu(submenuN) {setTimeout ("closesubmenu_time300('"+submenuN+"')", 300)}
function closesubmenu_time300(submenuN) {
var d=document.getElementById(submenuN);
d.style.display=='block' ? d.style.display='none' : d.style.display='none'
}





// Открытие и закрытие изображений для блока с 12 превьюшками

function openclose_bigimage(src_bigimg)
{
var img='<img src="' + src_bigimg + '" alt=""/>'
document.getElementById('bigimage').innerHTML=img
}

function close_big_image(bigimage)
{
bigimage.innerHTML='';
}

function item_open(imgid)
{
var img=document.getElementById(imgid);
var short_id='short_'+imgid
var s=document.getElementById(short_id);
s.style.display=="block" ?  s.style.display="none" : s.style.display="block";
s.style.display=="block" ?  img.src="/images/open.gif" : img.src="/images/close.gif";
var more_id='more_'+imgid
var m=document.getElementById(more_id);
s.style.display=="block" ?  m.style.display="none" : m.style.display="block";
}

var open_img;

function country_open(div)
{
var country_list=document.getElementById("country_list_wpap");
country_list.style.overflow=="visible" ?  country_list.style.overflow="hidden" : country_list.style.overflow="visible";
if(country_list.style.overflow=="visible") {open_img=div.style.backgroundImage};
country_list.style.overflow=="visible" ?  div.style.backgroundImage="url('/images/close.gif')" : div.style.backgroundImage=open_img;
country_list.style.overflow=="visible" ?  country_list.style.height="auto" : country_list.style.height="353px";
}

var country_bg_img

function country_onmouseover(country, color)
{
country.style.backgroundColor=color;
var src='url(images/continent_' + country.id + '.gif)';
document.getElementById('cont_'+country.id).style.backgroundImage=src;
document.getElementById('cont_'+country.id).style.backgroundRepeat='no-repeat';

country_bg_img=country.style.backgroundImage;
}

function country_onmouseout(country, color)
{
country.style.backgroundColor=color;
document.getElementById('cont_'+country.id).style.backgroundImage=country_bg_img;
}

/*   Ховер на стрелку у статьи  */
function arrow_onmouseover(arrow)
{
country.style.background="#d7d7d4";
src='url(/images/continent_' + country.id + '.gif)';
document.getElementById('cont_'+country.id).style.backgroundImage=src;
}

function arrow_onmouseout(arrow)
{
country.style.backgroundColor="#f8f8f6";
document.getElementById('cont_'+country.id).style.backgroundImage="url('/images/continent.gif')";
}


/* *********************** */

function formSubmit(formName) {
	document.forms[formName].submit();
}

function addFavorite(name) {
	window.external.addFavorite(document.getElementsByTagName("base")[0].href , name);
}

function imgView(href,w,h)
{
   	var maxwidth = screen.width;
	var maxheight = screen.height;
	var top = Math.max(Math.floor((screen.height - h) / 2), 10);
	var left = Math.max(Math.floor((screen.width - w) / 2), 10);
	var param = 'toolbar=0,top=' + top + ',left=' + left + ',Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0, Resizable=0';
	if (w <= maxwidth && h <= maxheight) param += ',scrollbars=0';
	else { param += ',scrollbars=1'; w += 20; h += 20; }
	if(w > maxwidth) w = maxwidth; else w += 17;
	param  = param + ',width=' + w;
	if(h > maxheight) h = maxheight; else h += 40;
	param = param + ',height=' + h;

	imgWin = window.open('', '_blank', param);
	imgWin.opener = window;
	imgWin.resizeTo(w,h);
    imgWin.document.open("text/html");
    imgWin.document.writeln("<html>");
    imgWin.document.writeln("<head><title> </title></head>");
    imgWin.document.writeln("<body leftMargin='0' topMargin='0'>");
    imgWin.document.writeln('<img src='+document.getElementsByTagName("base")[0].href + href+
    	' onclick="parent.close()" style=cursor:hand;>');
    imgWin.document.writeln("<br>");
    imgWin.document.write("</body></html>");
	imgWin.focus();
}

function order(href)
{
   	var maxwidth = screen.width;
	var maxheight = screen.height;
	var top = Math.max(Math.floor(screen.height / 2 - 75), 10);
	var left = Math.max(Math.floor(screen.width / 2 - 150), 10);
	var param = 'toolbar=0,top=' + top + ',left=' + left + ',Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0, Resizable=0,scrollbars=0, width=300, height=150';	
	imgWin = window.open(document.getElementsByTagName("base")[0].href + href, '_blank', param);	 
	imgWin.focus();
}

function openBasket() {
	if (self.opener && !self.opener.closed) {
		self.opener.location.href = "/shop/basket/";
		self.opener.focus();
		self.close();
	}
}

/*
if (self.opener && !self.opener.closed) {
			self.opener.location.href = '/usr/area/area.asp?id=' + intAreaID + '&' + 'filter_company=' + intCustomerID;
			self.opener.focus();
		}
*/


function search_form(form) {
	if(form.search.value == '') {
		alert('Введите критерий для поиска');
		return false;
	}
	else{return true;}
}

function subscribe(form) {
	var errStr='Укажите e-mail';
	var errEmail='Некорректный e-mail';
	if(form.email.value == '') {
		alert(errStr);
		return false;
	} else if (isEmailValid(form.email.value) == false) {
		alert(errEmail);
		return false;
	} else {
		return true;
	}
}

function checkContact() {
	f = document.contact;
	if (f.fio.value == "") {
		alert("Представьтесь, пожалуйста.");
		f.fio.focus();
		event.returnValue = false;
		return false;
/*	} else if (f.firm.value == "") {
		alert("Пожалуйста, укажите название Вашей организации.");
		f.firm.focus();
		event.returnValue = false;
		return false; */
	} else if (f.email.value == "") {
		alert("Пожалуйста, укажите адрес электронной почты.");
		f.email.focus();
		event.returnValue = false;
		return false;
	} else if (f.phone.value == "") {
		alert("Пожалуйста, укажите контактный телефон.");
		f.phone.focus();
		event.returnValue = false;
		return false;
	} else if (!(isEmailValid(f.email.value) || (f.email.value == ""))) {
		  alert("Указан неверный адрес электронной почты.");
		  f.email.focus();
		  event.returnValue = false;
		  return false;
	} else if (f.comments.value == "") {
		alert("Пожалуйста, укажите Ваш вопрос.");
		f.comments.focus();
		event.returnValue = false;
		return false;
	}
	return true;
}


function checkBasket() {
	f = document.basket_send;
	if (f.person2.value == "") {
		alert("Пожалуйста, укажите имя.");
		f.person2.focus();	
		event.returnValue = false;
		return false;
	}
	else if (f.phone.value == '') {
		alert("Пожалуйста, укажите телефон.");
		f.phone.focus(); 
		event.returnValue = false;
		return false;			
	}
	else if (f.to.value == "") {
		alert("Пожалуйста, укажите адрес электронной почты.");
		f.to.focus();
		event.returnValue = false;
		return false;
	}
	else if (!(isEmailValid(f.to.value) || (f.to.value == ""))) {
		  alert("Указан неверный адрес электронной почты.");
		  f.to.focus();
		  event.returnValue = false;
		  return false;
	}
	else if (f.order_addy.value == '') {
		alert("Пожалуйста, укажите адрес доставки.");
		f.order_addy.focus(); 
		event.returnValue = false;
		return false;			
	}	
	return true;
}

function checkReg() {
	f = document.regform;
	if (f.login.value == "") {
		alert("Пожалуйста, укажите логин.");
		f.login.focus();
		event.returnValue = false;
		return false;
/*	} else if (f.fname.value == "") {
		alert("Пожалуйста, укажите Ваше имя.");
		f.fname.focus();
		event.returnValue = false;
		return false; */
	} else if (f.email.value == "") {
		alert("Пожалуйста, укажите адрес электронной почты.");
		f.email.focus();
		event.returnValue = false;
		return false;
	} else if (!(isEmailValid(f.email.value) || (f.email.value == ""))) {
		  alert("Указан неверный адрес электронной почты.");
		  f.email.focus();
		  event.returnValue = false;
		  return false;
	}
	return true;
}

function isEmailValid(email) {
     var s = "[\\w\\-]+(\\.[\\w\\-]+)*@((([a-zA-Z0-9]+)|([a-zA-Z0-9]+[\\w\\-]*))(\\.([\\w^_]+\\.\\2))?\\.)?[\\w\\-]{2,}\\.[a-zA-Z]{2,}";
     var re = new RegExp(s);
     return re.test(email);
}

/* -- for calendar -- */

function Ddate() {
	var f = document.senddate;
	var m = parseInt(f.month.value);
	var y = parseInt(f.year.value);
	if(m < 10) {
		m = '0' + m;
	}
	f['fdate'].value = "01" + "." + m + "." + y;
	if(parseInt(m) < 10) {
		m = parseInt(m,10) + 1;
		if(parseInt(m) < 10) {
			m = '0' + m;
		}
	}
	else {
		if(parseInt(m) < 12) {
			m = parseInt(m) + 1;
		}
		else {
			m = '01';
			y = y + 1;
		}
	}
	f['ldate'].value = "01" + "." + m + "." + y;
	f.submit();
}

/* -- / for calendar -- */


function Subscribe(obj) {
if(obj.checked){
	document.getElementById('subcmd').value='subscribe';
}
	return true;
}

function ImagesView(href)
{
   	var maxwidth = screen.width;
	var maxheight = screen.height;
	var top = Math.max(Math.floor(screen.height / 2 - 475), 10);
	var left = Math.max(Math.floor(screen.width / 2 - 450), 10);
	var param = 'toolbar=0,top=' + top + ',left=' + left + ',Toolbar=0,Location=0,Directories=0,Status=yes,Menubar=0, Resizable=0,scrollbars=yes, width=800, height=600';	
	imgWin = window.open(document.getElementsByTagName("base")[0].href + href, '_blank', param);	 
	imgWin.focus();
}


function faq() {
	f = document.faqform;
	if (f.Description.value == "") {
		alert("Пожалуйста, укажите Ваш вопрос.");
		f.Description.focus();
		event.returnValue = false;
		return false;
/*	} else if (f.fname.value == "") {
		alert("Пожалуйста, укажите Ваше имя.");
		f.fname.focus();
		event.returnValue = false;
		return false; */
	}
	return true;
}