var staticWith=150;
var staticHeight=60;
var curTarget   = null;
var dragHelper  = null;
var MouseMoveTarget=null;
var timer  = null;
var arrowType;
var ShowHelpDialog=false;
var IE = false;

if (navigator.appName == "Microsoft Internet Explorer"){IE = true}
if (!IE){document.captureEvents(Event.MOUSEMOVE)}
//document.onmousemove = mouseMove;
//var imagepath="/";//"/impnow_2008/";
var imagepath="/impnow_2008/";//For Local
Number.prototype.NaN0=function(){return isNaN(this)?0:this;}
window.onload = function()
{	
    dragHelper = document.createElement('DIV');
	dragHelper.style.cssText = 'position: absolute; border: 0px solid black;display:none;';//display:none;
	document.body.appendChild(dragHelper);
	//init();
}
function GetDiloagContent(Message,ButtonListType,FncList,ArrowType)
{
	var str="";
	//ArrowType=4;
	str +="<table border='0' cellpadding='0' cellspacing='0' width='100%' style='background-color: transparent; border: 0px'>";
	if(ArrowType==1)str +=arr_top_left(); //"<tr><td align='left' background='"+imagepath+"images/DynamicPopup/popup_top_bg.gif' style='padding-left: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_left_top.gif'></td></tr>";
	if(ArrowType==3)str +=arr_top_right(); //"<tr><td align='right' background='"+imagepath+"images/DynamicPopup/popup_top_bg.gif' style='padding-right: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_right_top.gif'></td></tr>";
	if(ArrowType==2 || ArrowType==4)str +=top_bg(); //"<tr><td background='"+imagepath+"images/DynamicPopup/popup_top_bg.gif' style='background-repeat: repeat-X;' width='100%'>&nbsp;</td></tr>";
	str +="<tr><td width='7' background='"+imagepath+"images/DynamicPopup/left_bg.gif'></td><td colspan='2' bgcolor='FFFFFF'>";
	str +="<table class='DynamicPopup' border='0' cellpadding='3' cellspacing='0' width='100%'><tr><td height='25'>" + Message + "</td></tr>";
	str +="<tr><td>" + GetDlgButtonList(ButtonListType,FncList) + "</td></tr></table>";		
	str +="</td><td width='7' background='"+imagepath+"images/DynamicPopup/right_bg.gif'></td></tr>";
	if(ArrowType==2)str +=arr_bot_left(); //"<tr><td align='left' background='"+imagepath+"images/DynamicPopup/popup_bottom_bg.gif'  style='padding-left: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_left_bottom.gif'></td></tr>";
	if(ArrowType==4)str +=arr_bot_right(); //"<tr><td align='right' background='"+imagepath+"images/DynamicPopup/popup_bottom_bg.gif' style='padding-right: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_right_bottom.gif'></td></tr>";
	if(ArrowType==1 || ArrowType==3)str +=bot_bg(); //"<tr><td align='right' background='"+imagepath+"images/DynamicPopup/popup_bottom_bg.gif' style='background-repeat: repeat-X;' width='100%'>&nbsp;</td></tr>";
	str +="</table>";
	return str;
}
////////////////////
var HelpContent = "<span style=\"font-family: Arial;\"><b>Thank you for your interest in the</b> <br><b>WomenCertified Locator.</b> Here you will find listings of professionals that have earned the Seal women trust for better service. Please help us build this valueable resource. You can do this by nominating any professional or business that you feel deserves to earn the WomenCertified Seal. You will receive a $25 gift certificate from Restaurants.com for every nomination.</span>";
function GetContent(Message)
{
    var str = "";
    if(Message!="")
    {
        str += "<table width=\"100%\" height=\""+staticHeight+"\" cellpadding=\"6\" cellspacing=\"6\" style=\"border: 1px solid #11A78A; background-color:#EDF9F7; color: #666666; font-size:11px; font-family:Verdana, Arial, Helvetica, sans-serif;\">";
        str += "<tr>";
        str += "<td align=center>";
        str += "<table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\">";
        str += Message;
        str += "</table>";
        str += "</td>";
        str += "</tr>";
        str += "</table>";
    }
    return str;
}

//////////////////
//-- Top Left: Arrow - 1 - Start --//
function arr_top_left()
{
	var str='';
	str +="<tr><td width='7'></td><td><img src='"+imagepath+"images/DynamicPopup/arr_left_top.gif'></td><td width='200'></td><td width='7'></td></tr>";
	str +="<tr><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_top_left.gif'></td><td background='"+imagepath+"images/DynamicPopup/white_bg.gif'></td><td background='"+imagepath+"images/DynamicPopup/top_bg.gif'></td><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_top_right.gif'></td></tr>";
	return str;
}
//-- Top Left: Arrow - 1 - End --//

