//popup related script
var isIE = false;
var isSafari = false;
if (navigator.appName.substring(0,3) == "Mic"){
    isIE = true;
    }
else if (navigator.appVersion.indexOf("Safari") > 0){
    isSafari = true;
}

function getDim(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

// Decated to the information popup/tooltip
function findObjPos(obj){
	var ret = new Object();
	ret.w = obj.offsetWidth;
	ret.h = obj.offsetHeight;
	var curleft = curtop = 0;
	if (obj.offsetParent){
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent){
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	ret.x = curleft;
	ret.y = curtop;
	return ret;
}

// Popup Info Display / Hide
function ShowLocation(obj, heading, maintext, CloseButton, PopupWidth, positionLeft){
    var position = findObjPos(obj);
    var x = position.x;
    var y = position.y;
     
    var strPopupBody;
    var sourceMarginX = 80;
    var sourceMarginY = 00;
    
    var popupLayer = document.getElementById('l_InfoPopup');
    popupLayer.innerHTML = '';
    
    var l1 = document.createElement('div');
    var content = document.createElement('div');
    popupLayer.appendChild(l1);

    l1.innerHTML = "<table width=\"190\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr valign=\"top\"><td style=\"border-bottom: 1px solid rgb(51, 51, 51);\"><img border=\"0\" src=\"http://www.expedia.com/eta/tip_topLeft.gif\"/></td>	<td width=\"176\" style=\"border-top: 1px solid rgb(51, 51, 51); border-bottom: 1px solid rgb(51, 51, 51); background-color: rgb(102, 102, 102); font-size: 11px; font-family: Arial; font-weight: bold; color: rgb(255, 255, 255);\"><img src=\"http://media.expedia.com/ads/extras/media/images/UK/images_09.gif\" style=\"position: relative; top: 3px;\"/> Details	</td><td style=\"border-bottom: 1px solid rgb(51, 51, 51);\"><img border=\"0\" src=\"http://www.expedia.com/eta/tip_topRt.gif\"/></td>  </tr>  <tr valign=\"top\" bgcolor=\"#f7f7f7\"> 	<td bgcolor=\"f7f7f7\" style=\"border-left: 1px solid rgb(51, 51, 51);\">&nbsp;</td>	<td bgcolor=\"f7f7f7\" style=\" padding-top: 8px; padding-bottom: 8px; font-size: 11px; font-family: Arial; color: rgb(0, 0, 0);\">Special 	  offer: you can TRIPLE your points and collect 3,000 Nectar points if you 	  book now your tailor made package (flight + hotel, flight + car or flight 	  + hotel + car). Simply enter your Nectar card number on the booking confirmation 	  page.</td>	<td bgcolor=\"f7f7f7\" style=\"border-right: 1px solid rgb(51, 51, 51);\">&nbsp;</td>  </tr>  <tr valign=\"top\"> 	<td><img border=\"0\" src=\"http://www.expedia.com/eta/tip_bttmLeft.gif\"/></td>	<td bgcolor=\"#f7f7f7\" style=\"border-bottom: 1px solid rgb(51, 51, 51);\"><img src=\"http://www.expedia.com/eta/spaceit.gif\"/></td>	<td><img border=\"0\" src=\"http://www.expedia.com/eta/tip_bttmRt.gif\"/></td>  </tr></table>";
    
    
    if(CloseButton){
		var l5 = document.createElement('div');
		var closeLink = document.createElement('a');
		
		l5.className = 'l_InfoPopupClose';
		closeLink.href = 'javascript: HideLocation()';
		closeLink.innerHTML = closeString;
		
		l5.appendChild(closeLink);
		//l4.appendChild(l5);
	}
	
	popupLayer.style.width = PopupWidth + 'px';
	popupLayer.style.position = "absolute";
    popupLayer.style.display = 'block';
    
    // Setting popup position
    
    var WinHeight = (document.body.clientHeight)?document.body.clientHeight:window.innerHeight;
    var ScreenYposition = y - (document.body.scrollTop);
    
    if (!positionLeft){
        if ((x+PopupWidth)>760){
			popupLayer.style.left = x - 50 + "px";
			//popupLayer.style.left = x-((x+PopupWidth)-760) + "px";
			//alert(popupLayer.style.left);
        }
        else {
			
            popupLayer.style.left = x - 60 + "px";
        }
        
        popupLayer.style.top = (y + 15)  + "px";
        //popupLayer.style.top = (y + obj.offsetHeight) + "px";
    }
    else{
        popupLayer.style.left = (x - (PopupWidth)) + "px";
        
        if ((WinHeight - ScreenYposition) < popupLayer.offsetHeight){
        	if (navigator.appName.substring(0,3) == "Net") popupLayer.style.top = (y - (popupLayer.offsetHeight - (WinHeight - ScreenYposition))) + "px";
        	else popupLayer.style.top = (y - (popupLayer.offsetHeight - (WinHeight - (ScreenYposition)))) + "px";
        }
        else popupLayer.style.top = y + "px";
    }
    
    
    popupLayer.style.position = "absolute";
    popupLayer.style.display = "block";
    
}

function HideLocation(){
    new getObject("l_InfoPopup").style.display = "none";
}

// Get Object Function
function getObject(name){
	if (document.getElementById){
		this.obj = document.getElementById(name);
		if(document.getElementById(name))
		{
		this.style = document.getElementById(name).style;
		}
	}
	else if (document.all){
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
}