      function showHide(id) {
        
            obj = document.getElementById(id);
            obj.style.display = (obj.style.display == "block" ? "none" : "block");
      }
      
		function changeState(id) {
		
				obj = document.getElementById(id);
				document.getElementById(id).value = (obj.value == "open" ? "close" : "open");
		}
		
		function openBox(id) {
		
				obj = document.getElementById(id);
				if (obj.style.display == "none") 
				{
					obj.style.display = "inline";
				}
		}
		         
      function demo3(id, unique_id, p) {
        
            advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "<div class=\"loadingContainer\"><div>Loading...</div></div>"; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/tab.php?id="+id+"&unique_id="+unique_id+"&p="+p, tag: id+unique_id+"_tab" });
            advAJAX.setDefaultParameters({});
      }

      function ga_load(div_id) {
        
            advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "<div class=\"loadingContainer\" style=\"width: 220px; margin: 0 auto;\"><div style=\"text-align: center\">Gathering data from Google Analytics<br/>Please wait...</div></div>"; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText;},
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/inc_site/ga.php", tag: div_id });
            advAJAX.setDefaultParameters({});
      }
		
		function cartupdate(id, action, unique_id) 
		{
			 var amount = document.getElementById("ilosc"+id).value;
			 var add_var = document.getElementById("add_var_"+id).value;
			 var buy_options = document.getElementById("c_op_ins_"+unique_id).value;
			 var buy_options_text = document.getElementById("c_op_ins_text_"+unique_id).value;
			 
		    advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; updateCartComponent(); },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
			advAJAX.get({ url: "/cart.php?ident="+id+"&amount="+amount+"&action="+action+"&add_var="+encodeURIComponent(add_var)+"&buy_options="+encodeURIComponent(buy_options)+"&buy_options_text="+encodeURIComponent(buy_options_text), tag: "shoppingCart" });
			advAJAX.setDefaultParameters({});
			
      }
		
		function infoAlbumUpdate(prodId) {
		    advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
			advAJAX.get({ url: "/cart.php?action=infoalbum&prodId="+prodId, tag: "infoalbumClipboard" });
			advAJAX.setDefaultParameters({});
      }	
				
	   function loadPic(gid, ext, unique, module, prod_id) {	
        
            advAJAX.setDefaultParameters({
               onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
					onSuccess : function(obj) { 
				    	document.getElementById(obj.tag).innerHTML = obj.responseText; 
				  }
            });
            advAJAX.get({ url: "/inc/changePic.php?gid="+gid+"&ext="+ext+"&module="+module+"&unique="+unique+"&prod_id="+prod_id, tag: "g"+unique });
            advAJAX.setDefaultParameters({});
      }			
		
      function gallery(gallery, st) {
        
            advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "<img src=/img/mobileshop/loader.gif alt='Loading...' title='Loading...'>"; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/include/gallery.php?gallery="+gallery+"&st="+st, tag: "gallery_box" });
            advAJAX.setDefaultParameters({});
      }		
				
	   function galleryCategoryList(picId, catId, page) {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById("categoryList").innerHTML = "Loading"; },
              onSuccess : function(obj) { document.getElementById("categoryList").innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/galleryCategoryList.php?picId="+picId+"&catId="+catId+"&page="+page });
            advAJAX.setDefaultParameters({});
      }		
		
	   function changeText(picId) {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById("categoryList").innerHTML = "Loading"; },
              onSuccess : function(obj) { document.getElementById("categoryList").innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/galleryCategoryList.php?picId="+picId+"&catId="+catId+"&page="+page });
            advAJAX.setDefaultParameters({});
      }	
		
	   function maillist(mail,sname) {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById("maillist").innerHTML = "Loading"; },
              onSuccess : function(obj) { document.getElementById("maillist").innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/mailing.php?mail="+mail+"&sname="+encodeURIComponent(sname) });
            advAJAX.setDefaultParameters({});
      }	
		
	   function sendMail(message_id, groups) {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById("inputBox").innerHTML = " <img src=/img/ajax-loader.gif border=0>"; },
              onSuccess : function(obj) { document.getElementById("inputBox").innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/sendMail.php?message_id="+message_id+"&groups="+groups });
            advAJAX.setDefaultParameters({});
      }
 
	   function addComment(uid, id, module, div, page) {
			 
			 var sname="sname"+uid;
			 var string="string"+uid;
			 var text="text"+uid;
			 var form_data="form_data"+uid;
		 	 var uid="message"+uid;
		 	 //var page="page"+page
		 				 
			 document.getElementById(uid).innerHTML = "Loading... <img src=/img/ajax-loader.gif border=0>";
			 
			 if (document.getElementById(text)) {
			 	var checkedText = document.getElementById(text).value;
			 } else {
			 	var checkedText = "";
			 }
			 
			 if (document.getElementById(form_data)) {
			 	var checkedUpl = document.getElementById(form_data);
			 } else {
			 	var checkedUpl = "";
			 }			 
			 
	        JsHttpRequest.query(
	            '/inc_site/addComment.php', // backend
	            {
	                'name': document.getElementById(sname).value, 
						 'module': module,
						 'div': div,
						 'id': id,
						 'string': document.getElementById(string).value,  
						 'text': checkedText,
						 'page': page,
	                'upl': checkedUpl
	            },
	            // Function is called when an answer arrives. 
	            function(result, errors) {
	                // Write errors to the debug div.
	                document.getElementById(uid).innerHTML = errors; 
	            },
	            false  // do not disable caching
	        );
	   }
		
	   function load_file(uid) {
			 
			 var form_data = "form_data"+uid;
			 var output = "attach"+uid;
			 
			 document.getElementById(output).innerHTML = "Loading... <img src=/img/ajax-loader.gif border=0>";
			 		 
			 if (document.getElementById(form_data)) {
			 	var checkedUpl = document.getElementById(form_data);
			 } else {
			 	var checkedUpl = "";
			 }			 
			 
	        JsHttpRequest.query(
	            '/inc_site/load_file.php', // backend
	            {
						 'uid': uid,
	                'upl': checkedUpl
	            },
	            // Function is called when an answer arrives. 
	            function(result, errors) {
	                // Write errors to the debug div.
	                document.getElementById(output).innerHTML = errors; 
	            },
	            false  // do not disable caching
	        );
	   }		 
 			
	   function displayComment(id, module, div, amount, page_id) {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
              onSuccess : function(obj) {	document.getElementById(obj.tag).innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/include/addCommentsAndMedia.php?id="+id+"&module="+module+"&div="+div+"&amount="+amount+"&page="+page_id, tag: div });
            advAJAX.setDefaultParameters({});
      }	
		
	   function delComment(id, unique) {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
              onSuccess : function(obj) {	document.getElementById(obj.tag).innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/delComment.php?id="+id, tag: "del"+unique });
            advAJAX.setDefaultParameters({});
      }					
		
	   function updateCartComponent() {	
   	    if(!document.getElementById("updateCartComponent")) return;
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById("updateCartComponent").innerHTML = "Loading..."; },
              onSuccess : function(obj) { document.getElementById("updateCartComponent").innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/updateCartComponent.php" });
            advAJAX.setDefaultParameters({});
      }
		
      function orderDetails(id) {
        
            advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/inc_site/orderDetails.php?id="+id, tag: "orderDetail"+id });
            advAJAX.setDefaultParameters({});
      }	
			
      function saveOrderComment(id) {
        
            advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/../inc_site/saveOrderComment.php?id="+id+"&comment="+encodeURIComponent(document.getElementById("orderCommment"+id).value), tag: "commentStatus"+id });
            advAJAX.setDefaultParameters({});
      }	
			
	   function loadWebshopPic(element_id, id, ext) {	
        
            advAJAX.setDefaultParameters({
               onLoading : function(obj) { document.getElementById(element_id).innerHTML = "Loading..."; },
					onSuccess : function(obj) { 
				    	document.getElementById(element_id).innerHTML = obj.responseText; 
				  }
            });
            advAJAX.get({ url: "/inc/changeWebshopPic.php?id="+id+"&ext="+ext });
            advAJAX.setDefaultParameters({});
      }	
																				
	   function question(mail,sname,productid,firstname,phone,randomnr) {  	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "<br>Loading...<br><br>"; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "inc_site/question.php?mail="+mail+"&sname="+encodeURIComponent(sname)+"&productid="+productid+"&firstname="+encodeURIComponent(firstname)+"&phone="+phone+"&random="+randomnr, tag: "question"+randomnr });
            advAJAX.setDefaultParameters({});
      }	
		
      function saveTranslations(text_id, lang_id) {
        		
				var languages = lang_id.split("|");
				var modifiedUrl = "/inc_site/saveTranslations.php?";
		
				for(indeks in languages)
				{
					modifiedUrl += "&tr_"+text_id+"_"+languages[indeks]+"="+encodeURIComponent(document.getElementById("sentence_"+text_id+"_"+languages[indeks]).value);
				}
				
            advAJAX.setDefaultParameters({
              onInitialization : function(obj) { document.getElementById(obj.tag).innerHTML = "Preparing..."; },
              onLoading : function(obj) { document.getElementById(obj.tag).innerHTML = "Loading..."; },
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: modifiedUrl, tag: "msg_"+text_id });
            advAJAX.setDefaultParameters({});
				
      }			
		
	   function translationsList(cId, containerTarget) {	

            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById(containerTarget).innerHTML = "Loading"; },
              onSuccess : function(obj) { document.getElementById(containerTarget).innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/translationsList.php?cId="+cId });
            advAJAX.setDefaultParameters({});
      }	
		
	   function translationsListSingleSentence(cId, containerTarget) {	

            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById(containerTarget).innerHTML = "Loading"; },
              onSuccess : function(obj) { document.getElementById(containerTarget).innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/translationsListSingleSentence.php?cId="+cId });
            advAJAX.setDefaultParameters({});
      }			
		
		// admin functions
	   function currencyRates() {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById("currencyRates").innerHTML = "Update under process, be patient <img src=/img/ajax-loader.gif border=0>"; },
              onSuccess : function(obj) { document.getElementById("currencyRates").innerHTML = obj.responseText; }
            });
            advAJAX.get({ url: "/inc_site/currency.php" });
            advAJAX.setDefaultParameters({});
      }		
		
		// admin functions
	   function search_domain(domain_name, tld) {	
        
            advAJAX.setDefaultParameters({
				  onLoading : function(obj) { document.getElementById("domains_results").innerHTML = "<img src=\"/img/ajax-loader.gif\" border=\"0\">"; },
              onSuccess : function(obj) { document.getElementById("domains_results").innerHTML = obj.responseText; },
				  onError : function(obj) { document.getElementById("domains_results").innerHTML = "Error..."; }	
            });
            advAJAX.get({ url: "/inc_site/334.inc.php?domain_name="+encodeURIComponent(domain_name)+"&tld="+tld });
            advAJAX.setDefaultParameters({});
      }	
	
      function update_buy_options(buy_option_id, product_id, div_id, type) {
        
            advAJAX.setDefaultParameters({
              //onInitialization : function(obj) { document.getElementById(div_id).innerHTML = "Preparing..."; },
              //onLoading : function(obj) { document.getElementById(div_id).innerHTML = "<div class=\"loadingContainer\"><div>Loading...</div></div>"; },
              onSuccess : function(obj) { document.getElementById(div_id).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(div_id).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/update_buy_options.php?product_id="+product_id+"&buy_option_id="+buy_option_id+"&buy_option_type="+type, tag: "c_op_"+div_id });
            advAJAX.setDefaultParameters({});
      }
	
	function goto_cart() {
		window.location = "/handlekurv/";
	}
	
      function remove_buy_option(buy_option_id, product_id, div_id, buy_option_type) {
		var checkbox = document.getElementById("buy_op_"+div_id+"_"+buy_option_type+"["+buy_option_id+"]");
		if(document.getElementById("buy_op_"+div_id+"_"+buy_option_type+"["+buy_option_id+"]"))
			checkbox.checked = false;
		update_buy_options_cart(buy_option_id, product_id, div_id, buy_option_type, checkbox)
		/*	
             advAJAX.setDefaultParameters({
              onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
              onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            //advAJAX.get({ url: "/update_buy_options.php?page=cart&action=remove&product_id="+product_id+"&buy_option_type="+buy_option_type+"&buy_option_id="+buy_option_id+"&uid="+div_id, tag: "c_op_"+div_id });
           // advAJAX.setDefaultParameters({});
	     */
      }
	
      function update_buy_options_cart(buy_option_id, product_id, div_id, type, element) {
	{
		if(document.getElementById("ilosc"+div_id))
			products_count = document.getElementById("ilosc"+div_id).value;
		else if(document.getElementById("ilosc"+product_id))
			products_count = document.getElementById("ilosc"+product_id).value;
		var text = '';
		var price = "";
		var ins_opt = '';
		var ins_opt_text = "";
		var theForm = element.form, z = 0;
		for(z=0; z<theForm.length;z++){
			if(theForm[z].type != 'text')
			{
				val = theForm[z].value.split('|');
				if(theForm[z].type == 'checkbox' && theForm[z].checked == true)
				{
					if(val[1]!="")
					{
						ins_opt += val[0]+",";
					}
				}
				else if(theForm[z].type == 'select-one')
				{
					ins_opt += val[0]+",";
				}
				else if(theForm[z].type == 'radio' && theForm[z].checked == true && theForm[z].value != '')
				{
					ins_opt += val[0]+",";
				}
			}
			else
			{
				nameArr = theForm[z].id.split("_");
				name = nameArr[3];
				if(theForm[z].value != '')
					ins_opt_text += name+","+theForm[z].value+'|';
			}
		}
		document.getElementById("c_op_ins_"+div_id).value = ins_opt;
		document.getElementById("c_op_ins_text_"+div_id).value = ins_opt_text;
	}
		advAJAX.setDefaultParameters({
			onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
			onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/update_buy_options.php?page=cart_tab&unique_id="+div_id+"&product_id="+product_id+"&products_count="+products_count+"&buy_options_text="+ins_opt_text+"&buy_options="+ins_opt+"&buy_option_type="+type, tag: "c_op_"+div_id });
            advAJAX.setDefaultParameters({});
      }
	
      function save_buy_options(product_id, div_id) {
		options = document.getElementById("c_op_ins_"+div_id).value;
		products_count = document.getElementById("ilosc"+div_id).value;
		text = document.getElementById("c_op_ins_text_"+div_id).value;
             advAJAX.setDefaultParameters({
            });
            advAJAX.get({ url: "/update_buy_options.php?page=cart_tab&action=update&product_id="+product_id+"&buy_options="+options+"&text="+text+"&unique_id="+div_id+"&products_count="+products_count, tag: "c_op_"+div_id });
           advAJAX.setDefaultParameters({});
      }
	
	function update_buy_opt_text(element, div_id) {
		if(element.value != '')
		{
			nameArr = element.id.split("_");
			name = nameArr[3];
			document.getElementById("c_op_ins_text_"+div_id).value = name+','+element.value+'|';
		}
		else
			document.getElementById("c_op_ins_text_"+div_id).value = '';
	}
	
	function update_products_count(product_id,div_id,element){
		options = document.getElementById("c_op_ins_"+div_id).value;
		text = document.getElementById("c_op_ins_text_"+div_id).value;
		products_count = element.value;
             advAJAX.setDefaultParameters({
			onSuccess : function(obj) { document.getElementById(obj.tag).innerHTML = obj.responseText; },
			onError : function(obj) { document.getElementById(obj.tag).innerHTML = "Error..."; }
            });
            advAJAX.get({ url: "/update_buy_options.php?page=cart_tab&unique_id="+div_id+"&product_id="+product_id+"&products_count="+products_count+"&buy_options="+options+"&buy_options_text="+text, tag: "c_op_"+div_id });
           advAJAX.setDefaultParameters({});
      }
	
      function show(id) {
            obj = document.getElementById(id);
            obj.style.display = "block";
      }
	
      function hide(id) {
            obj = document.getElementById(id);
            obj.style.display = "none";
      }
	
	function toggle(radio,divs){
		divArr = divs.split("|");
		for(id in divArr)
		{
			if(document.getElementById(divArr[id]))
			{
				hide(divArr[id]);
				document.getElementById('select_'+divArr[id]).disabled = true;
			}
		}
		if(document.getElementById(radio.value))
		{
			show(radio.value);
			document.getElementById('select_'+radio.value).disabled = false;
		}
      }
