﻿function swap(id, src)
{
    document.getElementById(id).src = src;
}

function showTab(n, prefix)
{
    //hide all, turn off all tabs
//    for (var i=1; i<=max; i++)
//    {
//        document.getElementById('img-' + prefix + i.toString()).src = 'images/collapse.gif';
//        document.getElementById('div-' + prefix + i.toString()).style.display = 'none';
//    }
    
    if(document.getElementById('div-' + prefix + n.toString()).style.display == 'block')
    {
        //hide active div & update expander icon
        document.getElementById('img-' + prefix + n.toString()).src = 'images/collapse.gif';
        document.getElementById('div-' + prefix + n.toString()).style.display='none';
    }
    else
    {
        //turn on expander icon
        document.getElementById('img-' + prefix + n.toString()).src = 'images/expand.gif';
        //show indicated div
        document.getElementById('div-' + prefix + n.toString()).style.display='block';
    }
}

function showAll(prefix, max)
{
    for (var i = 1; i<= max; i++)
    {
        //turn on expander icon
        document.getElementById('img-' + prefix + i.toString()).src = 'images/expand.gif';
        //show indicated div
        document.getElementById('div-' + prefix + i.toString()).style.display='block';        
    }
    document.getElementById('exp-' + prefix).style.display='none';
    document.getElementById('coll-' + prefix).style.display='block';
}

function collapseAll(prefix, max)
{
    for (var i = 1; i<= max; i++)
    {
        //turn on expander icon
        document.getElementById('img-' + prefix + i.toString()).src = 'images/collapse.gif';
        //show indicated div
        document.getElementById('div-' + prefix + i.toString()).style.display='none';        
    }
    document.getElementById('exp-' + prefix).style.display='block';
    document.getElementById('coll-' + prefix).style.display='none';
}

function OpenCenterPopUp(url, width, height, title)
{	            
    var TopLeftX=screen.width / 2 - width/2;
    var TopLeftY=screen.height / 2 - height/2;
    var ran_unrounded=Math.random()*100000;
    var ran_number=Math.floor(ran_unrounded); 
    url = url + "?rnd=" + ran_number;
    var NewWindow = window.open(url,title,'top='+TopLeftY+', left='+TopLeftX+', width='+width+',height='+height+',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
}

function RewriteURL(url)
{
    var fullURL = parent.document.URL 
    if(fullURL.indexOf('?') > 0)
    {
        var uid = fullURL.substring(fullURL.indexOf('?'), fullURL.length);    
        window.location=url + uid;
    }
    else
        window.location=url;
    
}

var newwindow;

function poptastic(url)
{
	newwindow=window.open(url,'name','height=254,width=416,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

