




function LoadPassedValue() {


SetPassedValue('LocDataPass')
SetPassedValue('IsSummerPass')
SetPassedValue('IsWeekendPass')
SetPassedValue('LoadPass')
SetPassedValue('ClientNamePass')
SetPassedValue('ClientPhonePass')
SetPassedValue('ClientEmailPass')
SetPassedValue('ClientInterestPass')
SetPassedValue('ClientNotesPass')


}


function Dollar(ANumber) {
ANumber=ANumber*100;
ANumber=Math.round(ANumber);
var AString=ANumber.toString();
AString.slice(1,AString.length-2)
return AString.slice(0,AString.length-2) + '.' + AString.slice(AString.length-2,AString.length);
}





function SubmitForm(UrlName) {
var x=document.getElementById("formx");
x.action=UrlName
x.submit();
}




function GetValue(FormObjId) {

try
  {
  var FormObj=document.getElementById(FormObjId);
  return FormObj.value;
  }
catch(err)
  {
  }


}


function SetPassVar(FormObjId,PassValue) {
var FormObj=document.getElementById(FormObjId);
var PassObj=document.getElementById(FormObjId + 'Pass');
PassObj.value=PassValue;
}




function SetPassedValue(FormObjId) {


try
  {
var PassObj=document.getElementById(FormObjId);
PassObj.value=GetPassedValue(FormObjId);
  }
catch(err)
  {
  }
}




function GetPassedValue(ValueName) {
var str = String(window.location) + '&';

str= str.replace(/%2F/g,'/')
str= str.replace(/%2C/g,',')
str= str.replace(/%E9/g,'é')
str= str.replace(/%E8/g,'è')
str= str.replace(/%2B/g,'')
//str= str.replace(//+/g,' ')


Pos1=str.indexOf(ValueName + '=');

if (Pos1 < 0) 
{
return ''; 
}
else
{
str=str.substring(Pos1);
Pos1=str.indexOf('=') + 1;
Pos2=str.indexOf('&');
str=str.substring(Pos1,Pos2);
return str;
}


}




























function SaveQuote() {

var ClientName=GetValue("ClientNamePass");
var ClientPhone=GetValue("ClientPhonePass");
var ClientEmail=GetValue("ClientEmailPass");
var ClientInterest=GetValue("ClientInterestPass");
var ClientNotes=GetValue("ClientNotesPass");
var LocData=GetValue("LocDataPass");
var IsSummer=GetValue("IsSummerPass");
var IsWeekend=GetValue("IsWeekendPass");
var LoadP=GetValue("LoadPass");


var FileName=Date() + '.html';
FileName=FileName.replace(/ /g, "");
FileName=FileName.replace(/:/g, "");

var ThisDocument=document


document.open("text/html","replace") 

document.write('<TABLE border=1>') 


document.write('<TR><TD>') 
document.write('Filename')
document.write('</TD>') 
document.write('<TD>') 
document.write(FileName)
document.write('</TD>') 
document.write('</TR>') 

document.write('<TR><TD>') 
document.write('ClientName')
document.write('</TD>') 
document.write('<TD>') 
document.write(ClientName)
document.write('</TD>') 
document.write('</TR>') 


document.write('<TR><TD>') 
document.write('ClientPhone')
document.write('</TD>') 
document.write('<TD>') 
document.write(ClientPhone)
document.write('</TD>') 
document.write('</TR>') 

document.write('<TR><TD>') 
document.write('ClientEmail')
document.write('</TD>') 
document.write('<TD>') 
document.write(ClientEmail)
document.write('</TD>') 
document.write('</TR>') 

document.write('<TR><TD>') 
document.write('ClientInterest')
document.write('</TD>') 
document.write('<TD>') 
document.write(ClientInterest)
document.write('</TD>') 
document.write('</TR>') 

document.write('<TR><TD>') 
document.write('ClientNotes')
document.write('</TD>') 
document.write('<TD>') 
document.write(ClientNotes)
document.write('</TD>') 
document.write('</TR>') 

document.write('<TR><TD>') 
document.write('LocData')
document.write('</TD>') 
document.write('<TD>') 
document.write(LocData)
document.write('</TD>') 
document.write('</TR>') 

document.write('<TR><TD>') 
document.write('IsSummer')
document.write('</TD>') 
document.write('<TD>') 
document.write(IsSummer)
document.write('</TD>') 
document.write('</TR>') 

document.write('<TR><TD>') 
document.write('IsWeekend')
document.write('</TD>') 
document.write('<TD>') 
document.write(IsWeekend)
document.write('</TD>') 
document.write('</TR>') 


document.write('<TR><TD>') 
document.write('Load')
document.write('</TD>') 
document.write('<TD>') 
document.write(LoadP)
document.write('</TD>') 
document.write('</TR>') 

document.write('</TABLE>') 



//document.close() 
document.execCommand('SaveAs',true,FileName) 
}







