   function showloading(){
 	  document.getElementById('showloading').style.display = "block";
   }

   function hideloading(){
 	  document.getElementById('showloading').style.display = "none";
   }

function checklogin(form){
	if (document.getElementById('RequestLogin').value == "") {
		alert("Login / email väli tühi");
		return false;
	}
  SendNewPass(form);
return true;
}
 
function checkloginform(form) {

	if (form.Login.value == "") {
		alert("Login väli tühi");
		form.Login.focus();
		return false;
	}

return true;
}



function checkregform2 (form) {
	if (form.Name.value == "") {
		alert("Nimi märkimata");
		form.Name.focus();
		return false;
	}


	if (form.Epost.value == "") {
		alert("E-post märkimata");
		form.Epost.focus();
		return false;
	}

	if (form.Password1.value != form.Password2.value) {
		alert("Paroolid ei klapi");
		form.Password1.focus();
		return false;
	}

return true;

}


function checktag(form) {
	if (form.NameIn.value == "") {
		alert("Tühi nimetus");
		form.Name.focus();
		return false;
	}
//  addTag();
return false;
}

  function showdiv(name){

	  document.getElementById(name).style.display = "block";
  }
  function hidediv(name){
	  document.getElementById(name).style.display = "none";
  }

$(document).ready(function() {

    var options = {
//       target:        '#upmenu',   // target element(s) to be updated with server response
        success:       showResponse  // post-submit callback
    };

    // bind to the form's submit event
        $('#newuserform').submit(function() {
        $(this).ajaxSubmit(options);
        return false;
    });

        $('#login_form').submit(function() {
        $(this).ajaxSubmit(options);
        return false;
    });

});

// pre-submit callback
function showRequest(formData, jqForm, options) {
    var queryString = $.param(formData);
    return true;
}


// post-submit callback
function showResponse(responseText, statusText)  {
    if (responseText == 'Kasutaja loodud'){
        alert(responseText);
    }
    window.location=SiteUrl;
    
}

function ajax_request(ProductID){

    $.ajax({
       type: "POST",
       url: "src/product.php",
       data: "op=AddProduct&ProductID=" + ProductID,
       success: function(msg){
        message = msg.split("|");
        if (message[1] != ''){
            alert(message[1]);
        }
       }
     });
}

function DelShop(ID){
   alert('asd');
    $.ajax({
       type: "POST",
       url: "src/shop.php",
       data: "op=Remove&ProductID="+ID,
       success: function(msg){
        message = msg.split("|");
        if (message[1] != ''){
            document.getElementById("ShopTable").innerHTML = message[1];
        }
       }
     });

}
function SendShop(){

    $.ajax({
       type: "POST",
       url: "src/shop.php",
       data: "op=Cart",
       success: function(msg){
        message = msg.split("|");
          if (message[1] != undefined){
                alert(message[1]);
                window.location.reload(); return false;
          }else{
                alert('Meil juhtus õnnetus. Anna andeks ja anna meile sellest teada.');
          }
       }
     });

}


