
function ClientWidth() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function ClientHeight() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}	

function ScrollLeft() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.scrollLeft:document.body.scrollLeft;
}

function ScrollTop() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.scrollTop:document.body.scrollTop;
}
	
function win_open(group,type) {
	zayavka.style.visibility='visible'; 
	zayavka.style.left=((ClientWidth()-zayavka.clientWidth)/2)+ScrollLeft();
	zayavka.style.top=((ClientHeight()-zayavka.clientWidth+200)/2)+ScrollTop();	
		
	formFastTrans.style.visibility='hidden'; 
	formSendMail.elements.subject.value=type; 
	formSendMail.elements.text.value=group;
}

function melcomPrice(Price, group) {
	if (Price=="")
		document.write('<u style="cursor: pointer;" onClick="win_open(\''+group+'\',\'Узнать цену\')">Узнать цену</u>');
		

}

function openmenu(id) {
	if(document.getElementById('menu'+id).style.display=='none') {
		document.getElementById('menu'+id).style.display='block';
		document.getElementById('pic'+id).src='pic/minus.gif';
	} else {
		document.getElementById('menu'+id).style.display='none'; 
		document.getElementById('pic'+id).src='pic/plus.gif';
	}	
}

function formFastTrans_submit() {
	document.location = formFastTrans.elements.selector.value;
}



function getLeft(Obj) {
	var result = Obj.offsetLeft;
	while (Obj = Obj.offsetParent)
		result += Obj.offsetLeft;
	return result;
}

function getTop(Obj) {
	var result = Obj.offsetTop;
	while (Obj = Obj.offsetParent)
		result += Obj.offsetTop;
	return result;
}

function function_null() {;}

function function_OpenMenu(source, menu, position) {
	if (!position) position = "right";
	menu.style.left = getLeft(source);
	menu.style.top = getTop(source);
	switch (position) {
		case "right": menu.style.left = parseInt(menu.style.left) + source.offsetWidth; break;
		case "bottom": menu.style.top = parseInt(menu.style.top) + source.offsetHeight; break;
	}
	menu.style.visibility = "visible";
}
function function_OpenSubMenu(source, menu, position) {
	if (!position) position = "right";
	menu.style.left = source.offsetLeft;
	menu.style.top = source.offsetTop;
	switch (position) {
		case "right": menu.style.left = parseInt(menu.style.left) + source.offsetWidth; break;
		case "bottom": menu.style.top = parseInt(menu.style.top) + source.offsetHeight; break;
	}
	menu.style.visibility = "visible";
}
function function_CloseMenu(menu) {
	menu.style.visibility = "hidden";
}

OpenMenu = function_OpenMenu;
OpenSubMenu = function_OpenSubMenu;
CloseMenu = function_CloseMenu;

//function OpenMenu() {
//	alert();
//}

function OpenMenuClick(menu) {
	switch (menu.style.display) {
		case "block": menu.style.display = "none"; break;
		case "none": menu.style.display = "block"; break;
	}
}

function getCookie(name) {
    var p = name + "=";
    var si = document.cookie.indexOf(p);
    if (si == -1)
        return null;
    var ei = document.cookie.indexOf(";", si + p.length);
    if (ei == -1)
        ei = document.cookie.length;
    return unescape(document.cookie.substring(si + p.length, ei));
}

function GET(name) {
    var p = name + "=";
    var si = location.search.indexOf(p);
    if (si == -1)
        return null;
    var ei = location.search.indexOf("&", si + p.length);
    if (ei == -1)
        ei = location.search.length;
	var buf = location.search.substring(si + p.length, ei);
	buf = unescape(buf);
	var buf2 = "";
	for (var i=0; i<buf.length; i++) {
		var c = buf.charAt(i);
		if ((c.charCodeAt(0)>="А".charCodeAt(0)-848 && c.charCodeAt(0)<="Я".charCodeAt(0)-848) || (c.charCodeAt(0)>="а".charCodeAt(0)-848 && c.charCodeAt(0)<="я".charCodeAt(0)-848)) c = String.fromCharCode(buf.charCodeAt(i)+848)
		buf2 += c;
	}
    return buf2;
}

function cms_document_hotkeys() {
	if (event.ctrlKey && event.altKey)
		switch (String.fromCharCode(event.keyCode)) {
			case 'S':
				var url = document.URL.search(/\?/)==-1 ? document.URL + "?" : document.URL;
				url = url.replace(/viewmode/, "").replace(/editmode/, "").replace(/structmode/, "");
				if (!/\?$/.test(url) && !/\&$/.test(url)) url += "&";
				url += getCookie("STRUCT_MODE") ? "viewmode" : "structmode";
				location = !getCookie("STRUCT_MODE") ? "cms/auth.php@prev_url=" + escape(url) : url;
				break;
		}
}
document.attachEvent("onkeydown", cms_document_hotkeys);

function ShowOriginal(obj, target) {
	target = target ? target : "_blank";
	imgs=obj.getElementsByTagName('img');
	if (imgs[0]) {
		var src = imgs[0].src;
		var n = src.lastIndexOf('/');
		src = src.substring(0,n) + '/originals' + src.substring(n);
		window.open(src, target, "", true);
	}
}

function ShowOriginalIMG(obj, id) {
	imgs=obj.getElementsByTagName('img');
	if (imgs[0]) {
		var src = imgs[0].src;
		var n = src.lastIndexOf('/');
		src = src.substring(0,n) + '/originals' + src.substring(n);
		document.getElementById(id).src = src;
	}
}

function InsertPng(Src) {
	if(!navigator.appMinorVersion) document.write("<img border=0 src='"+Src+"'/>");
		else document.write("<img border=0 src='/DESIGN/MELCOM/images/transparent.gif' style=\"filter: progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+Src+"');\"/>");
}