﻿// JScript File
function message(msg)
{
    alert(msg);
}

function formatStr(sString)
{
    var intIndexOfMatch;
    // Loop over the string value replacing out each matching
    // substring.
    while (intIndexOfMatch != -1)
    {
        // Relace out the current instance.
        sString = sString.replace('å','aring;');
        // Get the index of any next matching substring.
        intIndexOfMatch = sString.indexOf( "å" );
    }
    
    intIndexOfMatch = 0;
    while (intIndexOfMatch != -1)
    {
        // Relace out the current instance.
        sString = sString.replace('ä','auml;');
        // Get the index of any next matching substring.
        intIndexOfMatch = sString.indexOf( "ä" );
    }
    intIndexOfMatch = 0;
    while (intIndexOfMatch != -1)
    {
        // Relace out the current instance.
        sString = sString.replace('ö','ouml;');
        // Get the index of any next matching substring.
        intIndexOfMatch = sString.indexOf( "ö" );
    }
    intIndexOfMatch = 0;
    while (intIndexOfMatch != -1)
    {
        // Relace out the current instance.
        sString = sString.replace('Å','Aring;');
        // Get the index of any next matching substring.
        intIndexOfMatch = sString.indexOf( "Å" );
    }
    intIndexOfMatch = 0;
    while (intIndexOfMatch != -1)
    {
        // Relace out the current instance.
        sString = sString.replace('Ä','Auml;');
        // Get the index of any next matching substring.
        intIndexOfMatch = sString.indexOf( "Ä" );
    }
    intIndexOfMatch = 0;
    while (intIndexOfMatch != -1)
    {
        // Relace out the current instance.
        sString = sString.replace('Ö','Ouml;');
        // Get the index of any next matching substring.
        intIndexOfMatch = sString.indexOf( "Ö" );
    }
    
    intIndexOfMatch = 0;
    while (intIndexOfMatch != -1)
    {
        // Relace out the current instance.
        sString = sString.replace("'","''");
        // Get the index of any next matching substring.
        intIndexOfMatch = sString.indexOf( "'" );
    }
    
    alert(sString);
    return sString;
}

function getImage(sHeadline,sImage,sImage1,sImage2,sImage3,sImage4)
{
  // this will make a child page popup 
  window.open("showImage.aspx?headline=" + sHeadline + "&img=" + sImage + "&img1=" + sImage1 + "&img2=" + sImage2 + "&img3=" + sImage3 + "&img4=" + sImage4 ,"Bild","height=600,width=600");
}

function editTemplate(sTemplateName)
{
    //window.open("templateeditor.aspx?templatename=" + sTemplateName, "Editera mall", "height=600,width=800");
    //alert(sTemplateName);
    window.open("templateeditor.aspx?templatename=" + sTemplateName,"Editor","height=600");
}

function editText(sTextName)
{
    //window.open("templateeditor.aspx?templatename=" + sTemplateName, "Editera mall", "height=600,width=800");
    //alert(sTemplateName);
    window.open("templateeditor.aspx?textname=" + sTextName,"Editor","height=600");
}

function editFile(sFile)
{
    //window.open("templateeditor.aspx?templatename=" + sTemplateName, "Editera mall", "height=600,width=800");
    //alert(sTemplateName);
    window.open("fileeditor.aspx?file=" + sFile,"FilEditor","height=600");
}



function swapClass(element,fromClass,toClass)
{
    var e = document.getElementById(element)
    if(e)
    {
         if(e.className == fromClass)
         {
            e.className = toClass;
         }
         else
         {
           e.className = fromClass;
         }
    }
    else{
    alert("error" + element);
    }
}

function SwapImage(name, direction,imageover,imageout)
{
    switch(direction)
    {
        case 'in':
        name.src = imageover;
        break;
        case 'out':
        name.src = imageout;
        break;
    }
}

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = './images/1.jpg'
Pic[1] = './images/2.jpg'
Pic[2] = './images/3.jpg'
//Pic[3] = '4.jpg'
//Pic[4] = '5.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}



