function JSONparse(str) {
    return eval('(' + str + ')');
}

function bla_bla (fn) {document.getElementById(fn).style.display='none';}

function paste(fn,name)
{ 
	var input=document.getElementById(fn);
	input.value+="<I>"+name+"</I>\n";
}

function inserttext(fn)
{
	txt = document.selection.createRange().text;
	paste(fn,txt);
}

function add2basket(wn,fn)
{
	openWIN('',wn,400,175);
	document.getElementById(fn).submit();
}

var myWinR;

function openIMG(URL,WName,w,h)
{
	if (myWinR != null && !myWinR.closed) myWinR.close();  
	sw = screen.width-100;
	sh = screen.availHeight-100;
	if (w > sw || h > sh)
	{
		if (w > sw) {w1 = sw;} else {w1 = w+17;}
		if (h > sh) {h1 = sh;} else {h1 = h+17;}
		mtw1 = (screen.width-w1)/2;
		mth1 = (screen.availHeight-h1)/2;
		myWinR = window.open('', WName, "width="+w1+",height="+h1+",top="+mth1+",left="+mtw1+",status=no,toolbar=no,scrollbars=yes,resizable=no,menubar=no");
		myWinR.focus();
	}
	else
	{
		mtw = (screen.width-w)/2;
		mth = (screen.availHeight-h)/2;
    	myWinR = window.open('', WName, "width="+w+",height="+h+",top="+mth+",left="+mtw+",status=no,toolbar=no,scrollbars=no,resizable=no,menubar=no");
		myWinR.focus();
	}
  	myWinR.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Группа компаний ВИРА</title></head><body style="margin: 0px;"><a href="javascript:window.close();"><img src='+URL+' border=0 width='+w+' height='+h+' alt="Закрыть окно"></a></body></html>');
}

function email(par_1,par_2,par_3)
{
	email = par_1 + "%40" + par_2 + "." + par_3;
	return email;
}

function email_href(par_1,par_2,par_3)
{
	email = 'm'+'a'+'i'+'l'+'t'+'o'+':' + email(par_1,par_2,par_3);
	window.location.href = email;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function openWIN(URL,WName,w,h,scr)
{
	sw = screen.width-100;
	sh = screen.availHeight-100;
	mtw = (screen.width-w)/2;
	mth = (screen.availHeight-h)/2;
	popup = window.open(URL,WName,"width="+w+",height="+h+",top="+mth+",left="+mtw+",status=no,toolbar=no,scrollbars="+scr+",resizable=no,menubar=no");
	popup.focus();
} 

function search_check()
{
	if (document.getElementById('name').value == '')
	{
		alert('Пожалуйста, введите условие для поиска!')
		return false;
	}
	document.getElementById('search').submit();
}

function forma_check()
{
	if (document.getElementById('name_z').value == '')
	{
		alert('Пожалуйста, введите Ф.И.О.!');
		return false;
	}
	if (document.getElementById('phone_z').value == '')
	{
		alert('Пожалуйста, введите Телефон!');
		return false;
	}
	if (document.getElementById('address_z').value == '')
	{
		alert('Пожалуйста, введите Адрес!');
		return false;
	}
	pageTracker._trackPageview('/basket_step3.html');
	document.getElementById('forma').submit();
}

function auth_check()
{
	if (document.getElementById('email1').value == '')
	{
		alert('Пожалуйста, введите E-mail!');
		return false;
	}

	if (document.getElementById('pas1').value == '')
	{
		alert('Пожалуйста, введите Пароль!');
		return false;
	}
}

function forma_delivery_price()
{
	if (document.getElementById('delevery_z').value == 1)
	{
		document.getElementById('summa_delevery_price_1').innerHTML = document.getElementById('summa_delevery_price').value;
		document.getElementById('summa_delevery_price_2').innerHTML = document.getElementById('summa_delevery_price').value;
	}

	if (document.getElementById('delevery_z').value == 2)
	{
		document.getElementById('summa_delevery_price_1').innerHTML = document.getElementById('summa_delevery_soon_price').value;
		document.getElementById('summa_delevery_price_2').innerHTML = document.getElementById('summa_delevery_soon_price').value;
	}

	if (document.getElementById('delevery_z').value == 3)
	{
		document.getElementById('summa_delevery_price_1').innerHTML = document.getElementById('summa_delevery_self_price').value;
		document.getElementById('summa_delevery_price_2').innerHTML = document.getElementById('summa_delevery_self_price').value;
	}
}

$(document).ready(function()
{
	$("a#products_img_big").fancybox({
		'padding':5,
		'margin':5,
		'autoScale':false,
		'transitionIn':'elastic',
		'transitionOut':'elastic',
		'titleShow':false,
		'hideOnContentClick':true,
		'easingIn':'easeOutBack',
		'easingOut':'easeInBack'
	});
});