load_timer = 0;

function hideMessage()
{
	with(document.getElementById('mess')){
		innerHTML = "";
		style.visibility = "hidden";
		style.color = "black";
	}
}
function createMessage(text, color, time_to_show)
{
	with(document.getElementById('mess'))
	{
		style.visibility = "visible";
		innerHTML = text;
		style.color = color;
	}
	if(time_to_show > 0)
		setTimeout("hideMessage()", time_to_show);
}

window.onscroll = setX;
var ScrollY = 0;

function setX()
{
	var m = document.getElementById('mess');
	if (m) {
		m.style.top = document.body.scrollTop + 200;
		ScrollY = document.body.scrollTop;
	}
}

function showmenu(n) {
    var chl = document.getElementById(n);
    if (chl.style.display == 'none') {
        chl.style.display = '';
        document.getElementById('img_'+n).src='/i/menu_sub_arrow_h.gif';
    }
    else {
        chl.style.display = 'none';
        document.getElementById('img_'+n).src='/i/menu_sub_arrow.gif';
    }
	setID(n);
}

function setID (nid) {
var menu = getCookieValue('menu');
	if (menu){
		var arr_menu = menu.split(",");
		var flag = true;
		for (var i=0; i < arr_menu.length; i++){
			if (arr_menu[i] == nid) {
				arr_menu.splice(i, 1);
				flag = false;
				}
		}
		if (flag) setCookie('menu', arr_menu.join(",")+","+nid, 0);
		else setCookie('menu', arr_menu.join(","), 0);
	} else setCookie('menu', nid, 0);
}

function initMenu() {
		var menu = getCookieValue('menu');
		if (menu) {
			var arr_menu = menu.split(",");
			for (var i = 0; i < arr_menu.length; i++) {
				var ch1;
				if (document.getElementById(arr_menu[i])) {
				ch1 = document.getElementById(arr_menu[i]);
				ch1.style.display = '';
				}
			}
		}

}

function getCookieValue (name) {
    var cookieValue = document.cookie;
    var r = new RegExp("\\b"+name+"\\b");
    var cookieStart = cookieValue.search(r);
    if (cookieStart == -1)
        cookieValue = null;
    else {
        cookieStart = cookieValue.indexOf("=", cookieStart) + 1;
		if (cookieStart != 0) {
	        var cookieEnd = cookieValue.indexOf(";", cookieStart);
	        if (cookieEnd == -1)
	            cookieEnd = cookieValue.length;
	        cookieValue = unescape(cookieValue.substring(cookieStart, cookieEnd));
		} else cookieValue = null;
    }
    return cookieValue;
}

function setCookie(name, val, expMonth) {
    var cook = name+"="+escape(val)+";";
    if (expMonth != 0) {
        var d = new Date();
        d.setMonth(d.getMonth()+expMonth);
        cook+="expires="+d.toUTCString()+";";
    }
    document.cookie = cook;
}

function newWin(name, url, width, height, args) {
		 var newWin = new Object();
		 newWin.args = args;
		 newWin.url = url;
		 newWin.name = name;
		 newWin.width = width;
		 newWin.height = height;
		 if (document.layers) {// browser is NN
		 	 newWin.left = window.screenX + ((window.outerWidth - newWin.width) / 2);
		 	 newWin.top = window.screenY + ((window.outerHeight - newWin.height) / 2);
		 	 var attr = 'screenX=' + newWin.left + ',screenY=' + newWin.top + ',resizable=yes,width=' + newWin.width + ',height=' + newWin.height + ',' + newWin.args;
		 }
		 else {// browser is MSIE
		 	   newWin.left = (screen.width - newWin.width) / 2;
		 	   newWin.top = (screen.height - newWin.height) / 2;
		 	   var attr = 'left=' + newWin.left + ',top=' + newWin.top + ',width=' + newWin.width + ',height=' + newWin.height + ',' + newWin.args;
		 }
newWin.win=window.open(newWin.url, newWin.name, attr);
newWin.win.opener=self;
newWin.win.focus();
}
function checkRequired(requiredFields, submitButtonId)
{
	var submit = true;

	for(i = 0; i < requiredFields.length; i++) {
		if(document.getElementById(requiredFields[i].id).value != '' && document.getElementById(requiredFields[i].id).value.length>0) {
			document.getElementById('req-' + requiredFields[i].id).innerHTML = '';
		} else {
			submit = false;
			document.getElementById('req-' + requiredFields[i].id).innerHTML = '*';
		}
	}
		document.getElementById(submitButtonId).disabled = !submit;
}

