










/*  */
// Initialize arrays
var attachments_1 = new Array(); // Huoltoyhtiö
var attachments_2 = new Array(); // Isännöitsijä
var attachments_3 = new Array(); // Asunnon vuokraus ja vaihto
var attachments_4 = new Array(); // SATOn asiakaspalvelu
var attachments_5 = new Array(); // Vuokravalvonta
var servicetitles = new Array("Huoltoyhtiö","Isännöitsijä","Asunnon vuokraus ja vaihto","SATOn asiakaspalvelu","Vuokravalvonta");
var serviceinfos = new Array("talojen ja asuntojen kunnossapito, vikailmoitukset, oven avaukset","talon ja asuntojen hoitoon liittyvät asiat, asukasyhteistyö","","mm. asumiseen liittyvä neuvonta, palautteet","vuokranmaksu, maksujärjestelyt, vakuudet");
function serviceAttachment(path, name)
{
 this.Name = name;
 this.Path = path; 
}
// get service info text
function getServiceInfo(id)
{
   if(serviceinfos.length >= id-1)
     return serviceinfos[id-1];
   return "";
}
function makeServiceLinks(serviceID, targetContainerID, excludeValue, includeValue)
{
  // Get the objects  
  var attachments = getServiceAttachments(serviceID);
  // Get the targetContainer
  var target = document.getElementById(targetContainerID);
  if(!target || attachments.length == 0)
     return;
  target.appendChild(document.createElement("br"));
  // Loop through links
  for(var i=0;i<attachments.length;i++)
  {
     if(!excludeValue){ excludeValue = null; }
     if(!includeValue){ includeValue= null; }
     if(excludeValue != null && attachments[i].Path.indexOf(excludeValue) != -1)
        continue;
     if(includeValue!= null && attachments[i].Path.indexOf(includeValue) == -1)
        continue;
     var anchor = document.createElement("a");
     anchor.id="attachmenlink_" + serviceID + "_" + i;
     anchor.setAttribute("href", attachments[i].Path);
     var textNode = document.createTextNode(attachments[i].Name);
     anchor.appendChild(textNode);
     target.appendChild(anchor);
     target.appendChild(document.createElement("br"));
  }
}
// listID: id of the select HTML element to populate
function makeServiceDropDown(listID, excludeValue, includeValue)
{
     var _exclude = excludeValue;
     var _include = includeValue;
     if(!excludeValue){ _exclude = null; }
     if(!includeValue){ _include = null; }
    var _sl = new selectionList(listID);
 
    addServiceOptions(1);
    addServiceOptions(2);
    addServiceOptions(3);
    addServiceOptions(4);
    addServiceOptions(5);
    
    // Event to fire when option is changed
    _sl.obj.onchange = function(){
       var selectedValue = this.options[this.selectedIndex].value;
       // Open new window when option is changed
       if(selectedValue == "")
          return;
       var newWindow = window.open(selectedValue,"attachmentwindow","");
       newWindow.focus();
    }
    function addServiceOptionTitle(title)
    {
        var attachments = new Array(new serviceAttachment("",title));
        var o = addOption("", title, "titleOption");    
    }
    function addServiceOptions(serviceID)
    {
        var attachments = getServiceAttachments(serviceID.toString());
        if(attachments.length == 0)
           return;
        // addOption("", " ");             
        // addServiceOptionTitle(" -- " + servicetitles[serviceID-1] + " -- ");
        // Loop through links
        for(var i=0;i<attachments.length;i++)
        {
             if(attachments[i].Name == "")
                continue;
             if(_exclude != null && attachments[i].Name.indexOf(_exclude) != -1)
                continue;
             if(_include != null && attachments[i].Name.indexOf(_include) == -1)
                continue;
             addOption(attachments[i].Path, "  " + attachments[i].Name);             
        }
        
    }   
    function addOption(value, text, classname)
    {
        var optn = document.createElement("option");
        optn.value = value;
        optn.text = text;
        if(classname) 
          optn.lassName = classname;
        _sl.obj.options.add(optn);
        return optn;
    }
    
}
function getServiceAttachments(serviceID)
{
    // GET ARRAY
    var attachments = eval("attachments_" + serviceID);
    return attachments;
}
// Get the attachments

attachments_1.push(new serviceAttachment("/cps/rde/xbcr/sato/files/Tuloilmoitus.pdf","Tuloilmoitus (PDF)"));

attachments_1.push(new serviceAttachment("/cps/rde/xbcr/sato/files/Lahtoilmoitus.pdf","Lähtöilmoitus (PDF)"));




attachments_4.push(new serviceAttachment("/cps/rde/xbcr/sato/files/VA_irtisanominen_poismuuttokysely_150210.pdf","Vuokrasopimuksen irtisanominen (PDF)"));


attachments_5.push(new serviceAttachment("/cps/rde/xbcr/sato/files/VA_suoraveloitusvaltakirja_121107.pdf","Suoraveloitus (PDF)"));

attachments_5.push(new serviceAttachment("/cps/rde/xbcr/sato/files/VA_vakuuden_palautus_131107.pdf","Vakuuden palauttaminen (PDF)"));


 

