function popup(WinName, url, w, h, centered){
	if (url && w && h)
	{
		if (centered) {
			win_popup = window.open(url, "", "width=" + w + ",height=" + h + ",left="+ (screen.availWidth - w) / 2 +",top="+ (screen.availHeight - h) / 2 +",resizable=yes,scrollbars=no,status=yes");
		} else {
			win_popup = window.open(url, "", "width=" + w + ",height=" + h + ",top=30,left=60,resizable=yes,status=yes");
		}
		win_popup.focus();
	}
}

function popup_foto(url)
{
	popup("foto", url, 100, 100);
}

function popup_entry_foto(url)
{
	popup("news", url, 100, 100);
}

function popup_music_foto(url)
{
	popup("music", url, 100, 100);
}

function popup_band_member_foto(url)
{
	popup("band_member", url, 100, 100);
}


function init()
{
	window.moveTo((screen.availWidth - document.foto.width) / 2, (screen.availHeight - document.foto.height) / 2 - 90);
	window.resizeBy(document.foto.width - 105, document.foto.height - 82);
	document.location.hash="start";
}

function getObject(obj) {
	var theObj;
	if(document.all) {
		if(typeof obj=="string") {
			return document.all(obj);
		} else {
			return obj.style;
		}
	}
	if(document.getElementById) {
		if(typeof obj=="string") {
			return document.getElementById(obj);
		} else {
			return obj.style;
		}
	}
	return null;
}

//char counter
function count(input,output,text,characters) {
	var inputObj=document.frm_link_insert.frm_comment;
	var outputObj=getObject(output);
	
	var lenght=characters - inputObj.value.length;
	if(lenght <= 0) {
		lenght=0;
		inputObj.value=inputObj.value.substr(0,characters);
	}
	outputObj.innerHTML = text.replace("{CHAR}",lenght);
}

function PMA_markRowsInit() {
    // for every table row ...
    var rows = document.getElementsByTagName('tr');
    for ( var i = 0; i < rows.length; i++ ) {
        // ... with the class 'odd' or 'even' ...
        if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
            continue;
        }
        // ... add event listeners ...
        // ... to highlight the row on mouseover ...
        if ( navigator.appName == 'Microsoft Internet Explorer' ) {
            // but only for IE, other browsers are handled by :hover in css
            rows[i].onmouseover = function() {
                this.className += ' hover';
            }
            rows[i].onmouseout = function() {
                this.className = this.className.replace( ' hover', '' );
            }
        }
        // Do not set click events if not wanted
        if (rows[i].className.search(/noclick/) != -1) {
            continue;
        }
        // ... and to mark the row on click ...
        rows[i].onmousedown = function() {
            var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'input' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
                return;
            }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
                this.className += ' marked';
            } else {
                this.className = this.className.replace(' marked', '');
            }

            if ( checkbox && checkbox.disabled == false ) {
                checkbox.checked = marked_row[unique_id];
            }
        }

        // ... and disable label ...
        var labeltag = rows[i].getElementsByTagName('label')[0];
        if ( labeltag ) {
            labeltag.onclick = function() {
                return false;
            }
        }
        // .. and checkbox clicks
        var checkbox = rows[i].getElementsByTagName('input')[0];
        if ( checkbox ) {
            checkbox.onclick = function() {
                // opera does not recognize return false;
                this.checked = ! this.checked;
            }
        }
    }
}
window.onload=PMA_markRowsInit;

