function getWidth(){	
	nWidth = document.body.clientWidth-5;
	document.getElementById("topDiv").runtimeStyle.posWidth=nWidth;
	document.getElementById("scrollDiv1").runtimeStyle.posWidth=nWidth - 10;
	document.getElementById("scrollDiv2").runtimeStyle.posWidth=nWidth - 10;
}

var timeout;
var divY=140;
var divSet="";
var menuSet="";

function showDiv(id,idY){
	timeout=clearTimeout(timeout);
	hideDiv();
	divSet="div"+id;
	menuSet="menu"+id;
	y = getDivY (idY) - 2;
	show(divSet,y);
}

function getDivY (szDivName) {
	if (ie){
		var nPos = 0;
		objCurrent = document.all[ szDivName ];
	
		// prevent relative Y positioning problems in IE55 and IE6:
		if( objCurrent.style.position.toLowerCase() != "absolute" )
			objCurrent.style.position = "static";
	
		while (objCurrent != null){
			nPos += objCurrent.offsetTop;
			objCurrent = objCurrent.offsetParent;
		}

		return nPos;
	}
	if( mozilla || opera5 || opera7) return document.getElementById( szDivName ).offsetTop; 
	return 0;
}

function hideDiv(){
	if(divSet!=""){
		hide();
	}
}

function createDiv(){
	var div="";
	for(var a=0; a<divData.length; a++){
		div+='<div id="div'+a+'" class="divView"';
			if(!opera5) div+=' onmouseover="showDiv('+a+',\'divY_'+a+'\')" onmouseout="timeout=setTimeout(\'hideDiv()\',1000)"';
	  div+='>';
		if(divData[a].length>0){
			div+='<table border="0" cellpadding="0" cellspacing="0" width="160">';
			div+='<tr bgcolor="#A7ACD6">';
			div+='<td colspan="6" height="1"><spacer type="block" /></td>';
			div+='</tr>';
				for(var b=0; b<divData[a].length; b++){
					div+='<tr valign="top" bgcolor="#6476B4">';
					div+='<td bgcolor="#8293C1"><div style="width:1px"><spacer type="block" /></div></td>';
					div+='<td class="submenuOff" id="div'+a+b+'"><div style="width:3px"><spacer type="block" /></div></td>';
					div+='<td bgcolor="#8293C1"><div style="width:1px"><spacer type="block" /></div></td>';
					div+='<td><img src="/pictures/bullet2.gif" width="13" height="7" alt="" border="0" vspace="3"></td>';
					div+='<td title="'+divData[a][b]["name"]+'" class="paddingMenu" width="100%" onmouseover="showBkg(\'div'+a+b+'\',1)" onmouseout="showBkg(\'div'+a+b+'\',0)" onclick="location.href=\''+divData[a][b]["href"]+'\'">';
					div+='<a href="'+divData[a][b]["href"]+'" class="linkMenu2">'+divData[a][b]["name"]+'</a>';
					div+='</a></td>';
					div+='<td bgcolor="#4C5785"><div style="width:1px"><spacer type="block" /></div></td>';
					div+='</tr>';
				}
			div+='<tr bgcolor="#3E466D">';
			div+='<td colspan="6" height="1"><spacer type="block" /></td>';
			div+='</tr>';
			div+='</table>';
		}
		div+='</div>';
	}

document.write(div);
}

// === Open Image ===
function openImage(id,w,h){
	if(oi!=null && !oi.closed) oi.close();
	var oi=window.open('/image.php?id='+id,'openImage','resizable=no,menubar=no,status=no,scrollbars=no,width='+w+',height='+h+',top=10,left=10');
	oi.focus();
return false;
}

// === Send Sort ===
function sendSort(){
	location.href="/?sort="+document.sort.sort.value;
return false;	
}

// === Send Sort Catalogue ===
function sendSortCatalogue(id){
	location.href="/catalogue/?id="+id+"&sort="+document.sort.sort.value;
return false;	
}

// === Send Sort Accessory ===
function sendSortAccessory(id){
	location.href="/accessories/?id="+id+"&sort="+document.sort.sort.value;
return false;	
}

// === Send Compare ===
function sendCompare(id){
	location.href="/compare/?id="+id+"&product="+document.compare.compare.value;
return false;	
}

// === Send Search ===
function sendSearch(){
	var search=document.search.search.value;
	if(search.length<2){
		alert("Слово для поиска слишком короткое!");
	}else{
		location.href="/search/?search="+search;	
	}
return false;	
}

// === Add Basket ===
function addBasket(productId, field){
	if (field == "no_id") {
		val = 1;
	} else {
		val = document.getElementById ("field_" + field).value;
	}
	location.href='/basket/add.php?id='+productId+'&count='+val+'&url='+location.href;
return false;
}