﻿
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.

//The statement below causes the menus to flicker in IE
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;
var id_div= null;
var recSeq=0;

function createDiv(idiv)
{
	if (!document.getElementById(idiv))http://localhost:4868/STRes/STWMain.aspx?SessID=F8EC650E-0B3F-483A-909E-BB4671C0F27C&Action=FITSeqList&Theme=TSE&SeqListLinear=Y&trip_type=AIRFHTL&QC=EUR&totaldest=1&destination1=CPH/CPH&checkin1=19 Mar 2010&checkout1=22 Mar 2010&numnights1=3&NumRooms=1&NumAdts1=2&NumChds1=0&Chd1Age1=&Chd2Age1=&NumAdts=2&NumChds=0&bookservices=HTL
	{
		//Create a new backdrop div
		var t = document.createElement('div');
		t.id = idiv;
		document.body.appendChild(t);
	}
}

function getMouseXY(e) {

  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX; //+ document.body.scrollLeft;.......The commented part of this line and the one below was causing the menu to flicker in GT when ie was used.
    tempY = event.clientY; //+ document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  if (id_div!=null)
  {
	
	if (IE) {tempX = (tempX + 15)}
	else  {tempX = (tempX + 17)}

	id_div.style.left = tempX + 'px';	
	
		//wH = ((GetWindowHeight() / 2) + GetScrollY() - (id_div.offsetHeight / 2));		
        //id_div.style.top  = wH + 'px';		
        id_div.style.top  = tempY + 'px';	
        id_div.style.display='';	
  }
  return true
}
// JScript File


function setSubMnu(mnu)
{
	switch (mnu)
	{	
		case 1: //Home Sub Menu
			document.getElementById('idNoSubMnu').style.display='none';
			document.getElementById('idHomeSubMnu').style.display='';
			document.getElementById('idGroupTravelSubMnu').style.display='none';
			break;
		case 3: //Group Travel Sub Menu
			document.getElementById('idNoSubMnu').style.display='none';
			document.getElementById('idHomeSubMnu').style.display='none';
			document.getElementById('idGroupTravelSubMnu').style.display='';
			break;
		default:
			document.getElementById('idNoSubMnu').style.display='';
			document.getElementById('idHomeSubMnu').style.display='none';
			document.getElementById('idGroupTravelSubMnu').style.display='none';
			break
	}
}

function OnOffLeftMenu(i)
{
	if (document.getElementById('idLeftMenu'))
	{
		switch (i.toUpperCase())
		{
			case 'OFF':
				document.getElementById('idLeftMenu').style.display='none';
				//document.getElementById('idLeftMenuMargin').style.display='none';
				break;
			case 'ON':
				document.getElementById('idLeftMenu').style.display='';
				//document.getElementById('idLeftMenuMargin').style.display='';
				break;
			default:
				document.getElementById('idLeftMenu').style.display='';
				//document.getElementById('idLeftMenuMargin').style.display='';
				break;
		}
	}
}

function SetMenuTabOn(i,p)
{
	document.getElementById('idtab1').src=p+'pics/home_off.gif'
	document.getElementById('idtab2').src=p+'pics/packagebuilder_off.gif'
	document.getElementById('idtab3').src=p+'pics/grouptravel_off.gif'
	document.getElementById('idtab4').src=p+'pics/travelguide_off.gif'
	document.getElementById('idtab5').src=p+'pics/helpcenter_off.gif'
	document.getElementById('idtab6').src=p+'pics/myaccount_off.gif'

	switch (i)
	{ 
		case 1:
			document.getElementById('idtab1').src=p+'pics/home_on.gif'
			break;
		case 2:
			document.getElementById('idtab2').src=p+'pics/packagebuilder_on.gif'
			break;
		case 3:
			document.getElementById('idtab3').src=p+'pics/grouptravel_on.gif'
			break;
		case 4:
			document.getElementById('idtab4').src=p+'pics/travelguide_on.gif'
			break;
		case 5:
			document.getElementById('idtab5').src=p+'pics/helpcenter_on.gif'
			break;
		case 6:
			document.getElementById('idtab6').src=p+'pics/myaccount_on.gif'
			break;
		default:
			break;
	}
	setSubMnu(i);
}