function FillLocationTable() {

var LocData=document.getElementById('LocDataPass');
var OneRow=document.getElementById('LocationTable').rows[0].cells;
txt='Potentiel solaire électrique pour ';
txt= txt + LocData.value.split("/")[0] + ' (latitude ';
txt= txt + LocData.value.split("/")[1] + ' N / longitude ';
txt= txt + LocData.value.split("/")[2] + 'E)';
OneRow[0].innerHTML=txt;
}



function SystemCal(OptionType) {


//OptionType=60 alors CIGS60
//OptionType=autres alors Mono160

var SystemPower=document.getElementById('LoadPass').value;
var Kwh=document.getElementById('LocDataPass').value;


//Ajustement pour utilisation estivale
var IsSummer=document.getElementById('IsSummerPass').value;

if (IsSummer=='true')
{
LocKwh=100000

for (i=44;i<=46;i++)
{

if (LocKwh>Number(Kwh.split("/")[i]))
{
LocKwh=Number(Kwh.split("/")[i])
}
}
}
else
{
LocKwh=Number(Kwh.split("/")[25]);
}


//Ajustement pour utilisation weekend
var IsWeekend=document.getElementById('IsWeekendPass').value;

if (IsWeekend=='true')
{
LocKwh=LocKwh*7/3
}


//Ajustement pour efficacité anticipé du système
LocKwh=LocKwh*SystEff

//Dimensionnement du systeme en fonction du PPV de l'endroit
SystemPower=SystemPower/LocKwh*1000


//Selections des panneaux



if (OptionType!=60)
{


//Hypothese Mono160

PanelQuant=Math.ceil(SystemPower/160);
PanelPmax=160;
PanelDescript='Solgate monocrytallin 160 watts';
ControlUnitCost=559.00;
ControlDescript='Import';


if (PanelQuant>0 && PanelQuant<6)
{
PanelUnitCost=1079;
}

else if (PanelQuant>5 && PanelQuant<11)
{
PanelUnitCost=1079;
}

else
{
PanelUnitCost=1079;
}



}

else
{

//Hypothese CIGS60

PanelQuant=Math.ceil(SystemPower/60);
PanelPmax=60;
PanelUnitCost=349;
PanelDescript='CentennialSolar CIGS 60 watts';


if (PanelQuant==1)
{
ControlUnitCost=26.60;
ControlDescript='Steca Solsum 5.0C';
}

else if (PanelQuant>1 && PanelQuant<3)
{
ControlUnitCost=119.99;
ControlDescript='Steca PR1010';
}

else if (PanelQuant>2 && PanelQuant<6)
{
ControlUnitCost=159.99;
ControlDescript='Steca PR2020';
}

else if (PanelQuant>5 && PanelQuant<9)
{
ControlUnitCost=189.99;
ControlDescript='Steca PR3030';
}

else
{
ControlUnitCost=559.00;
ControlDescript='Import';
}


}




}
















function SplitValue(TheValue,SplitIndex) {

var str = TheValue;
alert (str.split("/")[0])

Pos1=str.indexOf(ValueName + '=');

if (Pos1 < 0) 
{
return '-1'; 
}
else
{
str=str.substring(Pos1);
Pos1=str.indexOf('=') + 1;
Pos2=str.indexOf('&');
str=str.substring(Pos1,Pos2);
return str;
}


}