function chng_img_style(id, param, prd_nam, cnt){
	var im = document.getElementById(prd_nam);
	var im_o = document.getElementById(param + id);

	var nimg = im_o.src.replace(/50/g, "150");
	im.src = nimg;
//	alert(nimg);
	for(i = 0; i < cnt; i++) {
		document.getElementById(param + i).style.border = '1px solid #d4d4d4';
	}
	im_o.style.border='1px solid #FF0000';
}

function chng_img_style_med(id, param, prd_nam, cnt, bigimgnonfullway){
//	document.getElementById('bigimageframe').id = 'show_images_div(1);';
	if ((document.getElementById(param + id).style.border!='1px solid rgb(255, 0, 0)') && (document.getElementById(param + id).style.border!= '#ff0000 1px solid'))
    {
        //alert(document.getElementById(param + id).style.border);
    	global_js_bigimg = id;
        var lbigimgnonfullway = bigimgnonfullway;
        if (id == '0') {lbigimgnonfullway += ".jpg";} else
        {lbigimgnonfullway += "_"+id+".jpg";}
		//alert(lbigimgnonfullway);

		var im = document.getElementById(prd_nam);
		var imbig = document.getElementById('bigimgwid');
		var im_o = document.getElementById(param + id);

		//var nimg = im_o.src.replace(/small/g, "medium");
		var nimg = im_o.src.replace(/50/g, "150");
		//var bigisrc = im_o.src.replace(/small/g, "big");
		var bigisrc = im_o.src.replace(/50/g, "600");
		im.src = nimg;
		$("#bigimgwid").hide();
		//document.getElementById('bigimgwid').style.border.left='0';
		//document.getElementById('bigimgwid').style.border.top='0';
		imbig.src = lbigimgnonfullway;
		$("#bigimgwid").animate({ opacity: "show" }, "slow");
//	alert(nimg);
		for(i = 0; i < cnt; i++) {
			document.getElementById(param + i).style.border = '1px solid #d4d4d4';
			document.getElementById('shi_img_'+i).style.border='1px solid #d4d4d4';
		}
		im_o.style.border='1px solid #FF0000';
	}
}

function ClearCart(){
	document.forms['clear_cart'].submit();
}

