// SMILEYWEB 2.0
// ie.js
// contains scripts not used by Internet Explorer (pendants in the ie.js file)


// Til 'Om dig selv'-siden
function itemSwitch(id) {
  var lyr = getElemRefs(id);
  if (lyr.css.visibility=='hidden') lyr.css.visibility = 'visible';
  else lyr.css.visibility = 'hidden';
}


// Scripts til alle boxene
function boxesAddIeBorders() {
	
	boxElements = getElementByClass('box');

	for (var n = 0; n < boxElements.length; n++) {		
		
		if (boxElements[n].id) {
			boxleftid = ' id="'+boxElements[n].id+'_boxleft"';
			boxrightid = ' id="'+boxElements[n].id+'_boxright"';
		} else {
			boxleftid = '';
			boxrightid = '';
		}
		
	    boxElements[n].insertAdjacentHTML('beforeEnd', '<img src="design/'+sw['design']+'/'+sw['color']+'/box-left.png" class="box_left_ie"'+boxleftid+' border="0" alt="" style="height: '+(boxElements[n].offsetHeight-48)+'px;"><img src="design/'+sw['design']+'/'+sw['color']+'/box-right.png" class="box_right_ie"'+boxrightid+' border="0" alt="" style="height: '+(boxElements[n].offsetHeight-48)+'px;">');
		
	}
}


function boxesAddBorders() {
	boxElements = getElementByClass('box');

	for (var n = 0; n < boxElements.length; n++) {
		
	    boxElements[n].innerHTML += '<div style="background-image: url(design/'+sw['design']+'/'+sw['color']+'/box-left.png);" class="box_left"></div><div style="background-image: url(design/'+sw['design']+'/'+sw['color']+'/box-right.png);" class="box_right"></div>';
		
	}
}


function boxesUpdateBorder(id) {
	
	if (id) {
		boxLeft = document.getElementById(id+'_boxleft');
		boxRight = document.getElementById(id+'_boxright');
		boxLeft.style.bottom = '23px';
		boxRight.style.bottom = '23px';
		setTimeout("boxLeft.style.bottom = '24px';", 1);		
		setTimeout("boxRight.style.bottom = '24px';", 2);	
	} else {
		boxLefts = getElementByClass('box_left');
		boxRights = getElementByClass('box_right');
		for (var n = 0; n < boxLefts.length; n++) {
			boxLefts[n].style.bottom = '23px';
			boxRights[n].style.bottom = '23px';
			setTimeout("boxLefts["+n+"].style.bottom = '24px';", 1);		
			setTimeout("boxRights["+n+"].style.bottom = '24px';", 2);	
		}
	}	
	// update designbox-border
	document.getElementById('gfx_shadowleft').style.bottom = '1px';
	document.getElementById('gfx_shadowright').style.bottom = '1px';
	setTimeout("document.getElementById('gfx_shadowleft').style.bottom = '0px';", 1);
	setTimeout("document.getElementById('gfx_shadowright').style.bottom = '0px';", 1);
}
function boxesUpdateSnapBorder(id) {
	//alert("boxesUpdateSnapBorder");
	if (id) {
		boxBottom = document.getElementById(id+'_box_bottom_container_snap');
		boxBottom.style.bottom = '1px';
		setTimeout("boxBottom.style.bottom = '0px';", 1);		
	} else {
		boxBottoms = getElementByClass('box_bottom_container_snap');
		for (var n = 0; n < boxBottoms.length; n++) {
			boxBottoms[n].style.bottom = '1px';
			setTimeout("boxBottoms["+n+"].style.bottom = '0px';", 1);		
		}
	}	
	boxesUpdateBorder(id); 
}

// Open a popup window
function popupWindow(url, windowHeight, windowWidth) {

    // How big is the window gonna be?
    if (!windowHeight) windowHeight = 400;
    if (!windowWidth)  windowWidth  = 600;

    // Avoid making the popup larger than the user's screen
    if (windowHeight>screen.availHeight) windowHeight = screen.availHeight;
    if (windowWidth>screen.availWidth) windowWidth = screen.availWidth;

    // Position the window in the middle of the screen
    fromTop  = (screen.availHeight-windowHeight)/2;
    fromLeft = (screen.availWidth-windowWidth)/2;

    newWindow = window.open(url, 'sw_popup', 'height='+ windowHeight +', width='+windowWidth+', top='+fromTop+', left='+fromLeft+', dependent=no, directories=no, location=no, menubar=no, resizable=yes, scrollbars=yes, status=yes, toolbar=no');
    if (window.focus) { 
    
    if (!newWindow) return true;
    else newWindow.focus();
    
    }
    
    return false;

}

