/*
*   Global js functions
*/



function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
	return "";
}

function LCase(Value) {
	return Value.toString().toLowerCase();
}

function Len(Expression) {
	return Expression.toString().length;
}

function Right(Str, Length) {
	return Str.substring(Len(Str) - Length, Len(Str));
}

function InStr(Start, String1, String2, Compare) {
	if (Start > Len(String1)) return 0;
	if (Len(String2) == 0) return Start;
	if (Compare == 1) {String1 = LCase(String1); String2 = LCase(String2);}
	if (Start > 1) {
		var index = Right(String1, Len(String1) - Start + 1).indexOf(String2)
		if (index == -1) {return 0;} else {return index + Start;}
	} else {
		return String1.indexOf(String2) + 1
	}
}

function SessionArrayItem(g, n, s, l, sesionID, sessionTypeID) {
    var re;
    this.GPName = g;
    this.SessionName = n;
    this.SessionID = sesionID;
    this.SessionTypeID = sessionTypeID;
    this.start = new Date(s);
    this.end = new Date;
    this.end.setTime(this.start.getTime() + l * 60 * 1000); // in minutes ...
    //		this.end.setTime(this.start.getTime() + l * 1000); // in seconds ...
    return this;
}

function LinkRedirect(sURL, sFromDate, sToDate, redirectPath) {
	SetCookie('tickets_and_travel_redirect_2007', sURL, 9999);
	SetCookie('tickets_and_travel_fromdate', sFromDate, 9999);
	SetCookie('tickets_and_travel_todate', sToDate, 9999);
	window.open(redirectPath,'tandt_window','')
}


/*
*   Load Actions
*/
window.addEvent('domready', homeSlideShow);
//window.addEvent('domready', readyTextBoxes);
window.addEvent('domready', iterateForms);
window.addEvent('domready', readyPrint);
window.addEvent('domready', readyTNT);
window.addEvent('domready', initOverLabels);


function firefoxForceRerender(){
	// we need to trigger the rerender slightly in the future to give
	// the rendering threads a chance to sort themselves out
	setTimeout( firefoxForceRerenderTrigger, 10 );
}

function firefoxForceRerenderTrigger(){
	// we need to do something to the page to trick Firefox into rerendering it
	// just create a new SPAN, insert it at the end of the document and then
	// immediately delete it again
	var dummyNode = document.createElement("span");
	document.body.appendChild( dummyNode );
	Element.remove( dummyNode );
	
	if ($("ctrlFlash")) {
	    // $("ctrlFlash").style.display="none";
	    $("ctrlFlash").style.display="block";
	}
}	