function AddToCart(product_id,cena){
	createMessage("Минуточку...", "#4f4f4f");
	if (cena > 0){
		document.forms['prod_' + product_id].submit();
		createMessage("Товар успешно добавлен в корзину!\nДля того чтобы оформить заказ\nнажмите перейти на кассу вверху страницы", "#4f4f4f", 5000);
	}else{
		createMessage("Товар отсутствует в данный момент!", "#4f4f4f", 2000);
	}
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
				if (end == -1) {
					end = cookie.length;
				}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function fixDate (date) {
   var base = new Date(0);
   var skew = base.getTime();
   if (skew > 0)
       date.setTime(date.getTime() - skew);
}

function AddToACart(product_id,cena){
	createMessage("Минуточку...", "#4f4f4f");
	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
	if (cena > 0){
		var cart = getCookie("CART");
		if (cart){
			setCookie ("CART", cart + "=" + product_id + "|1|" + cena, now, "/");
		}else{
			setCookie ("CART", product_id + "|1|" + cena, now, "/");
		}
		parent.parent.frames.srct.location='/manager/inc/top.php';
		createMessage("Товар успешно добавлен в корзину!\nДля того чтобы оформить заказ\nнажмите перейти на кассу вверху страницы", "#4f4f4f", 5000);
	}else{
		createMessage("Товар отсутствует в данный момент!", "#4f4f4f", 2000);
	}
}


function DelFromCart(product_id){
	createMessage("Минуточку...", "#4f4f4f");
	document.getElementById('delete_' + product_id).value = 1;
	document.forms['OrderCart'].submit();
	createMessage("Товар удален из корзины!", "#4f4f4f", 5000);
}
function SelectDial(action){
		 switch (action){
		 	case "natural":
		 		var requiredFields = new Array();
				requiredFields[0] = {id: 'LastName'};
				requiredFields[1] = {id: 'first_name'};
				requiredFields[2] = {id: 'middle_name'};
				checkRequiredInput(requiredFields, 'submit-button');
		 		document.getElementById('natural_client').style.display='block';
		 		document.getElementById('legal_client').style.display='none';
		 		$('person_id').value=0;
		 	break;
		 	case "legal":
		 		var requiredFields = new Array();
				requiredFields[0] = {id: 'name'};
				requiredFields[1] = {id: 'inn'};
				requiredFields[2] = {id: 'real_address'};
				checkRequiredInput(requiredFields, 'submit-button');
		 		document.getElementById('natural_client').style.display='none';
		 		document.getElementById('legal_client').style.display='block';
		 		$('person_id').value=0;
		 	break;
		 	case "self":
		 		var requiredFields = new Array();
		 		checkRequiredInput(requiredFields, 'submit-button');
				document.getElementById('natural_client').style.display='none';
		 		document.getElementById('legal_client').style.display='none';
		 		$('person_id').value=0;
		 	break;
		 	case "delivery_no":
		 		var requiredFields = new Array();
				$('submit-button').disabled=false;
		 	break;
		 }
}
function checkRequiredInput(requiredFields, submitButtonId)
{
	var submit = true;
//	alert(requiredFields.length);
	for(i = 0; i < requiredFields.length; i++) {
		if(document.getElementById(requiredFields[i].id).value != '' && document.getElementById(requiredFields[i].id).value.length>=1) {
			document.getElementById(requiredFields[i].id).className = 'blackborder';
		} else {
			submit = false;
			document.getElementById(requiredFields[i].id).className = 'redborder';
		}
	}
	document.getElementById(submitButtonId).disabled = !submit;
}
function isEMAIL(myForm)
{
//	alert(myForm.value);
	var field = myForm.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(field)){
		alert("Неверно указан E-mail адресс! Пожалуйста повторите ввод.");
		document.getElementById('req-Email').innerHTML = '<br>Важно заполнить корректно! <br>(пример: name@mail.ua)';
		document.getElementById('Email').value = '';
		document.getElementById('Email').focus();
		document.getElementById('submit-button').disabled = true;
	}
}

//formFieldsGlobalRegister( document.login );
var forgot = 0;

function showForgotForm()
{
	forgot = 1;
	$('fp').style.display = 'none';
	$('rp').style.display = '';
	$('pass_text').style.display = 'none';
	$('forgot_text').style.display = '';
	$('pass_input').style.display = 'none';
	$('remember_checkbox').style.display = 'none';

	$('auth_button').value = '   Отправить   ';
}

function hideForgotForm()
{
	forgot = 0;
	$('fp').style.display = '';
	$('rp').style.display = 'none';
	$('pass_text').style.display = '';
	$('forgot_text').style.display = 'none';
	$('pass_input').style.display = '';
	$('remember_checkbox').style.display = '';

	$('auth_button').value = '   ОК   ';
}

function handle_send_forgot_password( result )
{
	$('forgot_text').style.display = 'none';
	$('rp').style.display = 'none';

	if ( result.AJAX_ERROR == undefined )
	{
		createMessage( result.message, 'green', 1500 );
		setTimeout( hideForgotForm, '1500' );
	}
}

function makeAuth()
{
	if ( !forgot ) {
		document.login.submit();
	}
	else {
		send_forgot_password( document.login.login.value );
	}
}

