// JavaScript Document
function SendToFriendPopup(i,propertyid)
{
	var pass='<?=$passid1?>';
	var url='<?php print "$thisurl"?>';
	
	if (i==3)
	{
		 //alert(WWWROOT+'/custompages_popupform.php?type=3&id='+propertyid+'&isIDX=1&cf=<?php print "$thisurl"?><?=$passid1?>);
		popwin = popupWindow("overlay", WWWROOT+'/custompages_popupform.php?type=3&id='+propertyid+'&isIDX=1&cf=<?php print "$thisurl"?><?=$passid1?>', 500,450,'<b>Send To Friend</b>');
		o();

    }
	
	
}

function SetPhoto(iIndex, pstrWidth, pstrHeight) 
{
	//intPhotoViewer = iIndex;
	LoadPhotoViewerNew(iIndex, pstrWidth, pstrHeight);
}

function SetPhotoLocal(iIndex, pstrWidth, pstrHeight) 
{
	intPhotoViewer = iIndex;
	LoadPhotoViewerLocal(iIndex, pstrWidth, pstrHeight);
}
function LoadPhotoViewerLocal(iIndex,width,height) 
{
		//var width = 256;
		//var height = 210;
	   // var intWidth = parseInt(pstrWidth);
		//var intHeight = parseInt(pstrHeight);
        var nocache = 0;
        date=new Date();
        newtime=date.getTime();
		document.getElementById('imgPhoto').innerHTML = "<img src='" + iIndex + "' width=" + width + " height=" + height + " pbsrcnl = '" + iIndex + "' id='"+ newtime + "' onClick='Pop(this,50);'  ondblclick='Revert(this,50);' style='cursor: pointer;'>";
}



function LoadPhotoViewerNew(iIndex, pstrWidth, pstrHeight) 
{	
		var width = pstrWidth;
		var height = pstrHeight;
	   // var intWidth = parseInt(pstrWidth);
		//var intHeight = parseInt(pstrHeight);
        var nocache = 0;
        date=new Date();
        newtime=date.getTime();
		document.getElementById('imgPhoto').innerHTML = "<img src='" + iIndex + "' width=" + width + " height=" + height + " pbsrcnl = '" + iIndex + "' id='"+ newtime + "' onClick='Pop(this,50);'  ondblclick='Revert(this,50);' style='cursor: pointer;'>";
}

function LoadPhotoViewer(iIndex) 
{
	
	if(document.images) 
	{
		document.images['imgPhotoView'].src = iIndex ;
		document.images['imgPhotoView'].width = 210;
		document.images['imgPhotoView'].height = 192;
	}
}

function virtualtourpopup(propid,siteid,virtualtourx,virtualtoury,virtualtourlink,mlsnum, virtualtourwidth,virtualtourheight)
{
	if(!virtualtourx)
	 virtualtourx = 450; 
	else
	 virtualtourx= virtualtourx+50;
	if(!virtualtoury)
	    virtualtoury = 400;
	else
		virtualtoury= virtualtoury+50;
	
	if(!virtualtourwidth)
	 virtualtourwidth = 450; 
	else
	 virtualtourwidth= virtualtourwidth+50;
	if(!virtualtourheight)
	    virtualtourheight = 400;
	else
		virtualtourheight= virtualtourheight+50;
	
	if(virtualtourlink)
	{
		var path = virtualtourlink;
		popwin = popupWindow("overlay", path, virtualtourx,virtualtoury,'VIRTUAL TOUR');
	}
	else
	{
		var path = WWWROOT+'/vieweggvt.php?isRefresh=1&propid='+mlsnum+'&siteid='+siteid+'&title=&isIDX=10&thispropid='+propid;
		document.getElementById('hdnIsRefresh').value=1;
		popwin = popupWindow("overlay", path, virtualtourwidth, virtualtourheight, 'VIRTUAL TOUR');
	}

	
	o();

	//return false;
}
function Localvirtualtourpopup(propid,siteid, virtualtourx, virtualtoury, virtualtourlink, mlsnum, virtualtourwidth,virtualtourheight)
{
	if(!virtualtourx)
	 virtualtourx = 450; 
	else
	 virtualtourx= virtualtourx+50;
	if(!virtualtoury)
	    virtualtoury = 400;
	else
		virtualtoury= virtualtoury+50;
	
	if(!virtualtourwidth)
	 virtualtourwidth = 450; 
	else
	 virtualtourwidth= virtualtourwidth+50;
	if(!virtualtourheight)
	    virtualtourheight = 400;
	else
		virtualtourheight= virtualtourheight+50;
	
	if(virtualtourlink)
	{
		var path = virtualtourlink;
		popwin = popupWindow("overlay", path, virtualtourx,virtualtoury,'VIRTUAL TOUR');
	}
	else
	{
		var path = WWWROOT+'/vieweggvt.php?isRefresh=1&propid='+propid+'&siteid='+siteid+'&title=';
		document.getElementById('hdnIsRefresh').value=1;
		popwin = popupWindow("overlay", path, virtualtourwidth, virtualtourheight, 'VIRTUAL TOUR');
	}

    o();

	//return false;
}
function LoadDetailContent(pintOption,mlsno,zip,city,state,streetaddress,schoolid,isLocal,isdetail)
{
		//alert(pintOption+"==="+mlsno+"==="+zip+"==="+city+"==="+state+"==="+streetaddress+"==="+schoolid+"==="+isLocal+"==="+isdetail);
	//if(isdetail==1)
		//document.getElementById("ShowSchoolListLoading").style.display = "";
	//else
	if(document.getElementById("ShowLoading"))
		GetLoadingForDetail();

	var strURL = WWWROOT+"/idx_post_detail.php?local="+1+"&mls="+mlsno+"&menu="+pintOption+"&city="+city+"&zip="+zip+"&state="+state+"&streetaddress="+streetaddress+"&school_id="+schoolid+"&isLocal="+isLocal;
	
	AjaxPostNew(strURL, 7);
}

