function addone2(qt){
    var num;
    if ((qt.value=='') || (isNaN(qt.value))){
    qt.value=1;
    qt.select();
    return }
else{
    qt.value++;
    qt.select()
    }
}

function minusone(qt){
   if (!isNaN(qt.value) && qt.value>1) qt.value--;
   else qt.value=''; qt.select();return false;
 }

function isNetscape(){
  if (navigator.appName == "Netscape") {
    return true
  }else{
    return false
  }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

if (isNetscape()) {
  layerRef="document.layers";
  styleSwitch="";
  netscape=1;
}else{
  layerRef="document.all";
  styleSwitch=".style";
  netscape=0;
}
$(function(){ // Dialog
 $('#comment_dialog').dialog({
	autoOpen: false,
	width: 430,
	resizable: false,
	buttons: {
	"Добавить комментарий": function() {
		var comment_name=$("#comment_name").val();
		var comment_email=$("#comment_email").val();
		var comment_text=$("#comment_text").val();
		var code=$("#code").val();
		var antispam_code=$("input[name=antispam_code]").val();
		var user_vote=$('input[name="user_vote"]:checked').val();
		var comment_url=$("#comment_url").val();
		if(comment_name=='') { $("#comment_name").focus();alert('Пожалуйста введите имя.');return false; }
		if(comment_email=='') {$("#comment_email").focus(); alert('Пожалуйста введите емайл.');return false; }
		if(user_vote!=1 && user_vote!=2 && user_vote!=3 && user_vote!=4 && user_vote!=5) { $("input[name=user_vote]").focus();alert('Пожалуйста поставьте Вашу оценку.');return false; }
		if(comment_text=='') { $("#comment_text").focus();alert('Пожалуйста введите комментарий.');return false; }
		if(code=='') { $("#code").focus();alert('Пожалуйста введите цифровой код.');return false; }
		$(this).dialog("close");
        $('#comment_dialog').load("/img/user_comment_add.php", {comment_name:comment_name, comment_email:comment_email, comment_text:comment_text, code:code, save:1, antispam_code:antispam_code,comment_url:comment_url,user_vote:user_vote}, function() {
			 alert('Спасибо '+comment_name+', Ваш комментарий успешно добавлен.\nПосле проверки администратором он будет опубликован.');
		     });
			},
	"Закрыть": function() {
		$(this).dialog("close");
		}
	}
});

 $('#dialog_link').click(function(){
 var comment_url1=$("#comment_url").val();
 $('#comment_dialog').load("/img/user_comment_add.php", {comment_url: comment_url1}, function() {
   $('#comment_dialog').dialog('open');
    });
	return false;
 });
});