function showSetPasswordForm()
{
	$( 'generate_password' ).value = 0;

	$( 'cp' ).style.display = 'none';
	$( 'gp' ).style.display = '';
	$( 'temp_password_form' ).style.display = 'none';
	$( 'set_password_form' ).style.display = '';
	$( 'temp_password_text' ).style.display = 'none';
	$( 'set_password_text' ).style.display = '';
}

function hideSetPasswordForm()
{
	$( 'generate_password' ).value = 1;

	$( 'cp' ).style.display = '';
	$( 'gp' ).style.display = 'none';
	$( 'temp_password_form' ).style.display = '';
	$( 'set_password_form' ).style.display = 'none';
	$( 'temp_password_text' ).style.display = '';
	$( 'set_password_text' ).style.display = 'none';
}
//---------------------------------------------------------------------------}}}
//{{{ openImage
/**
 * показывает картинку в новом popup-окне
 * Лучше всего задавать высоту и ширину в параметрах. Усли этого не делать, то
 * размеры картинки будут определены автоматически, однако при этом window.open в
 * таком случае будет вызван из обработчика события onload и popup-блокировщик
 * не сочтёт это "нежелательным popup'ом"
 * @param string img_url урл картинки
 * @param int width ширина картинки
 * @param int height высота картинки
 */
function openImage(img_url,width,height)
{
	function showIm()
	{
		var wnd = open('','_blank','height='+im.height+',width='+im.width+',toolbar=no,titlebar=no,scrollbars=no,menubar=no,resizable=no,status=no' );
		wnd.document.write( '<HTML><BODY style="margin:0px"><IMG src="'+img_url+'" onload="" onclick="window.close()" style="cursor:pointer"/></BODY></HTML>' );
		wnd.document.close();
	}
	if ( width && height )
	{
		var wnd = open('','_blank','height='+height+',width='+width+',toolbar=no,titlebar=no,scrollbars=no,menubar=no,resizable=no,status=no' );
		wnd.document.write( '<HTML><BODY style="margin:0px"><IMG src="'+img_url+'" onload="" onclick="window.close()" style="cursor:pointer"/></BODY></HTML>' );
		wnd.document.close();
	}
	else
	{
		var im = new Image();
		im.onload = showIm;
		im.src = img_url;
	}
}
function FormAction(FormName,FormAction){
	document.forms[FormName].action = FormAction;
	document.forms[FormName].submit();
}

var pw;
var strg;
var was=false;
function ow(filename,ww,hh,name)
{
	if(was && (!pw.closed)) pw.close();
	strg="height="+hh+"px,width="+ww+"px,toolbar=no,menubar=no,location=no,status=yes,directories=no,xcenter=yes,ycenter=yes,dependent=yes,resizable=1,scrollbars=1'";
	pw=window.open(filename, "zoom", strg);
	if(!was) was=true;
}
function goto_credit(tovar_cod) {
  url='http://www.creditonline.com.ua/comfort_credit/order/type/comfort?partner=2997615013.1&order='+tovar_cod+'&soap_cart_url=http://www.sis-tema.com.ua/include/credit/soapik_tovar.php';
  credit_window=window.open(url,"credit_window","toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=900,height=500,screenX=150,screenY=150,top=50,left=50");
}

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=setTimeout(hidetip,5000);
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

var old_tooltip_id = 'i1';

function getposOffset(overlay, offsettype) {

    var totaloffset = (offsettype == 'left') ? (overlay.offsetLeft) : (overlay.offsetTop + 13);
    var parentEl = overlay.offsetParent;
    while (parentEl != null) {

	totaloffset = (offsettype == 'left') ? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;
	parentEl = parentEl.offsetParent;
    }
    return totaloffset;
}

function overlay(curobj, subobj) {

//    overlayclose(old_tooltip_id);
    old_tooltip_id = subobj;
    if (document.getElementById) {

	var subobj = document.getElementById(subobj);
	subobj.style.left = getposOffset(curobj, 'left') + 'px';
	subobj.style.top = getposOffset(curobj, 'top') + 'px';
	subobj.style.display = 'block';
	return false
    } else
	return true
}

