// JavaScript Document
function ChangeLanguage(type)
{
	alert(type);
  document.getElementById("lang_hidden").value = type;
  document.form[0].post();
   
}

function prepareSearch(server,path)
{
	var keyword=document.getElementById("textfield").value;
	var full_path="http://"+server+path;
	//alert("http://"+server+path);
	window.location=full_path+'index.php?recepta=2&cat=&search='+keyword+'&page=1';
}

//Функцията се използва при затваряне на страницата за  ПРЕПОРЪЧВАНЕ НА ЗАВЕДЕНИЕ ОТ ПОТРЕБИТЕЛ
//тя пренасочва браузъра към последната страница, която е била заредена
// фумкцията се извиква от PHP функцията "CloseUserReccommendation", която и подава двата аргумента
function RedirectPage(fullpath)
{
	//var full_path="http://"+server+path;
	var full_path=fullpath;
	//alert("http://"+server+path);
	window.location=full_path+'index.php?restaurants=2&cat=&search='+keyword+'&page=1';
}

//function Pagination(page)
//(
	//alert("page");
	//document.getElementById("menu_of_"+"page").style.display="inline";
	//document.getElementById("page").style.display="none";
	//document.getElementById("page").style.display="none";
//)


function printpage()
{
	window.print();
}



/* функцията доставя данни за показаните търгове в момента. Started into TTarg*/
function StartUpdater()
{
	 var oData = {
        str_products: str_Products  // see TTarg, variable is global,
    };
	
	 var oHttp = zXmlHttp.createRequest();
	
	  //cancel any active requests
    if (oHttp.readyState != 0) {
        oHttp.abort();
    }
    
	
    oHttp.open("post", "get_product.php", true);
    oHttp.onreadystatechange = function () {
     if (oHttp.readyState == 4) {
            var aSuggestions = JSON.parse(oHttp.responseText);
            	for(ii=0; ii < aSuggestions.length; ii++)
				{
				(aSuggestions[ii][0]);
					name ="table_"+aSuggestions[ii][0];
					price_name = "current_price_"+aSuggestions[ii][0];
				
					try
					{
						document.getElementById(name).innerHTML = "<table>"+aSuggestions[ii][1]+"</table>";
						document.getElementById(price_name).innerHTML = aSuggestions[ii][2];
	
					}catch(err)
					{
						txt="There was an error on this page.\n\n";
	  						txt+="Error description: " + err.description + "\n\n";
	  						txt+="Click OK to continue.\n\n";
	  						alert(txt);	
					}
        }
    }
  }
    //send the request
  oHttp.send(JSON.stringify(oData));
  // call self again after 2 second....
  setTimeout ('StartUpdater()', 2000);
 
}
function SubmitForm(command_string)
{
	document.forms[0].elements["posted_object"].value =command_string;
	document.forms[0].submit();
}// end of SubmitForm...

// ShowUserInfo(action, name)
function ShowUserInfo()
{

	
 try{	
	if(user_state == 0)
	document.getElementById("user_div").innerHTML = '<div id="user_label"><p></p><p><a href="index.php?login=1">вход</a></p></div>';
	else
	document.getElementById("user_div").innerHTML = ('<div id="user_label"><p>Здравейте&nbsp;'+user_name+'</p><p><a href="index.php?login=2">изход</a></p></div>');
	}catch(err)
	{
						txt="There was an error on this page.\n\n";
  						txt+="Error description: " + err.description + "\n\n";
  						txt+="Click OK to continue.\n\n";
  						alert(txt);	
	}
	

}


function reklami()
{
  
	image_name = "header_bg.jpg";
	
    target = document.getElementById('main_reklama');

     
	target.style.backgroundImage ="url(images/header_bg.jpg)";
 
//	setTimeout ('reklami()', 1000);
}