//-- Top Right: Arrow - 3 - Start --//
function arr_top_right()
{
	var str="";
	str +="<tr><td width='7'></td><td width='200'></td><td><img src='"+imagepath+"images/DynamicPopup/arr_right_top.gif'></td><td width='7'></td></tr>";
	str +="<tr><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_top_left.gif'></td><td background='"+imagepath+"images/DynamicPopup/top_bg.gif'></td><td background='"+imagepath+"images/DynamicPopup/white_bg.gif'></td><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_top_right.gif'></td></tr>";
	return str;
}
//-- Top Right: Arrow - 3 - End --//

//-- Bottom Left: Arrow - 2 - Start --//
function arr_bot_left()
{
	var str="";
	str +="<tr><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_bot_left.gif'></td><td background='"+imagepath+"images/DynamicPopup/white_bg.gif'></td><td background='"+imagepath+"images/DynamicPopup/bot_bg.gif'></td><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_bot_right.gif'></td></tr>";
	str +="<tr><td width='7'></td><td><img src='"+imagepath+"images/DynamicPopup/arr_left_bottom.gif'></td><td width='200'></td><td width='7'></td></tr>";
	return str;
}
//-- Bottom Left: Arrow - 2 - End --//

//-- Bottom Right: Arrow - 4 - Start --//
function arr_bot_right()
{
	var str="";
	str +="<tr><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_bot_left.gif'></td><td background='"+imagepath+"images/DynamicPopup/bot_bg.gif'></td><td background='"+imagepath+"images/DynamicPopup/white_bg.gif'></td><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_bot_right.gif'></td></tr>";
	str +="<tr><td width='7'></td><td width='200'></td><td><img align='right' src='"+imagepath+"images/DynamicPopup/arr_right_bottom.gif'></td><td width='7'></td></tr>";
	return str;
}
//-- Bottom Right: Arrow - 4 - End --//

//-- Top BG: Arrow - 2 OR 4 - Start --//
function top_bg()
{
	var str="";
	str +="<tr><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_top_left.gif'></td><td colspan='2' background='"+imagepath+"images/DynamicPopup/top_bg.gif'></td><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_top_right.gif'></td></tr>";
	return str;
}
//-- Top BG: Arrow - 2 OR 4 - End --//

