function openPOPupWindow(actionPage,t,key)
{
/*
	var agentdir='<?=$agentdir?>';
	var siteid='<?=$siteid?>';
	var agentid='<?=$agentid?>';
	var domain ='<?=$domain?>';
	var httpapgcom ='<?=$httpapgcom?>';
*/	
/*
	if (domain)
		rootPath = "http://"+domain+'/';
	else
		rootPath = httpapgcom +"/agents/"+agentdir+'/';
*/
	var rootPath = WWWROOT;

	var w = (screen.width - 530)/2;
	var h = (screen.height - 380)/2 - 60;

	features= 'width='+510+',height='+280+',top='+h+',left='+w;
	LoginPage = rootPath+"/custompages_popup_login.php?t="+t+"&key="+key+"&apage="+actionPage;
	
	popupWindowSecond('overlay2','overlaymain2',LoginPage,440,235,'<b>LOGIN</b>');
	o2('overlay2','overlaymain2');
	/*
	win = window.open(LoginPage,'Login',features);
	if (parseInt(navigator.appVersion) >= 4)
	{
			win.window.focus();
	}
	*/
}

function o2(name, main)
{
			el = document.getElementById(name);
			//el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
			el.style.visibility = (el.style.visibility == "hidden") ? "visible" : "visible";
			
			e2 = document.getElementById(main);
			//e2.style.visibility = (e2.style.visibility == "visible") ? "hidden" : "visible";
			e2.style.visibility = (e2.style.visibility == "hidden") ? "visible" : "visible";
			
		}
		
		function popupWindowSecond(name, main, url, width, height, title)
        {
			var strSiteRoot = WWWROOT;
			//var strUrl = strSiteRoot + "/"+ url;
			
			var strUrl = url;
			
			var ua = navigator.userAgent.toLowerCase();
			isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)); 
			isGecko = (ua.indexOf("gecko") != -1);
			isSafari = (ua.indexOf("safari") != -1);
			isKonqueror = (ua.indexOf("konqueror") != -1);
			
			if (window.innerHeight && window.scrollMaxY) 
			{
				// Firefox
				browseHeight = window.innerHeight + window.scrollMaxY;
				browseWidth = window.innerWidth + window.scrollMaxX;
			}
			 /*else if (screen.availHeight > document.body.offsetHeight){ // all but Explorer Mac
				browseHeight = screen.availHeight;
				browseWidth = screen.availWidth;
				
				//browseHeight = document.body.scrollHeight;
				//browseWidth = document.body.scrollWidth;
			} */
			else 
			{ 
				// works in Explorer 6 Strict, Mozilla (not FF) and Safari

				browseHeight = document.body.scrollHeight;
				browseWidth = screen.availWidth - 22;
				//browseHeight = document.body.offsetHeight;
				//browseWidth = document.body.offsetWidth;
			}
			
			/*******************************************************/
			
			var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
			position = 2;
			var version4 = (navigator.appVersion.charAt(0) == "4"); 
			evnt = version4 ? event : null;
			
			if(navigator.appName == "Microsoft Internet Explorer") 
			{
				screenY = document.body.offsetHeight + 150;
				screenX = window.screen.availWidth;
				//screenY = document.body.scrollTop;
				//screenX = window.screen.availWidth;
			}
			else 
			{
				screenY = window.outerHeight;
				screenX = window.outerWidth;
			}
		
			leftvar = (screenX - width) / 2;
			rightvar = (screenY - height) / 2;
			//rightvar = screenY;
			
			if(navigator.appName == "Microsoft Internet Explorer") 
			{
				//leftprop = leftvar;
				//topprop = rightvar;
				
				leftprop = document.body.scrollLeft + ((screenX - width) / 2);
				
				if (window.pageYOffset)
				{
					  topprop = window.pageYOffset
				}
				else if (document.documentElement && document.documentElement.scrollTop)
				{
					topprop = document.documentElement.scrollTop
				}
				else if (document.body)
				{
					  topprop = document.body.scrollTop
				}				
				topprop = topprop + 30; 
				//topprop = document.documentElement.scrollTop + 40;
			}
			else 
			{
				//leftprop = (leftvar - pageXOffset);
				//topprop = parseInt(rightvar - pageYOffset);
				
				leftprop = pageXOffset  + ((screenX - width) / 2);
				topprop = parseInt(pageYOffset + 40,10);
		   }
		
			/********************************************************/
			
			if(screen.height >= height)
				{windowTop = ((screen.height - height)/2) - 80;}
			else
				{windowTop = 0;}
				
			if(screen.width >= width)
				{windowLeft = (screen.width - width)/2;}
			else
				{windowLeft = 0;}
			//alert(windowTop);
			
			windowLeft = leftprop;
			windowTop = topprop;
			//alert(topprop);
			//alert('Page : ' + pageYOffset + ', ' + pageXOffset + ' ---Screen : ' + windowTop + ', ' + windowLeft + ' --- Window : ' + browseHeight + ', ' + browseWidth);
			
			if(isIE)
			{
				frameDivWidth = width;
				frameInnerDivWidth = width;
				frameDivHeight = height-28;
				frameWidth = '100%';
				frameHeight = frameDivHeight - 10;
				lastRowHeight = "8";
			}	
			else
			{
				frameDivWidth = width;
				frameInnerDivWidth = width;
				frameDivHeight = height-20;
				frameWidth = '100%';
				frameHeight = frameDivHeight - 10;
				lastRowHeight = "8";				
			}
		    InerframeTableHeight = frameDivHeight - 40;
			if(document.getElementById(name))
			{
				var d = document.getElementById(main);
				var olddiv = document.getElementById(name);
				d.removeChild(olddiv);
			  
				e2 = document.getElementById(main);
				e2.style.visibility = (e2.style.visibility == "visible") ? "hidden":'';	
			}
			
			var newMainDiv=document.createElement('div');
			newMainDiv.setAttribute('id',main);
			newMainDiv.style.width= browseWidth+'px';
			newMainDiv.style.height=  browseHeight+'px';
			
			newMainDiv.style.padding = "0px";
			newMainDiv.style.textAlign = "left";
			newMainDiv.style.left = "0px";
			newMainDiv.style.top = "0px";

			newMainDiv.style.position="absolute";
			newMainDiv.style.visibility="hidden";
			newMainDiv.style.backgroundImage = "url(/images/overlay.gif)";
			
			/*** Inner Main Div ***/
			var newDiv=document.createElement('div');
			var h = height;
			var w = width;

			newDiv.setAttribute('id',name);
			
			newDiv.className="divBorderStyle";
			//newDiv.style.border = borderClass;
			newDiv.style.width= w + "px";
			newDiv.style.height= h + "px";
			newDiv.style.padding = "0px";
			newDiv.style.textAlign = "left";
			newDiv.style.left = windowLeft+"px";
			newDiv.style.top = windowTop+"px";

			newDiv.style.position="relative";
			newDiv.style.visibility="hidden";
			newDiv.style.overfilter="Alpha(opacity=90)";
			//alert("FW" + frameDivWidth);
			var middleTDwidth1 = frameDivWidth  - 24;
			var middleTDwidth2 = frameDivWidth  - 16;

			
			newDiv.innerHTML = '<div  class="divBgImage" style="verticle-align:top;overflow:hidden;border:0px; text-align:left;width:'+frameDivWidth+'px;cursor:default;color:#ffffff; font-family:MS Sans Serif, Arial, Helvetica, sans-serif; font-size:1px; font-weight:bold; margin:0px; padding:0px 0px 0px 0em; white-space:nowrap"><table border=0 height=28 width="+frameDivWidth+" cellpadding="0" cellspacing="0" style="border:none;"><tr><td width="8"><img src="'+strSiteRoot+'/images/popleft.gif" border="0" width=8></td><td width='+middleTDwidth1+' background="'+strSiteRoot+'/images/popcenter.gif" style="font-size:10px;color:#FFFFFF;">&nbsp;&nbsp;'+title+'</td><td width="8" valign="middle" background="'+strSiteRoot+'/images/popcenter.gif"><a href="" title="Close" onClick="removeElement2();return false;"><img alt="" align=right valign="middle" border=0 src="'+strSiteRoot+'/images/close-btn.gif" /></a></td><td width="8" height=28><img src="'+strSiteRoot+'/images/popright.gif"  border="0"></td></tr></table></div><div style="border:none; padding-top:40px; text-align:left;width:'+frameInnerDivWidth+'px;height:'+ frameDivHeight +'px;cursor:default; color:#ffffff; font-family:MS Sans Serif, Arial, Helvetica, sans-serif; font-size:8px; font-weight:bold; margin:0px; padding:0px 0px 0px 0em; white-space:nowrap" style="background-repeat:no-repeat;"><table border=0 bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" width="+frameDivWidth+" height='+ frameDivHeight +'px; style="border:none;"><tr><td width="8"  background="'+strSiteRoot+'/images/popbodyleft.gif" style="background-repeat:repeat-y; "></td><td width='+middleTDwidth2+' valign="middle" colspan="2"><iframe id="popuptest" name="popuptest" allowtransparency="true" frameborder="0" style=" margin-right:0px;margin-bottom:5px;" name="testFrame" id="testFrame" width="'+frameWidth+'" height="'+frameHeight+'" src="'+strUrl+'">If you see this you browser dosen\'t support iframes.</iframe></td><td width="8"  background="'+strSiteRoot+'/images/popbodyright.gif" style="background-repeat:repeat-y; "></td></tr><tr height="'+lastRowHeight+'"><td width="8" height="'+lastRowHeight+'" background="'+strSiteRoot+'/images/popfooterleft.gif" style="background-repeat:no-repeat;vertical-align:bottom;"></td><td width="534" height="'+lastRowHeight+'" valign="middle" colspan="2" background="'+strSiteRoot+'/images/popfootercenter.gif" style="background-repeat:repeat-x;vertical-align:bottom;"></td><td width="8" height="'+lastRowHeight+'" background="'+strSiteRoot+'/images/popfooterright.gif" style="background-repeat:no-repeat;vertical-align:bottom;"></td></tr></table></div>';