function overlayclose(subobj) {

    document.getElementById(subobj).style.display = 'none';
}

// Patterns
var formValidationMasks = new Array();
formValidationMasks['email'] = /\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/gi;	// Email
formValidationMasks['numeric'] = /^[0-9]+$/gi;	// Numeric
formValidationMasks['zip'] = /^[0-9]{5}\-[0-9]{4}$/gi;	// Numeric

var formElementArray = new Array();

/* These two event functions are from http://ejohn.org/apps/jselect/event.html */

function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
}
function removeEvent( obj, type, fn ) {
  if ( obj.detachEvent ) {
    obj.detachEvent( 'on'+type, obj[type+fn] );
    obj[type+fn] = null;
  } else
    obj.removeEventListener( type, fn, false );
}

function validateInput(e,inputObj)
{
	if(!inputObj)inputObj = this;
	var inputValidates = true;

	if(formElementArray[inputObj.name]['required'] && inputObj.tagName=='INPUT' && inputObj.value.length==0)inputValidates = false;
	if(formElementArray[inputObj.name]['required'] && inputObj.tagName=='SELECT' && inputObj.selectedIndex==0){
		inputValidates = false;
	}
	if(formElementArray[inputObj.name]['mask'] && !inputObj.value.match(formValidationMasks[formElementArray[inputObj.name]['mask']]))inputValidates = false;

	if(formElementArray[inputObj.name]['freemask']){
		var tmpMask = formElementArray[inputObj.name]['freemask'];
		tmpMask = tmpMask.replace(/-/g,'\\-');
		tmpMask = tmpMask.replace(/S/g,'[A-Z]');
		tmpMask = tmpMask.replace(/N/g,'[0-9]');
		tmpMask = eval("/^" + tmpMask + "$/gi");
		if(!inputObj.value.match(tmpMask))inputValidates = false
	}

	if(formElementArray[inputObj.name]['regexpPattern']){
		var tmpMask = eval(formElementArray[inputObj.name]['regexpPattern']);
		if(!inputObj.value.match(tmpMask))inputValidates = false
	}
	if(!formElementArray[inputObj.name]['required'] && inputObj.value.length==0 && inputObj.tagName=='INPUT')inputValidates = true;


	if(inputValidates){
		inputObj.parentNode.className='validInput';
	}else{
		inputObj.parentNode.className='invalidInput'
	}
}

function isFormValid()
{
	var divs = document.getElementsByTagName('DIV');
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='invalidInput')return false;
	}
	return true;
}

