var showTab = function (tab, tabContent, title, coords, address)
{       
	if (document.getElementById)
	{
		var divs=document.getElementsByTagName('div');
		for (var i=0;i<divs.length;i++)
		{
			if(divs[i].className=='tabcontent open')
			{
				divs[i].className = 'tabcontent';
			}
		}

		var spans=document.getElementsByTagName('span');
		for (var i=0;i<spans.length;i++)
		{
			if(spans[i].className=='tab active')
			{
				spans[i].className='tab';
			}
	
		}

		if (tab && tabContent)
		{
			tab.className = 'tab active';
			tabContent.className = 'tabcontent open';
		}
	}
	if (title)
	{
		MapsInit(title, coords, address);
	}
}

var showSubTab = function (tab, tabContent)
{       
	if (document.getElementById)
	{
		var divs=document.getElementsByTagName('div');
		for (var i=0;i<divs.length;i++)
		{
			if(divs[i].className=='stabcontent open')
			{
				divs[i].className = 'stabcontent';
			}
		}

		var spans=document.getElementsByTagName('span');
		for (var i=0;i<spans.length;i++)
		{
			if(spans[i].className=='stab active')
			{
				spans[i].className='stab';
			}
	
		}

		if (tab && tabContent)
		{
			tab.className = 'stab active';
			tabContent.className = 'stabcontent open';
		}
	}
}


var $ = function ( id )
{
	try
	{return ( typeof id == "string" )? document.getElementById( id ) : id;}
	catch ( e ) { };
}

var $addEventListener = function ( node, eventType, eventListener )
{
	try
	{
		node = $( node );
		if( node.attachEvent ) {node.attachEvent( "on" + eventType, eventListener );}
		else  {node.addEventListener( eventType, eventListener, false);}
	}
	catch ( e ) {}
}

function enableClickList()
{
try{
	var b;
	if (document.getElementsByTagName)
	{
		var uls=document.getElementsByTagName('ul');
		for (var i=0;i<uls.length;i++)
		{

			if(uls[i].className=='clickList interactive')
			{
				var lis=uls[i].getElementsByTagName('li');
				for(var j=0;j<lis.length;j++)
				{
					if(lis[j].parentNode.className=='clickList interactive')
					{
						lis[j].onclick=function( e ){if (this.className!='open') { $stopPropagation( e ); closeOpenItem(this.parentNode); this.className='open';} else {this.className=''};}
					}
				}
			}
		}
	}
}catch ( e ) {}
}



var $stopPropagation = function ( e ) {
 try {
  if ( window.IE ) {
   event.cancelBubble = true;
  }
  else
  {
   e.stopPropagation();
  }
 } catch ( e ) {}
}



function closeOpenItem(pElem)
{
try{
	var b;
	if (document.getElementsByTagName)
	{
		var lis=pElem.getElementsByTagName('li');
		for(var j=0;j<lis.length;j++)
		{
			if(lis[j].parentNode.className=='clickList interactive') {lis[j].className='';}
		}
	}
}catch ( e ) {}
}


function convertCurrency()
{
	var initValue = parseFloat($('initialvalue').value);
	var ratetype = '0';
	if ($('ratetypesell').checked) {ratetype = 's';} else {ratetype = 'b';}
	var initCurrency = $('initialcurrency')[$('initialcurrency').selectedIndex].value;
	var targetCurrency = $('targetcurrency')[$('targetcurrency').selectedIndex].value;
	var rateI = parseFloat($(ratetype+initCurrency).value);
	var rateT = parseFloat($(ratetype+targetCurrency).value);
	$('result').value = parseFloat(initValue*(rateI/rateT)).toFixed(2);
}


function convertCurrencyFive()
{
	var initValue = parseFloat($('initialvalueF').value);
	var ratetype = '0';
	if ($('ratetypesellF').checked) {ratetype = 's';} else {ratetype = 'b';}
	var initCurrency = $('initialcurrencyF')[$('initialcurrencyF').selectedIndex].value;
	var targetCurrency = $('targetcurrencyF')[$('targetcurrencyF').selectedIndex].value;
	for (var i=1; i<=5; i++)	
	{
		var rateI = parseFloat($(ratetype+initCurrency+i).value);
		var rateT = parseFloat($(ratetype+targetCurrency+i).value);
		$('result'+i).value = parseFloat(initValue*(rateI/rateT)).toFixed(2);
	}
}

$addEventListener( window, "load", enableClickList );

function Del(url)
{
	if (confirm('Вы уверены, что хотите удалить сообщение?'))
	{
		document.location.href = url;
	}
}

function DelO(url)
{
	if (confirm('Вы уверены, что хотите удалить заказ?'))
	{
		document.location.href = url;
	}
}


function isUndefined(v) {var undef; return v===undef;}

var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,width=800,height=500,resizable=1,scrollbars=1';

function raw_popup(url, target, features)
{
	if (isUndefined(features)) features = _POPUP_FEATURES;
	if (isUndefined(target  )) target   = '_blank';
	var theWindow = window.open(url, target, features);
	theWindow.focus();
}

function link_popup(src, features) {
	return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}