function initGigyaSignIn(){gigya.services.socialize.showLoginUI(conf,{containerID:"gigyaSignInDiv",cid:"",width:220,height:60});gigya.services.socialize.addEventHandlers(conf,{onLogin:insertLoginDataToDB})}function initGigyaSignInForChart(){$("#close").hide();$("#highChartTextDiv").hide();gigya.services.socialize.getUserInfo(conf,{callback:renderGigyaUI});gigya.services.socialize.showLoginUI(conf,{containerID:"gigyaSignInDiv",cid:"",width:220,height:60});gigya.services.socialize.addEventHandlers(conf,{onLogin:doProcess})}function renderGigyaUI(a){if(a.user!=null&&a.user.isConnected){alert("Logged-in user: "+a.user.firstName+" "+a.user.lastName);$("#gigyaUIDiv").hide();renderHiCharts();$("#chartDiv").show();$("#highChartInfo").show()}else{$("#gigyaUIDiv").show();$("#chartDiv").hide();$("#highChartInfo").hide()}}function doProcess(a){$("#chartDiv").show();$("#highChartContainer1").show();$("#highChartInfo").show();renderHiCharts();insertLoginDataToDB(a);$("#gigyaUIDiv").hide();$("#highChartInfo").show();$("#highChartEnlarge").show()}function insertLoginDataToDB(a){var b={};b.UID=a.UID;b.Signature=a.signature;b.UIDSig=a.signature;b.SignatureTimestamp=a.timestamp;b.TimeStamp=a.user.signatureTimestamp;b.UIDSignature=a.user.UIDSignature;b.Nickname=a.user.nickname;b.PhotoURL=a.user.photoURL;b.ThumbnailURL=a.user.thumbnailURL;b.Gender=a.user.gender;b.Email=a.user.email;b.ProxiedEmail=a.user.proxiedEmail;b.Country=a.user.country;b.State=a.user.state;b.City=a.user.city;b.Zip=a.user.zip;b.FirstName=a.user.firstName;b.LastName=a.user.lastName;b.ProfileURL=a.user.profileURL;b.IsSiteUID=a.user.isSiteUID;b.IsLoggedIn=a.user.isLoggedIn;b.IsConnected=a.user.isConnected;b.IsSiteUser=a.user.isSiteUser;b.LoginProviderUID=a.user.loginProviderUID;b.LoginProvider=a.user.loginProvider;b.IsTempUser=a.user.isTempUser;$.ajax({type:"POST",url:"/development/gigyasigninservice.svc/InsertGigyaLoginData",data:stringify(b),contentType:"application/json; charset=utf-8",processdata:false,dataType:"json",success:function(c){alert("success")},error:function(c){if(c.responseText){alert(c.responseText)}}})}function stringify(e){var b="{";var d=0;for(var a in e){if(d>0){b+=", "}var c="";for(var f=0;f<e[a].length;f++){if(e[a].substr(f,1)=="\\"){c+="\\\\"}else{if(e[a].substr(f,1)=='"'){c+='\\"'}else{c+=e[a].substr(f,1)}}}b+='"'+a+'":"'+c+'"';d++}b+="}";return b}function renderHiCharts(){var a;renderHighChart("highChartContainer1",450,300);renderHighChart("highChartContainer2",900,600);$("#highChartContainer2").hide()}function renderHighCharts(){var b;var a;$(document).ready(function(){renderHighChart("highChartContainer1",450,300);renderHighChart("highChartContainer2",900,600);a=$("#highChartcontainer1").html();$("#highChartContainer2").hide()})}function renderHighChart(a,c,b){var d={chart:{renderTo:a,defaultSeriesType:"column",width:c,height:b},title:{text:"Market Share Of Home Sales"},xAxis:{categories:[]},yAxis:{title:{text:"Sales Percentage"},min:0,max:100},plotOptions:{column:{stacking:"percent"}},series:[]};$.ajax({type:"GET",url:"/development/localhousingdataservice.svc/GetHomeSalesData",contentType:"application/json; charset=utf-8",success:function(e){$.each(e.Categories,function(g,h){d.xAxis.categories.push(h)});$.each(e.HomeSaleSeries,function(i,g){var h={data:[]};h.name=(g.HomeSaleType);$.each(g.HomeSaleTypeData,function(j,k){h.data.push(parseFloat(k))});d.series.push(h)});var f=new Highcharts.Chart(d)},error:function(e){if(e.responseText){alert(e.responseText)}}})}function highChartModelOverLay(){$("#highChartContainer2").dialog({width:950,height:650,modal:true})}function highChartShowText(){$("#highChartTextDiv").show();$("#highChartTextDiv").html('<div style=\'width:600; height:600; left-indent:10\'><p><strong>Summary:</strong><br /><br />Overview � Displays home closing share by sale type with each type representing their percentage of the entire market.  Sale types are New Homes, Regular Resale Homes (typical resale transactions between private parties), REO Sales (Real-Estate Owned by Banks), and Foreclosures (properties being transferred from homeowners to mortgage holders).   Source:  Market Activity Dashboard Report<br /><br /> How to Use it � Communicates the segments in the local housing market which are most active in the current month as well as in the same month one and two years prior.  Seeing the change in percentage from one year to a next is an indicator of performance of that sale type.  This can also be a gauge of market health; for instance, a large percentage of activity in REO Sales and Foreclosure Sales may imply a distressed market.</p> <a id = "close" href="javascript:highChartHideText()">Close</a><div>');$("#highChartContainer1").hide();$("#highChartInfo").hide();$("#highChartEnlarge").hide()}function highChartHideText(){$("#highChartContainer1").show();$("#highChartInfo").show();$("#highChartEnlarge").show();$("#highChartTextDiv").hide()}function showChartDescription(){$("#highChartTextDiv").show();$("#highChartContainer1").hide();$("#highChartInfo").hide();$("#highChartEnlarge").hide();$("#close").show()}function hideChartDescription(){$("#highChartContainer1").show();$("#highChartInfo").show();$("#highChartEnlarge").show();$("#highChartTextDiv").hide();$("#close").hide()}function renderZingCharts(){var b;var a;$(document).ready(function(){renderZingChart("ZingChartContainer1",450,300);renderZingChart("ZingChartContainer2",900,600);a=$("#ZingChartContainer1").html();$("#ZingChartContainer2").hide()})}function renderZingChart(a,c,b){$.ajax({type:"GET",url:"/development/localhousingdataservice.svc/GetHomeSalesData",contentType:"application/json; charset=utf-8",success:function(h){var d="";$.each(h.Categories,function(i,j){d=d+'"'+j+'",'});d=d.substring(0,d.length-1);var g="";$.each(h.HomeSaleSeries,function(k,i){g=g+'{"text":"'+i.HomeSaleType+'","background-color":"'+i.BgColor+'",';var j="";$.each(i.HomeSaleTypeData,function(l,m){j=j+m+","});j=j.substring(0,j.length-1);g=g+'"values" : ['+j+"]},"});g=g.substring(0,g.length-1);var f='{"graphset" : [{"type" : "bar","alpha":1,"stacked":true,"scale-x":{"values":['+d+'],"line-color":"#307C70","line-style":"solid","line-width":"3px","guide":{"line-color":"#ECC43B","line-style":"dashed","alpha":"1"},"tick":{"line-width":"3px","line-color":"#307C70","alpha":"1"},"item":{"font-size":"12px","font-color":"#307C70","font-weight":"bold","font-family":"Trebuchet MS"},"minor-guide":{"visible":false}},"legend":{"layout":"1x4","position":"55% 5%","width":"400px","height":"40px","visible":true,"background-color":-1,"border-width":"0px","item":{"font-family":"Trebuchet MS","font-weight":"bold","font-size":"11px","font-color":"#307C70","padding":"-2 2","shadow":0}},"plot":{"alpha":1,"animate":true,"tooltip-text":"Series text: %t<br>Value: %v","speed":0.5,"effect":5},"series" : ['+g+"]}]}";var e=jQuery.parseJSON(f);zingchart.render({id:a,width:c,height:b,data:e})},error:function(d){if(d.responseText){alert(d.responseText)}}})}function ZingChartModelOverLay(){$("#ZingChartContainer2").dialog({width:950,height:650,modal:true})}function ZingChartShowText(){$("#ZingChartTextDiv").show();$("#ZingChartTextDiv").html('<p>This is a sample text</p> <a id = "close" href="javascript:ZingHideText()">Close</a>');$("#ZingChartContainer1").hide();$("#ZingChartInfo").hide();$("#ZingChartEnlarge").hide()}function ZingHideText(){$("#ZingChartContainer1").show();$("#ZingChartInfo").show();$("#ZingChartEnlarge").show();$("#ZingChartTextDiv").hide()}function renderFusionCharts(){var b;var a;$(document).ready(function(){RenderFusionChart("fusionContainer1",450,300);RenderFusionChart("fusionContainer2",900,600);a=$("#container1").html();$("#fusionContainer2").hide()})}function fusionModelOverLay(){$("#fusionContainer2").dialog({width:950,height:650,modal:true})}function fusionShowText(){$("#fusionTextDiv").show();$("#fusionTextDiv").html('<p>This is a sample text</p> <a id = "close" href="javascript:fusionHideText()">Close</a>');$("#fusionContainer1").hide();$("#fusionInfo").hide();$("#fusionEnlarge").hide()}function fusionHideText(){$("#fusionContainer1").show();$("#fusionInfo").show();$("#fusionEnlarge").show();$("#fusionTextDiv").hide()}function RenderFusionChart(a,c,b){var d=new FusionCharts("/static/scripts/StackedColumn3D.swf","ChartUsingJSon_"+c+"_"+b,c,b,"0","1");$.ajax({type:"GET",url:"/development/localhousingdataservice.svc/GetHomeSalesDataForFusionCharts",contentType:"application/json; charset=utf-8",success:function(e){d.setJSONData(e);d.render(a)},error:function(e){if(e.responseText){alert(e.responseText)}}})}function renderWijmoCharts(){var b;var a;$(document).ready(function(){renderWijmoChart("#WijmoChartContainer1",500,300);$("#ZingChartContainer2").hide()})}function renderWijmoChart(a,c,b){$.ajax({type:"GET",url:"/development/localhousingdataservice.svc/GetHomeSalesData",contentType:"application/json; charset=utf-8",success:function(g){var d="";$.each(g.Categories,function(h,i){d=d+"<th>"+i+"</th>"});var f="";$.each(g.HomeSaleSeries,function(j,h){f=f+'<tr><th scope="row">'+h.HomeSaleType+"</th>";var i="";$.each(h.HomeSaleTypeData,function(k,l){i=i+"<td>"+l+"</td>"});f=f+i+"</tr>"});var e='<table id="wijbarchart" border="1" style="display: none"><caption>Market Share of Home Sales</caption><thead><tr><td></td>'+d+"<tbody>"+f+"</tbody></table>";$(a).html(e);$("#wijbarchart").wijbarchart({header:{text:"Market Share of Home Sales"},width:c,horizontal:false,stacked:true,height:b})},error:function(d){if(d.responseText){alert(d.responseText)}}})}function WijmoChartModelOverLay(){renderWijmoChart("#WijmoChartContainer2",900,600);$("#WijmoChartContainer2").dialog({width:950,height:650,modal:true})}function WijmoChartShowText(){$("#WijmoChartTextDiv").show();$("#WijmoChartTextDiv").html('<p>This is a sample text</p> <a id = "close" href="javascript:WijmoHideText()">Close</a>');$("#WijmoChartContainer1").hide();$("#WijmoChartInfo").hide();$("#WijmoChartEnlarge").hide()}function WijmoHideText(){$("#WijmoChartContainer1").show();$("#WijmoChartInfo").show();$("#WijmoChartEnlarge").show();$("#WijmoChartTextDiv").hide()}function populateState(e){var b=$(e).attr("id").toUpperCase();b=b.substring(b.lastIndexOf("_")+1,b.length);var a="-1";if(b=="DDLDIVISION"){a=$(e).val();$("select[id$=ddlBottomDivision]").val(a)}else{if(b=="DDLBOTTOMDIVISION"){a=$(e).val();$("select[id$=ddlDivision]").val(a)}}var c="<option value='-1'>Select a State</option>";var d="<option value='-1'>Select a City</option>";$("select[id$=ddlCity]").html(d);$("select[id$=ddlCity]").attr("disabled","disabled");$("select[id$=ddlBottomCity]").html(d);$("select[id$=ddlBottomCity]").attr("disabled","disabled");if(e.value=="-1"){$("select[id$=ddlState]").html(c);$("select[id$=ddlBottomState]").html(c);return}if(e.value!="-1"){$.ajax({type:"GET",url:"/development/LHDDropDownHandler.ashx?divisionid="+e.value,contentType:"application/json; charset=utf-8",success:function(g){for(var f=0;f<g.length;f++){c+="<option value='"+g[f].Abbr+"'>"+g[f].StateName+"</option>"}$("select[id$=ddlState]").html(c);$("select[id$=ddlBottomState]").html(c)},error:function(f){if(f.responseText){alert(f.responseText)}}})}}function populateCity(e,b){var c=$(e).attr("id").toUpperCase();c=c.substring(c.lastIndexOf("_")+1,c.length);var a="-1";if(c=="DDLDIVISION"){a=$(b).val();$("select[id$=ddlBottomState]").val(a)}else{if(c=="DDLBOTTOMDIVISION"){a=$(b).val();$("select[id$=ddlState]").val(a)}}var d="<option value='-1'>Select a City</option>";if(a=="-1"){$("select[id$=ddlCity]").html(d);$("select[id$=ddlBottomCity]").html(d);return}if(a!="-1"){$.ajax({type:"GET",url:"/development/LHDDropDownHandler.ashx?divisionid="+e.value+"&stateid="+a,contentType:"application/json; charset=utf-8",success:function(g){$("select[id$=ddlCity]").removeAttr("disabled");$("select[id$=ddlBottomCity]").removeAttr("disabled");for(var f=0;f<g.length;f++){d+="<option value='"+g[f].MsaId+"'>"+g[f].CityName+"</option>"}$("select[id$=ddlCity]").html(d);$("select[id$=ddlBottomCity]").html(d)},error:function(f){if(f.responseText){alert(f.responseText)}}})}}function BuildUrlAndRedirect(d,c,g){var a=$(d).attr("id").toUpperCase();a=a.substring(a.lastIndexOf("_")+1,a.length);var f="-1";if(a=="DDLDIVISION"){f=$(g).val();$("select[id$=ddlBottomCity]").val(f)}else{if(a=="DDLBOTTOMDIVISION"){f=$(g).val();$(g).val(f)}}var h=$(g).val();var b=$(c).val();var e=d[d.value].text.replace(/ /g,"-").toLowerCase();if(h!="-1"){$.ajax({type:"GET",url:"/development/LHDDropDownHandler.ashx?cityid="+h,contentType:"application/json; charset=utf-8",success:function(k){var i=location.port;var j;if(i!=""){j=location.protocol+"//"+location.hostname+":"+i+"/local-housing-data/"+e+"/"+k+".aspx"}else{j=location.protocol+"//"+location.hostname+"/local-housing-data/"+e+"/"+k+".aspx"}postLHD2Url(j,d.value,b,h)},error:function(i){if(i.responseText){}}})}}function postLHD2Url(e,c,d,f){var a="UNKNOWN";var g="UNKNOWN";var b="UNKNOWN";if(d.length>0){a=d}if(c.length>0){g=c}if(f.length>0){b=f}msaStateField=document.getElementById("lhdstate");msaStateField.value=d;msaDivisionField=document.getElementById("lhddivision");msaDivisionField.value=c;msaNameField=document.getElementById("lhdmsa");msaNameField.value=f;msalinkform=document.getElementById("lhdForm");msalinkform.action=e;msalinkform.submit()}function post2UrlLHD(h,c,e,d){var f=h.href;var a="UNKNOWN";var g="UNKNOWN";var b="UNKNOWN";if(e.length>0){a=e}if(c.length>0){g=c}if(d.length>0){b=d}msaStateField=document.getElementById("lhdstate");msaStateField.value=e;msaDivisionField=document.getElementById("lhddivision");msaDivisionField.value=c;msaNameField=document.getElementById("lhdmsa");msaNameField.value=d;msalinkform=document.getElementById("lhdForm");msalinkform.action=f;msalinkform.submit()}function NarrativeScienceTextModelOverLay(){$("div[id$=dialogNarrativeScienceText]").dialog({width:950,height:650,modal:true,open:function(b,a){window.setTimeout(function(){jQuery(document).unbind("mousedown.dialog-overlay").unbind("mouseup.dialog-overlay")},100)}});$("div.ui-dialog").css("z-index","1000001");$("div.ui-widget-overlay").css("z-index","1000000")}function loadDialogueAd(){try{if(this.isDfpAdCall){$("#adframe").attr({src:"/static/LHD/lhdads.aspx?dfpzone="+this.dfpZone+"&dfpkeyvalues="+this.dfpKeyValues+"&cb=0000000000"+Math.round(Math.random()*10000000000)})}else{$("#adframe").attr({src:"/static/LHD/lhdads.aspx?&adarea="+this.adarea+"&adKeywords="+this.adKeywords+"&cb=0000000000"+Math.round(Math.random()*10000000000)})}}catch(a){if(this.isDfpAdCall){$("#adframe").attr({src:"/static/LHD/lhdads.aspx?dfpzone="+this.dfpZone+"&cb=0000000000"+Math.round(Math.random()*10000000000)})}else{$("#adframe").attr({src:"/static/LHD/lhdads.aspx?&adarea="+this.adarea+"&cb=0000000000"+Math.round(Math.random()*10000000000)})}}}function CheckZipCode(b){var a=/^\d{5}$/;if(b!=null&&a.test(b)){ShowProcessingStatus(true);$.ajax({type:"GET",url:"/development/LHDZipCodeHandler.ashx?zipCode="+b,contentType:"application/json; charset=utf-8",dataType:"json",success:function(c){if(c!=null&&c!=""){window.location.href=c}else{ShowProcessingStatus(false);$("div.LHDzip_error").html("This is not a valid zip code.")}}})}else{$("div.LHDzip_error").html("Please enter a 5 number zip code.")}}function SubscribeENL(a,b){$.ajax({type:"GET",url:"/development/lhduserservice.svc/subscribenewsletter/"+a+"/"+b,contentType:"application/json; charset=utf-8",dataType:"json",success:function(c){if(c.IsSubscribed){$("#eNLSubscribeTemplate").dialog({width:790,modal:true,opacity:0.9});$("#msaName").html(gigyaMSAName);$("div.ui-dialog").css("z-index","10004");$("div.ui-widget-overlay").css("z-index","10003");$("a[id$=eNLlink]").hide()}},error:function(c){if(c.responseText){alert(c.responseText)}}})}function RenderENLLink(a,b){$.ajax({type:"GET",url:"/development/lhduserservice.svc/checksubscription/"+a+"/"+b,contentType:"application/json; charset=utf-8",dataType:"json",success:function(c){if(!c.IsSubscribed){$("a[id$=eNLlink]").show();$("a[id$=eNLlink]").click(function(d){SubscribeENL(a,b);return false})}},error:function(c){if(c.responseText){alert(c.responseText)}}})};
