var dolphintabs={
	subcontainers:[], last_accessed_tab:null,

	revealsubmenu:function(curtabref){
	this.hideallsubs()
	if (this.last_accessed_tab!=null)
		this.last_accessed_tab.className="off"
	if (curtabref.getAttribute("rel")) //If there's a sub menu defined for this tab item, show it
	document.getElementById(curtabref.getAttribute("rel")).style.display="block"
	curtabref.className="current"
	this.last_accessed_tab=curtabref
	},

	hideallsubs:function(){
	var tabItems=document.getElementById("dolphinnav").getElementsByTagName("a")
	for (var i=0; i<tabItems.length; i++){
			if (tabItems[i].getAttribute("rel"))
			{
			tabItems[i].className=""
			}
	}
	for (var i=0; i<this.subcontainers.length; i++)
		document.getElementById(this.subcontainers[i]).style.display="none"
	},


	init:function(menuId, selectedIndex){
	var tabItems=document.getElementById(menuId).getElementsByTagName("a")
	var tabSupmenu=document.getElementById("upper")
	var tabSubmenu=document.getElementById("downer")
		for (var i=0; i<tabItems.length; i++){
			if (tabItems[i].getAttribute("rel"))
				this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("rel") //store id of submenu div of tab menu item
			if (i==selectedIndex){ //if this tab item should be selected by default
				tabItems[i].className="current"
				this.revealsubmenu(tabItems[i])
			}
		tabItems[i].onmouseover=function(){
		dolphintabs.revealsubmenu(this)
		}
		} //END FOR LOOP
		tabSupmenu.onmouseover = function(){
		dolphintabs.hideallsubs()
		}
		tabSubmenu.onmouseover = function(){
		dolphintabs.hideallsubs()
		}
	}

}


function open_window(href){
myWindow=window.open(href,'','width=250,height=370,top=10,left=10, resizable=yes,scrollbars=yes');
myWindow.focus();
return false;
}

function update_cart_info(){
//alert("d");
new Ajax.Updater('update_part_cart','/catalogue/updatecart/', {asynchronous:true, evalScripts:true, requestHeaders:['X-Update', 'update_part_cart']});
}

function redirect(url){
	window.location.href=url;
}

function deleteProductFromOrder(){
	$('sendOrderForm').action = "/catalogue/cart";
	$('sendOrderForm').submit();
}

function addcartchangecount(input,price){
	try {$('amount').update(input.value*price);} catch(err){alert('В поле количество вводите только цифры.');};
}