function initFormValidation()
{
	var inputFields = document.getElementsByTagName('INPUT');
	var selectBoxes = document.getElementsByTagName('SELECT');

	var inputs = new Array();


	for(var no=0;no<inputFields.length;no++){
		inputs[inputs.length] = inputFields[no];

	}
	for(var no=0;no<selectBoxes.length;no++){
		inputs[inputs.length] = selectBoxes[no];

	}

	for(var no=0;no<inputs.length;no++){
		var className = inputs[no].parentNode.className;
		if(className && className.indexOf('validInput')>=0)continue;
		var required = inputs[no].getAttribute('required');
		if(!required)required = inputs[no].required;

		var mask = inputs[no].getAttribute('mask');
		if(!mask)mask = inputs[no].mask;

		var freemask = inputs[no].getAttribute('freemask');
		if(!freemask)freemask = inputs[no].freemask;

		var regexpPattern = inputs[no].getAttribute('regexpPattern');
		if(!regexpPattern)regexpPattern = inputs[no].regexpPattern;

		var div = document.createElement('DIV');
		div.className = 'invalidInput';
		inputs[no].parentNode.insertBefore(div,inputs[no]);
		div.appendChild(inputs[no]);
		div.style.width = inputs[no].offsetWidth + 'px';

		addEvent(inputs[no],'blur',validateInput);
		addEvent(inputs[no],'change',validateInput);
		addEvent(inputs[no],'paste',validateInput);
		addEvent(inputs[no],'keyup',validateInput);


		formElementArray[inputs[no].name] = new Array();
		formElementArray[inputs[no].name]['mask'] = mask;
		formElementArray[inputs[no].name]['freemask'] = freemask;
		formElementArray[inputs[no].name]['required'] = required;
		formElementArray[inputs[no].name]['regexpPattern'] = regexpPattern;

		validateInput(false,inputs[no]);

	}
}
var is_ie = ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );
document.onkeypress=function( event )
{
	ev = is_ie ? window.event : event;
	var keyCode = undefined == ev.which ? ev.keyCode : ev.which;
	// проверка нажатости шифта и ктрла, а также два кода клавиш - для совместимости браузеров
	if (ev.shiftKey && ( 13 == keyCode || 10 == keyCode ) ){
		location.href='/call.html';
	}
}
function valid_add_new_tovar_save(){
	var valid = 0;
	if (document.getElementById('prod_name').value != '') {valid +=1;}
	if (document.getElementById('ext_name_ru').value != '') {valid +=1;}
	if (document.getElementById('color_name').value != '') {valid +=1;}
	if (document.getElementById('brand').value != 0) {valid +=1;}
	if (valid == 4){
		document.getElementById('sbm_up').disabled = false;
		document.getElementById('sbm_down').disabled = false;
	} else {
		document.getElementById('sbm_up').disabled = true;
		document.getElementById('sbm_down').disabled = true;
	}
}
function prop_visible(class_id){
	if (document.getElementsByName('class_' + class_id)[0].style.display == ''){
		for (i = 0; i< document.getElementsByName('class_' + class_id).length; i++){
			document.getElementsByName('class_' + class_id)[i].style.display = 'none';
		}
	} else {
		for (i = 0; i< document.getElementsByName('class_' + class_id).length; i++){
			document.getElementsByName('class_' + class_id)[i].style.display = '';
		}
	}
}
function category_compare_visible (category_id){
	//alert(document.getElementById('prop_table_' + category_id).style.display);
	if (document.getElementById('prop_table_' + category_id).style.display == ''){
		document.getElementById('prop_table_' + category_id).style.display = 'none';
	} else {
		document.getElementById('prop_table_' + category_id).style.display = '';
	}
}
function edit_compare_box(action_do,tovar_id_do){
	$.ajax({
		type: "POST",
		url: "/inc/compare_cart.php",
		data: { action: action_do, tovar_id: tovar_id_do},
		success: function(data) {
			if (data != 0){
				document.getElementById('compare_box').style.display = '';
				document.getElementById('compare_box').innerHTML = data;
			} else {
				document.getElementById('compare_box').style.display = 'none';
			}
		}
	})
}

