function TestCode(e)
{
	var str1;
	var keychar;
	var numcheck;

	if(window.event) // IE
	{
		str1 = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		str1 = e.which;
	}
	//keychar = String.fromCharCode(keynum);
	if(str1==13){

		//alert(document.frm1.feedback_btn1.type);
		document.frm1.feedback_btn1.click(false);

	}
}



function SendFeedBack(){
 
    var x_tail;
    if(document.frm1.feedback_contact.value.length<=0)
        {alert("Введите контактные данные"); return; }
    if(document.frm1.feedback_message.value.length<=0)
        {alert("Введите сообщение"); return; }
    if(document.frm1.security_code.value.length<=0)
        {alert("Введите код"); return; }
    var x=document.frm1.feedback_contact.value;
    var y=document.frm1.feedback_message.value;
    var z=document.frm1.security_code.value;

    if(x.length>250){x=x.slice(0,249);}
    if(y.length>1000){y=y.slice(0,999); }

    x_tail="&regime=site&feedback_contact="+x+"&feedback_message=" +y+"&security_code="+z;
    var div_msg = document.getElementById("feedback_msg");
    div_msg.innerHTML = "<img src='./img/ajax1.gif'>&nbsp;&nbsp;Ждите! Идет отправка сообщения ...";
    ajaxFunction("div_feedback","module/mini_module_feedback_read_ajax.php","feedback_flag_select=send"+x_tail);
	
}

function ReCalc(){
    var x_value=getCookie("order_new");
    var x_tail='';
    if(x_value !=null){
          if(x_value.length>0){
          //вычисляем хвост
             var x_arr=x_value.split('x');
                for(i = 1; i < x_arr.length; i++){
                  x_tail=x_tail + "&shop_sel" + x_arr[i]  + "=" + document.frm1.elements["shop_sel"+x_arr[i]].value
                        + "&shop_contact="+ document.frm1.shop_contact.value+"&article_id=" + document.frm1.article_id.value;
                }
        }
    }
    //alert(x_tail);
   ajaxFunction("div_order","module/mini_module_basket_read_ajax.php","shop_flag_select=init"+x_tail);
}

function MakeOrder(){
    var x_value=getCookie("order_new");
    var x_tail='';
    if(x_value !=null){
          if(x_value.length>0){
          //вычисляем хвост
             var x_arr=x_value.split('x');
                for(i = 1; i < x_arr.length; i++){
                  x_tail=x_tail + "&shop_sel" + x_arr[i]  + "=" + document.frm1.elements["shop_sel"+x_arr[i]].value;
                }
         }
    }else{alert("Корзина заказа пуста."); return}

    if(document.frm1.shop_contact.value.length<=0){
        alert("Укажите контактную информацию."); return}

   if(document.frm1.shop_contact.value.length>1000)
      document.frm1.shop_contact.value=document.frm1.shop_contact.value.slice(0,999);

   x_tail=x_tail+"&shop_contact=" + document.frm1.shop_contact.value+"&article_id=" + document.frm1.article_id.value;
   ajaxFunction("div_order1","module/mini_module_basket_read_ajax.php","shop_flag_select=make"+x_tail);
}

function delCookie(){
  var date=new Date();
  date.setTime(date.getTime()-24*60*60*1000);
  var expires="; expires="+date.toGMTString();
  var cookie_name="order_new"; 
  document.cookie=cookie_name +"="+ "" + expires;

}

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));
      setStr = cookie.substring(offset, end);
    }
  }
  return(setStr);
}



function setCookie(z)
{
  
  var date=new Date();
  date.setTime(date.getTime()-24*60*60*1000);
  var expires="; expires="+date.toGMTString();
  //expires=";";
  //alert(date.getTime());
  
  //alert(date.toGMTString());
  var cookie_name="order_new";
  if(document.frm1.elements["chk"+z].checked==true)
  {
    var results = document.cookie.match ( cookie_name + "=(.*?)(;|$)" );
    //alert(results);
    if (results){
      var cookie_value = getCookie(cookie_name);
      document.cookie=cookie_name + "=" + cookie_value  + "x" +z ;

    }else{
      document.cookie=cookie_name + "=" + "x" +z ;

    }
     //alert(document.cookie);
    
  }else{
  
    var results = document.cookie.match ( cookie_name + "=(.*?)(;|$)" );
    if (results){
      var cookie_value = getCookie(cookie_name);
      document.cookie=cookie_name + "=" + cookie_value.replace("x" +z,"") ;
      }
  }
  //alert(document.cookie);
}

