/*************************************************************************
  dw_tooltip.js   requires: dw_event.js and dw_viewport.js
  version date: May 21, 2005 moved init call to body onload
  (March 14, 2005: minor changes in position algorithm and timer mechanism)
  
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2003-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is! 
*************************************************************************/
var tipImgTxt = '<div ><table id="mainId" style="position:absolute;left:85px;" width="365" height="294" border="0" cellpadding="0" cellspacing="0"><tr><td width="38" align="left" valign="top" ><img id="imgid" src="images/popup_01.png" width="38" height="294" alt=""></td><td width="339" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="10" background="images/popup_02.jpg"></td></tr><tr><td height="274" bgcolor="#FFFAFA"><div style="width:309px; height:274px; overflow:auto"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2" class="search_txt3">Over View </td><td width="24%" id="id1" class="footer_text">10/31/2007</td><td width="22%" id="id2" class="sort_select">Price: $35 </td><td width="19%"><a id="id3" href="#" class="book_it">Book it</a></td></tr><tr><td colspan="5" class="top_pad"><span class="search_head" id="id4" >Ramada Plaza Orlando</span><br><span class="content_text1" id="id5">8738 International Drive (International Drive)<br>Orlando, FL 32819-9317, United States<br>407-345-8195</span></td></tr><tr><td colspan="5"  class="top_pad5"><span class="search_head">Description:</span> <span id="id6" class="popup_txt">The Best Western Plaza International Orlando is a 2 Diamond AAA rated hotel with 672 spacious rooms, deluxe doubles and suites with 25-inch televisions, coffee/tea maker, in-room safe, hairdryer, iron and ironing board, telephone with voice mail, dataports, movies The Best Western Plaza International Orlando is a 2 Diamond AAA rated hotel with 672 spacious rooms, deluxe doubles and suites with 25-inch televisions, coffee/tea maker, in-room safe, hairdryer....</span></td></tr><tr><td colspan="5"  class="top_pad5"><span class="amenity_txt" id="id7"><span class="amenity_head">Amenities:</span> Parking (free), Sprinklers, High-speed internet (for a fee), Electronic keys, ATM/Bank</span></td></tr><tr><td colspan="5"  class="top_pad5"><span id="id8" class="activity_txt"><span class="activity_head">Activities:</span> Pool (outdoor), Hot tub, Game room, Pool (children)</span></td></tr><tr><td width="13%" class="list_rating">Rating:</td><td width="22%" id="id9" ><img src="images/star_full.gif" width="11" height="11"><img src="images/star_full.gif" width="11" height="11"><img src="images/star_empty.gif" width="11" height="11"><img src="images/star_empty.gif" width="11" height="11"><img src="images/star_empty.gif" width="11" height="11"></td><td align="right" class="pad_3"><img src="images/img_phone.gif" width="9" height="16"></td><td colspan="2" id="id10" class="list_calltoll">1-800-345-9384</td></tr></table></div></td></tr><tr><td height="10" background="images/popup_05.jpg"></td></tr></table></td><td width="18" align="right" valign="top"><img src="images/popup_03.png" width="18" height="294" alt=""></td></tr></table></div>';
 var el;
