
function swapImage(imgName,newImg) { eval('document.' + imgName + '.src = "' + newImg + '"'); }
function showdiv(id) { if(id != "" && id != null) document.getElementById(id).style.display = "block"; }
function hidediv(id) { if(id != "" && id != null) document.getElementById(id).style.display = "none"; }



function windowOpener(url,width,height,name,scrolls) {
	browserName = navigator.appName;
	browserVer = navigator.appVersion.substring(0,1);
	if (width==null) {width=600;}
	if (height==null) {height=400;}
	if (name==null) {name="globaltPopup"}
    if (scrolls=='true') {
		scrollsOption="yes";
	} else {
		scrollsOption="no";
	}
	var topPx = (browserName=="Netscape")?"screenX":"top";
	var leftPx = (browserName=="Netscape")?"screenY":"left";
	if (browserName != "Netscape" || browserVer != 2) {
		controlWindow=window.open(url,name,"toolbar=no,height="+height+",width="+width+",location=no,directories=no,status=no,menubar=no,scrollbars="+scrollsOption+",resizable=no,"+leftPx+"=100,"+topPx+"=100");
	}    
}


/* ################# 1.1 Popup examples ################# */

function rsWindow(url,name,scrolls,resize) {
    	if (scrolls==null) {scrolls="no";}
		if (resize==null) {resize="no";}
		fsWindow=window.open(url,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrolls+",resizable="+resize);
}

/* ################# /1.1 Popup examples ################# */

function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

function printPage()
{
    if (window.print)
    {
        window.print();
    }
    else
    {
        alert("Press Ctrl-P to print");
    }
}


/* ################# 1.1 FAQ ################# */

function click_faq_header(el) {
	var element = document.getElementById(el);
	hide_all(element);
	if (element.style.display == "none") {
		element.style.display = "block";
		open_header(el);
	} else {
		element.style.display = "none";
	}
}

function hide_headers() {
	var qheaders = getElementsByClassName(document, "p", "faq_question_open");
	if (qheaders.length > 0) {
		removeClassName(qheaders[0], "faq_question_open");
		addClassName(qheaders[0], "faq_question");
	}
}

function open_header(el) {
	var qheaders = getElementsByClassName(document, "p", "faq_question");
    removeClassName(qheaders[el.substr(7,el.length)], "faq_question");
    addClassName(qheaders[el.substr(7,el.length)], "faq_question_open");
}

function hide_all(skip) {
	hide_headers();
	var q = getElementsByClassName(document, "div", "faq");
	for (var i = 0; i<q.length; i++) {
		var elm = document.getElementById("faqItem"+i);
		if (elm != null && elm != skip) {
			elm.style.display = "none";
		}
	}
}

// ------------------------------------------------------
/*
	Copyright Robert Nyman, http://www.robertnyman.com
	Free to use if this text is included
*/
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}	
	}
	return (arrReturnElements)
}

function addClassName(oElm, strClassName){
	var strCurrentClass = oElm.className;
	if(!new RegExp(strClassName, "i").test(strCurrentClass)){
		oElm.className = strCurrentClass + ((strCurrentClass.length > 0)? " " : "") + strClassName;
	}
}

function removeClassName(oElm, strClassName){
	var oClassToRemove = new RegExp((strClassName + "\s?"), "i");
	oElm.className = oElm.className.replace(oClassToRemove, "").replace(/^\s?|\s?$/g, "");
}
// ------------------------------------------------------
					

/* ################# /1.1 FAQ ################# */


/* ################# /SE NetBusiness ################# */
/*
 * New fuctionalities for the TSIC SE site are 
 * the "Mina produkter" table row expand/collapse feature and 
 * the NetBusiness login form input field value switcher feature.
 * 
 */

// Both features are triggered on the window.onload event
window.onload = productDetails;

function productDetails()
{
	// Script execution depends on the features of the browser
	if (!document.getElementById || !document.getElementsByTagName) return false;
	
	//Firefox nextSibling fix from http://www.agavegroup.com
	function getNextSibling(startBrother){
  		endBrother=startBrother.nextSibling;
  		while(endBrother.nodeType!=1){
    		endBrother = endBrother.nextSibling;
  		}
  		return endBrother;
	}
	//Firefox firstChild fix
	function getFirstChild(startBrother){
  		endBrother=startBrother.firstChild;
  		while(endBrother.nodeType!=1){
    		endBrother = endBrother.nextSibling;
  		}
  		return endBrother;
	}		
	
	//Hide product detail rows
	function hideDetails()
	{
		var product_details = getElementsByClassName(document, 'td', 'product-details');
		for (var i = 0; i < product_details.length; i++) {
			removeClassName(product_details[i], 'product-details');
			addClassName(product_details[i], 'product-details hide');
		}
	}
	hideDetails();	
	
	//Create links within the td elements to show and hide product details
	function createButtons()
	{
		var products = getElementsByClassName(document, 'td', 'product');
		for (var i = 0; i < products.length; i++) 
		{
			var text = products[i].innerHTML;
			products[i].innerHTML = '<a href="#" class="closed">' + text + '</a>';
			var buttons = products[i].getElementsByTagName('a');
			for (var j = 0; j < buttons.length; j++) 
			{
				buttons[j].onclick = function()
				{
					if(this.className == 'closed')
					{
						this.className = 'opened'
						var this_row = this.parentNode.parentNode;
						var next_row = getNextSibling(this_row); //Calls the nextSibling fix
						var product_details = getFirstChild(next_row); //Calls the firstChild fix
						product_details.className = 'product-details show'
					}
					else
					{
						this.className = 'closed'
						var this_row = this.parentNode.parentNode;
						var next_row = getNextSibling(this_row); //Calls the nextSibling fix
						var product_details = getFirstChild(next_row); //Calls the firstChild fix
						product_details.className = 'product-details hide'
					}
				}
			}		
		}
	}
	createButtons();
	
	// NetBusiness login form input field value switcher
	var username = document.getElementById('username')
	if (username)
	{
		username.value = "Änvandanamn";
		username.onblur = exitUsername;
		username.onfocus = enterUsername;		
	}
    function exitUsername() 
	{
        if (username.value=="") {
            username.value = "Änvandanamn";
        }
    }        
    function enterUsername() 
	{
        if (username.value == "Änvandanamn") {
            username.value = "";
        }
    }		
}


/* ################# /SE NetBusiness ################# */