var isViewItinMap=false;
function ViewMaps()
{
	document.getElementById('idHotelListings').style.display='none';
	document.getElementById('idMapListings').style.display='';
	if (!isViewItinMap){DisplayMap()}
	isViewItinMap=true;
	
	//Below Map functions are essential when map is hidden.
	//Make sure that below functions are called after you display the map.
	//map.checkResize(); 
	//map.setCenter(new GLatLng(defLat, defLng), map.getZoom());	
	//MarkLines();
	
}
function ViewHotels()
{
	document.getElementById('idHotelListings').style.display='';
	document.getElementById('idMapListings').style.display='none';
}			

function hideImg(id)
{
	var prdImg=document.getElementById(id).getElementsByTagName('img')
	for (var i=0; i<prdImg.length; i++) 
	{
		if (prdImg[i].src.indexOf('NoImage.gif')>=0){prdImg[i].style.display='none'}
	}
}


function ShowModal(tid)
{
    try
    {
        /*
            -Create the backdrop
            -Show the backdrop
            -Show the requested element
            -Center the requested element
        */
        if (!document.getElementById('divbackdrop'))
        {
            //Create a new backdrop div
            var t = document.createElement('div');
            t.id = 'divbackdrop';
            document.body.appendChild(t)
        }
        var b = document.getElementById('divbackdrop');
        b.style.opacity = '.75';
        b.style.filter = 'alpha(opacity=75)';
        b.style.position = 'absolute';
        b.style.backgroundColor = '#000000';
        b.innerHTML = '&nbsp;';
        b.style.zIndex = 100;
        b.style.left = 0;
        b.style.top = 0;
        b.style.float = 'left';
        b.style.display = 'block';
        b.style.width = GetPageWidth() + 'px';
        b.style.height = GetPageHeight() + 'px';
       
        //b.style.left = GetScrollX();
        //b.style.top = GetScrollY();
        CenterDisplay('divbackdrop');
        CenterDisplay(tid);
        document.getElementById(tid).style.display = 'inline';
        document.getElementById(tid).style.zIndex = 1000;
        document.body.style.overflow="hidden";
        HideElement('APPLET', tid);
        HideElement('SELECT', tid);
        
        //alert('Backdrop: ' + document.getElementById('divbackdrop').style.zIndex + '\nItem (' + tid + '): ' + document.getElementById(tid).style.zIndex);
    }
    catch (ex)
    {
        //There was an error
        //alert('Overlay(' + tid + ') Failed: \n' + ex.description);
    }
}

function HideModal(tid)
{
    try
    {
        document.getElementById('divbackdrop').style.display = 'none';
        //document.getElementById('divbackdrop').style.overflow-x = 'auto';
        //document.getElementById('divbackdrop').style.overflow-y = 'auto';
        document.getElementById(tid).style.display = 'none';
        document.body.style.overflow="auto";
        ShowElement('APPLET');
        ShowElement('SELECT');
    }
    catch (ex)
    {
        //There was an error
        //alert('HideOverlay(' + tid + ') Failed: \n' + ex.description);
    }
}

//Hotel Popup
var iframeid='';
var divid='';
var d_obj;
var f_obj;


function IFRAMELoadEvent(func, idframe)
{
	var ifrm=document.getElementById(idframe)
    if (ifrm.attachEvent) {ifrm.attachEvent('onload', func);}
	else if (ifrm.addEventListener) {ifrm.addEventListener('load', func, false);}
	else {document.addEventListener('load', func, false);} 
}

  
 function eventPush(objid, duhevent, handler) {
   var obj=document.getElementById(objid);
   if (obj.addEventListener) {
     obj.addEventListener(duhevent, handler, false);
   } else if (obj.attachEvent) {
     obj.attachEvent('on'+duhevent, handler);
   }
}

 function eventPull(objid, duhevent, handler) {
   var obj=document.getElementById(objid);
   if (obj.removeEventListener) {
     obj.removeEventListener(duhevent, handler, false);
   } else if (obj.detachEvent) {
     obj.detachEvent('on'+duhevent, handler);
   }
}