var Tooltip = {
    followMouse: false,
    offX:-7,
    offY:-50,
    tipID: "tipDiv",
    showDelay: 0,
    hideDelay: 2500,
    
    ready:false, timer:null, tip:null, 
  
    init: function() {  
        if ( document.createElement && document.body && typeof document.body.appendChild != "undefined" ) {
            if ( !document.getElementById(this.tipID) ) {
             el = document.createElement("DIV");
                el.id = this.tipID; 
				
				el.style.position="absolute";
				el.style.top='0px';
				document.body.appendChild(el);
            }
            this.ready = true;
        }
    },
    
    show: function(e,data) {

        if (this.timer) { clearTimeout(this.timer);	this.timer = 0; }
        this.tip = document.getElementById( this.tipID );
        if (this.followMouse) // set up mousemove 
            dw_event.add( document, "mousemove", this.trackMouse, true );
        this.writeTip("");  // for mac ie
		viewport.getAll();	


if(parseInt(el.style.top)>650)
	{
		this.writeTip(tipImgTxt);
		document.getElementById('imgid').src="images/popup_01_down.png";
		document.getElementById('mainId').style.top="-200"+"px";
	    newdata(data);
	
		pngfix();
		}else
			{
				this.writeTip(tipImgTxt);
				document.getElementById('mainId').style.top="0"+"px";
	            newdata(data); 
						
				pngfix();
			}
		//el.style.top='0'+"px";	 
		/*if(e.clientY>400)
		 {	 
		 	
		 	
            //document.getElementById('mainDiv').style.top=(e.clientY-700)+'px';
			
			newdata(data);
			pngfix();
	     }
		else
		{
	         this.writeTip( tipImgTxt);
			 newdata(data);
			 
			 pngfix();
		 }*/
        this.positionTip(e);
		this.timer = setTimeout("Tooltip.toggleVis('" + this.tipID + "', 'visible')", this.showDelay);
    },
    
    writeTip: function(msg) {
		  if ( this.tip && typeof this.tip.innerHTML != "undefined" ) this.tip.innerHTML = msg;
    },   
    positionTip: function(e) {
        if ( this.tip && this.tip.style ) {
            // put e.pageX/Y first! (for Safari)
            var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
            var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
		    if ( x + this.tip.offsetWidth + this.offX > viewport.width + viewport.scrollX ) 
			{
                x = x - this.tip.offsetWidth - this.offX;
                if ( x < 0 ) x = 0;
            } 
			else x = x + this.offX;
        
            if ( y + this.tip.offsetHeight + this.offY > viewport.height + viewport.scrollY ) {
                y = y - this.tip.offsetHeight - this.offY;
                if ( y < viewport.scrollY ) y = viewport.height + viewport.scrollY - this.tip.offsetHeight;
            } else y = y + this.offY;
            
            this.tip.style.left = x + "px"; this.tip.style.top = y + "px";
			
        }
    },
    
    hide: function() {
        if (this.timer) { clearTimeout(this.timer);	this.timer = 0; }
        this.timer = setTimeout("Tooltip.toggleVis('" + this.tipID + "', 'hidden')", this.hideDelay);
        if (this.followMouse) // release mousemove
            dw_event.remove( document, "mousemove", this.trackMouse, true );
        this.tip = null; 
    },

    toggleVis: function(id, vis) { // to check for el, prevent (rare) errors
        var el = document.getElementById(id);
        if (el) el.style.visibility = vis;
    },
    
    trackMouse: function(e) {
    	e = dw_event.DOMit(e);
     	Tooltip.positionTip(e);
    }
    
}
 
 function pngfix()
 {
	  var arVersion = navigator.appVersion.split("MSIE")
	  var version = parseFloat(arVersion[1])
		if ((version >= 5.5) && (document.body.filters)) 
			{ 
				for(var i=0; i<document.images.length; i++)
   					{
      					var img = document.images[i]
						var imgName = img.src.toUpperCase()
						   if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      						  {
							   		var imgID = (img.id) ? "id='" + img.id + "' " : "";
							        var imgClass = (img.className) ? "class='" + img.className + "' " : "";
        							var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
							        var imgStyle = "display:inline-block;" + img.style.cssText ;
							        if (img.align == "left") imgStyle = "float:left;" + imgStyle;
							        if (img.align == "right") imgStyle = "float:right;" + imgStyle;
							        if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
							        var strNewHTML = "<span " + imgID + imgClass + imgTitle
							        + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
							        + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
							        + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" ;
							        img.outerHTML = strNewHTML;
									i = i-1;
      							}
   					}
				}	el.style.top='0px';
  }
  
function newdata(data)
{
   
   //number of id=9
   //id1-date id2-price id3-bookit link id4-hotel name id5-hotel addr id6-Description id7-Amenities id8-Activities 
   //id9-rating id10-phone num
   //["date","price',"link","hotel name","address","description","amenities","activities","rating","phone number"];
   
   for(var i=0;i<data.length;i++)
   {
	   if(data[8]=="1" && data[8]<2)
	   {
			data[8] = '<img src="images/star_full.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" />';
	   }
	   else if(data[8]=="2" && data[8]<3)
	   {
		   data[8] = '<img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" />';
	   }
	   else if(data[8]=="3" && data[8]<4)
	   {
		   data[8] = '<img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" />';
	   }
	   else if(data[8]=="4" && data[8]<5)
	   {
		   data[8] = '<img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" />';
	   }
	   else if(data[8]=="5"  && data[8]>5)
	   {
		   data[8] = '<img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" />';
	   }
	   else
	   {
		   data[8] = '<img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_full.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" /><img src="images/star_empty.gif" width="11" height="11" />';
	   }
		document.getElementById('id'+(i+1)).innerHTML=data[i];
   }
   
}
