var popWidth = 700;
var popHeight = 530;

var newWindow = '';
var lastWindow;

var surveyId;

function popup(mylink, windowname){
    if(!newWindow.closed && newWindow.location){
        if(mylink != lastWindow){
            var href;
            if (typeof(mylink) == 'string'){
                href=mylink;
            }else{
                href=mylink.href;
            }
            newWindow.location = href;
            lastWindow = href;
        }
        newWindow.focus();
        return false;
    }else{
        var href;
        if (typeof(mylink) == 'string'){
            href=mylink;
        }else{
            href=mylink.href;
        }
        lastWindow = href;
        newWindow = window.open(href, windowname, 'width='+popWidth+',height='+popHeight+',scrollbars=yes');
        newWindow.focus();
        return false;
    }
}

function surveypopup(windowname,sessionhash){
	var mylink = '/survey.php?survey=' + this.surveyId + '&' + sessionhash;
    if(!newWindow.closed && newWindow.location){
        if(mylink != lastWindow){
            var href;
            if (typeof(mylink) == 'string'){
                href=mylink;
            }else{
                href=mylink.href;
            }
            newWindow.location = href;
            lastWindow = href;
        }
        newWindow.focus();
        return false;
    }else{
        var href;
        if (typeof(mylink) == 'string'){
            href=mylink;
        }else{
            href=mylink.href;
        }
        lastWindow = href;
        newWindow = window.open(href, windowname, 'width=800,height=600,scrollbars=yes');
        newWindow.focus();
        return false;
    }
}

function replaceContents(id){
    this.surveyId = id;

    for(i = 0; i < surveysList.length; i++){
    	var option = "surveyOption" + surveysList[i];
    	document.getElementById(option).className = "surveyOption";
    }

    var surveyOption = "surveyOption" + id;
    document.getElementById(surveyOption).className = "surveyOptionSelected";
    document.getElementById('descrip').innerHTML = desc[id];
}

function buttonActivate(item){
    item.className = 'buttonHover';
}
function buttonDeactivate(item){
    item.className = 'button';
}