// --------------------------------------------------------------------------------------------------------- SET: Variables (BEGIN)
var firstTimer=true;
var loadMap=false;
var loadFlash=false;
var setSearch=false;
var loadWalkOn=false;
var reloadArticle=false;
var loadChat=false;
// --------------------------------------------------------------------------------------------------------- SET: Variables (END)
// --------------------------------------------------------------------------------------------------------- SET: Core Styles (BEGIN)
document.write("<style type=\"text/css\"><!--");
document.write("div#pop_overlay{width:100%;height:100%;background:#000000;opacity:0.6;z-index:20;margin:auto;min-height:100%;display:none;}");
document.write("body > div#pop_overlay{position: fixed;top:0px;left:0px;display:none;}");
document.write("div#pop_container{width:100%;height:100%;background:transparent;z-index:25;margin:auto;display:none;}");
document.write("body > div#pop_container {position: fixed;top:0px;left:0px;display:none;background:transparent}");
document.write("div#pop_inner{position:absolute;display:block;margin:auto;left:50%;top:50%;text-align:center; z-index:30;}");
document.write("div#pop_walkon {width:560px;height:315px;position:fixed;margin:0px;padding:0px;z-index:35;overflow:hidden; }");
document.write("body > div#pop_walkon{width:560px;height:315px;position:fixed;margin:0px;padding:0px;bottom:0px;z-index:35;overflow:hidden;}");
document.write("--></style>");
document.write("<!--[if gte IE 5.5]><![if lt IE 7]><style type=\"text/css\">");
document.write("div#pop_overlay {filter:alpha(opacity=60);-moz-opacity:0.6;position: absolute;left: expression( (( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );top: expression( (( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );}");
document.write("div#pop_container {position: absolute;left: expression( (( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );top: expression( (( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );}");
document.write("html {height: 100%;overflow:hidden;overflow-y:auto;}");
document.write("body {margin:0px;height: 100%;overflow:hidden;overflow-y:auto;}");
document.write("div#pop_walkon{width:560px;height:315px;position: absolute !important;margin-right:15px;overflow:hidden;}");
document.write("</style><![endif]><![endif]-->");
document.write("<!--[if IE 7]><style type=\"text/css\">");
document.write("div#pop_overlay {filter:alpha(opacity=60);-moz-opacity:0.6;position: fixed;top:0px;left:0px;}");
document.write("div#pop_container {position: fixed;top:0px;left:0px;}");
document.write("</style><![endif]-->");
// --------------------------------------------------------------------------------------------------------- SET: Core Styles (BEGIN)
// --------------------------------------------------------------------------------------------------------- SET: Functions (BEGIN)
function onLoadPopUp() {// ---------------------------------------------------------------------------- FUNC: onLoadPopUp v.1.0
	displayPopUp();
	setDDConfig();
	if(loadMap){initMap();}
	if(loadFlash){flashLoader();}
	//if(setSearch){listpriceAdjust(buyrent,lpl,lph);}
	if(loadWalkOn){loadWalkonVideo(wo_id,wo_align,wo_siteid,wo_width,wo_height);}
	if(loadChat){chatLoader();}
}

function displayPopUp() {// --------------------------------------------------------------------------- FUNC: displayPopUp v.1.0
	//alert('firstTimer: '+firstTimer);
	if(firstTimer==true)
	{
		var pop_over = document.createElement("div")
		pop_over.id="pop_overlay"
		document.body.appendChild(pop_over)

		var pop_cont = document.createElement("div")
		pop_cont.id="pop_container"

		var pop_inner = document.createElement("div")
		pop_inner.id="pop_inner"
		pop_cont.appendChild(pop_inner)
		
		document.body.appendChild(pop_cont)

		var pop_walkon = document.createElement("div")
		pop_walkon.id="pop_walkon"
		//pop_cont.appendChild(pop_walkon)
		document.body.appendChild(pop_walkon)

		//document.body.appendChild(pop_cont)

		//document.body.innerHTML+="<div id='pop_overlay'></div><div id='pop_container'><div id='pop_inner'></div></div>";
		firstTimer=false;
		document.getElementById('pop_overlay').style.display='none';
		document.getElementById('pop_container').style.display='none';
		document.getElementById('pop_walkon').style.display='none';
	}
	else
	{
		var check=document.getElementById('pop_overlay').style.display;
		//alert('check: '+check);
		if(check=='none')
		{
			document.getElementById('pop_overlay').style.display='block';
			document.getElementById('pop_container').style.display='block';
			//window.scroll='no';
		}
		else
		{
			document.getElementById('pop_inner').innerHTML="";
			document.getElementById('pop_overlay').style.display='none';
			document.getElementById('pop_container').style.display='none';
			if(reloadArticle){reloadNewsPreview();}
			//window.scroll='yes';
		}
	}
}

