var id;
var offTop;
if (navigator.appName.indexOf("Microsoft")!=-1) document.cookie="brouser=IE; path=/";
function pressGoods (){
	document.cookie="nameGoods="+escape (arguments[1])+" ; path=/";
	document.cookie="pathGoods="+location.href+" ; path=/";
	if (findCookie("autotefic") && arguments[0]=="passwordForm"){
		location.href="/production/buy.asp";
	} else {
		openPop(arguments[0]);
	}	
}
//======= определение верхней точки отсчета popUp-меню ============
function offset () {
	offTop=parseInt(arguments[0].offsetTop);
}
//================ мотиватор открытия popUp-меню ==================

clickPopCount=0;

//--- расстояние до таблицы с выпадающим списком --->
doTable=265;
//---расстоние от <tr> до выпадающего списка-------->
doPopup=60;
//-------------------------------------------------->

function selectPop(){
	clickPopCount++;
	plusBanner=0;
	if (findCookie("closeBanner")=="yes")plusBanner=124;	
	if (clickPopCount==1){
		openPop("popUp"+arguments[0]);
		id=arguments[0];
		//----------------- высота выпадающего меню----------------------->
		popHeight=document.getElementById("pop"+arguments[0]).offsetHeight;
		//---------------------------------------------------------------->
		
		paramAdd=arguments[0];
		
			if (navigator.userAgent.indexOf("Netscape")==-1)document.getElementById("myBody").attachEvent("onmousedown", addEventToBody);
			
			//------------ максимальная высота выпадающего меню ----------------->
			if (popHeight<174){
				document.getElementById("pop"+arguments[0]).style.height=document.getElementById("pop"+arguments[0]).offsetHeight;
			} else {
				document.getElementById("pop"+arguments[0]).style.height=174;
				popHeight=174;
				}
			//------------------------------------------------------------------->
			if (navigator.userAgent.indexOf("Opera")==-1){
				if ((document.body.clientHeight+document.body.scrollTop)-(offTop+doTable+doPopup-plusBanner)<popHeight){
					document.getElementById("popUp"+arguments[0]).style.top=offTop+(282-popHeight)-plusBanner;
					document.getElementById("downShadow"+arguments[0]).style.visibility="hidden";
					document.getElementById("rightShadow"+arguments[0]).style.height=popHeight;
					document.getElementById("upBorger"+arguments[0]).style.visibility="visible";
					document.getElementById("downBorger"+arguments[0]).style.visibility="hidden";
				} else {
					if (navigator.userAgent.indexOf("Netscape")==-1 && offTop){
						document.getElementById("popUp"+arguments[0]).style.top=offTop+306-plusBanner;
					} else if (offTop){
						document.getElementById("popUp"+arguments[0]).style.top=offTop+308-plusBanner;
					}
					document.getElementById("downShadow"+arguments[0]).style.visibility="visible";
					document.getElementById("rightShadow"+arguments[0]).style.height=popHeight+4;
					document.getElementById("upBorger"+arguments[0]).style.visibility="hidden";
					document.getElementById("downBorger"+arguments[0]).style.visibility="visible"; 				 
				}
			}				
	} else if (clickPopCount==2 && arguments[1]) {
		closePop("popUp"+arguments[0]);
		location.href=arguments[1];		
	} else if (clickPopCount==2 && arguments[0]==id) {
		closePop("popUp"+arguments[0]);		
	} else {		
		closePop("popUp"+id);		
	}
}
function openPop(){
	var Obj = document.getElementById(arguments[0]); 
		Obj.style.display="block";
		if (arguments[0]=="askForm" || arguments[0]=="passwordForm" || arguments[0]=="alertForm"){
			topSum=parseInt (document.body.scrollTop) + parseInt ((document.body.clientHeight/2)-(Obj.style.height.substr (-0,3)/2));
			if (topSum<151){
				topSum=151;
			}
			Obj.style.top=topSum;
			if (arguments[1]){			
				document.getElementById("alertMess").innerHTML=arguments[1];
			}
			if (arguments[2]){
				document.getElementById("alertHead").innerHTML=arguments[1];			
				document.getElementById("alertMess").innerHTML=arguments[2];
				document.getElementById("alertImg").innerHTML=arguments[3];				
				document.getElementById("alertButton").innerHTML=arguments[4];
			}
			if (arguments[0]=="askForm"){
				document.ask.elements[0].value=unescape (findCookie("nameGoods"));
			}
		}
}
function closePop(){
	var Obj = document.getElementById(arguments[0]);
		Obj.style.display="none";
		clickPopCount=0; 	 
}
function addEventToBody() {
	var x = event.clientX;
	var y = event.clientY;
	if (document.getElementById("pop"+paramAdd).componentFromPoint(x,y)=="outside") {
		closePop("popUp"+paramAdd);
		
		document.getElementById("myBody").detachEvent("onmousedown", addEventToBody);
	}
}
//====================== zoom ============================
colorPic="01";
function cinema (){
	path=arguments[0];
	var Obj = document.getElementById("bigPhoto"+arguments[1]);
	Obj.innerHTML="<div><img src='/images/gallery/"+path+"_"+colorPic+".jpg' border='0'></div>";
	
}
function inner(){
	var Obj = document.getElementById("bigPhoto"+arguments[1]);
	Obj.innerHTML="<div style='line-height: 10px'>&nbsp;</div><div><img src='/images/gallery/"+arguments[0]+"_big.jpg' width='480' height='300' border='0' title='Закрыть' onclick='erase("+arguments[1]+")' style='cursor: pointer;'></div>";
}