function LoadDetailContentOtherInfo(pintOption,mlsno,zip,city,state,streetaddress)
{
	if(document.getElementById("ShowLoading"))
		GetLoadingForDetail();
		
	var strURL = WWWROOT+"/idx_post_detail.php?mls="+mlsno+"&menu="+pintOption+"&city="+city+"&zip="+zip+"&state="+state+"&streetaddress="+streetaddress;
	AjaxPostNew(strURL, 7);
}

function AfterLoadDetailMenu(pContent, menuload)
{

		document.getElementById("LoadDetailContent").innerHTML = pContent; 

		if(menuload!=6 && menuload!=5)
		{
			document.getElementById("ShowLoading").style.display = "none";

			if(document.getElementById('MapFrame'))
				document.getElementById('MapFrame').style.display = "";
		}
		if(document.getElementById("nosalesdata"))
		{
			if(menuload==6 && document.getElementById("nosalesdata").value==1)
				document.getElementById("ShowLoading").style.display = "none";

			if(document.getElementById('MapFrame'))
				document.getElementById('MapFrame').style.display = "";
		}
		if(menuload==5 && document.getElementById("ShowLoading"))
		{
			
				document.getElementById("ShowLoading").style.display = "none";
		}

		
	if(menuload==3)	
	{
		LoadTestScoreChart();
	}
	if(menuload==4)	
	{
		LoadDemographicChart();
		//LoadHousingChart();
		//LoadEducationChart();
	}
	if(menuload==8)	
	{	
		//document.getElementById("ShowSchoolListLoading").style.display = "none";
		LoadSchoolTestScoreChart();
		//LoadSchoolProgramChart();
		LoadSchoolEnrollmentChart();
		//LoadResourcesChart();

	}

}

function LoadDemographicChart()
{
		if((document.getElementById('DivDemographics')))
		{ 
		   var chart = new FusionCharts(WWWROOT+'/idx/js/Column2D.swf', 'ChartId', '300', '164', '0', '0');
		    chart.setDataURL("idx/js/demographics.xml");		   
		    chart.render('DivDemographics');
		}
}
function LoadHousingChart()
{
		if((document.getElementById('DivHousing')))
		{
		   var chart = new FusionCharts( WWWROOT+'/idx/js/Pie3D.swf', "ChartId", "350", "180", "0", "0");
		   chart.setDataURL("idx/js/housing.xml");		   
		   chart.render("DivHousing");
		}
}
function LoadEducationChart()
{
		if((document.getElementById('DivEducation')))
		{
		   var chart = new FusionCharts(WWWROOT+'/idx/js/Bar2D.swf', "ChartId", "211", "185", "0", "0");
		   chart.setDataURL("idx/js/education.xml");		   
		   chart.render("DivEducation");
		}
}
function LoadTestScoreChart()
{
		if((document.getElementById('DivTestscore')))
		{
		  var chart = new FusionCharts( WWWROOT+'/idx/js/MSColumn2D.swf', "ChartId", "370", "300", "0", "0");
		   chart.setDataURL("idx/js/testscore.xml");
		   chart.render("DivTestscore");
		}
}

