function showProcessBar_New(text ,clientId , date)
{		
	var dialogWidth = 400;	
	var dialogHeight = 180;	
	var dialogTop = (window.screen.height/2)-(dialogHeight/2);	
	var dialogLeft = (window.screen.width/2)-(dialogWidth/2);		
	if(window.showModelessDialog)
	{		
		event.srcElement.disabled = true;	
	}
	if(date ==  "")	
	{}
	else if(window.showModelessDialog)
	{	
		win = window.showModelessDialog("ClientSites/OrderInProcess.htm", text, "dialogHeight: "+dialogHeight+"px; dialogWidth: "+dialogWidth+"px; dialogTop: "+dialogTop+"px; dialogLeft: "+dialogLeft+"px; edge: Raised; center: Yes; help: No; resizable: No; status: No; Scroll: No;");			
	}

	CustomPostBack(clientId);
}

function CustomPostBack(clientId)
{
	__doPostBack(clientId,'');	
}  

function showMapLocation(mapLinkId,webMapLink)
{	
	var mapTable = document.getElementById("MapTable");	
	var mapImage = document.getElementById("MapImage");	
	mapImage.src = "images/wait.gif";
	mapImage.src = "MapImage.aspx?WebMapLink="+webMapLink;
		
	mapTable.style.display = "block";
	mapTable.style.position = "absolute";
	var pos = getElementPos(mapLinkId);
	mapTable.style.left = pos.x;
	mapTable.style.top = pos.y-30;		
}
function getElementPos(sElementID)
{ 
	if(!document.getElementById) return null; 
	var e = document.getElementById(sElementID); 
	if(e == null ) return null; 
	var p = { x: 0, y: 0}; 
	while(e) 
	{ 
	p.x += parseInt(e.offsetLeft,10); 
	p.y += parseInt(e.offsetTop,10); 
	e = e.offsetParent; 
	} 
	return p; 
}
function CloseMap()
{	
	var mapTable = document.getElementById("MapTable");	
	mapTable.style.display = "none";
}

function PrepareText(objSender, strText)
{
	if(objSender.value == strText)
	{
		objSender.value = "";
	}
	else{
		if(objSender.value == "")
		{
			objSender.value = strText;
		}
		else
		{
			objSender.value = objSender.value;
		}
	}
}
function GetSelectedValue(selectdate,comboid,errortext)
{
	window.close();
	var Select=window.opener.document.getElementById(comboid);
	var Error=window.opener.document.getElementById(errortext);
	Error.style.display="none";
	for(var i=0;i<=Select.length-1;i=i+1)
		{
			var ddlText=Select.options[i].value;
			if(ddlText==selectdate)
				{
					Select.selectedIndex=i;
					break;
				}
		}
}
function BestilClickAction(ProductId,anncode,strMachineName)
{
	var SelectedDate=getElementsByClassName(document,"select","SelectDateDropDownList")[0];
	var ErrorText=getElementsByClassName(document,"span","SelectDateError")[0];
	if(SelectedDate.value != "" && SelectedDate != null)
	{
		ErrorText.style.display="none";		
		var strUrl = SapSites.Modules.HotelInfo.SelectDate.GetDetails(SelectedDate.value,ProductId,anncode,strMachineName);
		if(strUrl.value != "")
			location.href = strUrl.value;
	}
	else
	{
		ErrorText.style.display="block";
	}
	
}
function ArrivalDateCombo()
{
	var SelectedDate=getElementsByClassName(document,"select","SelectDateDropDownList")[0];
	var ErrorText=getElementsByClassName(document,"span","SelectDateError")[0];
	if(SelectedDate.value != "" && SelectedDate != null)
		ErrorText.style.display="none";
	else
		ErrorText.style.display="block";
}
function getElementsByClassName(oElm, strTagName, strClassName)
{
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++)
	{
		oElement = arrElements[i];      
		if(oRegExp.test(oElement.className))
		{
			arrReturnElements.push(oElement);
		}   
	}
	return (arrReturnElements);
}
function setArrivalDateColor(types, listId)
{
	var list = document.getElementById(listId);
	var arr = types.split(",");
	for(i=0 ; i < arr.length ; i++)
	{		
		list.options[i].className = "arrivalDate" + arr[i];
	}
}
function ShowSelectADate(clientId)
{	
	document.getElementById(clientId).style.display = "inline";	
}

