﻿function myGetElementById(theId){
	var elem;  
	if( document.getElementById ){
		 // this is the way the standards work    
		elem = document.getElementById( theId );  
	}else if( document.all ) {
		// this is the way old msie versions work      
		elem = document.all[theId];  
	}else if( document.layers ) {
		// this is the way nn4 works    
		elem = document.layers[theId];  
	}
	return(elem);
}

function setVisibility(theId, bVisible){
    var elem = myGetElementById(theId);
    if(elem){
        if(bVisible){
            elem.style.display = 'inline';
        }else{
            elem.style.display = 'none';
        }
	}
}

function gnu(bYes){
    if(bYes){
        alert('Jajjamensan, gnu it is');
        }
        else{
        alert('Nope, no gnu');
        }
}

function newwin(urlo, title, w, h, resizable, scrollbars){
    if((resizable == false) || (resizable == 'no')){
        resizable = 'no'; // Convert bool to appropriate string
    }else{
        resizable = 'yes'; // Default is yes
    }
    
    if((scrollbars == false) || (scrollbars == 'no')){
        scrollbars = 'no'; // Convert bool to appropriate string
    }else{
        scrollbars = 'yes'; // Default is yes
    }    
    
    var bModal = false;
    if(document.URL.indexOf('butik.', 0) > -1){
        bModal = true;
    }
    
    
    
    if(!isNaN(screen.availHeight)){
		var wndLeft = parseInt((screen.availWidth - w)/2);
		var wndTop = parseInt((screen.availHeight - h)/2);
		if(wndTop-15>0) wndTop-=15;
		else wndTop = 0;
	}else{
		var wndLeft = 5;
		var wndTop = 5;
	}
    
    var sParams = 'directories=no,height=' + h + ',width=' + w + ',hotkeys=no,menubar=no,resizable='+resizable+',toolbar=no,scrollbars='+scrollbars+',screenx='+wndLeft+',screeny='+wndTop+',left='+wndLeft+',top='+wndTop;

    
    // Show modal?
    if(!bModal){
        // Nope, no modal
        myWin = window.open(urlo, title, sParams);
    }else{
        // Modal
        // IE style?
        if (window.showModalDialog) {
            myWin = window.showModalDialog(urlo, title, 'dialogWidth:' + w + 'px;dialogHeight:' + h + 'px;scroll:no;');
        }else{
            sParams += ',modal=yes';
            myWin = window.open(urlo, title, sParams);
        }
    }
    
    if(myWin.length) {
		myWin.focus();
	}
    
    
}

function openblog(){
    var daBlogWindow = window.open('Design4Walls/', 'Design4Walls', 'toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=840');	
}

function showGuide(kollektion, lang, bModal){
    if(bModal==undefined){
        bModal = false;
    }
	if(!isNaN(screen.availHeight)){
		var wndLeft = parseInt((screen.availWidth - 780)/2);
		var wndTop = parseInt((screen.availHeight - 540)/2);
		if(wndTop-15>0) wndTop-=15;
		else wndTop = 0;
	}else{
		var wndLeft = 5;
		var wndTop = 5;
	}

	if(typeof(kollektion)=='undefined'){
		kollektion = '';
	}
	bArkitekt = false;

    var sUrl = 'tapetguiden/default.asp?arkitekt=' + bArkitekt + '&kollektion=' + kollektion + '&lang=' + lang;
    var sWinName = 'btguidewin';
    var w = 750;
    var h = 540;
    var sParams = 'directories=no,height=' + h + ',width=' + w + ',hotkeys=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,screenx='+wndLeft+',screeny='+wndTop+',left='+wndLeft+',top='+wndTop;

    // Show modal?
    if(!bModal){
        // Nope, no modal
        myWin = window.open(sUrl, sWinName, sParams);
    }else{
        // Modal
        // IE style?
        if (window.showModalDialog) {
            myWin = window.showModalDialog(sUrl, sWinName, 'dialogWidth:' + w + 'px;dialogHeight:' + h + 'px;scroll:no;');
        }else{
            sParams += ',modal=yes';
            myWin = window.open(sUrl, sWinName, sParams);
        }
    }
    
    if(myWin.length) {
		myWin.focus();
	}

}

function modalWin(urlo, name, w, h) {
    if (window.showModalDialog) {
        myModalWin = window.showModalDialog(urlo, name, 'dialogWidth:' + w + 'px;dialogHeight:' + h + 'px;scroll:no;');
    } else {
        myModalWin = window.open(urlo, name,'height=' + h + ',width=' + w + ',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
    }
    if(myModalWin.length){
        myModalWin.focus();
    }
} 