function erase (){
	var Obj = document.getElementById("bigPhoto"+arguments[0]);
	Obj.style.lineHeight=0;
	Obj.innerHTML="";
}
//============ изменение цвета пунктов меню ===============
function overOutColor(){
var Obj1 = document.getElementById(arguments[0]);
var Obj2 = document.getElementById(arguments[0]+2);	
	if (arguments[1]) {
	    Obj2.style.backgroundColor ="#ebebeb";
	} else { 
		if (navigator.userAgent.indexOf("Netscape")!=-1){
			if (Obj1.style.backgroundColor !="rgb(255, 139, 2)") Obj2.style.backgroundColor ="#ffffff";
		} else if (Obj1.style.backgroundColor != "#ff8b02"){
			Obj2.style.backgroundColor ="#ffffff";
		}			 
	}
}
//========== мотиватор закрытия/открытия меню ============
	function closeMotivator (){
	if (findCookie("close"+arguments[0])==arguments[0]){
		document.getElementById(arguments[0]).style.display=arguments[1];
		if (arguments[1]=="block"){
			document.getElementById(arguments[0]+"Minus").style.display="inline";
			document.getElementById(arguments[0]+"Plus").style.display="none";
			clearCook(arguments[0]);
		} else {
			document.getElementById(arguments[0]+"Minus").style.display="none";
			document.getElementById(arguments[0]+"Plus").style.display="inline";
		}
	}
	}	
//===== запись куки для мотиватора закрытия/открытия =====
	function cook(){
		document.cookie="close"+arguments[0]+"="+arguments[0]+" ; path=/";
		closeMotivator (arguments[0],arguments[1]);
	}
//===================== очистка куки =====================
	function clearCook(){
	document.cookie="close"+arguments[0]+"=0"+" ; path=/";
	}
	
//==================== поиск куки ========================
	function findCookie(szName) 
    {
      var i=nStartPosition=nEndPosition=0;
      var szCookieString=document.cookie;  
      while (i <= szCookieString.length) {
	      nStartPosition = i;
	      nEndPosition = nStartPosition + szName.length;
	      if (szCookieString.substring(nStartPosition,nEndPosition) == szName){
		      nStartPosition = nEndPosition + 1;
		      nEndPosition = document.cookie.indexOf(";",nStartPosition);
		      if(nEndPosition < nStartPosition){
			      nEndPosition = document.cookie.length;
			  }
		      return document.cookie.substring(nStartPosition,nEndPosition);  
		      break;    
	      }
	      i++;  
      }
      return false;
    }
//=================== смена страницы ======================
function setPageNumber(){
	if (arguments[1]=="undefined") {
		document.page.pageOn.value=arguments[0];		
	} else {
		document.page.pageOn.value=arguments[0];
		document.page.pageTurnOn.value=arguments[1];
	}
	document.page.onPage.value=document.scribeOnPage.onPage.value;
	document.page.submit();
}	

//=========================================================
//=== проверка формы и сравнение пароля с тест паролем ====
function testFieldPass(){
	if (arguments[0].password.value != arguments[0].passwordTest.value){
		openPop("alertForm","Неверный пароль");
	} else {
		testField(arguments[0]);
	}
}
function testField(){
	for (i=0; i<arguments[0].elements.length;i++){
		if (arguments[0].elements[i].type=='text' && arguments[0].elements[i].value =='') {
			openPop("alertForm","Заполните, пожалуйста, все поля формы");
			return;	
		}
	findChar=/\"/g;
	arguments[0].elements[i].value=arguments[0].elements[i].value.replace (findChar, "&quot;");
	findChar=/\'/g;
	arguments[0].elements[i].value=arguments[0].elements[i].value.replace (findChar, "&rsquo;");
}
arguments[0].submit();
}
function testChar(){
for (i=0; i<arguments[0].elements.length;i++){
	findChar=/\"/g;
	arguments[0].elements[i].value=arguments[0].elements[i].value.replace (findChar, "&quot;");
	findChar=/\'/g;
	arguments[0].elements[i].value=arguments[0].elements[i].value.replace (findChar, "&rsquo;");
}
arguments[0].submit();
}
//============================================================

function madeItemSum(){
itemSum="";
for (madeItemSum.i=0; madeItemSum.i<arguments[0].elements.length; madeItemSum.i++){ 
		if (arguments[0].elements[madeItemSum.i].type=="checkbox" && arguments[0].elements[madeItemSum.i].checked) { 
			itemSum+=arguments[0].elements[madeItemSum.i].value+";";
		}
}
arguments[0].addOn.value=itemSum;
}