$(document).ready(function() { 

// malsup.com/jquery/form/#code-samples
    var options = { 
        target:     '#form_echo',   // target element(s) to be updated with server response 
        type:      'post'
    }; 
 
    // bind to the form's submit event 
    $('#info_form').submit(function() { 
        $(this).ajaxSubmit(options); 
        return false; 
    }); 
    
    var options2 = { 
        target:     '#form_echo_pass',   // target element(s) to be updated with server response 
        type:      'post'
    }; 
 
    // bind to the form's submit event 
    $('#info_form_pass').submit(function() { 
        $(this).ajaxSubmit(options2); 
        return false; 
    }); 
      
    
    var options3 = { 
        target:     '#form_echo_pass',   // target element(s) to be updated with server response 
        type:      'post'
    }; 
     
    // bind to the form's submit event 
    $('#reset_password').submit(function() { 
        $(this).ajaxSubmit(options3); 
        return false; 
     }); 
     
     var options4 = { 
        target:     '#form_echo_pass',   // target element(s) to be updated with server response 
        type:      'post'
    }; 
     
    // bind to the form's submit event 
    $('#ni_form').submit(function() { 
        $(this).ajaxSubmit(options4); 
        return false; 
     });
     
     
           
    
    jQuery("#box_izdelki_vsi .pagination a").css("cursor", "pointer").click(function () {
    jQuery.get("/include/ajax_pagination.php", { page: jQuery(this).attr("title")},
      function(data){
          jQuery("#box_izdelki_vsi").html(data);
      });
    });
    
    jQuery("#box_izdelki_vsi_akcije .pagination2 a").css("cursor", "pointer").click(function () {
    jQuery.get("/include/ajax_pagination_akcije.php", { page: jQuery(this).attr("title")},
      function(data){
          jQuery("#box_izdelki_vsi_akcije").html(data);
      });
    });
    
    jQuery("#box_izdelki_vsi_kz .pagination3 a").css("cursor", "pointer").click(function () {
    jQuery.get("/include/ajax_pagination_kz.php", { page: jQuery(this).attr("title")},
      function(data){
          jQuery("#box_izdelki_vsi_kz").html(data);
      });
    });
    
    jQuery("#box_izdelki_vsi_darilni_katalog .pagination4 a").css("cursor", "pointer").click(function () {
        jQuery.get("/include/ajax_pagination_dk.php", { page: jQuery(this).attr("title")},
          function(data){
              jQuery("#box_izdelki_vsi_darilni_katalog").html(data);
          });
        });
   /*     
    jQuery("#strinjamSplosniPogoji").click(function () {
    jQuery.get("/include/ajax/potrdi_splosne_pogoje.php", { page: jQuery(this).attr("title")},
      function(data){
          jQuery("#komentarji").html(data);
      });
    });*/
    
    jQuery(".additemIzbor a").css("cursor", "pointer").click(function () {
    jQuery.get("/include/ajax.add_item.php", { item_id: jQuery(this).attr("rel")},
      function(data){
          jQuery("#kosarica_items").html(data);
      });
    }); 
    
    jQuery(".additemAI a").css("cursor", "pointer").click(function () {
    jQuery.get("/include/ajax.add_item.php", { item_id: jQuery(this).attr("rel")},
      function(data){
          jQuery("#kosarica_items").html(data);
      });
    });

//autocomplete
  	$("#kraj").autocomplete(cities, {
  		matchContains: true,
		minChars: 0
  	});
  	/*
  	$("#postna_st").autocomplete(postne_st, {
  		matchContains: true,
		minChars: 0
  	});*/
    
}); 

function checkPwd(){
  p1 = document.getElementById("pass1");
  p2 = document.getElementById("pass2");
  err1 = document.getElementById('err_pwd1');
  err2 = document.getElementById('err_pwd2');
  color1 = "#FFFFFF";
  color2 = "#FFE6E6";  
  var str_len1 = checkLenght("pass1");
  var str_len2 = checkLenght("pass2");
  min_pwd_len = 6;

  if(str_len1 < min_pwd_len){
    p1.style.backgroundColor = color2;
    err1.innerHTML ='(min 6 znakov)';
    if(str_len2 > 0){
    err2.innerHTML ='Ponovi geslo:';
    p2.style.backgroundColor = color2;    
    }
  }
  else{
    p1.style.backgroundColor = color1;
    err1.innerHTML ='';
    p2.style.backgroundColor = color1;
    if(str_len2 > 0){
      if(p1.value != p2.value) {
      p2.style.backgroundColor = color2;
      err2.innerHTML ='Geslo se ne ujema! Ponovi geslo:';
      }
      else {
      p2.style.backgroundColor = color1;
      err2.innerHTML ='Geslo se ujema.';
      }
    }
  }
}

function checkLenght(x){
  var string = document.getElementById(x).value;
  return string.length;
}

var testresults
function checkemail(){
var str=document.getElementById("enaslov").value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str)){
testresults=true;
document.getElementById("enaslov").style.backgroundColor = "#FFFFFF";
}
else{
document.getElementById("enaslov").style.backgroundColor = "#FFE6E6";
testresults=false;
}
return (testresults)
}

function checkbae(){
if (document.layers||document.getElementById||document.all)
return checkemail();
else{
return true
}
}