function LoadSchoolTestScoreChart()
{

		if((document.getElementById('DivTestScoreGraph')))
		{

		   var chart = new FusionCharts( WWWROOT+'/idx/js/MSColumn2D.swf', "ChartId", "370", "300", "0", "0");
		   chart.setDataURL("idx/js/schoolscore.xml");
		   chart.render("DivTestScoreGraph");
		}
}

function LoadSchoolEnrollmentChart()
{

		if((document.getElementById('DivEnrollmentGraph')))
		{

		   var chart = new FusionCharts( WWWROOT+'/idx/js/Pie3D.swf', "ChartId", "370", "300", "0", "0");
		  chart.setDataURL("idx/js/enrollment.xml");
		   chart.render("DivEnrollmentGraph");
		}
}


function FeedDistrictXmlData(universalid,stateid,DistrictName,statename,test_abbrv,grade)
{

	url=WWWROOT+"/idx_xmldata.php?type=district&universalid="+universalid+"&stateid="+stateid+"&DistrictName="+DistrictName+"&statename="+statename+"&test_abbrv="+test_abbrv+"&grade="+grade;
	if(document.getElementById("ShowGraphLoading"))
	{
		document.getElementById("ShowGraphLoading").style.display = "";
	}
	if(document.getElementById("DivTestScore"))
	{
		document.getElementById("DivTestScore").style.display = "none";
	}
   var http1 = createRequestObject1();
   http1.open('get',url,true);
   http1.onreadystatechange = function() 
   {
	 if(http1.readyState == 4 && http1.status == 200)
	   {
		  // Text returned FROM the PHP script
		  var response = http1.responseText;
			if(document.getElementById("ShowGraphLoading"))
				{
					document.getElementById("ShowGraphLoading").style.display = "none";
				}
				if(document.getElementById("DivTestScore"))
				{
					document.getElementById("DivTestScore").style.display = "";
				}
					//alert(response)
				LoadTestScoreChart();
		
		 
	   }
   }
   
   http1.send(null);
return false;

}//sendRequest

function FeedSchoolXmlData(schooluniversalid,districtuniversalid,stateuniversalid,school_name,DistrictName,statename,test_abbrv,grade)
{
	url=WWWROOT+"/idx_xmldata.php?type=school&schooluniversalid="+schooluniversalid+"&districtuniversalid="+districtuniversalid+"&stateuniversalid="+stateuniversalid+"&school_name="+school_name+"&DistrictName="+DistrictName+"&statename="+statename+"&test_abbrv="+test_abbrv+"&grade="+grade;

	if(document.getElementById("ShowSchoolGraphLoading"))
	{
		document.getElementById("ShowSchoolGraphLoading").style.display = "";
	}
	if(document.getElementById("DivTestScoreGraph"))
	{
		document.getElementById("DivTestScoreGraph").style.display = "none";
	}
   var http1 = createRequestObject1();
   http1.open('get',url,true);
   http1.onreadystatechange = function() 
   {
	 if(http1.readyState == 4 && http1.status == 200)
	   {
		  // Text returned FROM the PHP script
		  var response = http1.responseText;
			if(document.getElementById("ShowSchoolGraphLoading"))
				{
					document.getElementById("ShowSchoolGraphLoading").style.display = "none";
				}
				if(document.getElementById("DivTestScoreGraph"))
				{
					document.getElementById("DivTestScoreGraph").style.display = "";
				}
				//alert(response);
				LoadSchoolTestScoreChart();
	   }
   }
   
   http1.send(null);
	return false;

}//FeedSchoolXmlData
//******************************************//