function FillPageSizeCombo()
{
	var PageSizeCombo = getElementsByClassName(document,"select","SearchBoxResultsDropdown");
	if( PageSizeCombo != null)
	{
		AjaxPro.timeoutPeriod = 60*1000;
		SapSites.Modules.Search.SearchResult.GetPageSizeCollection(CallBackPageSizeCombo);
	}
}
function CallBackPageSizeCombo(result)
{
	var Collection = new Ajax.Web.NameValueCollection();
	var PageSizeCombo = getElementsByClassName(document,"select","SearchBoxResultsDropdown")[0];	
	if(PageSizeCombo != null)
	{
			if(result != null && result.value[0] != null)
			{
				Collection = result.value[0];
				var arrayCount = 0;
				var keys = Collection.getKeys();
				for(var i=0; i < keys.length; i++)
				{
					if(!FindItemByValue(PageSizeCombo ,Collection.getValue(keys[i])))
					{
						PageSizeCombo.options[arrayCount] = new Option(keys[i],Collection.getValue(keys[i]));
						arrayCount++;
					}
				}
			}	
			if(result != null && result.value[1] != null && result.value[1] != "")
			{
				for(nIndx=0;nIndx<PageSizeCombo.length;nIndx++)
				{
					if(PageSizeCombo.options[nIndx].value == result.value[1])
					{
						nSelectedIndx = nIndx;
					}
				}
				PageSizeCombo.selectedIndex = nSelectedIndx;
			}
			else
				PageSizeCombo.selectedIndex = 0;
	}
}
function FillSortCombo()
{
	var SortCombo = getElementsByClassName(document,"select","SearchBoxDropdownCommon")[0];
	if( SortCombo != null)
	{
		AjaxPro.timeoutPeriod = 60*1000;
		SapSites.Modules.Search.SearchResult.GetSortCollection(CallBackSortCombo);
	}
}
function CallBackSortCombo(result)
{
	var Collection = new Ajax.Web.NameValueCollection();
	if(result != null && result.value[0] != null)
	{
		Collection = result.value[0];
		var SortCombo = getElementsByClassName(document,"select","SearchBoxDropdownCommon")[0];	
		var arrayCount = 0;
		var keys = Collection.getKeys();
		if(SortCombo != null)
		{
			for(var i=0; i < keys.length; i++)
			{
				if(!FindItemByValue(SortCombo,Collection.getValue(keys[i])))
				{
					SortCombo.options[arrayCount] = new Option(keys[i],Collection.getValue(keys[i]));
					arrayCount++;
				}
			}
		}
	}
	if(result != null && result.value[1] != null && result.value[1] != "" && SortCombo != null)
	{
		for(nIndx=0;nIndx<SortCombo.length;nIndx++)
		{
			if(SortCombo.options[nIndx].value == result.value[1])
			{
				nSelectedIndx = nIndx;
			}
		}
		SortCombo.selectedIndex = nSelectedIndx;
	}
	else if(SortCombo != null)
		SortCombo.selectedIndex = 0;	
}

function SortResultGrid()
{
	var SortCombo = getElementsByClassName(document,"select","SearchBoxDropdownCommon")[0];
	if( SortCombo != null)
	{
		var SortValue = SortCombo.options[SortCombo.selectedIndex].value;	 		
		if(SortValue != "--")
		{
			AjaxPro.timeoutPeriod = 60*1000;
			SapSites.Modules.Search.SearchResult.SortSearchResultGrid(SortValue);
			__doPostBack('','');
		}
	}
}
function FindItemByValue(dropDownClientId,srcValue)
{
	var bRet = false;
	for(var i=0;i<dropDownClientId.options.length;i++)
	{
		if(dropDownClientId.options[i].value == srcValue)
		{
			bRet = true;
			break;
		}
	}
	return bRet;
}

function ChangeGridPageCount()
{
	var PageSizeCombo = getElementsByClassName(document,"select","SearchBoxResultsDropdown")[0];
	if( PageSizeCombo != null)
	{
		var PageSizeComboValue = PageSizeCombo.options[PageSizeCombo.selectedIndex].value;	 		
		if(PageSizeComboValue != " ")
		{
			AjaxPro.timeoutPeriod = 60*1000;
			SapSites.Modules.Search.SearchResult.ReloadSearchResultGrid(PageSizeComboValue);
			__doPostBack('','');
		}
	}
}

