
window.onload=init;
function init() {
	//startList();
	
	//tooltip.d();//  всплывающии подсказки
	try{
	sessionRestart(1200000);
	}catch(e){}
}


function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("menu_fall");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}


function doDiv(id) {
	var obj, oimg;

	if (!(obj = document.getElementById('his_div_'+id))) return;
	if (!(oimg = document.getElementById('i_'+id))) return;
	
	if (!obj) {
		oimg.src = gc_path+"/images/minus.gif";
		return;
	}
	
	if (obj.style.display == 'block') {
		obj.style.display = 'none';
		oimg.src = gc_path+"/images/plus.gif";
	} else {
		obj.style.display = 'block';
		oimg.src = gc_path+"/images/minus.gif";
	}
}



function checkSearchField(obj) {
	var elem;
	if (obj.value == 'num') {
		if ((elem = document.getElementById('num_search'))) elem.style.display='block';
		if ((elem = document.getElementById('reg_search'))) elem.style.display='none';
		if ((elem = document.getElementById('search_query'))) elem.value='';
	} else {
		if ((elem = document.getElementById('num_search'))) elem.style.display='none';
		if ((elem = document.getElementById('reg_search'))) elem.style.display='block';
		if ((elem = document.getElementById('search_from'))) elem.value='';
		if ((elem = document.getElementById('search_to'))) elem.value='';
	}
}


