/**
 * visar en flik
 * @author Pär Thernström
 * @param tabID flikens namn
 * @param t länk som ska aktiveras
 */
function tabShow(tabID, t) {

	// göm alla tabbar
	allElements = document.getElementsByTagName("*");
	msg = "";
	for (i=0; i<allElements.length; i++) {
		if (allElements[i].id.indexOf("tab_") != -1) {		
			allElements[i].className = allElements[i].className.replace(/tabCurrent/, "");
		}			
	}

	// visa vald flik
	divVald = document.getElementById("tab_" + tabID);
	divVald.className = divVald.className + " tabCurrent";

	// listan med länkarna
	ul = document.getElementById("tabList");
	li = ul.getElementsByTagName("*");
	for (i=0; i<li.length; i++) {
		li[i].className = li[i].className.replace(/tabCurrent/, "");
	}
	t.className = t.className + " tabCurrent";
	t.blur();

} // function tabShow


/*

Parse the current page's querystring
var qs = new Querystring()

var v1 = qs2.get("name1")
eller
var v3 = qs2.get("name3", "default value")

*/
/* Client-side access to querystring name=value pairs
	Version 1.2.3
	22 Jun 2005
	Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

/**
 * make transparent png's work in ie
 * idea from http://homepage.ntlworld.com/bobosola/pnginfo.htm
 * @author Pär Thernström/AGoodID
 * @param i element/image
 */
function pngfix(i) { 

	var arrV = navigator.appVersion.split("MSIE")
	var v = parseFloat(arrV[1])
	w = i.width;
	h = i.height;
	if ((v >= 5.5) && (v < 7) && (document.body.filters))  {
		i.onload = null;
		i.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + i.src + "', sizingMethod='scale')";
		i.src = "/site/pix/redesign/transp_pix.gif";
		i.width = w;
		i.height = h;		
    }
}

/**
 *  funktioner till toplist-tabbar, kommentera dessa vid tillfälle....
 * @author dan larsson
 */
 	var currentPanel;
   
	function showPanel(panelNum) {
    	if (currentPanel != null) {
        	hidePanel();
      	}
      	document.getElementById('panel'+panelNum).style.display = 'block';
        currentPanel = panelNum;
        setState(panelNum);
	}
   
	function hidePanel() {
    	document.getElementById('panel'+currentPanel).style.display = '';
      	document.getElementById('tab'+currentPanel).className = '';
	}
   
	function setState(tabNum) {
    	document.getElementById('tab'+tabNum).className = (tabNum==currentPanel) ? 'selected' : '';
  	}

  	
function xWindow(name, w, h, x, y, loc, men, res, scr, sta, too){
	var e='',c=',',xf='left=',yf='top='; this.n = name;
	if (document.layers) {
		xf='screenX='; 
		yf='screenY=';
	}
	
	this.f = (w?'width='+w+c:e)+(h?'height='+h+c:e)+(x>=0?xf+x+c:e)+
    (y>=0?yf+y+c:e)+'location='+loc+',menubar='+men+',resizable='+res+
    ',scrollbars='+scr+',status='+sta+',toolbar='+too;
  
    this.opened = function() {return this.w && !this.w.closed;};
  	this.close = function() {if(this.opened()) this.w.close();};
  	this.focus = function() {if(this.opened()) this.w.focus();};
  	this.load = function(sUrl) {
  		if (this.opened()) this.w.location.href = sUrl;
    	else this.w = window.open(sUrl,this.n,this.f);
    	this.focus();
    	return false;
	};
}