function onFormSubm()
{
	var path='/catalog/'+$('#dVName').val()+'/'+$('#dPage').val()+'/'+$('#dShow').val()+'/'+$('#dSort').val()+'/';
	//alert(path);
	window.location=path;
	return false;
}


function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}
 
function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 9 >= b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}

//Поиск
function showSrh()
{
	$("#shr_p1").hide();
	$(".shr_p2").fadeIn("slow");
}
function hideSrh()
{
    $("#shr_p1").show();
    $(".shr_p2").fadeOut("slow");
for(var i=33; i<=55; ++i)
{
	if(document.forms.search.elements[i].type=='checkbox')
	{
		document.forms.search.elements[i].checked=false;
	}else if(document.forms.search.elements[i].type=='text')
	{
		document.forms.search.elements[i].value='';	
	}
}
	
}


//Прайсы
function counter( a , p )
{
    $.get("/redirect.html", { a: a, p: p } );
}
function showCommentForm( phoneId )
{
$.get("/ajax/addComment.php", { phoneId : phoneId },
  function(data){
    $("#addComment").html(data);
    $(".add_bot").hide();
    $(".add_hide").show();
  });
}
function hideCommentForm()
{
    $(".add_bot").show();
    $(".add_hide").hide();
    $("#addComment").html('');
}

function showMistakeForm( phoneId )
{
$.get("/ajax/addMistake.php", { phoneId : phoneId },
  function(data){
    $("#addMistake").html(data);
  });
}


// Сравнение
$(document).ready(
function ()
{
    $("#LcmpFF").change(function (){
        changeModel( $(this).val() , $("#LcmpFM") );
    });
    $("#LcmpSF").change(function (){
        changeModel( $(this).val() , $("#LcmpSM") );
    });
});
function changeModel( vendorId , selObj )
{
    $.get("/ajax/compare.php",{ vendorId: vendorId }, function(data){
      selObj.html(data);
    });
}



// Выбор в блоке поиска по словам
$(document).ready(
function ()
{
    $("#selM").change(function (){
        changeSelectModel( $(this).val() , $("#selS") );
    });
    $("#selS").change(function (){
        changeSelectUrl( $(this).val() );
    });
});
function changeSelectModel( vendorId , selObj , phoneId )
{
    $.get("/ajax/select.php",{ vendorId: vendorId , phoneId: phoneId }, function(data){
      selObj.html(data);
    });
}
function changeSelectUrl( phoneRewUrl )
{
    window.location.href = '/phone/'+phoneRewUrl+'.html';
}


// СМС
function chengeSMSLen()
{
   var text=$("#SMSText").val();
   
   if($('#SMSLeght').val() == '')
   {
      $("#SMSLeght").val(70);
   }
   var limit = $("#SMSLeght").val();
   
   if(text.length > limit )
   {
      $("#SMSText").val( text.substring(0,limit) );
      $("#SMSTextLeght").html( '0' );
   }
   else
   {
      $("#SMSTextLeght").html( limit-text.length ); 
   }
}
