﻿/*//////////////////////////////
// Variables
//////////////////////////////*/
var funcs = {
    global: {
        externalLinks: function () {
            if (!$('a.EXLINK, a.exlink').attr('target')) {
                $('a.EXLINK, a.exlink').bind({
                    click: function (event) {
                        window.open($(event.target).attr('href'));
                        return false;
                    },
                    keyup: function (event) {
                        window.open($(event.target).attr('href'));
                        return false;
                    }
                });
            }
        }
    },
    inomhus: {
        home: {
            mainFlash: function () {
                var flashvars = {
                    url1: 'adnatur.aspx',
                    url2: 'adgrey.aspx',
                    url3: 'adwhite.aspx',
                    url4: 'http://www.facebook.com/pages/ALCRO-vi-som-%C3%A4lskar-att-m%C3%A5la/303923358957?sk=app_145250415542321'
                };
                var params = { wmode: 'transparent' };
                swfobject.embedSWF('Flash/adnatur/inomhusTopBanner_noFB.swf', 'flashtop', '737', '250', '9.0.0', false, flashvars, params, false);
            },
            init: function () {
                jQuery('.cycle-fotos').cycle('fade');
                funcs.inomhus.home.mainFlash();
            }
        }
    },
    utomhus: {
        home: {
            opentavling: function () {
                window.open('http://clients.mrmpartners.se/viivilla/', 'Tavling', 'statusbar=no;toolbar=no,width=718,height=550,scrollbars=1');
            },
            popHus: function (id) {
                window.open('flash/comp/originellt.aspx?id=' + id, '', 'statusbar=no;toolbar=no,width=700,height=630,scrollbars=1');
            },
            puffar: {
                puff4: function () {
                    openSize('trahusputshus/bestall/index.html', '670', '449');
                }
            }
        }
    },
    arkitekt: {
        home: {
            mainFlash: function () {
                var flashvars = {
                    url1: '../adnaturark.aspx',
                    url2: '../adgreyark.aspx',
                    url3: '../adwhite.aspx'
                };
                var params = { wmode: 'transparent' };
                swfobject.embedSWF('../Flash/adnatur/arkitekt-topbanner.swf', 'flashReplace', '656', '194', '9.0.0', false, flashvars, params, false);
            }
        }
    },
    pro: {
        home: {
            mainFlash: function () {
                var flashvars = {
                    url1: '../adnaturpro.aspx',
                    url2: '../adgreypro.aspx',
                    url3: '../adwhite.aspx'
                };
                var params = { wmode: 'transparent' };
                swfobject.embedSWF('../Flash/adnatur/pro-topbanner.swf', 'flash_bannerreplace', '531', '231', '9.0.0', false, flashvars, params, false);
                swfobject.embedSWF('../Flash/pro/mineraliska_ytor.swf', 'proPuff', '385', '232', '8.0.0', false);
            }
        }
    },
    spray: {
        home: {
            mainFlash: function () {
                var id = 'flashReplace';
                var getURL = $('#' + id + ' a').attr('href');
                var flashvars = {
                    url: getURL
                };
                var params = { wmode: 'transparent' };
                swfobject.embedSWF('../Flash/spray/intro.swf', id, '738', '416', '9.0.0', false, flashvars, params, false);
            }
        }
    }
};
/*//////////////////////////////
// Functions
//////////////////////////////*/
function openfasad() {
    newWindow = window.open('http://www.alcro.se/fasadexperten/frameset.html','fasad','fullscreen=1,statusbar=no;toolbar=no,width=1024,height=768,top=0,left=0');
}
function openSchablon(Name) {
    newWindow = window.open('schablon_visa.aspx?name='+Name,'Schablon','toolbar=no,width=250,height=280,top=0,left=0');
}
function openSchablonSize(Name,width,height) {
    newWindow = window.open('/images/schabloner/'+Name+'.jpg','','toolbar=no,width='+width+',height='+height+',top=0,left=0');
}
function openSize(Name,width,height) {
    if(Name.toString().indexOf('tavling.aspx') != -1) {
        width = '670';
        height = '518';
    }
    newWindow = window.open(Name,'','toolbar=no,width='+width+',height='+height+',top=100,left=100');
}
function showMioCollection(id) {
	try {
        document.getElementById('MioCollectionImage').style.display = 'none';
        document.getElementById('MioCollectionWrapper').style.display = 'block';
        document.getElementById('MioCollectionTable1').style.display = 'none';
        document.getElementById('MioCollectionTable2').style.display = 'none';
        document.getElementById('MioCollectionTable3').style.display = 'none';
        document.getElementById('MioCollectionTable4').style.display = 'none';
        document.getElementById('MioCollectionTable5').style.display = 'none';
        document.getElementById('MioCollectionInfo1').style.display = 'none';
        document.getElementById('MioCollectionInfo2').style.display = 'none';
        document.getElementById('MioCollectionInfo3').style.display = 'none';
        document.getElementById('MioCollectionInfo4').style.display = 'none';
        document.getElementById('MioCollectionInfo5').style.display = 'none';
        document.getElementById('MioCollectionInfo'+id).style.display = 'block';
        document.getElementById('MioCollectionTable'+id).style.display = 'block';
    }catch(err){}

    document.getElementById('MioCollectionContentInfo').style.display = 'none';

    if (id == '1') {
      document.getElementById('MioCollectionImage').src = 'images/urban_lounge_anis.jpg';
      document.getElementById('MioCollectionImage').alt = 'Urban lounge';
    }
    else if (id == '2') {
      document.getElementById('MioCollectionImage').src = 'images/skandinaviskt_sparris.jpg';
      document.getElementById('MioCollectionImage').alt = 'Skandinavisk natur & tradition';
    }
    else if (id == '3') {
      document.getElementById('MioCollectionImage').src = 'images/engelsk_tradition_karlek.jpg';
      document.getElementById('MioCollectionImage').alt = 'Engelsk tradition';
    }
    else if (id == '4') {
      document.getElementById('MioCollectionImage').src = 'images/koloniala_honung.jpg';
      document.getElementById('MioCollectionImage').alt = 'Koloniala världen';
    }
    else if (id == '5') {
      document.getElementById('MioCollectionImage').src = 'images/provence_monsun.jpg';
      document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }
    document.getElementById('MioCollectionImage').style.display = 'block';
}
function closeMioCollection() {
    document.getElementById('MioCollectionWrapper').style.display = 'none';
}
function showMioColor(parent,id) {
    if (parent == '1' && id == '1') {
        document.getElementById('MioCollectionImage').src = 'images/urban_lounge_anis.jpg';
        document.getElementById('MioCollectionImage').alt = 'Urban Lounge';
    }    
    else if (parent == '1' && id == '2') {
        document.getElementById('MioCollectionImage').src = 'images/urban_lounge_ljung.jpg';
        document.getElementById('MioCollectionImage').alt = 'Urban Lounge';
    }    
    else if (parent == '1' && id == '3') {
        document.getElementById('MioCollectionImage').src = 'images/urban_lounge_silverpil.jpg';
        document.getElementById('MioCollectionImage').alt = 'Urban Lounge';
    }    
    else if (parent == '1' && id == '4') {
        document.getElementById('MioCollectionImage').src = 'images/urban_lounge_guld.jpg';
        document.getElementById('MioCollectionImage').alt = 'Urban Lounge';
    }    
    else if (parent == '1' && id == '5') {
        document.getElementById('MioCollectionImage').src = 'images/urban_lounge_brownie.jpg';
        document.getElementById('MioCollectionImage').alt = 'Urban Lounge';
    }    
    else if (parent == '1' && id == '6') {
        document.getElementById('MioCollectionImage').src = 'images/urban_lounge_paris.jpg';
        document.getElementById('MioCollectionImage').alt = 'Urban Lounge';
    } 
    else if (parent == '2' && id == '1') {
        document.getElementById('MioCollectionImage').src = 'images/skandinaviskt_sparris.jpg';
        document.getElementById('MioCollectionImage').alt = 'Skandinavisk natur & tradition';
    }   
    else if (parent == '2' && id == '2') {
        document.getElementById('MioCollectionImage').src = 'images/skandinaviskt_papaya.jpg';
        document.getElementById('MioCollectionImage').alt = 'Skandinavisk natur & tradition';
    }   
    else if (parent == '2' && id == '3') {
        document.getElementById('MioCollectionImage').src = 'images/skandinaviskt_olivblad.jpg';
        document.getElementById('MioCollectionImage').alt = 'Skandinavisk natur & tradition';
    }   
    else if (parent == '2' && id == '4') {
        document.getElementById('MioCollectionImage').src = 'images/skandinaviskt_vetekorn.jpg';
        document.getElementById('MioCollectionImage').alt = 'Skandinavisk natur & tradition';
    }   
    else if (parent == '2' && id == '5') {
        document.getElementById('MioCollectionImage').src = 'images/skandinaviskt_kyla.jpg';
        document.getElementById('MioCollectionImage').alt = 'Skandinavisk natur & tradition';
    }   
    else if (parent == '3' && id == '1') {
        document.getElementById('MioCollectionImage').src = 'images/engelsk_tradition_karlek.jpg';
        document.getElementById('MioCollectionImage').alt = 'Engelsk tradition';
    }   
    else if (parent == '3' && id == '2') {
        document.getElementById('MioCollectionImage').src = 'images/engelsk_tradition_kamel.jpg';
        document.getElementById('MioCollectionImage').alt = 'Engelsk tradition';
    }   
    else if (parent == '3' && id == '3') {
        document.getElementById('MioCollectionImage').src = 'images/engelsk_tradition_tallbarr.jpg';
        document.getElementById('MioCollectionImage').alt = 'Engelsk tradition';
    }   
    else if (parent == '3' && id == '4') {
        document.getElementById('MioCollectionImage').src = 'images/engelsk_tradition_stormnatt.jpg';
        document.getElementById('MioCollectionImage').alt = 'Engelsk tradition';
    }   
    else if (parent == '4' && id == '1') {
        document.getElementById('MioCollectionImage').src = 'images/koloniala_honung.jpg';
        document.getElementById('MioCollectionImage').alt = 'Koloniala världen';
    }   
    else if (parent == '4' && id == '2') {
        document.getElementById('MioCollectionImage').src = 'images/koloniala_oktan.jpg';
        document.getElementById('MioCollectionImage').alt = 'Koloniala världen';
    }   
    else if (parent == '4' && id == '3') {
        document.getElementById('MioCollectionImage').src = 'images/koloniala_plommon.jpg';
        document.getElementById('MioCollectionImage').alt = 'Koloniala världen';
    }   
    else if (parent == '4' && id == '4') {
        document.getElementById('MioCollectionImage').src = 'images/koloniala_brons.jpg';
        document.getElementById('MioCollectionImage').alt = 'Koloniala världen';
    }   
    else if (parent == '5' && id == '1') {
        document.getElementById('MioCollectionImage').src = 'images/provence_monsun.jpg';
        document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }   
    else if (parent == '5' && id == '2') {
        document.getElementById('MioCollectionImage').src = 'images/provence_lingonshake.jpg';
        document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }   
    else if (parent == '5' && id == '3') {
        document.getElementById('MioCollectionImage').src = 'images/provence_vaniljglass.jpg';
        document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }   
    else if (parent == '5' && id == '4') {
        document.getElementById('MioCollectionImage').src = 'images/provence_lin.jpg';
        document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }   
    else if (parent == '5' && id == '5') {
        document.getElementById('MioCollectionImage').src = 'images/provence_fjader.jpg';
        document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }   
    else if (parent == '5' && id == '6') {
        document.getElementById('MioCollectionImage').src = 'images/provence_romans.jpg';
        document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }   
    else if (parent == '5' && id == '7') {
        document.getElementById('MioCollectionImage').src = 'images/provence_silkesgra.jpg';
        document.getElementById('MioCollectionImage').alt = 'Romantik i Provence';
    }   
}
function CheckFlash() {
    var hasFlash = false;
    var skipFlashURL = 'utomhus.aspx';
    //Check for flash if browser is netscape
    //submitted to www.a1javascripts.com by Joshua Luft-Glidden
    if (navigator.appName == 'Netscape') {
        for (i = 0; i < navigator.plugins.length; i++) {
            if (navigator.plugins[i].name == 'Shockwave Flash')
                hasFlash = true;
        }
    }
    //Check for flash if browser is IE
    else if (navigator.appName == 'Microsoft Internet Explorer') {
        document.writeln('<script language="VBscript">');
        document.writeln('\'Test to see if VBScripting works');
        document.writeln('detectableWithVB = False');
        document.writeln('If ScriptEngineMajorVersion >= 2 then');
        document.writeln('   detectableWithVB = True');
        document.writeln('End If');
        document.writeln('\'This will check for the plugin');
        document.writeln('Function detectActiveXControl(activeXControlName)');
        document.writeln('   on error resume next');
        document.writeln('   detectActiveXControl = False');
        document.writeln('   If detectableWithVB Then');
        document.writeln('      detectActiveXControl = IsObject(CreateObject(activeXControlName))');
        document.writeln('   End If');
        document.writeln('End Function');
        document.writeln('</scr' + 'ipt>');
        hasFlash = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
	}
    if (!hasFlash) {
        document.location = skipFlashURL;
    }
}
