function ShowPhoto(url, width, height) {
	var scroll = (screen.width < 1000) ? "yes" : "no";

	var left = (self.screen.width >> 1) - (width >> 1);
	var top = (self.screen.height >> 1) - (height >> 1);
	var param = 'left='+left+',top='+top+',width='+width+',height='+height+',';

	window.open(url, '_blank', param+'menubar=no, scrollbars=' + scroll + ', status=no');
}


function ShowDesc(url) {
	width = 400;
	height = 500;

	var left = (self.screen.width >> 1) - (width >> 1);
	var top = (self.screen.height >> 1) - (height >> 1);
	var param = 'left='+left+',top='+top+',width='+width+',height='+height+',';

	window.open(url, '_blank', param+'menubar=no, scrollbars=1, status=no');
}


function GetObj(objId) {
	if (navigator.appName.substring(0,2) !="Mi")
		return document.getElementById(objId);
	else
		return document.all[objId];
}

function GetAbsoluteTop(obj_id) {
   var obj;
   var result = 0;
   obj = GetObj(obj_id);
   while( obj.tagName != 'BODY' ) {
     result += obj.offsetTop;
     obj = obj.offsetParent;
   }
   return result;
}

function GetAbsoluteLeft(obj_id) {
   var obj;
   var result = 0;
   obj = GetObj(obj_id);
   while( obj.tagName != 'BODY' ) {
     result += obj.offsetLeft;
     obj = obj.offsetParent;
   }
   return result;
}

function SetFavorites() {
	window.external.AddFavorite('http://www.climatpiter.com', '"КЛИМАТ-ПИТЕР"')
}

function hide_menu(id) {
	document.getElementById("img"+id).src = eval("menu"+id+"_off.src");
	if(id_menu!='' ) {
		timer=window.setTimeout("document.getElementById('div"+id+"').style.visibility='hidden';id_menu='';",1000);
	}
}

function menu_select(td) {
//	td.className = 'selected';
}

function menu_unselect(td) {
//	td.className = 'unselected';
}


var id_menu = 0;
var id_div = 0;
var id_submenu = 0;
var timer = '';

function menu_on (id,is_parent, param) {
	 var div;

	if(id_menu!=0){
		document.getElementById("menu"+id_menu).className = 'menu_unselected';
		id_menu = 0;
	}
	if(id_div!=0){
		document.getElementById("div"+id_div).style.display="none";
		id_div = 0;
	}
	if(id_submenu!=0){
		document.getElementById("submenu"+id_submenu).className = 'submenu_unselected';
		id_submenu = 0;
	}

	document.getElementById("menu"+id).className = 'menu_selected';
	if (param == 0) {
		document.getElementById("menu"+id).style.zIndex = 10000;
	} else {
		document.getElementById("menu"+id).style.zIndex = 9000;
	}
	id_menu = id;
	if(is_parent == 1){
		div = document.getElementById("div"+id);
		//div.style.left = GetAbsoluteLeft("menu"+id);
		//div.style.top = GetAbsoluteTop("menu"+id) + 18;
		div.style.display="Block";
		id_div=id;
	}

	clearTimeout(timer);
}

function menu_off(id,is_parent) {
	document.getElementById("menu"+id).className = 'menu_unselected';
	if(is_parent == 1){
		timer = window.setTimeout(" document.getElementById('div"+id+"').style.display='none'; id_div = 0; id_menu = 0",0);
	}

}

function submenu_off (id,id_parent) {
	document.getElementById("submenu"+id).className = "submenu_unselected";
	//GetObj("href"+id).className = "submenu";
	timer = window.setTimeout(" document.getElementById('div"+id_div+"').style.display='none'; id_div=0; document.getElementById('menu"+id_menu+"').className = 'menu_unselected';  id_menu = 0;",1000);
}

function submenu_on (id,id_parent) {
	if(id_menu!=0){
		document.getElementById("menu"+id_menu).className = 'menu_selected';
	}
	if(id_div!=0){
		document.getElementById("div"+id_div).style.display = 'Block';
	}
	if(id_submenu!=0){
		document.getElementById("submenu"+id_submenu).className = 'submenu_unselected';
		//document.getElementById("href"+id).className = "submenu";
		id_submenu = 0;
	}

	document.getElementById("submenu"+id).className = "submenu_selected";
	//document.getElementById("href"+id).className = "submenu_sel";
	id_submenu = id;

	clearTimeout(timer);
}


function CheckMail(form){
	return (CheckField(form, "email", "Вы не ввели 'e-mail'", 3, 3, 200));
}




function ChangeProducerVent(form){
	var href;
    var obj;
    obj = GetObj("producer");
    href = obj.options[obj.selectedIndex].value;
    form.action = href;
}

function ChangeProducer(form){
    var href;
    var from, to, currency;
    ChangeProducerVent(form);

    href = '';
    from = parseFloat(GetObj("from").value);
    if(from || from == 0){
        href += 'from/' + from + '/';
    } else {
        alert('Параметры мощности должны быть числовыми. Цифры после запятой отделяются точкой.');
        return false;
    }
    to = parseFloat(GetObj("to").value)
    if(to || to == 0){
        href += 'to/' + to + '/';
    } else {
        alert('Параметры мощности должны быть числовыми. Цифры после запятой отделяются точкой.');
        return false;
    }

    currency = GetObj("currency");
    if(currency) {
    	href += 'currency/' + currency.options[currency.selectedIndex].value + '/';
    }
    document.location.href = form.action + href;
//    alert(href);
    return false;
//    form.action += href;

    //form.action += 'currency/'+GetObj("currency").value+'/';
    //document.location.href = href;
}


function LightRow(id, color){

    var theRow;
    theRow = GetObj("row_" + id);

    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.background = color;
    }
}

function Go(url){
	document.location.href = url;
}

function GetLink(splited_link,target) {
	newlink = unescape(splited_link).replace(/\|/g,"");
	if(!target || target == 1) {
		newwin = window.open(newlink,"_blank","toolbar=1,scrollbars=1,status=1,location=1,menubar=1,resizable=1,personalbar=1");
		if (newwin) {
			newwin.focus();
		}
	} else {
		window.location = newlink;
	}
}
//--------------------------------// Slide
function Slide(id) {
	if(!(obj = document.getElementById(id)))
		return;

	if(!obj.style.display || obj.style.display == 'none')
		obj.style.display = 'block';
	else
		obj.style.display = 'none';
}