// BOF =======================================================
var isOp7 = false, currUA = navigator.userAgent.toLowerCase();
if (window.opera) isOp7 = (currUA.indexOf('opera 7')!=-1 || currUA.indexOf('opera/7')!=-1);
// ===========================================================
function isDef ()
{
    for (var i=0; i<arguments.length; ++i) if (typeof(arguments[i]) == 'undefined') return false;
    return true;
}
// ===========================================================
function showLayer (n)
{
    if (!(e=MM_findObj(n))) return;
    if (e.style && isDef(e.style.display)) e.style.display='block';
    else if(isDef(e.display)) e.display='block';
}
function hideLayer (n)
{
    if (!(e=MM_findObj(n))) return;
    if (e.style && isDef(e.style.display)) e.style.display='none';
    else if(isDef(e.display)) e.display='none';
}
// ===========================================================
function getWindowWidth ()
{
    var windowWidth = 0;
    if (typeof(window.innerWidth) == 'number') {
        windowWidth = window.innerWidth;
    }
    else {
        if (document.documentElement && document.documentElement.clientWidth) windowWidth = document.documentElement.clientWidth;
        else if (document.body && document.body.clientWidth) windowWidth = document.body.clientWidth;
    }
    return windowWidth;
}
function getWindowHeight ()
{
    var windowHeight = 0;
    if (typeof(window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) windowHeight = document.documentElement.clientHeight;
        else if (document.body && document.body.clientHeight) windowHeight = document.body.clientHeight;
    }
    return windowHeight;
}
var defaultWidth = null;
function setContent ()
{
    var windowWidth = getWindowWidth();
    if (windowWidth > 0) {
        var objContent = MM_findObj('content');
        var objColumnLeft   = 'columnLeft';
        var objColumnCenter = 'columnCenter';
        var objColumnRight  = 'columnRight';
        if (!objContent) return;
        if (xHeight(objColumnCenter) < xHeight(objColumnRight)) xHeight(objColumnCenter, xHeight(objColumnRight));
        var contentWidth = (defaultWidth ? defaultWidth : xWidth(objContent));
        if (windowWidth - contentWidth > 20) {
            if (defaultWidth) xWidth(objContent, defaultWidth);
            if (objColumnLeft) showLayer(objColumnLeft);
        } else {
            if (!defaultWidth) defaultWidth = contentWidth;
            xWidth(objContent, windowWidth-20);
            if (objColumnLeft) hideLayer(objColumnLeft);
        }
    }
}
// ===========================================================
function MM_preloadImages () //v3.0
{ 
    var d=document; if(d.images) {
        if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}
    }
}
function MM_swapImgRestore () //v3.0
{
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImgRestoreId (a)
{
    if ((x=MM_findObj(a))!=null && x.oSrc) x.src=x.oSrc;
}
function MM_findObj (n, d) //v4.01
{
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage () //v3.0
{
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  if (typeof(validateStr)!='object') validateStr=Array();
  var str=validateStr;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (!val.match(/^[-\.\w]+@(([\w]|[\w][\w-]*[\w])\.)+([a-z]{2,})$/ig)) errors+='- '+str[nm]+'\n';
      } else if (test.indexOf('isZipCode')!=-1) {
        if (!val.match(/^[\s]*[0-9]{3}[\s]*[0-9]{2}[\s]*$/ig)) errors+='- '+str[nm]+'\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val.replace(/[ ]/g, ""))) errors+='- '+str[nm]+'\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+str[nm]+'\n'; }
  } if (errors) alert('Följande fel uppstod:\n'+errors);
  document.MM_returnValue = (errors == '');
}
// ===========================================================
var activeMenu = null;
var menuTimer = null;
function setMenu (m, t)
{
    // Reset timer
    if (menuTimer) {
        clearTimeout(menuTimer);
        menuTimer = null;
    }
    // New menu equals current menu
    if (activeMenu == m) return;
    // Hide menu?
    if (activeMenu && (m || t)) {
        hideLayer('navMenu'+activeMenu);
        activeMenu = null;
    }
    // Show menu?
    if (m) {
        var tX = xOffsetLeft('navCell'+m), tY = xPageY('navCell'+m)+(xHeight('navCell'+m)/2)+1;
        xWidth('navMenu'+m, Math.max(xWidth('navMenu'+m), xWidth('navCell'+m)));
        xLeft('navMenu'+m, tX);
        xTop('navMenu'+m, tY);
        showLayer('navMenu'+m);
        activeMenu = m;
    } else if (!t) {
        menuTimer = setTimeout('setMenu(null,true)', 1500);
    }
}
// ===========================================================
function sendContactForm ()
{
    MM_validateForm('v_namn','','R','v_epost','','NisEmail','v_gata','','R','v_postnr','','RisZipCode','v_ort','','R');
    return document.MM_returnValue;
}
// ===========================================================
function openWindow (url, w, h, n)
{
    var t = 'width='+w+',height='+h+',location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0';
    if (screen && screen.width) {
        t+=',left='+Math.round((screen.width-w)/2)+',top='+Math.round((screen.height-h)/2);
    }
    window.open(url, n?n:'_blank', t);
}
// ===========================================================
function sendSelectBox (form)
{
    var o = MM_findObj(form);
    if (!o) return false;
    o.submit();
}
// EOF =======================================================
