$(document).ready(function(){solutionLink=document.location.href.replace(/.*#/,"");if(solutionLink.length==10){MySolarStory.loadSolarStory(solutionLink)}var f={custom_settings:{name:"photo1"},upload_success_handler:g,upload_url:"/BrightSolutions/MySolarStory/upload.php",flash_url:"/BrightSolutions/flash/swfupload.swf",file_size_limit:"2 MB",file_upload_limit:"0",file_queue_limit:"1",file_types:"*.jpg;*.jpeg",button_placeholder_id:"uploadButton1",button_image_url:"/BrightSolutions/images/browse.png",button_width:68,button_height:20,button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,file_dialog_complete_handler:i,file_queue_error_handler:k,debug:false};var j={custom_settings:{name:"photo2"},upload_success_handler:g,upload_url:"/BrightSolutions/MySolarStory/upload.php",flash_url:"/BrightSolutions/flash/swfupload.swf",file_size_limit:"2 MB",file_upload_limit:"0",file_queue_limit:"1",file_types:"*.jpg;*.jpeg",button_placeholder_id:"uploadButton2",button_image_url:"/BrightSolutions/images/browse.png",button_width:68,button_height:20,button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,file_dialog_complete_handler:i,file_queue_error_handler:k,debug:false};var d={custom_settings:{name:"photo3"},upload_success_handler:g,upload_url:"/BrightSolutions/MySolarStory/upload.php",flash_url:"/BrightSolutions/flash/swfupload.swf",file_size_limit:"2 MB",file_upload_limit:"0",file_queue_limit:"1",file_types:"*.jpg;*.jpeg",button_placeholder_id:"uploadButton3",button_image_url:"/BrightSolutions/images/browse.png",button_width:68,button_height:20,button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,file_dialog_complete_handler:i,file_queue_error_handler:k,debug:false};var h={custom_settings:{name:"photo4"},upload_success_handler:g,upload_url:"/BrightSolutions/MySolarStory/upload.php",flash_url:"/BrightSolutions/flash/swfupload.swf",file_size_limit:"2 MB",file_upload_limit:"0",file_queue_limit:"1",file_types:"*.jpg;*.jpeg",button_placeholder_id:"uploadButton4",button_image_url:"/BrightSolutions/images/browse.png",button_width:68,button_height:20,button_action:SWFUpload.BUTTON_ACTION.SELECT_FILE,file_dialog_complete_handler:i,file_queue_error_handler:k,debug:false};var e=new SWFUpload(f);var c=new SWFUpload(j);var b=new SWFUpload(d);var a=new SWFUpload(h);function k(l,n,m){if(m=="File size exceeds allowed limit."){alert("The file you have selected is too large. Please try to reduce the size of your photo before uploading.")}}function i(){this.startUpload()}function g(m,l,n){$("#SubmitForm input[name='"+this.customSettings.name+"']").val(l);$("#"+this.customSettings.name+"_display").val(m.name)}});var MySolarStory={submitMySolarStory:function(){$("#SubmitForm .validation").removeClass("validation");name=siteScript.validateInput("#SubmitForm input[name='name']","Please enter your name.");if(name==false){return false}email=$("#SubmitForm input[name='email']").val();if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)==false){$("#SubmitForm input[name='email']").parent().parent().addClass("validation");$("#SubmitForm input[name='email']").focus();alert("Please enter a valid e-mail address.");return false}date_activated="";system_type="";size="";output="";installer="";hot_water_date_activated="";hot_water_system_type="";hot_water_size="";hot_water_installer="";story_type=$("#SubmitForm input[name='story_type']:checked").val();if(story_type=="PV"||story_type=="BOTH"){date_activated=siteScript.validateInput("#SubmitForm input[name='date_activated']","Please enter the date your system was activated.");if(date_activated==false){return false}system_type=siteScript.validateInput("#SubmitForm select[name='system_type']","Please select the system type..");if(system_type==false){return false}size=siteScript.validateInput("#SubmitForm input[name='size']","Please enter your system size.");if(size==false){return false}output=$("#SubmitForm input[name='output']").val();installer=siteScript.validateInput("#SubmitForm input[name='installer']","Please enter your installer.");if(installer==false){return false}}if(story_type=="HW"||story_type=="BOTH"){hot_water_date_activated=siteScript.validateInput("#SubmitForm input[name='hot_water_date_activated']","Please enter the date your system was activated.");if(hot_water_date_activated==false){return false}hot_water_system_type=siteScript.validateInput("#SubmitForm select[name='hot_water_system_type']","Please select the system type..");if(hot_water_system_type==false){return false}hot_water_size=siteScript.validateInput("#SubmitForm input[name='hot_water_size']","Please enter your system size.");if(hot_water_size==false){return false}hot_water_installer=siteScript.validateInput("#SubmitForm input[name='hot_water_installer']","Please enter your installer.");if(hot_water_installer==false){return false}}comment=siteScript.validateInput("#SubmitForm textarea[name='comment']","Please enter your solar story.");if(comment==false){return false}video_url="";upload_video=$("#SubmitForm input[name='upload_video']:checked").val();if(upload_video=="Yes"){video_url=$("#SubmitForm input[name='video_url']").val();video_url_obj=$("#SubmitForm input[name='video_url']");if(video_url.match(/youtube\.com\/watch\?v=([a-z0-9-_]+)/i)==null){video_url_obj.parent().parent().addClass("validation");video_url_obj.focus();alert("Please enter a valid YouTube Video URL.");return false}}receive=$("#SubmitForm input[name='receive']:checked").val();photo1=$("#SubmitForm input[name='photo1']").val();photo2=$("#SubmitForm input[name='photo2']").val();photo3=$("#SubmitForm input[name='photo3']").val();photo4=$("#SubmitForm input[name='photo4']").val();post={name:name,email:email,receive:receive,story_type:story_type,date_activated:date_activated,system_type:system_type,size:size,output:output,installer:installer,hot_water_date_activated:hot_water_date_activated,hot_water_system_type:hot_water_system_type,hot_water_size:hot_water_size,hot_water_installer:hot_water_installer,comment:comment,photo1:photo1,photo2:photo2,photo3:photo3,photo4:photo4,upload_video:upload_video,video_url:video_url};$.post("/BrightSolutions/xhr/postMySolarStory.php",post,function(b,a){if($("Error",b).length==1){alert($("Error",b).text())}else{if($("Success",b).length==1){document.getElementById("SubmitForm").getElementsByTagName("form")[0].reset();$("#video_fields").hide();$("#SolarPVSection").show();$("#SolarHWSection").hide();alert($("Success",b).text())}else{alert("An error has occurred. Please try again shortly.")}}})},loadSolarStory:function(a){$.ajax({type:"POST",url:"/BrightSolutions/xhr/getMySolarStory.php?id="+a,data:{v:a},success:function(b){$("#AboutSolution").html("");txt="";if($("StoryType",b).text()=="PV"||$("StoryType",b).text()=="BOTH"){if($("StoryType",b).text()=="BOTH"){txt=txt+'<div class="SolarInfoColumn">'}txt=txt+"<b>Solar PV Information</b><br />";txt=txt+"<b>Date Activated:</b> "+$("DateActivated",b).text()+"<br />";txt=txt+"<b>System Type:</b> "+$("SystemType",b).text()+"<br />";txt=txt+"<b>System Size:</b> "+$("Size",b).text()+" kW<br />";if($.trim($("Output",b).text())!=""){txt=txt+"<b>Kilowatt-Hour (kWh) Output:</b> "+$("Output",b).text()+"<br />"}txt=txt+"<b>Installer:</b> "+$("Installer",b).text()+"<br />";if($("StoryType",b).text()=="BOTH"){txt=txt+"</div>"}$("#AboutSolution").append(txt)}txt="";if($("StoryType",b).text()=="HW"||$("StoryType",b).text()=="BOTH"){if($("StoryType",b).text()=="BOTH"){txt=txt+'<div class="SolarInfoColumn">'}txt=txt+"<b>Solar Water Heating Information</b><br />";txt=txt+"<b>Date Activated:</b> "+$("HotWaterDateActivated",b).text()+"<br />";txt=txt+"<b>System Type:</b> "+$("HotWaterSystemType",b).text()+"<br />";txt=txt+"<b>System Size:</b> "+$("HotWaterSize",b).text()+" kW<br />";txt=txt+"<b>Installer:</b> "+$("HotWaterInstaller",b).text()+"<br />";if($("StoryType",b).text()=="BOTH"){txt=txt+"</div>"}$("#AboutSolution").append(txt)}$("#AboutSolution").append('<div style="clear: left;"></div><p><b>Solar Story:</b></p>');$("#AboutSolution").append("<p>"+$("SolarStory",b).text()+"</p>");if($("Photo1",b).text()!=""){$("#AboutSolution").append('<div class="photo"><a target="_blank" href="/BrightSolutions/MySolarStory/img.php?img='+$("Photo1",b).text()+'&size=large"><img src="/BrightSolutions/MySolarStory/img.php?img='+$("Photo1",b).text()+'&size=thumb" alt="photo"/></a></p>')}if($("Photo2",b).text()!=""){$("#AboutSolution").append('<div class="photo"><a target="_blank" href="/BrightSolutions/MySolarStory/img.php?img='+$("Photo2",b).text()+'&size=large"><img src="/BrightSolutions/MySolarStory/img.php?img='+$("Photo2",b).text()+'&size=thumb" alt="photo"/></a></p>')}if($("Photo3",b).text()!=""){$("#AboutSolution").append('<div class="photo"><a target="_blank" href="/BrightSolutions/MySolarStory/img.php?img='+$("Photo3",b).text()+'&size=large"><img src="/BrightSolutions/MySolarStory/img.php?img='+$("Photo3",b).text()+'&size=thumb" alt="photo"/></a></p>')}if($("Photo4",b).text()!=""){$("#AboutSolution").append('<div class="photo"><a target="_blank" href="/BrightSolutions/MySolarStory/img.php?img='+$("Photo4",b).text()+'&size=large"><img src="/BrightSolutions/MySolarStory/img.php?img='+$("Photo4",b).text()+'&size=thumb" alt="photo"/></a></p>')}$("#AboutSolution").append('<div style="clear: left;"><small>Submitted by: '+$("Name",b).text()+"</small></div>");$("#ParentID").val(a);if(document.documentElement){document.documentElement.scrollTop=-8000}siteScript.populateComments(b);$("#ThoughtContainer").show();if($("VideoURL",b).text()!=""){$("#VideoPlayerContainer").show();siteScript.videoURL=$("VideoURL",b).text()}else{$("#VideoPlayerContainer").hide();siteScript.videoURL=""}}})}};