function setCookieFromBasket(z)
{
  var date=new Date();
  date.setTime(date.getTime()-24*60*60*1000);
  var expires="; expires="+date.toGMTString();
  //expires=";";
  //alert(date.getTime());
  
  //alert(date.toGMTString());
  var cookie_name="order_new";
  if(document.frm1.elements["chk" + z].checked==true)
  {
    var results = document.cookie.match ( cookie_name + "=(.*?)(;|$)" );
    //alert(results);
    if (results){
      var cookie_value = getCookie(cookie_name);
      document.cookie=cookie_name + "=" + cookie_value  + "x" +z ;

    }else{
      document.cookie=cookie_name + "=" + "x" +z ;

    }
      //alert(document.cookie);
    
  }else{
  
    var results = document.cookie.match ( cookie_name + "=(.*?)(;|$)" );
    if (results){
      var cookie_value = getCookie(cookie_name);
      document.cookie=cookie_name + "=" + cookie_value.replace("x" +z,"") ;
      }
  }
  //alert(document.cookie);  

}


function TestCheck(z){
 //alert(z);
  var cookie_name="order_new";
  var results = document.cookie.match ( cookie_name + "=(.*?)(;|$)" );
  if (results){
    var cookie_value = getCookie(cookie_name);
    if (cookie_value.length > 0){
      //alert(document.cookie);
      if(cookie_value.indexOf("x" +z)!=-1){
      //alert("x" +z);
      document.frm1.elements["chk"+z].checked=true;
      }
    }
  }
}

 var popbackground="#ffffff"  //specify backcolor or background image for pop window
var windowtitle=""  //pop window title

function detectexist(obj){
return (typeof obj !="undefined")
}

function jkpopimage(imgpath, popwidth, popheight, textdescription){

function getpos(){
leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
if (window.opera){
leftpos-=screenLeft
toppos-=screenTop
}
}

getpos()
var winattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+leftpos+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
if (typeof jkpopwin=="undefined" || jkpopwin.closed)
jkpopwin=window.open("","",winattributes)
else{
//getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
//jkpopwin.moveTo(leftpos, toppos)
jkpopwin.resizeTo(popwidth, popheight+40)
}
jkpopwin.document.open()
jkpopwin.document.write('<html><title>'+windowtitle+'</title><body '+bodyattribute+' style="margin: 2px; padding: 0;"><img src="'+imgpath+'" style="margin-bottom: 0.5em"><br><div style="margin: 0 11px; font-size: .8em; line-height: 1.1; font-family: verdana, arial, helvetica, sans-serif; color: #000;">'+textdescription+'</div></body></html>')
jkpopwin.document.close()
jkpopwin.focus()
}
////////////////////////////////////////////////////////////
function AddBasket(z){
 var date=new Date();
  date.setTime(date.getTime()-24*60*60*1000);
  var expires="; expires="+date.toGMTString();
  //expires=";";
  //alert(date.getTime());
  
  //alert(date.toGMTString());
  var cookie_name="order_new";
  var x_value=getCookie(cookie_name);
  //Проверка корзины
  var z1=z;

  var item_id= "x" +z1 ;

  //alert(document.cookie);
  //alert(item_id);

  if(x_value!=null){
      if(x_value.indexOf(item_id)==-1)
      {
                var results = document.cookie.match ( cookie_name + "=(.*?)(;|$)" );
                //alert(results);
                if (results){
                  var cookie_value = getCookie(cookie_name);
                  document.cookie=cookie_name + "=" + cookie_value  + "x" +z1 ;

                }else{
                  document.cookie=cookie_name + "=" + "x" +z1 ;

                }
                 //alert(document.cookie);
                 alert("Товар добавлен в корзину заказов");
                 return false;
      }else{

               //alert(document.cookie);
               alert("Этот товар уже в Вашей корзине");}
               return false;

  }else{

                var results = document.cookie.match ( cookie_name + "=(.*?)(;|$)" );
                //alert(results);
                if (results){
                  var cookie_value = getCookie(cookie_name);
                  document.cookie=cookie_name + "=" + cookie_value  + "x" +z1 ;

                }else{
                  document.cookie=cookie_name + "=" + "x" +z1 ;

                }
                 //alert(document.cookie);
                 alert("Товар добавлен в корзину заказов");
                 return false;


   }
}


function ViewBasket(){
         document.location.href="index.php?flag_show_basket=1";
}
/////////////////////////////////////////////////////////////////////////////////////////


