var HighLiteColor = GetStyleBGColor();
// ***************************
// ** Wait Window functions **
// ***************************
function OpenWaitWindow(TouropOptions)
{
	if( TouropOptions == "ALL" )
	{
		var browser = navigator.appName;
		var version = parseInt(navigator.appVersion);
		var CanShow = true;
		
		//Detect which borwsers don't support the "advanced" functions in the wait window
		if( browser.substring(0,8) == "Netscape" && version < 6 ) CanShow = false;
		
		if( CanShow )
		{
			var h,w,l,t;
			var win;
				
			h = 50;
			w = 350;
			l = (screen.width - w) / 2;
			t = (screen.height - h) / 2;
			parent.wrmain.document.forms[0].CloseWindow.value = "0";
			win = parent.wrmain.window.open( "Wait.aspx","WaitWindow", "scrollbars=no,status=no,height="+h+",width="+w+",left="+l+",top="+t);
			win.focus();
		}
	}
}

function CloseWaitWindow()
{
	parent.wrmain.document.forms[0].CloseWindow.value = "1";
}

// *****************************************************
// ** Function for replacing .Net's postback function **
// *****************************************************

var oldPostBack

function ReplacePostBack(FunctionName)
{
	oldPostBack = __doPostBack;
	__doPostBack = FunctionName;
}

// **************************
// ** Open Calendar window **
// **************************

function GetDate(source,params)
{
	var h,w,l,t;
	
	h = 210;
	w = 300;
	l = (screen.width - w) / 2;
	t = (screen.height - h) / 2;

	newwind = window.open( "SelectDate.aspx?srcField=" + source + params,"GetDate", "scrollbars=no,height="+h+",width="+w+",left="+l+",top="+t);
	newwind.focus();
}

// **************************
// ** Open AccoInfo window **
// **************************

function AccoInfo(Tourop,Accocode,OwnOffer)
{
	h = screen.availHeight - 25;
	w = 750;
	l = 0;
	t = 0;
	url = "AccoInfo.aspx?Tourop=" + Tourop + "&Accocode=" + Accocode + "&OwnOffer=";
	url+=OwnOffer=='True'?"1":"0";
	newwind = window.open( url, "AccoInfo", "scrollbars=yes,height="+h+",width="+w+",left="+l+",top="+t);
	newwind.focus();
}

// ****************************
// ** Update Navigation Menu **
// ****************************

function Navigate(PageNumber)
{
	NavigateShow(PageNumber, "");
}

function NavigateShow(PageNumber, Prefix)
{
	//change navigation if frame exists
	//doesn't work because of security
	//for(t=0; t<parent.frames.length; t++)
	//	if( parent.frames[t].name == 'wrnav' ) parent.wrnav.location.href = "Navigate.aspx?Page=" + PageNumber;
	
	parent.wrnav.location.href = Prefix + "Navigate.aspx?Page=" + PageNumber;
}

// **********************************
// ** Get some variable from style **
// **********************************

function getStyle (selector, cssPropertyName) 
{
	if (document.styleSheets) 
	{
		for (var i = document.styleSheets.length - 1; i >= 0; i--) 
		{
			var rules, selectorText;
			if (document.styleSheets[i].cssRules) 
			{
				rules = document.styleSheets[i].cssRules;
			}
			else if (document.styleSheets[i].rules) 
			{
				rules = document.styleSheets[i].rules;
			}
			if (rules) 
			{
				for (var j = rules.length - 1; j >= 0; j--) 
				{
					selectorText = rules[j].selectorText;
					if (selectorText.toLowerCase() == selector.toLowerCase()) 
					{
						return rules[j].style[cssPropertyName];
					}
				}
			}
		}
	} 
	return void 0;
}

//Retrieves the HIGHLITE backgroundcolor
function GetStyleBGColor()
{
	var kleur = "#FFFFFF";
	
	if (typeof(getStyle('.HighLite', 'backgroundColor')) != "undefined" )
	{
		if (getStyle('.HighLite', 'backgroundColor').length>0)
		kleur = getStyle ('.HighLite', 'backgroundColor');
	}
	
	return kleur;
}

function padleft(val, ch, num) 
{
	var re = new RegExp(".{" + num + "}$");
	var pad = "";
	if (!ch) ch = " ";
	do
	{
		pad += ch;
	}while(pad.length < num);
	return re.exec(pad + val);
}

function padright(val, ch, num)
{
	var re = new RegExp("^.{" + num + "}");
	var pad = "";
	if (!ch) ch = " ";
	do
	{
		pad += ch;
	} while (pad.length < num);
	return re.exec(val + pad);
}

