﻿var ajax_cursor_html = '<img src="' + site_path + 'images/cursor-load.gif" width="16" height="16" alt="Подождите...">';
var ajax_wait_message = 'Пожалуйста, подождите, пока загрузятся данные с сервера.';
var ajax_cursor_class_name = 'hour_glass';
var cursor_x_shift = -5;
var cursor_y_shift = -5;

function CountryChanged(select) {
	var ids = new Array();
	for (var i = 0; i < select.length; i++) {
		if (select.options[i].selected)
			ids.push(select.options[i].value);
	} // end for
	var div = document.getElementById('Cities_Container');
	if (div) {
		var event = 
			function (result) {
				div.innerHTML = result;
			} // end event
		HttpRequest(site_path + 'selectcities.aspx?Params=' + ids.join(','), null, null, event);
	} // end if
	return false;
} // end function

function CountryChangedNew(select) {
	if (select.length > 2) {
		var div = document.getElementById('Cities_Container');
		if (div) {
			var event = 
				function (result) {
					div.innerHTML = result;
				} // end event
			HttpRequest(site_path + 'selectcities.aspx?Params=' + select, null, null, event);
		} // end if
	} //end if
	return false;
} // end function

function CityChanged(select) {
	var ids = new Array();
	for (var i = 0; i < select.length; i++) {
		if (select.options[i].selected)
			ids.push(select.options[i].value);
	} // end for
	var div = document.getElementById('Hotels_Container');
	if (div) {
		var event = 
			function (result) {
				div.innerHTML = result;
			} // end event
		HttpRequest(site_path + 'selecthotels.aspx?Cities.id=' + ids.join(','), null, null, event);
	} // end if
	return false;
} // end function

function UniversalLister(pageName,containerId, objectName,start, pageSize, additionalParams)
{
	//alert("PN=" + pageName + " containerId=" + containerId + " objectName=" + objectName + " start=" + start);
	var div = document.getElementById(containerId);
	if (div) {
		var event = 
			function (result) {
				//alert(result);
				//document.write(result);
				div.innerHTML = result;
			} // end event
		//alert(containerId);	
		if ((start == 0) && (pageSize == 0)) HttpRequest(site_path + pageName + '?ObjectName=' + objectName + additionalParams, null, null, event);
		else HttpRequest(site_path + pageName + '?ObjectName=' + objectName + '&StartIndex=' + start + '&PageSize='+ pageSize + additionalParams, null, 1, event);
	} // end if
	return false;
} // end function

function ListerDepending(containerId, start, pageSize, contentName, addParams) {
	var div = document.getElementById(containerId);
	if (div) {
		var event = 
			function (result) {
				//alert(result);
				div.innerHTML = result;
			} // end event
			var stringParams = "";
			stringParams += (containerId == "" || containerId == undefined) ? "ContainerId=0" : "ContainerId=" + containerId;
			stringParams += (start == "" || start == undefined) ? "&StartIndex=1" : "&StartIndex=" + start;
			stringParams += (pageSize == "" || pageSize == undefined) ? "&PageSize=1" : "&PageSize=" + pageSize;
			stringParams += (contentName == "" || contentName == undefined) ? "&ContentName=0" : "&ContentName=" + contentName;
			//stringParams += (addParams == "" || addParams == undefined) ? "&AdditionalParams=0" : "&AdditionalParams=" + addParams;
		HttpRequest(site_path + 'tourlist.aspx?' + stringParams + addParams, null, 1, event);
	} // end if
	return false;
} // end function

