
function visFelter(valg) {
   document.getElementById("startslutt").style.display="none";
   document.getElementById("brodtekst").style.display="none";
  if (valg==63) {
      document.getElementById("startslutt").style.display="block";
   }
  if (valg==9 || valg==75 || valg==33) {
      document.getElementById("brodtekst").style.display="block";
   }
}


function leggikurv(pid) {
 var antall=jQuery("#antall"+pid).attr("value");
	if (parseInt(antall)<1) antall=1;
 jQuery.ajax({
  type: "GET",
  url: "tom.php",
  dataType: "html",
  contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
  data: "prod=tilkurv&pid="+pid+"&ant="+antall,
  success: function(response){
   $("#kurv").html(response);
	alert("Varen er lagt i handlekurven.");
  },
  error: function(){
   alert("Error occured during Ajax request...");
  }
 });
} // END OF FormAjaxStuff()


function visBilder() {
 var id=jQuery("#aid").attr("value");
 jQuery.ajax({
  type: "GET",
  url: "tom.php",
  dataType: "html",
  contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
  data: "innlegg=list_bilder&aid="+id,
  success: function(response){
   $("#bildene").html(response);
  },
  error: function(){
   alert("Error occured during Ajax request...");
  }
 });
} // END OF FormAjaxStuff()



function ajaxFileUpload() {
//starting setting some animation when the ajax starts and completes
	$("#loading")
		.ajaxStart(function(){
   		$(this).show();
		})
		.ajaxComplete(function(){
			$(this).hide();
		});
       
/*
prepareing ajax file upload
	url: the url of script file handling the uploaded files
	fileElementId: the file type of input element id and it will be the index of  $_FILES Array()
	dataType: it support json, xml
	secureuri:use secure protocol
	success: call back function when the ajax complete
	error: callback function when the ajax failed
*/
$.ajaxFileUpload
	(
		{
			url:'tom.php?innlegg=lagrefil',
			secureuri:false,
			fileElementId:'fileToUpload',
			dataType: 'json',
			success: function (data, status) {
	                    if(typeof(data.error) != 'undefined') {
	                        if(data.error != '') {
	                        	alert(data.error);
	                        } else {
                              visBilder();
                        	}
                    		}
		                },
      		          error: function (data, status, e) {
                    		alert(e);
		                }
   			      }
		)
  return false;

}  