function openNew(obj, width, height, titul) {
	var newwin = window.open('/images/spacer.gif', 'Information', 'toolbar=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + width + ',height=' + height);
	newwin.document.open();
	newwin.document.write('<html><head><title>'+ titul + '</title></head>');
 	newwin.document.write('<body style="margin-left:0; margin-right:0; margin-top:0; margin-bottom:0;padding-top:0; padding-left:0; padding-right:0; padding-bottom:0;"><a href="javascript:void(0)" onClick="window.close()"><img src="' + obj + '" border="0" alt="Скрыть"/></a></body></html>');
 	newwin.document.close();
	newwin.focus();
}

var TimerId;



 function choiceAction(e){
 
		var obj = document.getElementById('choiceAction');
		 x = e.pageX-200;
		 y = e.pageY+10;

		//if (self.pageYOffset) y = self.pageYOffset;
		//if (document.body.scrollTop) y = document.body.scrollTop;

		obj.style.left = x+"px"
		obj.style.top = y+"px";
		obj.style.display = 'block';
		
}




var iToCmpare=new Array();

function setToCmp(id,flag){
	iToCmpare[id]=flag;
}



function toCompare(){
	var ids=new Array();
	
	for (var key in iToCmpare)
	 if(iToCmpare[key]) ids.push(key);
		
	ids = ids.join(',');
	if (!ids) {
		alert('Не выбрано ни одного элемента для сравнения');
		return;
	}
	document.getElementById('cmp').good_ids.value=ids;
	document.getElementById('cmp').submit();	
	
	
}

function clearUserReristerForm(obj){	
	for (var key in obj.elements)
		if (obj.elements[key])
		if(obj.elements[key].value){
		if((obj.elements[key].value)&&(obj.elements[key].id!='clr')&&((obj.elements[key].id!='reg'))) obj.elements[key].value='';
		if(obj.elements[key].name=='region') obj.elements[key].value='0';
		}
	
}


var cur_menu=0;
var out=0;
function showSubMenu(id){
	showSubSubMenu(0);
	if(cur_menu!=0)
		if(document.getElementById('sub_menu_'+cur_menu))
			document.getElementById('sub_menu_'+cur_menu).style.display='none';
	
	if(id!=0)
		if(document.getElementById('sub_menu_'+id))
			document.getElementById('sub_menu_'+id).style.display='block';
	cur_menu=id;
	out=0;
	
	
}
function setOut(code){
	//alert(code+" "+out);
	if((code==2)&&(out==1))
		out=0;
	 else
		out=code;
	
}

function closeAll(){
	
	
	if(out==1){
	if(document.getElementById('sub_sub_menu_'+cur_sub_menu))
		document.getElementById('sub_sub_menu_'+cur_sub_menu).style.display='none';
	if(document.getElementById('sub_menu_'+cur_menu))
		document.getElementById('sub_menu_'+cur_menu).style.display='none';
	
	//alert();
	cur_menu=0;
	cur_sub_menu=0;
	}
	out=0;
}



var cur_sub_menu=0;
var out_sub=0;
function showSubSubMenu(id){
	
	if(cur_sub_menu!=0)
		if(document.getElementById('sub_sub_menu_'+cur_sub_menu))
			document.getElementById('sub_sub_menu_'+cur_sub_menu).style.display='none';
	if(id!=0)
		if(document.getElementById('sub_sub_menu_'+id))
			document.getElementById('sub_sub_menu_'+id).style.display='block';
	cur_sub_menu=id;
	out_sub=0;
}


var current_thumb_pic=0;
var select_thumb_pic=1;

function changeMainPic(id,psrc,pwidth,pheight) {
	var mobj, pobj;
	
	
		
	if ((pobj = document.getElementById('thumb_pic_'+id))) { 
		select_thumb_pic = id; 
	} else {
		return;
	}
	if ((mobj = document.getElementById('main_pic'))) {
	
		mobj.src=psrc;
		mobj.width=pwidth;
		mobj.height=pheight;
		
	}

}

var  price="ue";
var  ru_price= new Array();
var  ue_price= new Array();
var  in_rub_str=new Array();
var  in_ue_str = new Array();
var  in_ue_anhor = new Array();
var  in_rub_anhor= new Array();
function switchPrice(){
	
	if((ru_price.length==0)&&(ue_price.length==0))
		getPriceSpan();
	if(in_rub_str.length==0)
		getPriceNameSpan();
	
	
	if(price=='rub'){
		price='ue';
		hideElementsInArray(ru_price);
		showElementsInArray(ue_price);
		hideElementsInArray(in_ue_anhor);
		showElementsInArray(in_rub_anhor,'block');
		hideElementsInArray(in_rub_str);
		showElementsInArray(in_ue_str);
		
		
		if(document.getElementById('ue_string'))
			document.getElementById('ue_string').style.display="block";
		
		
	}

	else{
		price='rub';
		hideElementsInArray(ue_price);
		showElementsInArray(ru_price);
		hideElementsInArray(in_rub_anhor);
		showElementsInArray(in_ue_anhor,'block');
		hideElementsInArray(in_ue_str);
		showElementsInArray(in_rub_str);
	
		
		if(document.getElementById('ue_string'))
			document.getElementById('ue_string').style.display="none";
		
		
		
	}

	
	
}

function getPriceSpan(){
	
	spans= new Array();
	spans=document.getElementsByTagName("span");
	
	for(i in  spans){
		
		if(spans[i].className=="price_rub")
			 	ru_price[ru_price.length+1]=spans[i];
		
		if(spans[i].className=='price_ue')
				ue_price[ue_price.length+1]=spans[i];
	}
	
}

function getPriceNameSpan(){
	
	spans= new Array();
	spans=document.getElementsByTagName("span");
		
	for(i in  spans){
		
		if(spans[i].className=="in_rub_str")
			 	in_rub_str[in_rub_str.length+1]=spans[i];
			 	
		if(spans[i].className=="in_ue_str")
			 	in_ue_str[in_ue_str.length+1]=spans[i];
		
	}
	spans=document.getElementsByTagName("a");
	for(i in  spans){
		
		if(spans[i].className=="in_ue_anhor")
			 	in_ue_anhor[in_ue_anhor.length+1]=spans[i];
			 	
		if(spans[i].className=="in_rub_anhor")
			 	in_rub_anhor[in_rub_anhor.length+1]=spans[i];
		
	}
	
	
}

function hideElementsInArray(array){
	
	if(array.length==0) return;
	for(i  in  array){
		array[i].style.display='none';
	}
	
}

function showElementsInArray(array,type){
	
	if(array.length==0) return;
	for(i  in  array){
		if(type=='block')
			array[i].style.display="block";
		else
			array[i].style.display="inline";
	}
	
}


function showBlock(id,time){
	
	
	if(obj=document.getElementById(id)){
		obj.style.display="block";
		if(time>0){
			setTimeout(function(){hideBlock(id);},time)	
		}
				
	}
	
}
	
function hideBlock(id){
	if(obj=document.getElementById(id))
			obj.style.display="none";
	
	
}



function sentToBasket(item_id,p){
	var obj=null;
	if(isNaN(item_id)) return 0
	if(obj=document.getElementById('to_basket_msg_'+item_id)){
		img=obj.parentNode.getElementsByTagName("img");
		if(img[0]){
			img[0].last_src=img[0].getAttribute('src');
			img[0].last_onclick=img[0].onclick;
			img[0].onclick="void()";
			img[0].src="/css/img/load.gif";
			
			
		}
				
	}
				
	
	var params = new Array();
	params['item_id'] = item_id;  
	params['item_number'] = 1;
	if(p){
		for(i in p)
			params[i]=p[i];
		
	}
	
	 var doSubmit=function(){ 
							var p =params; var image=img[0];var i_id=item_id;
							return function(){
								serverRequest('POST',gc_path+'/basket/add/2/',p,
									function(){if(image){image.src=image.last_src;image.onclick=image.last_onclick} showBlock('to_basket_msg_'+i_id,5000);}
									,null,null); 
								
							}
		
					}();
	doSubmit()
	//setTimeout(doSubmit,2000);
	
	
	return 0;
	
}


function showGroupDescr(id){
	if(obj=document.getElementById('group_list')){
		var div_list=obj.getElementsByTagName('div'); 
		if(div_list.length>0){
			for(var i in div_list){
				if(div_list[i].className=='no_displ_right'){
					
					div_list[i].style.display='none';
				}				
			}	
		}
		
		var a_list=obj.getElementsByTagName('a'); 
		if(a_list.length>0){
			for(var i in a_list){
				a_list[i].className='group_name_start';
				
			}
		
		}
		
		
	}
	
	if(obj=document.getElementById('group_image_list')){
		var div_list=obj.getElementsByTagName('div'); 
		if(div_list.length>0){
			for(var i in div_list){
				if(div_list[i].className=='gr_descr_st'){
					div_list[i].style.display='none';
				}				
			}	
		}
	}
			
		
	document.getElementById('group_pic_'+id).style.display='block';
	document.getElementById('group_descr_'+id).style.display='block';
	document.getElementById('group_name_link_'+id).className=document.getElementById('group_name_link_'+id).className+'   group_name_start_selected';
	
	
}
	
// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddtopmenu = 0;

// open hidden layer
function mopen(id, idp)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	if(ddtopmenu) ddtopmenu.style.backgroundColor = '#0b92bf';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
	ddtopmenu = document.getElementById(idp);
	ddtopmenu.style.backgroundColor = '#a2a2a2';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	if(ddtopmenu) ddtopmenu.style.backgroundColor = '#0b92bf';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

var titletab = 0;
var tabact = 0;

function tabOpen(id){
	if(tabact){
		tabact.className= 'close';
		titletab.className = 'normal';
	}
	else{
		titletab = document.getElementById('1');
		tabact = document.getElementById('tab1');
		tabact.className= 'close';
		titletab.className = 'normal';
	}
	titletab = document.getElementById(id);
	tabact = document.getElementById('tab'+id);
	tabact.className= 'goods_tab_box';
	titletab.className = 'active';
}




