function LoadCalendar(url) {
 if (window.XMLHttpRequest) {
	try {
		req_LoadCalendar= new XMLHttpRequest();
	}
	catch (e) {
		req_LoadCalendar = false;
	}
 }
 else if(window.ActiveXObject) {
	 try {
		req_LoadCalendar = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				req_LoadCalendar = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				req_LoadCalendar = false;
			}
		}
 }
 if (req_LoadCalendar) {
 req_LoadCalendar.onreadystatechange=processLoadCalendar;
 req_LoadCalendar.open("GET", url, true);
 req_LoadCalendar.send(null);
 }

}

function processLoadCalendar()
{	
	if (req_LoadCalendar.readyState == 4)
	{	
		if (req_LoadCalendar.status == 200)
		{	
			window.document.getElementById("calendar").innerHTML = req_LoadCalendar.responseText;
		}
		else
		{
			alert("Данните не могат да бъдат заредени");
		}
	}
}

function CheckUserName(url) {
	//alert(url);
 if (window.XMLHttpRequest) {
	try {
		req_LoadCalendar= new XMLHttpRequest();
	}
	catch (e) {
		req_LoadCalendar = false;
	}
 }
 else if(window.ActiveXObject) {
	 try {
		req_LoadCalendar = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				req_LoadCalendar = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				req_LoadCalendar = false;
			}
		}
 }
 if (req_LoadCalendar) {
 req_LoadCalendar.onreadystatechange= processCheckUserName;
 req_LoadCalendar.open("GET", url, true);
 req_LoadCalendar.send(null);
 }

}

function processCheckUserName()
{	
	if (req_LoadCalendar.readyState == 4)
	{	
		if (req_LoadCalendar.status == 200)
		{	
			window.document.getElementById("errorDiv").innerHTML = req_LoadCalendar.responseText;
		}
		else
		{
			alert("Данните не могат да бъдат заредени");
		}
	}
}


function CheckBlogName(url) {
	//alert(url);
 if (window.XMLHttpRequest) {
	try {
		req_LoadCalendar= new XMLHttpRequest();
	}
	catch (e) {
		req_LoadCalendar = false;
	}
 }
 else if(window.ActiveXObject) {
	 try {
		req_LoadCalendar = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				req_LoadCalendar = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				req_LoadCalendar = false;
			}
		}
 }
 if (req_LoadCalendar) {
 req_LoadCalendar.onreadystatechange= processCheckUserName;
 req_LoadCalendar.open("GET", url, true);
 req_LoadCalendar.send(null);
 }

}

function processCheckBlogName()
{	
	if (req_LoadCalendar.readyState == 4)
	{	
		if (req_LoadCalendar.status == 200)
		{	
			window.document.getElementById("errorDiv").innerHTML = req_LoadCalendar.responseText;
		}
		else
		{
			alert("Данните не могат да бъдат заредени");
		}
	}
}

function SetValue(id, val) {
document.getElementById('des').value = val;
document.getElementById('hidden_id').value = id;
document.getElementById('key_search').style.display = 'none';
}

function Ajax(file, data, div)
{
	$.ajax({
	   type: "POST",
	   url: file,
	   data: data,
	   cache: false,
	   success: function(html){
	     $("#"+div).html(html);
	   }
	});
}

function AjaxSearch(file, data, div)
{
	 
	if ( document.getElementById('receiver').value == '' ) 
	   	document.getElementById('model').style.display='none';
	   	else 
	  document.getElementById('model').style.display='block';
	   
	   
	$.ajax({
	   type: "POST",
	   url: file,
	   data: data,
	   cache: false,
	   success: function(html){
	     $("#"+div).html(html);
	    
	   }
	});
}

function setFriendVal( val ) {
document.getElementById('receiver').value=val;
document.getElementById('model').style.display='none';
}


function AjaxAppend(file, data, div, f_id)
{	
	$.ajax({
	   type: "POST",
	   url: file,
	   data: data,
	   cache: false,
	   success: function(html){
	     
	     $("#"+div).append(html);
	     calculatePrice('tr_'+f_id, 'price_'+f_id);
	   }
	});
}


function reloadAjax(file, data, div)
{	
	 Ajax(file, data, div);
	 setTimeout('reloadAjax("'+file+'","'+ data+'","'+ div+'")', 5000);
}

var pr = 0;

function viewHistory(prev) { 
		if ( prev == '0' ) pr = pr+1;
		else pr = pr-1;
		if (pr > 0) pr = 0;
		if (pr < -2) pr = -2;
		  $.ajax({
        type: 'GET',
        url: '/view_history.php/?id='+pr,
        data: null,
        cache: false,
        success: function(html){
        	document.getElementById('list_history_alax').innerHTML = html;
        //  $("#"+div).html(html);
         valid = html;
        }
     });
}

