 var tempobj = "";
 /*function ShowWaitDiv()
 {
    var div = document.getElementById("waitIndicator");
    var div2 = document.getElementById("waitIndicator2");
    div2.style.margin = (screen.height*0.25);
    
    div.style.top = 1;
    div.style.left = 1;
    div.style.width = '100%';
    div.style.height = '100%';
    div.style.visibility = 'visible';
    window.scrollBy(0,0);
}*/

function ShowSearchMessage(divName,src)
{
	if(document.getElementById)
	{
		obj = document.getElementById(divName);	
		if(obj)
		{
			obj.src = src;
			
            obj.style.top = (screen.availHeight-100)*0.25 + "px";
            obj.style.left = (screen.availWidth-300)*0.5 + "px";
            obj.style.width = "300px";
            obj.style.height = "141px";
            
	        obj.style.visibility = 'visible';
	        
		}
	}
	else{
	    /*alert('gah');*/
	}
	
	
	return true;
}
function showHideDiv(divName, state)
{
	div = document.getElementById(divName);	
	div.style.visibility = state;
}
function findCtrl(name)
{			
	frm = document.forms[0];
	for(i=0;i<frm.elements.length;i++)
	{
		elName = frm.elements[i].name;
			
		startIndex= elName.length-name.length;		
		elNameRight = elName.substring(startIndex,elName.length);				
		foundName = false;
		if(elNameRight.toLowerCase()==name.toLowerCase())
			foundName = true;
		/*
		elId = frm.elements[i].id;		
		if(elId && elId!="")
		{
			startIndex= elId.length-name.length;		
			elIdRight = elName.substring(startIndex,elId.length);		
			
			alert(elIdRight.toLowerCase())
			if(elIdRight.toLowerCase()==name.toLowerCase())		
				foundName = true;
		}
		*/
						
		if(foundName)
		{		
			return frm.elements[i];
		}				
	}		
	
	return null;	
}
function validatePassword(oSrc, args) 
{
name = args.Value.toLowerCase();

valid = true;
allowedChrs = "abcdefghijklmnopqrstuvwxyzåäö1234567890 @.,-_/!?";

for(i=0;i<name.length;i++)
{			
	if(allowedChrs.indexOf(name.toLowerCase().substring(i,i+1))<0)
	{					
		valid = false;
		break;
	}
}

args.IsValid = valid;
}

function validateName(oSrc, args) 
{
name = args.Value.toLowerCase();

valid = true;
allowedChrs = "abcdefghijklmnopqrstuvwxyzåäö ";

for(i=0;i<name.length;i++)
{			
	if(allowedChrs.indexOf(name.toLowerCase().substring(i,i+1))<0)
	{					
		valid = false;
		break;
	}
}

args.IsValid = valid;
}

//var isInBooking = false;

function HandleSummaryValidation(divName,src)
{
/*	
	if(isInBooking==true)
	{
		alert("Please wait - your booking is already beeing commited!\n\nVänligen vänta - din bokning håller redan på att bearbetas!");		
		return false;
	}
	
	isInBooking = true;
	displaySearchMsg(divName,src);			
	return true;
	}
	*/	
	displaySearchMsg(divName, src);
	return true;
}

function displaySearchMsg(divName, src)
{
	if(document.getElementById)
	{
		obj = document.getElementById(divName);	
		
		if(obj)
		{
			obj.src = src;
			h = 0;
			if(document.body)
			{			
				h = document.body.scrollHeight
			}

			if(h>0)
			{
				obj.style.height = h;
				obj.height = h;			
			}
			
			showHideDiv(divName,'visible')
		}
	}
}

function showHideDiv(divName, state)
{
	div = document.getElementById(divName);	
	div.style.visibility = state;
}

function validateCriteria(destErrorText, infErrorText, dateErrorText, iframeSrc)
{	
	ddAdt = findCtrl('ddAdt');
	ddInf = findCtrl('ddInf');
	/*if (ddAdt != null && ddAdt.selectedIndex != null && ddInf != null && ddInf.selectedIndex != null){*/
	    adt = ddAdt[ddAdt.selectedIndex].value;
	    inf = ddInf[ddInf.selectedIndex].value;
	
		
	    ddDayFrom = findCtrl('ddDayFrom');
	    ddMonthYearFrom = findCtrl('ddMonthYearFrom');
    	
	    ddDayTo = findCtrl('ddDayTo');
	    ddMonthYearTo = findCtrl('ddMonthYearTo');
    			
	    dateStringFrom = ddMonthYearFrom[ddMonthYearFrom.selectedIndex].value +"-" +ddDayFrom[ddDayFrom.selectedIndex].value;
	    dateStringTo = ddMonthYearTo[ddMonthYearTo.selectedIndex].value +"-" +ddDayTo[ddDayTo.selectedIndex].value;
    	
	    dateFrom = DateFromString(dateStringFrom);
	    dateTo = DateFromString(dateStringTo);
    	
	    today=new Date();	
	    todayDateString = today.getFullYear() +"-" +(today.getMonth()+1) +"-" +today.getDate();	
	    todayDate = DateFromString(todayDateString);
    	
	    compareDateTo = false;
	    rdType = findCtrl('type');	
	    if(rdType.id.indexOf('Return')>-1)
	    {		
		    if(rdType.checked)
			    compareDateTo = true;		
	    }
	    else
	    {
		    if(!rdType.checked)
			    compareDateTo = true;			
	    }
    			
	    if(dateFrom<todayDate || (compareDateTo && dateTo<todayDate))
	    {
		    alert(dateErrorText);
		    return false;
	    }	
    			
	    if(compareDateTo && (dateTo<dateFrom))
	    {
		    alert(dateErrorText);
		    return false;
	    }
    	
	    /*alert(ddCityFrom.options[ddCityFrom.selectedIndex].value);*/
	    if(ddCityFrom.options[ddCityFrom.selectedIndex].value == 'FROM' || ddCityTo.options[ddCityTo.selectedIndex].value == 'TO') 
	    {
		    alert(destErrorText);
		    return false;
	    }
    	
	    if(inf>adt)
	    {
		    alert(infErrorText);
		    return false;		
	    }
    	
	    displaySearchMsg('ifrmSearch',iframeSrc);
    	
	//}
	return true;
}


function printBooking(url)
{
wnd = window.open(url, 'bookingConf', 'width=800,height=600,scrollbars=yes,toolbar=yes');
}