function ShowFrame()
{
	document.getElementById('Wait').style.display='none';
	ShowModal(divid);    
	d_obj.style.display = 'block';
	f_obj.style.display = 'block';
	document.getElementById(iframeid).contentWindow.DisplayMap();
	eventPull(iframeid,'load',ShowFrame);
}


function loadiframe(idDiv, idFrame,w,h,ihtml)
{
    iframeid=idFrame;
    divid=idDiv;
    var d = document.getElementById(idDiv);
    var f = document.getElementById(idFrame);
    
    d_obj=d;
    f_obj=f;
    
    var a=new Date()
    var t=a.getTime();

    //load the url to iframe
    f.src = '';
        
//    f.onload =function(){
//		document.getElementById('Wait').style.display='none';
//		ShowModal(divid);    
//		d_obj.style.display = 'block';
//		f_obj.style.display = 'block';	alert('aaaa');
//		f_obj.onload=null;}
		
    eventPush(idFrame,'load',ShowFrame)
		

    f.src = ihtml+'&'+t;

    //frame style
    f.style.width = w + 'px';
    f.style.height = h + 'px';
    f.style.display = 'none';
    
    //Set DIV style
    d.style.width = w + 'px';
    d.style.height = h + 'px';
    d.style.display = 'none';

}
function hideiframe(idDiv, idFrame)
{
    var d = document.getElementById(idDiv);
    var f = document.getElementById(idFrame);
    var b = document.getElementById('divbackdrop');

    f.style.display = 'none';
    d.style.display = 'none';
    HideModal(idDiv);
    if (b){b.style.display='none';}
    f.src = '';
}

function displaySplash(txt)
{
	//document.getElementById('Wait').style.display='block';
	//document.getElementById('Wait').style.zIndex=9000;
	ShowModal('Wait');
	document.getElementById('tdwaitmessage').innerHTML = txt
	//CenterDisplay('Wait');
	
}

function ReadMore(ul)
{
	var prot = document.location.protocol;
	ul=ul.replace(/http:/,prot);
	ul+='&ShowPopup=Y';
	displaySplash('Loading Hotel Details...')
	loadiframe('idModal','idIFrame','820','710',ul);
}
function CloseReadMore()
{
	hideiframe('idModal','idIFrame');
}

function BookBtnHide()
{
	var flt=document.getElementById('tblairoptions1').getElementsByTagName('input');
	for (var i=0;i<flt.length;i++)
	{
		if (flt[i].value.indexOf('Book')>=0)
		{
			flt[i].style.display='none'
		}
		
	}

}

//overriding show() function from utils.js
function showMe(idDiv,a,b,c)
{
	if (!document.getElementById('idShowPop'))
	{
		var idT=document.createElement('div');
		idT.setAttribute('id',['idShowPop'])
		document.body.appendChild(idT);
	}
	var idT=document.getElementById('idShowPop');

	if (idDiv!='')
	{
		//document.getElementById(idDiv).style.display='';
		idT.innerHTML=document.getElementById(idDiv).innerHTML;
		idT.style.display='block';
		id_div=idT;
		if (IE) {tempX = (tempX + 25);}
		else  {tempX = (tempX + 30);}
		id_div.style.left = tempX + 'px';
		id_div.style.top = tempY + 'px';
		//alert('tempX='+tempX+'   tempY='+tempY);
	}
}
//overriding show() function from utils.js
function hideMe(idDiv,a,b,c)
{
	var idT=document.getElementById(idDiv);
	idT.style.display='none';
	document.body.removeChild(id_div);
}