function activate_campare_button(tovar_id){
		var str = '<a style="cursor:pointer;" onClick="deactivate_campare_button('+tovar_id+'); edit_compare_box(\'add\','+tovar_id+')">Сравнить</a>';
		if (document.getElementById('cmp_' + tovar_id) != undefined) {document.getElementById('cmp_' + tovar_id).innerHTML = '<span class="compare" name="comparison_details"> <span class="sprite"><i></i></span>'+str+'</span>';}
}
function deactivate_campare_button(tovar_id){
		var cmpr = getCookie("COMPARE");
		var ptrn = /[0-9]\-[0-9]/;
		var str = 'к&nbsp;сравнению';
		if (cmpr){
			str = '<a href="/compare_products/" onClick="deactivate_campare_button('+tovar_id+'); edit_compare_box(\'add\','+tovar_id+')">к&nbsp;сравнению</a>';
		}
		document.getElementById('cmp_' + tovar_id).innerHTML = '<span class="compare" name="comparison_details"> <span class="sprite"><i></i>Добавлено </span>'+str+'</span>';
}
function delete_from_compare(tovar_id_do){
	var new_location = window.location.toString().split('?');
	$.ajax({
		type: "POST",
		url: "/inc/compare_cart.php",
		data: { action: 'delete', tovar_id: tovar_id_do},
		success: function(data) {
			window.location = new_location[0];
		}
	})
}
function hide_same_prop(){
	if(document.getElementsByClassName) {
		for (i = 0; i<document.getElementsByClassName("same").length; ++i){
			document.getElementsByClassName("same")[i].style.display = 'none';
		}
	} else {
		for (i = 0; i<$(".same").length; ++i){
			$(".same")[i].style.display = 'none';
		}
	}
	for (i = 0; i < document.getElementsByName('show_only_not_same').length; ++i){
		document.getElementsByName('show_only_not_same')[i].innerHTML = '<span style="cursor:default; background-color: #F1F8EF"><u>Только различающиеся</u></span>';
		document.getElementsByName('show_all_prop')[i].innerHTML = '<a onClick = "show_same_prop();" style="cursor:pointer;">Все характеристики</a>';
	}
	/*
	document.getElementById("show_only_not_same").innerHTML = '<span style="cursor:default; background-color: #F1F8EF"><u>Только различающиеся</u></span>';
	document.getElementById("show_all_prop").innerHTML = '<a onClick = "show_same_prop();" style="cursor:pointer;">Все характеристики</a>';
	*/
}
function show_same_prop(){
	if(document.getElementsByClassName) {
		for (i = 0; i<document.getElementsByClassName("same").length; ++i){
			document.getElementsByClassName("same")[i].style.display = '';
		}
	} else {
		for (i = 0; i<$(".same").length; ++i){
			$(".same")[i].style.display = '';
		}
	}
	for (i = 0; i < document.getElementsByName('show_only_not_same').length; ++i){
		document.getElementsByName('show_only_not_same')[i].innerHTML = '<a onClick = "hide_same_prop();" style="cursor:pointer;">Только различающиеся</a>';
		document.getElementsByName('show_all_prop')[i].innerHTML = '<span style="cursor:default; background-color: #F1F8EF"><u>Все характеристики</u></span>';
	}
	/*
	document.getElementById("show_only_not_same").innerHTML = '<a onClick = "hide_same_prop();" style="cursor:pointer;">Только различающиеся</a>';
	document.getElementById("show_all_prop").innerHTML = '<span style="cursor:default; background-color: #F1F8EF"><u>Все характеристики</u></span>';
	*/
}