function launchPopUp(poptype,coreelement,id,var1) {// ------------------------------------------------------ FUNC: launchPopUp v.1.0
	page=''
	displayPopUp();
	pi = document.getElementById('pop_inner');
	pw = document.getElementById('pop_walkon');
	if(!coreelement){
		page='core/';
	}
	//alert('POPUP: '+poptype);
	switch(poptype){
	//------------------------------------------------------------------------------ AREA: User Info Request (BEGIN)
		case "req_email":
		case "req_phonenum":
			page+='system_popup_request.asp?msgtype=' + poptype;
			pi.style.width="350px";
			pi.style.height="325px";
			pi.style.marginLeft="-175px";
			pi.style.marginTop="-163px";

			iframe_width="100%";
			iframe_height="325";
		break;
		case "req_addr":
			page+='system_popup_request.asp?msgtype=' + poptype;
			pi.style.width="350px";
			pi.style.height="300px";
			pi.style.marginLeft="-175px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "req_openquest":
		case "req_fullinfo":
			page+='system_popup_request.asp?msgtype=' + poptype;
			pi.style.width="350px";
			pi.style.height="450px";
			pi.style.marginLeft="-175px";
			pi.style.marginTop="-225px";

			iframe_width="100%";
			iframe_height="450";
		break;
	//------------------------------------------------------------------------------ AREA: User Info Request (END)
	//------------------------------------------------------------------------------ AREA: Photo Galleries (BEGIN)
		case "admin_photo_img_saveedit":
			page+='system_popup_confirm.asp?confirmtype=' + poptype + '&id=' + id;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "admin_photo_img_saveadd":
		case "admin_photo_img_del":
		case "admin_photo_gal_del":
		case "admin_photo_cat_del":
			page+='system_popup_confirm.asp?confirmtype=' + poptype;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "admin_photo_img_edit":
			page+='system_popup_galimage.asp?displaymode=Edit&id='+ id + '&imagepage='+ var1;
			pi.style.width="700px";
			pi.style.height="420px";
			pi.style.marginLeft="-350px";
			pi.style.marginTop="-210px";

			iframe_width="100%";
			iframe_height="420";
		break;
		case "admin_photo_img_add":
			page+='system_popup_galimage.asp?displaymode=Add&id='+ id;
			pi.style.width="700px";
			pi.style.height="380px";
			pi.style.marginLeft="-350px";
			pi.style.marginTop="-190px";

			iframe_width="100%";
			iframe_height="380";
		break;
		case "pop_photoimage":
			page+="galleries_details_imgview.asp?imageid=" + id
			pi.style.width="760px";
			pi.style.height="570px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-285px";

			iframe_width="100%";
			iframe_height="570";
		break;
	//------------------------------------------------------------------------------ AREA: Photo Galleries (END)
	//------------------------------------------------------------------------------ AREA: Property (BEGIN)
		case "admin_prop_book_del":
			page+='system_popup_confirm.asp?confirmtype=' + poptype + '&id=' + id;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "admin_prop_confirmsave":
		case "admin_prop_archive":
		case "admin_prop_restore":
		case "admin_prop_update":
		case "admin_prop_img_del":
		//case "archiveprops":
		//case "restoreprops":
		//case "updateprops":
		//case "deletepropimages":
			page+='system_popup_confirm.asp?confirmtype=' + poptype;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "admin_prop_img_saveedit":
			page+='system_popup_propimage.asp?displaymode=Edit&actiontype=admin_prop_img_saveedit&id='+ id + '&imageid='+ var1;
			pi.style.width="700px";
			pi.style.height="410px";
			pi.style.marginLeft="-350px";
			pi.style.marginTop="-205px";

			iframe_width="100%";
			iframe_height="410";
		break;
		case "admin_prop_img_edit":
			page+='system_popup_propimage.asp?displaymode=Edit&id='+ id + '&imagepage='+ var1;
			pi.style.width="700px";
			pi.style.height="410px";
			pi.style.marginLeft="-350px";
			pi.style.marginTop="-205px";

			iframe_width="100%";
			iframe_height="410";
		break;
		case "admin_prop_img_add":
			page+='system_popup_propimage.asp?displaymode=Add&id='+ id;
			pi.style.width="700px";
			pi.style.height="380px";
			pi.style.marginLeft="-350px";
			pi.style.marginTop="-190px";

			iframe_width="100%";
			iframe_height="380";
		break;
	//------------------------------------------------------------------------------ AREA: Property (END)
	//------------------------------------------------------------------------------ AREA: Property Search (BEGIN)
		case "propsrch_sel_buildingstyle":
			checkeditems=document.advsearch.buildingstylesel.value;

			page+='property_search_buildingstyleselect.asp?checkeditems=' + checkeditems;
			pi.style.width="760px";
			pi.style.height="300px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "propsrch_sel_buildingtype":
			checkeditems=document.advsearch.buildingtypesel.value;
			
			page+='property_search_buildingtypeselect.asp?checkeditems=' + checkeditems;
			pi.style.width="760px";
			pi.style.height="300px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "propsrch_sel_city":
			statetarget="";
			for ( i = 0; i < document.advsearch.state.length; i++) { 
				if (document.advsearch.state[i].checked) {statetarget=document.advsearch.state[i].value;} 
			} 
			if (statetarget=="") {statetarget="none";}
			
			targetcounties=document.advsearch.countysel.value;
			checkedcities=document.advsearch.citysel.value;

			page+='property_search_cityselect.asp?targetstate=' + statetarget + '&targetcounties=' + targetcounties + '&checkedcities=' + checkedcities;
			pi.style.width="760px";
			pi.style.height="300px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "propsrch_sel_county":
			statetarget="";
			for ( i = 0; i < document.advsearch.state.length; i++) { 
				if (document.advsearch.state[i].checked) {statetarget=document.advsearch.state[i].value;} 
			} 
			if (statetarget=="") {statetarget="none";}
			
			checkedcounties=document.advsearch.countysel.value;

			page+='property_search_countyselect.asp?targetstate=' + statetarget + '&checkedcounties=' + checkedcounties;
			pi.style.width="760px";
			pi.style.height="300px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
	//------------------------------------------------------------------------------ AREA: Property Search (END)
	//------------------------------------------------------------------------------ AREA: Messaging (BEGIN)
		case "admin_msg_close":
			page+='system_popup_confirm.asp?confirmtype=' + poptype;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
	//------------------------------------------------------------------------------ AREA: Messaging (END)
	//------------------------------------------------------------------------------ AREA: User (BEGIN)
		case "user_booking_del":
			page+='system_popup_confirm.asp?confirmtype=' + poptype + '&id=' + id;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "admin_user_del":
		case "admin_group_del":
		case "admin_user_doc_del":
		case "admin_user_fav_del":
		case "admin_user_msg_close":
		case "admin_user_search_del":
		case "admin_user_search_emailenable":
		case "admin_user_search_emaildisable":

		case "user_doc_del":
		case "user_fav_del":
		case "user_fav_del":
		case "user_msg_close":
		case "user_search_del":
		case "user_search_emailenable":
		case "user_search_emaildisable":
			page+='system_popup_confirm.asp?confirmtype=' + poptype;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "admin_user_pass":
			page+='system_popup_pass.asp?id='+id+'&msgtype=' + poptype;
			pi.style.width="350px";
			pi.style.height="150px";
			pi.style.marginLeft="-175px";
			pi.style.marginTop="-75px";

			iframe_width="100%";
			iframe_height="150";
		break;
		case "sel_groupusers":
			page+='admin_groups_sel_users.asp?grpid=' + id;
			pi.style.width="760px";
			pi.style.height="450px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-225px";

			iframe_width="100%";
			iframe_height="450";
		break;
	//------------------------------------------------------------------------------ AREA: User (END)
	//------------------------------------------------------------------------------ AREA: News (BEGIN)
		case "savenltrpreview":
		case "updateagents":
		case "deleteagents":
		case "deletefavs":
		case "del_grp":
		case "del_articles":
		case "del_newsletters":
			page+='system_popup_confirm.asp?confirmtype=' + poptype;
			pi.style.width="200px";
			pi.style.height="300px";
			pi.style.marginLeft="-100px";
			pi.style.marginTop="-150px";

			iframe_width="100%";
			iframe_height="300";
		break;
		case "sel_newsarticles":
			page+='admin_news_sel_newsarticles.asp?grpid=' + id;
			pi.style.width="760px";
			pi.style.height="450px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-225px";

			iframe_width="100%";
			iframe_height="450";
		break;
		case "view_newsletter":
			//cm = document.getElementById('changesmade')
			//if(cm.value=='true'){launchPopUp("savenltrpreview",true,id);return}
			page+='admin_news_preview_newsletter.asp?grpid=' + id;
			pi.style.width="760px";
			pi.style.height="500px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-250px";

			iframe_width="100%";
			iframe_height="500";
		break;
		case "news_sel_kw":
			page+='admin_news_edit_keywords.asp?id=' + id;
			pi.style.width="550px";
			pi.style.height="450px";
			pi.style.marginLeft="-275px";
			pi.style.marginTop="-225px";

			iframe_width="100%";
			iframe_height="450";
		break;
		case "news_sel_kwfilter":
			page+='news_keywords.asp?filtertype='+id;
			pi.style.width="550px";
			pi.style.height="450px";
			pi.style.marginLeft="-275px";
			pi.style.marginTop="-225px";

			iframe_width="100%";
			iframe_height="450";
		break;
		case "news_clear_kwfilter":
			page+='news_keywords.asp?filtertype='+id+'&actiontype=clear';
			pi.style.width="250px";
			pi.style.height="60px";
			pi.style.marginLeft="-125px";
			pi.style.marginTop="-30px";

			iframe_width="100%";
			iframe_height="60";
		break;
	//------------------------------------------------------------------------------ AREA: News (END)
	//------------------------------------------------------------------------------ AREA: Agents (BEGIN)
		case "sel_agentcredentials":
			page+='admin_agents_edit_credentials.asp?id=' + id + '&actiontype=list';
			pi.style.width="550px";
			pi.style.height="450px";
			pi.style.marginLeft="-275px";
			pi.style.marginTop="-225px";

			iframe_width="100%";
			iframe_height="450";
		break;
	//------------------------------------------------------------------------------ AREA: Agents (END)
	//------------------------------------------------------------------------------ AREA: Email Sender (BEGIN)
		case "email_template_group":
		case "email_template_user":
			page+='system_email_template.asp?displaymode='+poptype+'&id='+id;
			pi.style.width="760px";
			pi.style.height="650px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-325px";

			iframe_width="100%";
			iframe_height="650";
		break;
	//------------------------------------------------------------------------------ AREA: Email Sender (END)
	//------------------------------------------------------------------------------ AREA: Site Edit (BEGIN)
		case "edit_createsite":
			page+='system_db_sitecreation.asp';
			pi.style.width="760px";
			pi.style.height="650px";
			pi.style.marginLeft="-380px";
			pi.style.marginTop="-325px";

			iframe_width="100%";
			iframe_height="650";
		break;
		case "edit_pagecontent":
			page+='admin_siteedit_pageedit.php?pageedit='+id+'&amp;pagereturn=core/admin_siteedit_popupclose.asp';
			pi.style.width="960px";
			pi.style.height="522px";
			pi.style.marginLeft="-480px";
			pi.style.marginTop="-261px";

			iframe_width="100%";
			iframe_height="522";
		break;
		case "edit_propcontent":
			page+='admin_siteedit_pageedit.php?pageedit='+id+'&amp;pagereturn=core/admin_siteedit_popuppropclose.asp&amp;mlsnum='+var1;
			pi.style.width="960px";
			pi.style.height="522px";
			pi.style.marginLeft="-480px";
			pi.style.marginTop="-261px";

			iframe_width="100%";
			iframe_height="522";
		break;
		case "edit_elementcontent":
			page+='admin_siteedit_editelement.asp?id='+id;
			pi.style.width="960px";
			pi.style.height="522px";
			pi.style.marginLeft="-480px";
			pi.style.marginTop="-261px";

			iframe_width="100%";
			iframe_height="522";
		break;
		case "edit_addimage":
			page+='admin_siteedit_addimage.asp';
			pi.style.width="960px";
			pi.style.height="522px";
			pi.style.marginLeft="-480px";
			pi.style.marginTop="-261px";

			iframe_width="100%";
			iframe_height="522";
		break;
		case "edit_addimages":
			page+='admin_siteedit_addimages.asp';
			pi.style.width="960px";
			pi.style.height="522px";
			pi.style.marginLeft="-480px";
			pi.style.marginTop="-261px";

			iframe_width="100%";
			iframe_height="522";
		break;
		case "edit_secnav":
			page+='admin_siteedit_secnav.asp?actiontype=admin_siteedit_link_list&area='+id+'&secondaryarea='+var1;
			pi.style.width="960px";
			pi.style.height="522px";
			pi.style.marginLeft="-480px";
			pi.style.marginTop="-261px";

			iframe_width="100%";
			iframe_height="522";
		break;
	//------------------------------------------------------------------------------ AREA: Site Edit (END)
		case "":
		break;
	}
	//----------------------------------------------- Config and Display Windows
	//alert('page: '+page);
	//obj.innerHTML=page;
	pi.innerHTML=	'<iframe name=\"confirmWindow\" id=\"locationselect\" width=\"'+ iframe_width +'\" height=\"' + iframe_height + '\" src=\"'+page+'\" frameborder=\"no\" scrolling=\"no\" style=\"background-color:#FFFFFF;\"></iframe>';
}
// --------------------------------------------------------------------------------------------------------- SET: Functions (END)
// --------------------------------------------------------------------------------------------------------- INIT: Pop-up (BEGIN)
//self.setTimeout('displayPopUp()', 1500)
window.onload=onLoadPopUp
// --------------------------------------------------------------------------------------------------------- INIT: Pop-up (END)