//-- Bottom BG: Arrow - 1 OR 3 - Start --//
function bot_bg()
{
	var str="";
	str +="<tr><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_bot_left.gif'></td><td colspan='2' background='"+imagepath+"images/DynamicPopup/bot_bg.gif'></td><td width='7'><img src='"+imagepath+"images/DynamicPopup/corner_bot_right.gif'></td></tr>";
	return str;
}
//-- Bottom BG: Arrow - 1 OR 3 - End --//
/* OLD function GetDiloagContent(Message,ButtonListType,FncList,ArrowType)
{
	var str="";
	var imagepath="/impnow_2008/";
	str +="<table border='0' cellpadding='0' cellspacing='0' width='100%' style='background-color: transparent; border: 0px'>";
	if(ArrowType==1)str +="<tr><td align='left' background='"+imagepath+"images/DynamicPopup/popup_top_bg.gif' style='padding-left: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_left_top.gif'></td></tr>";
	if(ArrowType==3)str +="<tr><td align='right' background='"+imagepath+"images/DynamicPopup/popup_top_bg.gif' style='padding-right: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_right_top.gif'></td></tr>";
	if(ArrowType==2 || ArrowType==4)str +="<tr><td background='"+imagepath+"images/DynamicPopup/popup_top_bg.gif' style='background-repeat: repeat-X;' width='100%'></td></tr>";
	str +="<tr><td><table class='DynamicPopup' border='0' cellpadding='3' cellspacing='0' width='100%'>";
	str +="<tr><td>" + Message + "</td></tr>";
	str +="<tr><td>" + GetDlgButtonList(ButtonListType,FncList) + "</td></tr>";		
	str +="</table></td></tr>";
	if(ArrowType==2)str +="<tr><td align='left' background='"+imagepath+"images/DynamicPopup/popup_bottom_bg.gif'  style='padding-left: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_left_bottom.gif'></td></tr>";
	if(ArrowType==4)str +="<tr><td align='right' background='"+imagepath+"images/DynamicPopup/popup_bottom_bg.gif' style='padding-right: 10px; background-repeat: repeat-X;' width='100%'><img src='"+imagepath+"images/DynamicPopup/arr_right_bottom.gif'></td></tr>";
	if(ArrowType==1 || ArrowType==3)str +="<tr><td align='right' background='"+imagepath+"images/DynamicPopup/popup_bottom_bg.gif' style='background-repeat: repeat-X;' width='100%'>&nbsp;</td></tr>";
	str +="</table>";
	return str;
}*/
function GetDlgButtonList(ButtonListType,FncList)
{
	var str="";
	var fncarr=FncList.split(",");
//	alert(fncarr[0]);
	if(ButtonListType==1)str="<input type=\"Button\" value=\"Cancel\" onclick=\"dlgCancel(" + fncarr[0] + ");\">";
	if(ButtonListType==2)str="<input type=\"Button\" value=\"Yes\" onclick=\"dlgYes(" + fncarr[0] + ");\"> <input type=\"Button\" value=\"No\" onclick=\"dlgNo(" + fncarr[1] + ");\">";
	return str;
}
function CloseToolTipNow()
{	
	dragHelper.style.display = 'none';
}
function CloseToolTip()
{	
	if(this.timer)
	{
		clearTimeout(this.timer);
		this.timer=0;
	}
	this.timer=setTimeout("CloseToolTipNow()",500);
	
}
function StopToolTip()
{	
	dragHelper.style.display = 'none';
	setTimeout("CloseToolTipNow()",1000)
}
function dlgCancel(fnc)
{
	dragHelper.style.display = 'none';
	//alert("Clicked Cancel");
	fnc();
}
function dlgYes(fnc)
{
	dragHelper.style.display = 'none';
	//alert("Clicked Yes");
	fnc();
}
function dlgNo(fnc)
{
	dragHelper.style.display = 'none';
	//alert("Clicked No");
	fnc();
}
function OpenDialog(ev,Message,ButtonListType,FncList,ShowArrow)
{
 /*   if(this.timer)
	{
		clearTimeout(this.timer);
		this.timer=0;
	}     */
	var ev         = ev || window.event;
	//var target   = ev.target || ev.srcElement;
	var mousePos = mouseCoords(ev);

/*	if(ShowHelpDialog)
	{
		if(staticHeight==60)
		{
			staticHeight=45;
		}
	}     */

	dragHelper.style.width=staticWith + "px";
/*	dragHelper.style.height=staticHeight + "px";    */
	var nTop=mousePos.y;
	var nLeft=mousePos.x;
	if((nTop - 15) >staticHeight)
	{
		nTop=nTop-15-staticHeight;
	}
	nLeft=nLeft+15;
	//alert(nTop);
/*	arrowType=1;	
	if(nTop >staticHeight)
	{
		arrowType=2;
		nTop=nTop-staticHeight;
	}
	if(nLeft>staticWith)
	{
		arrowType=3;
		if(ShowHelpDialog)
			nLeft=nLeft-(staticWith-20);
		else
			nLeft=nLeft-staticWith;
	}
	if(nTop!=mousePos.y && nLeft!=mousePos.x)
	{
		arrowType=4;
	}
	if(ShowArrow==false)arrowType=0;
	if(arrowType==0)
	{
		nTop=nTop-staticHeight;
	}  */
	nTop=nTop + "px";
	nLeft=nLeft + "px";

	dragHelper.style.top  = nTop;
	dragHelper.style.left = nLeft;
	if(ShowHelpDialog)
		dragHelper.innerHTML=GetHelpContent(HelpContent);//GetHelpContent(Message);
	else
		dragHelper.innerHTML=GetContent(Message);//dragHelper.innerHTML=GetDiloagContent(Message,ButtonListType,FncList,arrowType);
	dragHelper.style.display = 'block';
//	alert(dragHelper.style.top);
}
function GetHelpContent(Message)
{
	var str="";
	str +="<table cellpadding='8' cellspacing='8' style='border: 1px solid #11A78A; background-color:#EDF9F7; color: #666666; font-size:11px; font-family:Verdana, Arial, Helvetica, sans-serif;'>";
	str +="<tr>";
	str +="	<td>"+ Message +"</td>";
	str +="</tr>";
	str +="</table>";
	
	return str;
}
function mouseMove(ev)
{
	//ev         = ev || window.event;
	/*We are setting target to whatever item the mouse is currently on Firefox uses event.target here, MSIE uses event.srcElement */
	//this.MouseMoveTarget   = ev.target || ev.srcElement;
	//if(this.MouseMoveTarget.id=="dragHelper")alert(this.MouseMoveTarget.id);
}

/////////// Mouse Cordination - Start /////////////
var IE = false;
if (navigator.appName == "Microsoft Internet Explorer"){IE = true}
if (!IE){document.captureEvents(Event.MOUSEMOVE)}
function mouseCoords(ev)
{	
	
	if (!IE)
	{		
		return {x:ev.pageX, y:ev.pageY};
	}
	return{
		x:ev.clientX + document.documentElement.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.documentElement.scrollTop  - document.body.clientTop
		};	
}

function getMouseOffset(target, ev)
{
	ev = ev || window.event;

	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

function getPosition(e)
{
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	return {x:left, y:top};
}
/////////// Mouse Cordination - End /////////////