function get_callback(tmyphone,tmyname,tcomment,turl,cproductid,tform ){
 //alert('In Ajax');
 document.getElementById('SubmitButtonCallbackid').disabled=true;
 $.ajax({

  type: "POST",
  url: "/inc/callbackrobot.php",
  data: "myphone=" + tmyphone + "&myname=" + tmyname + "&comment=" + tcomment +  "&turl=" + turl + "&cproductid=" + cproductid,
  success: function(msg){
  //alert(msg);
    if (msg == '-1')
    {
    	document.getElementById('messageInfoId').innerHTML = "Не указан телефон. Сообщение не было отправлено.";
    	document.getElementById('SubmitButtonCallbackid').disabled=false;
    }
    else
    {
    	if (msg == '-2')
    	{
    		document.getElementById('messageInfoId').innerHTML = "Не указано имя. Сообщение не было отправлено.";
    		document.getElementById('SubmitButtonCallbackid').disabled=false;
    	}
    	else
    	{
    		if (msg == '-3')
    		{
    			document.getElementById('messageInfoId').innerHTML = "Неверный формат номера телефона. Сообщение не было отправлено.";
    			document.getElementById('SubmitButtonCallbackid').disabled=false;
    		}
    		else
    		{
    			if (msg == '1')
    			{
    				document.getElementById('messageInfoId').innerHTML = "Сообщение успешно отправлено и будет рассмотрено нашими менеджерами в ближайшее время."
    			//	alert(document.getElementById('SubmitButtonCallbackid').enabled);
    				document.getElementById('SubmitButtonCallbackid').disabled=true;
                //    alert(document.getElementById('SubmitButtonCallbackid').enabled);
    				document.getElementById('MyphoneCallbackid').disabled=true;
    				document.getElementById('MynameCallbackid').disabled=true;
    				document.getElementById('TextareaCallbackid').disabled=true;

					setTimeout('$(".callback_div_class").animate({ opacity: "hide" }, "slow");',5000);

    			}
    		}

    	}
    }
   //alert(msg);
  }
});
}
function fs_category_change(){
	var category_id_do = document.getElementById('fs_category_id').value;
	$.ajax({
		type: "POST",
		url: "/inc/ajax/fs_category.php",
		data: { category_id: category_id_do},
		success: function(data) {
			if (data != 0){
				$('#fs_brand_id').html(data);
				$('#fs_tovars').html('<option value="0" disabled>Выберите бренд...</option>');
			}
		}
	})
}
function fs_brand_change(){
	var category_id_do = document.getElementById('fs_category_id').value;
	var brand_id_do = document.getElementById('fs_brand_id').value;
	$.ajax({
		type: "POST",
		url: "/inc/ajax/fs_brand.php",
		data: { category_id: category_id_do, brand_id: brand_id_do},
		success: function(data) {
			if (data != 0){
				$('#fs_tovars').html(data);
			}
		}
	})
}
function fs_tovar_select(){
	var tovar_id_do = document.getElementById('fs_tovars').value;
	$.ajax({
		type: "POST",
		url: "/inc/ajax/fs_tovar.php",
		data: { tovar_id: tovar_id_do},
		success: function(data) {
			if (data != 0){
				document.location = data;
			}
		}
	})
}
function fs_show(category_id_do,brand_id_do){
	//alert(category_id_do + ' ' + brand_id_do);
	if (category_id_do != undefined){
		$('#fs_category_id').val(category_id_do);
		$.ajax({
			type: "POST",
			url: "/inc/ajax/fs_category.php",
			data: { category_id: category_id_do},
			success: function(data) {
				if (data != 0){
					$('#fs_brand_id').html(data);
					$('#fs_tovars').html('<option value="0" disabled>Выберите бренд...</option>');
					if (brand_id_do != undefined){
						$('#fs_brand_id').val(brand_id_do);
							$.ajax({
								type: "POST",
								url: "/inc/ajax/fs_brand.php",
								data: { category_id: category_id_do, brand_id: brand_id_do},
								success: function(data) {
									if (data != 0){
										$('#fs_tovars').html(data);
									}
								}
							})
					}
				}
			}
		})
	}
	$("#fast_select").animate({ opacity: "show" }, "slow");
}
function fs_close(){
	$("#fast_select").animate({ opacity: "hide" }, "slow");
}
function show_fs_compare(category_id_do,category_name){
	$('#category_name_compare').html('Категория: ' + category_name);
	$('#fs_category_id_compare').val(category_id_do);
	$.ajax({
		type: "POST",
		url: "/inc/ajax/fs_category.php",
		data: { category_id: category_id_do},
		success: function(data) {
			if (data != 0){
				$('#fs_brand_id_compare').html(data);
				$('#fs_tovars_compare').html('<option value="0" disabled>Выберите бренд...</option>');
			}
		}
	})
	$("#fast_select_compare").animate({ opacity: "show" }, "slow");
}

function fs_close_compare(){
	$("#fast_select_compare").animate({ opacity: "hide" }, "slow");
}
function fs_brand_change_compare(){
	var category_id_do = $('#fs_category_id_compare').val();
	var brand_id_do = $('#fs_brand_id_compare').val();
	$.ajax({
		type: "POST",
		url: "/inc/ajax/fs_brand.php",
		data: { category_id: category_id_do, brand_id: brand_id_do},
		success: function(data) {
			if (data != 0){
				$('#fs_tovars_compare').html(data);
			}
		}
	})
}
function fs_tovar_select_compare(){
	var tovar_id_do = $('#fs_tovars_compare').val();
	$.ajax({
		type: "POST",
		url: "/inc/compare_cart.php",
		data: { action: 'add', tovar_id: tovar_id_do},
		success: function(data) {
			if (data != 0) {
				var new_location = window.location.toString().split('?');
				window.location = new_location[0];
			}
		}
	})
}