
jQuery(function( $ ){
	$jq('#scroll_top').click(function(){
 		$jq.scrollTo( $jq('body'), {speed:0} );
	});
});

function showNewContent( name ) {
	$jq('#' + name).show('normal');
}

function displ(nnn)
{
	if (document.getElementById(nnn).style.display == 'none')
	{
		document.getElementById(nnn).style.display = ''
	}
	 else
	{
		document.getElementById(nnn).style.display = 'none'
	}
}

function softinstall(n,nameid)
{
    if (n == 0)
    {
    	document.getElementById(nameid).style.display = 'none';
    }
    if (n == 1)
    {
    	document.getElementById(nameid).style.display = '';
    }
}

function displ_bgcolor(nnn)
{
	if (document.getElementById(nnn).style.color == '#ff0000' || document.getElementById(nnn).style.color == 'rgb(255, 0, 0)')
	{
		document.getElementById(nnn).style.color = '#808080';
		document.getElementById(nnn).style.fontWeight  = 'normal';
	}
	 else
	{
		document.getElementById(nnn).style.color = '#ff0000';
		document.getElementById(nnn).style.fontWeight  = 'bold'
	}
}

function loadDesc( desc_id, pl_id )
{
    var desc_con = 'desc_cont_' + pl_id;
 	if (document.getElementById(desc_con).style.display == 'block')
	{
		document.getElementById(desc_con).style.display = 'none';
	}
	else
	{
		var name = 'desc_inner_' + pl_id;
		$jq('#desc_wrap_' + pl_id).css("display","inline");
		$jq('#desc_cont_' + pl_id).css("display","block");
	}

	//show_node('desc_cont_' + pl_id);

	var toLoad2 = URL_HOME + 'price.php?desc_id=' + desc_id;

	$jq('#' + name).load(toLoad2,'',showNewContent( name ));
	$jq('#' + name).load(toLoad2,'',showNewContent( name ));



	return false;
}


// shopping cart functions
function addToCart( pl_id )
{
	var toLoad = URL_HOME + 'price.php?add_item_id=' + pl_id;
	$jq('#sidebar_cart').hide('fast',loadCart);
	$jq('#sidebar_cart').remove();
	$jq('#loader').remove();
	$jq('#cont_list').append('<div id="loader"></div>');
	$jq('#loader').fadeIn('normal');


	//$jq('#sidebar_cart').load(toLoad,'',showNewContent( name ))
	return false;

	function loadCart()
	{
		$jq('#right_cont').append('<div id="sidebar_cart"></div>');
		$jq('#sidebar_cart').load(toLoad,'',showNewCart)
	}

	function showNewCart()
	{
		$jq.scrollTo( $jq('body'), {speed:0} );
		$jq('#sidebar_cart').slideDown('slow',hideLoader);
	}

	function hideLoader()
	{
		$jq('#loader').fadeOut('normal');
	}
}

function deleteFromCart( pl_id )
{
	var toLoad = URL_HOME + 'price.php?delete_item_id=' + pl_id;

	$jq('#content').hide('fast',loadCart);
	$jq('#content').remove();
	$jq('#loader').remove();
	$jq('#cont_list').append('<div id="loader"></div>');
	$jq('#loader').fadeIn('normal');

	//$jq('#sidebar_cart').load(toLoad,'',showNewContent( name ))
	return false;

	function loadCart()
	{
		$jq('#cont_list').append('<div id="content"></div>');
		$jq('#content').load(toLoad,'',showNewCart);
	}

	function showNewCart()
	{
		$jq.scrollTo( $jq('body'), {speed:0} );
		$jq('#content').slideDown('fast',hideLoader);
	}

	function hideLoader()
	{
		$jq('#loader').fadeOut('normal');
	}
}

function increaseQty( pl_id )
{
	var toLoad = URL_HOME + 'price.php?inc_qty_id=' + pl_id;

	$jq('#content').hide('fast',loadCart);
	$jq('#content').remove();
	$jq('#loader').remove();
	$jq('#cont_list').append('<div id="loader"></div>');
	$jq('#loader').fadeIn('normal');

	return false;

	function loadCart()
	{
		$jq('#cont_list').append('<div id="content"></div>');
		$jq('#content').load(toLoad,'',showNewCart);
	}

	function showNewCart()
	{
		$jq.scrollTo( $jq('body'), {speed:0} );
		$jq('#content').slideDown('fast',hideLoader);
	}

	function hideLoader()
	{
		$jq('#loader').fadeOut('normal');
	}
}

function decreaseQty( pl_id )
{
	var toLoad = URL_HOME + 'price.php?dec_qty_id=' + pl_id;

	$jq('#content').hide('fast',loadCart);
	$jq('#content').remove();
	$jq('#loader').remove();
	$jq('#cont_list').append('<div id="loader"></div>');
	$jq('#loader').fadeIn('normal');

	return false;

	function loadCart()
	{
		$jq('#cont_list').append('<div id="content"></div>');
		$jq('#content').load(toLoad,'',showNewCart);
	}

	function showNewCart()
	{
		$jq.scrollTo( $jq('body'), {speed:0} );
		$jq('#content').slideDown('fast',hideLoader);
	}

	function hideLoader()
	{
		$jq('#loader').fadeOut('normal');
	}
}


function checkSearchForm()
{

	if ($jq('#form_goods_search_s_word').attr('value') == '' || $jq('#form_goods_search_s_word').attr('value').trim().length == 0)
	{
		alert("Введите текст поиска.");
		$jq('#form_goods_search_s_word').focus();
		return false;
	}
	else document.forms['form_goods_search'].submit;
}

function checkOrderForm()
{
	if ($jq('#form_order_name').attr('value') == 0)
	{
		$jq('#form_order_name').focus();
		return false;
	}

	if ( ($jq('#form_order_phone').attr('value') == 0 || $jq('#form_order_phone').attr('value').length < 6 )
		&& ($jq('#form_order_m_phone').attr('value') == 0 || $jq('#form_order_m_phone').attr('value').length < 6))
	{
		$jq('#form_order_phone').focus();
		return false;
	}

	else document.forms['form_order'].submit;
}


