        function open_window(link,w,h) //opens new window
        {
                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) //opens new window
	{
		var win = "menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'perintableWin',win);
		newWin.focus();
	}
        function confirmDelete(id, ask, url) //confirm order delete
        {
                temp = window.confirm(ask);
                if (temp) //delete
                {
                        window.location=url+id;
                }
        }



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

        function validate() // newsletter subscription form validation
        {
                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() // review form verification
        {
                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 HiddenBlock(object,id)
{
	if(object)
	{
	        if(object.className=='image_plus')
	        {
	                object.className='image_minus';
	        }
	        else
	        {
	                object.className='image_plus';
	        }
	        if(document.getElementById(id).style.display=='block')
	        {
	                document.getElementById(id).style.display='none';
	        }
	        else
	        {
	                document.getElementById(id).style.display='block';
	        }
	        document.cookie=SetCookie(id,document.getElementById(id).style.display);
	}        
}
function SetBlock(object,objectsecond,cookiename)
{
	if(object)
	{
		var cookieval=GetCookie(cookiename);

        if(cookieval=='none')
        {
                object.className='image_plus';
                objectsecond.style.display=cookieval;
        }
        else
        {
                object.className='image_minus';
                objectsecond.style.display=cookieval;
        }
	}   

}
function init()
{

        SetBlock(document.getElementById('c_top_goods'),document.getElementById('top_good'),'top_good');
        SetBlock(document.getElementById('c_voting'),document.getElementById('voting'),'voting');
        SetBlock(document.getElementById('c_news_kino'),document.getElementById('news_kino'),'news_kino');
        SetBlock(document.getElementById('c_top_reyting'),document.getElementById('top_reyting'),'top_reyting');
        SetBlock(document.getElementById('c_random_pic'),document.getElementById('random_pic'),'random_pic');
        SetBlock(document.getElementById('c_top_sell'),document.getElementById('top_sell'),'top_sell');
        SetBlock(document.getElementById('c_admin_news'),document.getElementById('admin_news'),'admin_news');

}

function GetCookie(name)
{

var p = name + "="
var si = document.cookie.indexOf(p)
if(si == -1) return null
var ei = document.cookie.indexOf(";", si + p.length)
if(ei == -1) ei = document.cookie.length
return unescape(document.cookie.substring(si + p.length, ei))
}
function SetCookie(name, value) {
        var expires=60*60*24*365;
        var path="/";
        var todaydate=new Date();
        var domain=".spanime.ru";

        var expdate=new Date(todaydate.getTime()+expires*1000);
    var curCookie = name + "=" + escape(value) +
                "; expires=" + expdate.toGMTString()  +
                "; domain=" + domain +
                ((path) ? "; path=" + path : "");
        return curCookie;
}        