function TourAdding(containerId, tCountry, tTourType, tTitle, tCompany, tPrice, tPlacement, tPeriod, tArrival, tTransport, tProgram1, tProgram2, tAuthor) {
	var div = document.getElementById(containerId);
	if (div) {
		var event = 
			function (result) {
				//alert(result);
				div.innerHTML = result;
			} // end event
			var stringParams = "";
			stringParams += (tCountry == "" || tCountry == undefined) ? "TCountry=0" : "TCountry=" + tCountry;
			stringParams += (tTourType == "" || tTourType == undefined) ? "&TTourType=0" : "&TTourType=" + tTourType;
			stringParams += (tTitle == "" || tTitle == undefined) ? "&TTitle=0" : "&TTitle=" + escape(tTitle);
			stringParams += (tCompany == "" || tCompany == undefined) ? "&TCompany=0" : "&TCompany=" + tCompany;
			stringParams += (tPrice == "" || tPrice == undefined) ? "&TPrice=0" : "&TPrice=" + escape(tPrice);
			stringParams += (tPlacement == "" || tPlacement == undefined) ? "&TPlacement=0" : "&TPlacement=" + escape(tPlacement);
			stringParams += (tPeriod == "" || tPeriod == undefined) ? "&TPeriod=0" : "&TPeriod=" + escape(tPeriod);
			stringParams += (tArrival == "" || tArrival == undefined) ? "&TArrival=0" : "&TArrival=" + escape(tArrival);
			stringParams += (tTransport == "" || tTransport == undefined) ? "&TTransport=0" : "&TTransport=" + escape(tTransport);
			stringParams += (tProgram1 == "" || tProgram1 == undefined) ? "&TProgram1=0" : "&TProgram1=" + escape(tProgram1);
			stringParams += (tProgram2 == "" || tProgram2 == undefined) ? "&TProgram2=0" : "&TProgram2=" + escape(tProgram2);
			stringParams += (tAuthor == "" || tAuthor == undefined) ? "&TAuthor=0" : "&TAuthor=" + tAuthor;
			stringParams += "&ContainerId=" + containerId;
			//alert(site_path + 'tourlist.aspx?' + stringParams);
		HttpRequest(site_path + 'tourlist.aspx?' + stringParams, null, 2, event);
	} // end if
	return false;
} // end function
function FilterMenu(containerId, addParams) {
	var div = document.getElementById(containerId);
	if (div) {
		var event = 
			function (result) {
				//alert(result);
				div.innerHTML = result;
			} // end event
		HttpRequest(site_path + 'contandcont.aspx?' + addParams, null, 3, event);
		//document.forms["filterMenu"].elements["collectionIds"].value = "";
	} // end if
	return false;
} // end function
function AddTourFirmAddress(containerId, addParams) {
	var div = document.getElementById(containerId);
	if (div) {
		var event = 
			function (result) {
				//alert(result);
				div.innerHTML = result;
			} // end event
		HttpRequest(site_path + 'addaddress.aspx?' + addParams, null, 3, event);
	} // end if
	return false;
} // end function
function SelectCustomList(containerId, addParams) {
	//alert(containerId + " " + addParams);
	var div = document.getElementById(containerId);
	if (div) {
		var event = 
			function (result) {
				//alert(result);
				div.innerHTML = result;
			} // end event
		HttpRequest(site_path + 'advertiserajaxhandler.aspx?' + 'containerId=' + containerId + addParams, null, 3, event);
		//document.forms["filterMenu"].elements["collectionIds"].value = "";
	} // end if
	return false;
} // end function

function GetIds(link)
{
	var ids = new Array();
	var selIds = link.options;
	for (var i = 0; i < selIds.length; i++)
		if ((selIds[i].selected) && (selIds[i].value != "default"))
			ids.push(selIds[i].value);
	//alert(ids);
	return ids;
}
function CheckDatesForSections(containerId, formObj) {
	//alert(containerId + " " + addParams);
	var urlParams = "";
	if (formObj.bannerplace)
		urlParams += "&placeId=" + GetIds(formObj.bannerplace);
	if (formObj.bannersections)
		urlParams += "&bannersections=" + GetIds(formObj.bannersections);
	if (formObj.bannercountries)
		urlParams += "&bannercountries=" + GetIds(formObj.bannercountries);
	if (formObj.curDatePeriods)
		urlParams += "&dateperiods=" + formObj.curDatePeriods.value;
	if (formObj.bufDatePeriods)
		urlParams += "&bufdateperiods=" + formObj.bufDatePeriods.value;
	if (formObj.curmplan)
		urlParams += "&mplan=" + formObj.curmplan.value;
	//alert(urlParams);
	var div = document.getElementById(containerId);
	if (div) {
		var event = 
			function (result) {
				//alert(result);
				div.innerHTML = result;
			} // end event
		HttpRequest(site_path + 'advertiserajaxhandler.aspx?' + 'containerId=' + containerId + urlParams, null, 11, event);
	} // end if
	return false;
} // end function

function PersonalGaleriesLister(startIndex, pageSize, additionalParams) {
	var div = document.getElementById('PersonalGalaries');
	if (div) {
		var event = 
			function (result) {
				div.innerHTML = result;
			} // end event
			var stringParams = "";
			stringParams += (startIndex == "" || startIndex == undefined) ? "&StartIndex=1" : "&StartIndex=" + startIndex;
			stringParams += (pageSize == "" || pageSize == undefined) ? "&PageSize=1" : "&PageSize=" + pageSize;
		HttpRequest(site_path + 'PersonalGaleriesLister.aspx?MyParam=0' + stringParams, additionalParams, 1, event);
	} // end if
	return false;
} // end function

function Road100MansStoriesLister(startIndex, pageSize, additionalParams) {
	var div = document.getElementById('StoriesList_Container');
	if (div) {
		var event = 
			function (result) {
				div.innerHTML = result;
			} // end event
			var stringParams = "";
			stringParams += (startIndex == "" || startIndex == undefined) ? "&StartIndex=1" : "&StartIndex=" + startIndex;
			stringParams += (pageSize == "" || pageSize == undefined) ? "&PageSize=1" : "&PageSize=" + pageSize;
		HttpRequest(site_path + 'Lister100roadmansGallaries.aspx?MyParam=0' + stringParams, additionalParams, 1, event);
	} // end if
	return false;
} // end function