//{{{ LinkMouseOver_Head
/**
 * эффект наведения для head
 */
function LinkMouseOver_Head(i,fromColor,toColor,el)
{
	if (el.nodeName != 'A') el = findParent(el, 'A');
	if (el.style.color == fromColor)	{
		el.style.color = toColor;
	}
	el.style.textDecoration = (i==1) ? 'underline' : 'none';
}
//===========================================================================}}}
//{{{ LinkMouseOver
/**
 * эффект наведения для ссылок
 */
function LinkMouseOver(el)
{
	var tmp = el;
	if(el.nodeName != 'A' && el.parentNode){el = el.parentNode};
	if(el.nodeName != 'A') {el = tmp;}
	el.style.textDecoration = 'underline';
}
//===========================================================================}}}
//{{{ LinkMouseOut
/**
 * эффект наведения для ссылок (уход)
 */
function LinkMouseOut(el)
{
	var tmp = el;
	if(el.nodeName != 'A' && el.parentNode){el = el.parentNode};
	if(el.nodeName != 'A') {el = tmp;}
	el.style.textDecoration = 'none';
}
//===========================================================================}}}
//{{{ MenuCellMouseOver
/**
 * эффект наведения для пунктов в меню
 */
function MenuCellMouseOver(fromColor,toColor,el)
{
	if (el.nodeName != 'TD') el = findParent(el, 'TD');
	if (el.bgColor == fromColor) {
		el.bgColor = toColor;
	}
}
function MenuItemMouseOver(fromColor,toColor,el)
{
	if (el.nodeName != 'DIV') el = findParent(el, 'DIV');
	el.style.backgroundColor = toColor;
	if (el.style.backgroundColor == fromColor) {
		el.style.backgroundColor = toColor;
	}
}
//===========================================================================}}}
//{{{ CatalogueCellClick
/**
 * клик по пункту главного меню каталога
 * @param Event ev событие
 */
function CatalogueCellClick(ev)
{
	var tmp = undefined == window.event ? ev.target : event.srcElement;
	var pic_url;
	var el = findParent(tmp, 'TABLE');
	if (el && (el = nextSibling(el, 'DIV')))
	{
		if (tmp.nodeName != 'IMG') {
			tmp = findChild(nextSibling(findParent(tmp, 'TD'), 'TD'), 'IMG');
		}
		pic_url = escape(tmp.src);
		switch (el.style.display)
		{
		case 'block':
			tmp.src = unescape(pic_url.substring(0,pic_url.length-5)+'1.gif');
			el.style.display = 'none';
			break;
		case 'none':
			tmp.src = unescape(pic_url.substring(0,pic_url.length-5)+'2.gif');
			el.style.display = 'block';
			break;
		}
	}
}
// временная функция для открытия пункта меню ( для работы в случае дивов )
function CatalogueItemClick(ev)
{
	var tmp = undefined == window.event ? ev.target : event.srcElement;
	var pic_url;
	var el = findParent(tmp, 'DIV');
	if ( tmp.nodeName == 'IMG' ) {
		el = findParent(el, 'DIV');
	}
	if (el && (el = nextSibling(el, 'DIV')))
	{
		if (tmp.nodeName != 'IMG') {
			tmp = findChild(nextSibling(tmp, 'DIV'), 'IMG');
		}
		pic_url = escape(tmp.src);
		switch (el.style.display)
		{
		case 'block':
			tmp.src = unescape(pic_url.substring(0,pic_url.length-5)+'1.gif');
			el.style.display = 'none';
			break;
		case 'none':
			tmp.src = unescape(pic_url.substring(0,pic_url.length-5)+'2.gif');
			el.style.display = 'block';
			break;
		}
	}
}

//Catalog:: expand no vip categories
function ShowNoVips(ev)
{
	var tmp = undefined == window.event ? ev.target : event.srcElement;
	var pDiv = el = findParent(tmp, 'DIV');
	//show novips div
	if (el && (el = nextSibling(el, 'DIV')))
	{
		switch (el.style.display)
		{
		case 'block':
			el.style.display = 'none';
			break;
		case 'none':
			el.style.display = 'block';
			break;
		}
	}
	//show link novips hide
	if (el && (el = nextSibling(el, 'DIV')))
	{
		switch (el.style.display)
		{
		case 'block':
			el.style.display = 'none';
			break;
		case 'none':
			el.style.display = 'block';
			break;
		}
	}
	//hide link vips show
		switch (pDiv.style.display)
		{
		case 'block':
			pDiv.style.display = 'none';
			break;
		case 'none':
			pDiv.style.display = 'block';
			break;
		}
}
//Catalog:: collapse no vip categories
function HideNoVips(ev)
{
	var tmp = undefined == window.event ? ev.target : event.srcElement;
	var pDiv = el = findParent(tmp, 'DIV');
//hide novips div
	if (el && (el = previousSibling(el, 'DIV')))
	{
		switch (el.style.display)
		{
		case 'block':
			el.style.display = 'none';
			break;
		case 'none':
			el.style.display = 'block';
			break;
		}
	}
//show link novips_show
	if (el && (el = previousSibling(el, 'DIV')))
	{
		switch (el.style.display)
		{
		case 'block':
			el.style.display = 'none';
			break;
		case 'none':
			el.style.display = 'block';
			break;
		}
	}
//hide link vips_hide
		switch (pDiv.style.display)
		{
		case 'block':
			pDiv.style.display = 'none';
			break;
		case 'none':
			pDiv.style.display = 'block';
			break;
		}
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function toggleCrossSiteNavigation(init)
{
	var csnContainer = jQuery('div#csn');
	var csnA = jQuery('a#csn_button');
	
	if( init )
	{
		if( getCookie('csn') == 'hidden' )
		{
			csnContainer.css('width', '0');
			csnA.css('background', 'url(/pic/header/csn-show.png) top left no-repeat');
		}
		else
		{
			csnA.css('background', 'url(/pic/header/csn-hide.png) top left no-repeat');
		}
		csnContainer.html('<object class="csn_object" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="crosssitenav" align="middle" height="113" width="387"><param name="allowScriptAccess" value="sameDomain"><param name="movie" value="/static/crosssitenav.swf"><param name="quality" value="high"><param name="scale" value="exactfit"><param name="wmode" value="transparent"><param name="bgcolor" value="#ffffff"><embed src="/static/crosssitenav.swf" quality="high" scale="exactfit" wmode="transparent" bgcolor="#ffffff" swliveconnect="true" id="crosssitenav" name="crosssitenav" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" height="113" width="387"></object>');
	}
	else
	{
		if( getCookie('csn') == 'hidden' )
		{
			csnContainer.animate( { width: '387px' }, 550, 'linear', function(){ csnA.css('background', 'url(/pic/header/csn-hide.png) top left no-repeat'); });
			setCookie( 'csn', 'visible', null, '/' );
		}
		else
		{
			csnContainer.animate( { width: '0' }, 550, 'linear', function(){ csnA.css('background', 'url(/pic/header/csn-show.png) top left no-repeat'); } );
			setCookie( 'csn', 'hidden', null, '/' );
		}
	}
   
	return false;
}

//===========================================================================}}}
/*============================================================================*
 * vim: set expandtab tabstop=3 shiftwidth=3 foldmethod=marker:               *
 *   END OF FILE                                                              *
 *============================================================================*/