function get(obj,page)
{
	  /* page = 1 (contact agent) && page = 2 (map info) */
	 if(document.getElementById('txtFirstName11').value == "")
      {
		alert("Please Enter First Name");
		document.getElementById('txtFirstName11').focus();
		return false;
	  }
 	  if(document.getElementById('txtLastName').value == "")
      {
		alert("Please Enter Last Name");
		document.getElementById('txtLastName').focus();
		return false;
	  }
 	  if(document.getElementById('txtEmail').value == "")
      {
		alert("Please Enter Email");
		document.getElementById('txtEmail').focus();
		return false;
	  }
	  if(!emailCheck(document.getElementById('txtEmail').value))
	  {
		return false;
	  }
	  if(document.getElementById('txtPhone').value == "")
      {
		alert("Please Enter Phone");
		document.getElementById('txtPhone').focus();
		return false;
	  }
	  if(document.getElementById('txtComments').value == "")
      {
		alert("Please Enter Comments");
		document.getElementById('txtComments').focus();
		return false;
	  }
	  getstr = "";
	  getstr += "txtFirstName11="+document.getElementById('txtFirstName11').value+"&txtLastName="+document.getElementById('txtLastName').value+"&";
 	  getstr += "txtEmail="+document.getElementById('txtEmail').value+"&txtPhone="+document.getElementById('txtPhone').value+"&";
	  getstr += "txtComments="+document.getElementById('txtComments').value;
	
	 if(page == 1) 
		 var strURL = WWWROOT+"/idx_post_contactinfo.php?t=1&"+getstr;
	 if(page == 2) 
		 var strURL = WWWROOT+"/idx_post_mapinfo.php?t=1&"+getstr;
		 
	  AjaxPostNew(strURL, 8);
}
function AfterContactAgent(pContent)
{
	
	document.getElementById('divContactAgent').style.display = "none"; 
	document.getElementById('divContactAgentRes').style.display = ''; 
}
function OpenCalculatorWindow(propertyid)
{
	//window.open(WWWROOT+'/idx_calculator.php?listnum='+propertyid,'','width=380,height=260,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yesscreenX=650,screenY=600,top=200,left=400');	

	var ppleft = (window.screen.width - 540) / 2;
	var pptop = (window.screen.height - 300) / 2;
	popwin = popupWindow('overlay', WWWROOT+'/idx_calculator.php?listnum='+propertyid+'&type=request', 390, 300,'Calculate Payments');
	o();
}

function ChangeSchoolTab(pFlag)
{
	if(pFlag==2)
	{
		document.getElementById("Tab1").className = ''
		document.getElementById("Tab2").className = 'selected'
		document.getElementById("Tab3").className = ''
		document.getElementById("ShowElementary").style.display='none'
		document.getElementById("ShowMiddle").style.display=''
		document.getElementById("ShowHigh").style.display='none'

	}
	else if(pFlag==3)
	{
		document.getElementById("Tab1").className = ''
		document.getElementById("Tab2").className = ''
		document.getElementById("Tab3").className = 'selected'
		document.getElementById("ShowElementary").style.display='none'
		document.getElementById("ShowMiddle").style.display='none'
		document.getElementById("ShowHigh").style.display=''

	}
	else
	{
		document.getElementById("Tab1").className = 'selected'
		document.getElementById("Tab2").className = ''
		document.getElementById("Tab3").className = ''
		document.getElementById("ShowElementary").style.display=''
		document.getElementById("ShowMiddle").style.display='none'
		document.getElementById("ShowHigh").style.display='none'

	}

}
function ChangeGraphTab(pFlag)
{
	if(pFlag==2)
	{
		document.getElementById("Tab1").className = ''
		document.getElementById("Tab2").className = 'selected'
		//document.getElementById("Tab3").className = ''
		//document.getElementById("Tab4").className = ''
		document.getElementById("DivEnrollment").style.display=''
		document.getElementById("DivTestScore").style.display='none'
		//document.getElementById("DivPrograms").style.display='none'
		//document.getElementById("DivResources").style.display='none'
	}
	/*else if(pFlag==3)
	{
		document.getElementById("Tab1").className = ''
		document.getElementById("Tab2").className = ''
		document.getElementById("Tab3").className = 'selected'
		document.getElementById("Tab4").className = ''
		document.getElementById("DivEnrollment").style.display='none'
		document.getElementById("DivTestScore").style.display='none'
		document.getElementById("DivPrograms").style.display=''
		document.getElementById("DivResources").style.display='none'

	}
	else if(pFlag==4)
	{
		document.getElementById("Tab1").className = ''
		document.getElementById("Tab2").className = ''
		document.getElementById("Tab3").className = ''
		document.getElementById("Tab4").className = 'selected'
		document.getElementById("DivEnrollment").style.display='none'
		document.getElementById("DivTestScore").style.display='none'
		document.getElementById("DivPrograms").style.display='none'
		document.getElementById("DivResources").style.display=''

	}*/
	else
	{
		document.getElementById("Tab1").className = 'selected'
		document.getElementById("Tab2").className = ''
		//document.getElementById("Tab3").className = ''
		//document.getElementById("Tab4").className = ''
		document.getElementById("DivEnrollment").style.display='none'
		document.getElementById("DivTestScore").style.display=''
		//document.getElementById("DivPrograms").style.display='none'
	//	document.getElementById("DivResources").style.display='none'

	}

}

function resizeIframe(){
		
		
		  var ifr = document.getElementById("main");
		  var ifrBody = ifr.contentWindow.document[getDocBody(ifr.contentWindow)];
		  ifr.style.height=ifrBody.scrollHeight+"px";
		}
		
function getDocBody(win)
{
	if (!win) win=window;
	if (win.document.compatMode && win.document.compatMode != "BackCompat")
	{ //standards compliant mode 

		return "documentElement";
	}
		  return "body";
		}