//alert(newDiv.innerHTML);
			
			document.body.appendChild(newMainDiv);
			document.getElementById(main).appendChild(newDiv);
        }

		function removeElement1() 
		{
			/*if(!mortgageForm)
			{
				mortgageForm = '';	
			}
			if(mortgageForm == 'mortgage')
			{
				alert('here');
				if(newLinks == 1)
					parent.window.location.href = '/custompages_formsubmitted.php';	
				else
					parent.window.location.href = 'custompages_formsubmitted.php';	
			}*/

			var d = document.getElementById('overlayMain');
		  	var olddiv = document.getElementById('overlay');
		  	d.removeChild(olddiv);
		  
		  	e2 = document.getElementById("overlayMain");
			e2.style.visibility = (e2.style.visibility == "visible") ? "hidden" : "visible";
		}
		
		function removeElement2() 
		{
			/*if(!mortgageForm)
			{
				mortgageForm = '';	
			}
			if(mortgageForm == 'mortgage')
			{
				alert('here');
				if(newLinks == 1)
					parent.window.location.href = '/custompages_formsubmitted.php';	
				else
					parent.window.location.href = 'custompages_formsubmitted.php';	
			}*/
			
			var d = document.getElementById('overlaymain2');
		  	var olddiv = document.getElementById('overlay2');
		  	d.removeChild(olddiv);
		  
		  	e2 = document.getElementById("overlaymain2");
			e2.style.visibility = (e2.style.visibility == "visible") ? "hidden" : "visible";
		}
	function iepopupSelect_new()
	{ 
			var b_version=navigator.appVersion;
			if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  Done by bhawdeep
			{
				if(document.forms.length>0)
				{
					for(var j=0; j<document.forms.length ;j++)
					{
						if(document.forms[j])
						{
							var arrSelect=document.forms[j].getElementsByTagName("SELECT");
							for (var i=0; i<arrSelect.length; i++)
							{
								if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
								{
									arrSelect[i].style.display='none';
								}
							}
						}
					}
				 }
		   }
	}
	function iepopupSelect()
	{
			var b_version=navigator.appVersion;
			if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  Done by bhawdeep
			{
				if(parent.window.document.forms.length>0)
				{
					for(var j=0; j<parent.window.document.forms.length ;j++)
					{
						if(parent.window.document.forms[j])
						{
							var arrSelect=parent.window.document.forms[j].getElementsByTagName("SELECT");
							for (var i=0; i<arrSelect.length; i++)
							{
								if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
								{
									arrSelect[i].style.display='none';
								}
							}
						}
					}
				 }
		   }
	}

	function iepopupDeSelect()
	{
			var b_version=navigator.appVersion;
			if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  Done by bhawdeep
			{
				if(parent.window.document.forms.length>0)
				{
					for(var j=0; j<parent.window.document.forms.length ;j++)
					{
						if(parent.window.document.forms[j])
						{
							 var arrSelect=parent.window.document.forms[j].getElementsByTagName("SELECT");
							  for (var i=0; i<arrSelect.length; i++)
							  {
									if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
									{
										arrSelect[i].style.display='';
									}
							   }
						  }
					  }
				 }
		   }
	}	
	function iepopupDeSelect_new()
	{
			var b_version=navigator.appVersion;
			if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  Done by bhawdeep
			{
				if(document.forms.length>0)
				{
					for(var j=0; j<document.forms.length ;j++)
					{
						if(document.forms[j])
						{
							 var arrSelect=document.forms[j].getElementsByTagName("SELECT");
							  for (var i=0; i<arrSelect.length; i++)
							  {
									if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
									{
										arrSelect[i].style.display='';
									}
							   }
						  }
					  }
				 }
		   }
	}