
messageObj = new DHTML_modalMessage();	// We only create one object of this class
messageObj.setShadowOffset(5);	// Large shadow
var checkid=1;
var checkmouse=1;
var browser=navigator.appName;
var timer;


function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
return [ myWidth,myHeight];
}

function findPosition(obj) {

var curleft = curtop = 0;
if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft
                curtop += obj.offsetTop
        }
}
return [curleft,curtop];

}
function findPos2(targetObj) {
	
var windowsize=getWindowSize();
	
 var cumulativeOffset = Position.cumulativeOffset(targetObj);
var realOffset = Position.realOffset(targetObj);
 var scrollTop = (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
 var scrollLeft = (document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
 
 
 var position = [cumulativeOffset[0]-(realOffset[0]-scrollLeft),cumulativeOffset[1]-(realOffset[1]-scrollTop)];
 var spaceY=windowsize[1]-position[1]+scrollTop;
 var spaceX=windowsize[0]-position[0]+scrollLeft;
//alert(scrollTop);
 var boxH=354;
 var boxW=510;
 // alert(boxH);
 if(spaceY<boxH){
	 position[1]=position[1]-boxH+100;
 }
 if(spaceX<boxW){
	 position[0]=position[0]-boxW+100;
 }
 
return position ;

}
function findPos(element) {

//var element = document.getElementById(elementId);
var left = 0;
var top = 0;

if (element != null)
{
    // Try because sometimes errors on offsetParent after DOM changes.
    try
    {
        while (element.offsetParent)
        {
            // While we haven't got the top element in the DOM hierarchy
            // Add the offsetLeft
            left += element.offsetLeft;
            // If my parent scrolls, then subtract the left scroll position
            if (element.offsetParent.scrollLeft) {left -= element.offsetParent.scrollLeft; }

            // Add the offsetTop
            top += element.offsetTop;
            // If my parent scrolls, then subtract the top scroll position
            if (element.offsetParent.scrollTop) { top -= element.offsetParent.scrollTop; }

            // Grab
            element = element.offsetParent;
        }
    }
    catch (e)
    {
        // Do nothing
    }

    // Add the top element left offset and the windows left scroll and subtract the body's client left position.
    left += element.offsetLeft + document.body.scrollLeft - document.body.clientLeft;
  //left += element.offsetLeft - document.body.scrollLeft - document.body.clientLeft;
    // Add the top element topoffset and the windows topscroll and subtract the body's client top position.
 top += element.offsetTop + document.body.scrollTop - document.body.clientTop;
	
}
return {x:left, y:top};

}

function toutProductInfo(url,pid,div) {

myPos = findPos(div)
x = myPos.x+10

if(browser=="Microsoft Internet Explorer")
{
	y = myPos.y-5;
	//alert ("ie");
}
else
{
	y = myPos.y-100
}

	timer=setTimeout("displayMessage('"+url+"','"+pid+"','"+x+"','"+y+"')", 100);
}

function tout(url,pid,div) {
var x=0;
var y=0;
//alert('h1');
x = jQuery(div).position().left - 40;
y = jQuery(div).position().top - 40;
/*
myPos = findPos2(div)
pos2=findPos(div)
x = myPos[0]-5
y = myPos[1]
alert(y);
alert(pos2.y);
*/
/*
if(browser=="Microsoft Internet Explorer")
{
	y = myPos[1]-5;
	//alert ("ie");
}
else
{
	y = myPos[1]-100
}
*/
//0alert(y);
	timer=setTimeout("displayMessage('"+url+"','"+pid+"','"+x+"','"+y+"')", 100);
}
function cleartout() {
	clearTimeout(timer);
}
var closeTimer = null;
function displayMessage(url,pid,x,y)
{
	if(checkid==1) {
		messageObj.setSource(url);
		messageObj.setCssClassMessageBox(false);
		//messageObj.setCssClassMessageBox('popup_parentdiv');
		//messageObj.setSize(400,200);
		//messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
		messageObj.display(x,y);
		checkid=0;
		if(checkmouse==1) {
			/*
			 jQuery('.popup_parentdiv').hover(
				function ()
				{},
				function(){
					checkmouse=0;
					setTimeout("closeMessage();",500);
				}
			  );
			*/
			jQuery('#DHTMLSuite_modalBox_contentDiv').bind('mouseenter',function() {
				clearTimeout(closeTimer);
			});
			jQuery('#DHTMLSuite_modalBox_contentDiv').bind('mouseleave',function() {
				checkmouse=0;
				closeTimer = setTimeout("closeMessage();",250);
			});
		}
	}
}

function displayStaticMessage(messageContent,cssClass)
{
	messageObj.setHtmlContent(messageContent);
	messageObj.setSize(300,150);
	messageObj.setCssClassMessageBox(cssClass);
	messageObj.setSource(false);	// no html source since we want to use a static message here.
	messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes	
	messageObj.display();
	
	
}

function closeMessage()
{
	checkid=1;
	lastID2 = "smallimage6";
	messageObj.close();	
	jQuery('#DHTMLSuite_modalBox_contentDiv').html('&nbsp;')
}

jQuery(document).ready(function() {

  jQuery('.listingProductImage').mouseout(function(){
     clearTimeout(timer);
  });

});