function SelectOptionToPrint(id)
{
	popwin = popupWindow("overlay", WWWROOT+'/idx_selectprint_option.php?id='+id, 400,300,'<b>Select Option To Print</b>');
	o();
}

function PrintVersionValidation(id)
{
		var check=false;
	for (i=0; i<document.getElementsByName('rdoPrintOpt').length; i++)  {
		  	if (document.getElementsByName('rdoPrintOpt')[i].checked) {
				check=true;
		  	} 
		} 
		if(check==false)
		{
			alert("Please choose at least one option");
			return false;
		}
		else
			PrintDelectedOptionData(id);
}

function setfocus()
{
	
}
function createRequestObject1(){
	var xmlHttp;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();

	}catch (e)	{
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e)	{
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e)	{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	return xmlHttp;

}//createRequestObject
function ExpandCommnets(showdiv,hidediv)
{
	//var newshowdiv = '"'+showdiv+'"';
	//var newhidediv = '"'+hidediv+'"';

		document.getElementById(showdiv).style.display='';
		document.getElementById(hidediv).style.display='none';
}
function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}


function LoadSchoolListContent(divId,schooltype,districtid,zip,city,state,streetaddress,intPage,mls,isprint,isNodistrict)
{

	if(document.getElementById(divId+'Loader')!=null)
	{
		element = document.getElementById(divId+'Loader');
		element.style.display = 'block';
	}
 	var schoolhttp = createRequestObject1();mls

	 var strURL = WWWROOT+"/idx_schoollist.php?local="+1+"&districtid="+districtid+"&mls="+mls+"&isprint="+isprint+"&divId="+divId+"&schooltype="+schooltype+"&city="+city+"&zip="+zip+"&state="+state+"&streetaddress="+streetaddress+"&&_pge="+intPage+"&isNodistrict="+isNodistrict;

	   schoolhttp.open('get',strURL,true);
	   schoolhttp.onreadystatechange = function() 
	   {
		 if(schoolhttp.readyState == 4 && schoolhttp.status == 200)
		   {
			  // Text returned FROM the PHP script
			  var response = schoolhttp.responseText;
			  if(response)
			  {	
					/*if(document.getElementById(divId+'Loader')!=null)
					{

						element = document.getElementById(divId+'Loader');
						element.style.display = 'none';
					}*/
					
					 document.getElementById(divId).innerHTML = response;

					 if(document.getElementById(divId+'Loader')!=null)
						{
							element = document.getElementById(divId+'Loader');
							element.style.display = 'none';
						}
				
			  }
		   }
	   }
	   
	   schoolhttp.send(null);
}
function ShowStreetView(MAPKEY)
{
	document.getElementById("DivStreetView").style.display='block';
	document.getElementById('imgStreetView').style.display = 'none';
	window.parent.resizeMapIframe();
	/*
	if(document.getElementById("DivStreetView").style.display=='block')
	{
		document.getElementById('imgStreetView').src = WWWROOT+'/idx/theme1/images/show_street_view.gif';
		//document.getElementById('submain').src = "";
		document.getElementById("DivStreetView").style.display='none';
	}
	else
	{
	
		//document.getElementById('submain').src = WWWROOT+'/idx/StreetMapNew.php?api=' + MAPKEY;
		document.getElementById("DivStreetView").style.display='block';
		document.getElementById('imgStreetView').src = WWWROOT+'/idx/theme1/images/hide_street_view.gif';
		window.parent.resizeMapIframe();
	
	
	}*/
}

function GetGraphLoadingOnload()
{

	document.write("<html><body><div id='ShowSchoolGraphLoading'>Loading</div></body></html>");
	GetHeightWidthBrowser();
	var newwidth = (strTop + strHeight/2)-100;
	var newheight = (strWidth/2-75);
	document.getElementById('ShowLoading').style.top = newwidth+"px";
	document.getElementById('ShowLoading').style.left = newheight+"px";
	document.getElementById('ShowLoading').style.position = "absolute";
	document.getElementById('ShowLoading').innerHTML = '<table border=0 cellpadding=0 cellspacing=0 width=110 bgcolor="#fffff" style="border:1px solid #ff0000"><tr><td width="25" align=center><img src="'+IMGROOT+'/rating/loading.gif"></td><td width="60" align="left"><span style="font-family:Arial;font-size:12px;text-decoration:none;text-transform:uppercase;letter-spacing:0px;font-weight:700;color:#FF0000;line-height:38px;padding-left:3px;">&nbsp;Loading...</span></td></tr></table>';
}
