function hmen(obj)
{
	if (document.getElementById('dir'+obj).childNodes.length==2)
	{
		document.location="/index.php?categoryID=" + obj;
	}
	else
	{
		
		for (i=2;i<=document.getElementById('dir'+obj).childNodes.length-1;i++)
		{
			if (document.getElementById('dir'+obj).childNodes[i].style.display=="block")
			{
				document.getElementById('dir'+obj).childNodes[i].style.display="none";
				a = 0;
			}
			else
			{
				document.getElementById('dir'+obj).childNodes[i].style.display="block";
				a = 1;
			}
		}
		//alert(document.getElementById('dir'+obj).childNodes[0].src);
		if (a==1)
		{
			document.getElementById('dir'+obj).childNodes[0].src = '/images/dot_orange.png';
		}
		else
		{
			document.getElementById('dir'+obj).childNodes[0].src = '/images/dot_green.png';
		}
		
	}
}

	function open_window(link,w,h)
	{
		var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'newWin',win);
		newWin.focus();
	}

	function open_printable_version(link)
	{
		var win = "menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'perintableWin',win);
		newWin.focus();
	}

	function confirmDelete(id, ask, url)
	{
		temp = window.confirm(ask);
		if (temp) //delete
		{
			window.location=url+id;
		}
	}

	

	function confirmUnsubscribe()
	{
		temp = window.confirm('{/literal}{$smarty.const.QUESTION_UNSUBSCRIBE}{literal}');
		if (temp) //delete
		{
			window.location="/index.php?killuser=yes";
		}
	}

	function validate()
	{
		if (document.subscription_form.email.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		if (document.subscription_form.email.value == 'Email')
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		return true;
	}
	function validate_disc()
	{
		if (document.formD.nick.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_NICKNAME}{literal}");
			return false;
		}

		if (document.formD.topic.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_MESSAGE_SUBJECT}{literal}");
			return false;
		}

		return true;
	}
	function validate_search()
	{

		if (document.Sform.price1.value!="" && ((document.Sform.price1.value < 0) || isNaN(document.Sform.price1.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}
		if (document.Sform.price2.value!="" && ((document.Sform.price2.value < 0) || isNaN(document.Sform.price2.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}

		return true;
	}
	<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

	function timechange()
	{
		$('#timeplace').text($('#timeselect option:selected').val());
		
	}

	
var myDate = new Date();
var hour = myDate.getHours(); 
var minute = myDate.getMinutes(); 
var second = myDate.getSeconds(); 
var days = myDate.getDate(); 

if (days%2 == 1)
{
	var ld = 1;
}
else
{
	var ld = 0;
}

var limit = (15+ld*24)*60*60-hour*3600-minute*60-second; 
if (limit<0)
{
	limit = (15+2*24)*60*60-hour*3600-minute*60-second; 
}
function processTimer(){
  if (limit > 0) {
    setTimeout("processTimer()",1000);
    limit--;
  } else {
    // здесь действия после завершения таймера
    //..
  }
  var ds = parseInt(limit/(3600 * 24)); // дни 
  var hrs = parseInt((limit - ds*(3600 * 24))/3600); // часы
  var mim = parseInt((limit - ds*(3600 * 24) - hrs*3600)/60); // минуты
  var sec = limit - mim*60 - hrs*3600 - ds*(3600 * 24); // секунды 
  // строка с оставшимся временем
  limit_str = "&nbsp;&nbsp;";
  limit_str = ds + " д. ";
  if (hrs < 10) limit_str = limit_str + "0";
  limit_str = limit_str + hrs + ":";
  if (mim < 10) limit_str = limit_str + "0";
  limit_str = limit_str + mim + ":";
  if (sec < 10) limit_str = limit_str + "0";
  limit_str = limit_str + sec + "";      
  // вывод времени
  el_timer = document.getElementById("timer");
  
  if (el_timer) el_timer.innerHTML = limit_str;
	
}

function myf() {
		
			$("#addettocart").fadeOut(2000);
		
		}

$(document).ready(function(){


	var mynDate = new Date ();
	var hrenmorjoviy = mynDate.getHours();
	var nononon;
	if ((0 <= hrenmorjoviy && hrenmorjoviy<9) || 22 < hrenmorjoviy)
	{nononon = 0;}
	if ((9 <= hrenmorjoviy && hrenmorjoviy<12) || 20 < hrenmorjoviy)
	{nononon = Math.floor((Math.random()*100)%3);}
	if ((12 <= hrenmorjoviy && hrenmorjoviy<16) || 20 < hrenmorjoviy)
	{nononon = Math.floor((Math.random()*100)%4);}
	if (16 <= hrenmorjoviy &&  hrenmorjoviy<=20)
	{nononon = Math.floor((Math.random()*100)%3);}

	$('#delbtimer').text(nononon);
	
	$('.inbuy').mouseover( function() {
		$(this).attr('src','/images/buy_sel.png');
		//$(this).parent().parent().find(".num_b").show("slow");
		
	});
	$('.inbuy').mouseout( function() {
		$(this).attr('src','/images/buy.png');
		//$(this).parent().parent().find(".num_b").hide("slow");
	});
	
	$('.inbuy_la').mouseover( function() {
		if ($(this).attr('byd') == '1')
		{
		
			$(this).attr('src','/images/to_basket_sel.png');
		}
		else
		{
			$(this).attr('src','/images/buy_sel.png');
		}
		
	});
	$('.inbuy_la').mouseout( function() {
	
		if ($(this).attr('byd') == '1')
		{
		
			$(this).attr('src','/images/to_basket.png');
		}
		else
		{
			$(this).attr('src','/images/buy.png');
		}
	});
	
	$('.inbuy_la').click( function() {
		if ($(this).attr('byd') == '1')
		{
		
			document.location=$(this).parent().attr('href');
		}
		else
		{
			$("#inatc").html('<img src="/images/loadingAnimation.gif"><br><b>Добавлено в корзину</b>');
			$("#addettocart").fadeIn("300");
			$.get($(this).parent().attr('href')+'&t_count='+$('#delta'+$(this).attr('ida')).val(), function(data){
				$("#inatc").html(data);
			});
			
			setTimeout(function () {
				$("#addettocart").fadeOut(2000);
				},6000);
			setTimeout(function () {
				$("#inatc").text('Добавлено в корзину');
				},8000);
			
			//$("#addettocart").load($(this).parent().attr('href')+'&t_count='+$('#delta'+$(this).attr('ida')).val());
			$('#hiderok'+$(this).attr('ida')).css('visibility', 'hidden');			
			$(this).parent().attr('href', '/index.php?shopping_cart=yes');
			$(this).attr('byd','1');
			$(this).attr('src','/images/to_basket_sel.png');
			
			
			
        }
		
		
	});
	
	$('.inbuy_la').parent().click( function() {
		return false;
	});
	
	$('#uot').change( function() {
	if($(this).val() == '1')
	{
		$('#aquot').show();
		$(this).val('0');
	}
	else
	{
		$('#aquot').hide();
		$(this).val('1');
	}
	});
	
	
	$('#special_block').slideshow({
		width:200,      // width in px
		height:240,     // height in px
		index:0,        // start from frame number N
		time:8000,      // time out beetwen slides
		title:false,     // show title
		titleshow:false,// always show title
		callback:null,  // callback function - call when slide changed - receive index and label
		panel:false,     // show controls panel
		play:true,     // play slideshow
		loop:true,      // looping
		effect:'fade',  // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY
		effecttime:1000,// aviable fast,slow,normal and any valid fx speed value
		filter:true,    // remove <br/>, empty <div>, <p> and other stuff
		nextclick:false,      // bind content click next slide
		playclick:false,      // bind content click play/stop
		playhover:false,      // bind content hover play/stop
		playhoverr:false,     // bind content hover stop/play (reverse of playhover)
		playframe:false,       // show frame "Play Now!"
		loadframe:false,       // show frame with "loading"
		fullscreen:false,     // in full window size
		imgresize:false,      // resize image to slideshow window
		imgzoom:false,         // zoom image to slideshow window (for smaller side)
		imgcenter:true,       // set image to center
		imgajax:false,         // load images from links
		imglink:false,         // go to external link by click
		linkajax:false,       // load html from links
		help:'',
		controls :{         // show/hide controls elements
			'hide':true,    // show controls bar on mouse hover
			'first':true,   // goto first frame
			'prev':true,    // goto previouse frame (if it first go to last)
			'play':true,    // play slideshow
			'next':true,    // goto next frame (if it last go to first)
			'last':true,    // goto last frame
			'help':true,    // show help message
			'counter':true  // show slide counter
		}
	});
	
	
		$('#new_products_block').slideshow({
		width:200,      // width in px
		height:260,     // height in px
		index:0,        // start from frame number N
		time:8000,      // time out beetwen slides
		title:false,     // show title
		titleshow:false,// always show title
		callback:null,  // callback function - call when slide changed - receive index and label
		panel:false,     // show controls panel
		play:true,     // play slideshow
		loop:true,      // looping
		effect:'fade',  // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY
		effecttime:1000,// aviable fast,slow,normal and any valid fx speed value
		filter:true,    // remove <br/>, empty <div>, <p> and other stuff
		nextclick:false,      // bind content click next slide
		playclick:false,      // bind content click play/stop
		playhover:false,      // bind content hover play/stop
		playhoverr:false,     // bind content hover stop/play (reverse of playhover)
		playframe:false,       // show frame "Play Now!"
		loadframe:false,       // show frame with "loading"
		fullscreen:false,     // in full window size
		imgresize:false,      // resize image to slideshow window
		imgzoom:false,         // zoom image to slideshow window (for smaller side)
		imgcenter:true,       // set image to center
		imgajax:false,         // load images from links
		imglink:false,         // go to external link by click
		linkajax:false,       // load html from links
		help:'',
		controls :{         // show/hide controls elements
			'hide':true,    // show controls bar on mouse hover
			'first':true,   // goto first frame
			'prev':true,    // goto previouse frame (if it first go to last)
			'play':true,    // play slideshow
			'next':true,    // goto next frame (if it last go to first)
			'last':true,    // goto last frame
			'help':true,    // show help message
			'counter':true  // show slide counter
		}
	});
	
	$('.forslide').css('display','block');
	
	
});

processTimer();

function DecCnt(ident){if (document.getElementById(ident).value>1) document.getElementById(ident).value--;}
function IncCnt(ident){document.getElementById(ident).value++; }

