/*************************************************************************
  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!
*************************************************************************/

// adjust horizontal and vertical offsets here
// (distance from mouseover event which activates tooltip)
Tooltip.offX = 5;  
Tooltip.offY = 5;
Tooltip.followMouse = false;  // must be turned off for hover-tip

//start ajax stuff
function createRequestObject(){
	var request_;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_ = new XMLHttpRequest();
	}
	return request_;
}

var http = createRequestObject();
var thediv = "div";
function displayProductReviews(prodid,page,thisdiv){
	var num = Math.random();
	thediv = "div" + prodid;
	http.open('get', 'http://www.flamingoworld.com/develope/ajax/productReviews.php?prodid=' + prodid + "&div=" + thediv + "&page=" + page +"&rand=" + num);
	http.onreadystatechange = handleInfo;
	http.send(null);
}

function displayMerchantCoupons(mid){
	var num = Math.random();
	http.open('get', 'http://www.flamingoworld.com/develope/ajax/merchantDeals.php?mid=' + mid + "&rand=" + num);
	http.onreadystatechange = handleInfo;
	http.send(null);
}

function displayPrices(prodid){
	var num = Math.random();
	http.open('get', 'http://www.flamingoworld.com/develope/ajax/showPriceComparison.php?prodid=' + prodid + "&rand=" + num);
	http.onreadystatechange = handleInfo;
	http.send(null);
}

function handleInfo(){
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById(thediv).innerHTML = response;
	}
}
//end ajax stuff


function getNextImage(nextlimit, prodid) {
	var num = Math.random();
 	var url = "/responseGetNextImage.php?limit=" + escape(nextlimit) + "&prodid=" + escape(prodid) + "&rnd=" + escape(num);
 	http.open("GET", url, true);
 	http.onreadystatechange = updateImage;
 	http.send(null);
}

function updateImage() {
 	if (http.readyState == 4) {
  	if (http.status == 200) {
     	var response = http.responseText;
     	document.getElementById("productImage").innerHTML = response;
     	
 			
		}
	}
}

function doTooltips(e, mid, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.clearTimer();
  var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
  if ( tip && tip.onmouseout == null ) {
      tip.onmouseout = Tooltip.tipOutCheck;
      tip.onmouseover = Tooltip.clearTimer;
  }
  if ( mid > 0){
  	this.thediv = "div" + mid;
 		var msg = "<div id='" + this.thediv + "' style='width:100%;height:250px;overflow: auto;'></div>";
 		Tooltip.show(e, msg);
 		displayMerchantCoupons(mid);
	}else{
		Tooltip.show(e, msg);
	}
}

function showMerchantDeals(e, mid, thisObj) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.clearTimer();
  var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
  if ( tip && tip.onmouseout == null ) {
      tip.onmouseout = Tooltip.tipOutCheck;
      tip.onmouseover = Tooltip.clearTimer;
  }
  
  thediv = "div" + mid;
 	var msg = "<div id='" + thediv + "' style='width:320;height:250px;overflow: auto;'></div>";
 	Tooltip.show(e, msg, thisObj);
 	displayMerchantCoupons(mid);	
}


function showReviews(e, prodid, page) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.clearTimer();
  var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
  if ( tip && tip.onmouseout == null ) {
      tip.onmouseout = Tooltip.tipOutCheck;
      tip.onmouseover = Tooltip.clearTimer;
  }
  
  this.thediv = "div" + prodid;
 	var msg = "<div id='" + this.thediv + "' style='width:300;height:250px;'></div>";
 	Tooltip.show(e, msg);
 	displayProductReviews(prodid, page, this.thediv);	
}

function showPrices(e, prodid) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.clearTimer();
  var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
  if ( tip && tip.onmouseout == null ) {
      tip.onmouseout = Tooltip.tipOutCheck;
      tip.onmouseover = Tooltip.clearTimer;
  }
  
  thediv = "divp" + prodid;
 	var msg = "<div id='" + thediv + "' style='width:300;height:250px;'></div>";
 	Tooltip.show(e, msg);
 	displayPrices(prodid);	
}


function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.timerId = setTimeout("Tooltip.hide()", 300);
}

Tooltip.tipOutCheck = function(e) {
  e = dw_event.DOMit(e);
  // is element moused into contained by tooltip?
  var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
  if ( this != toEl && !contained(toEl, this) ) Tooltip.hide();
}

// returns true of oNode is contained by oCont (container)
function contained(oNode, oCont) {
  if (!oNode) return; // in case alt-tab away while hovering (prevent error)
  while ( oNode = oNode.parentNode ) if ( oNode == oCont ) return true;
  return false;
}

Tooltip.timerId = 0;
Tooltip.clearTimer = function() {
  if (Tooltip.timerId) { clearTimeout(Tooltip.timerId); Tooltip.timerId = 0; }
}

Tooltip.unHookHover = function () {
    var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
    if (tip) {
        tip.onmouseover = null; 
        tip.onmouseout = null;
        tip = null;
    }
}

dw_event.add(window, "unload", Tooltip.unHookHover, true);
	
			
			
		
Image1 = new Image(100,21)
Image1.src = "http://www.flamingoworld.com/images/rating/0star_on.gif"

Image2 = new Image(100,21)
Image2.src = "http://www.flamingoworld.com/images/rating/1star_on.gif"

Image3 = new Image(100,21)
Image3.src = "http://www.flamingoworld.com/images/rating/2star_on.gif"

Image4 = new Image(100,21)
Image4.src = "http://www.flamingoworld.com/images/rating/3star_on.gif"

Image5 = new Image(100,21)
Image5.src = "http://www.flamingoworld.com/images/rating/4star_on.gif"

Image6 = new Image(100,21)
Image6.src = "http://www.flamingoworld.com/images/rating/5star_on.gif"


function zoomin2() {
document.emp.src = Image4.src; return true;
}

function zoomin() {
document.emp.src = Image3.src; return true;
}

function zoomout() {
document.emp.src = Image2.src; return true;
}

function change(to) {
	if(to == 1){
		document.emp.src = Image1.src; return true;
	}else{
		if(to == 2){
			document.emp.src = Image2.src; return true;
		}else{
			if(to == 3){
				document.emp.src = Image3.src; return true;
			}else{
				if(to == 4){
					document.emp.src = Image4.src; return true;
				}else{
					if(to == 5){
						document.emp.src = Image5.src; return true;
					}else{
						if(to == 6){
							document.emp.src = Image6.src; return true;
						}
					}
				}
			}
		}
	}
}

function original() {
document.emp.src = Image1.src; return true; 
}

function rate(points){
	document.map.score.value = points;
	window.map.submit();
}
function findPosX(obj){
  var curleft = 0;
  if(obj.offsetParent)
      while(1) 
      {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}

function findPosY(obj){
  var curtop = 0;
  if(obj.offsetParent)
      while(1)
      {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}