/* generel vars */

// browser check
var ie = document.all ? 1 : 0		
var ns = document.layers ? 1 : 0

/* popups */
function popup(src,windowname,width,height,screenX,screenY,scrollbars,resizable) 
{
	var evalString = windowname+" = window.open(src,windowname,'status=no,scrollbars="+(scrollbars ? scrollbars : 'no' )+",resizable="+(resizable ? 'yes' : 'no' )+",,width='+width+',height='+height";
	if(screenX) {
		evalString += "+',screenX='+screenX+',screenY='+screenY+',top='+screenX+',left='+screenY);"
	} else {
		evalString += ");"
	}
	eval(evalString);
	eval('if(window.'+windowname+') { window.'+windowname+'.focus(); }');
}

function housePopup(src,windowname) {
	popup(src,windowname,338,620,0,0,false,true);
}

function staticPopup(src,windowname) {
	popup(src,windowname,338,500);
}

function helpPopup(src,windowname) {
	popup(src,windowname,300,400);
}

/* dynamically set viewer title */
function setViewerTitle(string) {
	/*if(!containerName || !parent.document.getElementById(containerName)) {
		containerName='titlecontainer';
	}*/
	if(parent.document.getElementById('titlecontainer')) {
		if(string) {
			parent.document.getElementById('titlecontainer').innerHTML = string;
		} else {
			parent.document.getElementById('titlecontainer').innerHTML ='';
		}
	}
}

/* mark all / no checkboxes */
function setCheckboxes(form, group, value)
{
    var elements = document.forms[form].elements[group+'[]'];
    var count	 = (typeof(elements.length) != 'undefined')
                  ? elements.length
                  : 0;

    if (count) {
        for (var i = 0; i < count; i++) {
            elements[i].checked = value;
        }
    } else {
        elements.checked = value;
    }
    return true;
}

/*
function highlight(item,mode)
{
	if(mode==1) {
		if(item.className.indexOf('over')==-1) {
			item.className=item.className+'over';
		}
	} else {
		item.className=item.className.replace('over','');	
	}
}*/

function confirmLink(confirmMsg, confirmItem)
{
    // opera has crappy js implementation!!!
    if (typeof(window.opera) != 'undefined') { return true; }
    return confirm(confirmMsg + '\n' + confirmItem);
}

function previewUpload(url, mode) {
	document.getElementById('previewUploadTd').style.display="block";
	document.getElementById('previewUpload').innerHTML = '<img src="'+url+'" border="0" id="previewUploadImage">';
	setTimeout("document.getElementById('previewUploadDimensions').innerHTML=document.getElementById('previewUploadImage').width+'x'+document.getElementById('previewUploadImage').width+' px';",500);
	if(document.all) {
		fileSize = document.getElementById('previewUploadImage').fileSize;
		fileSize = Math.round(fileSize/10)/100; // round on kb with 2 decimals
		if(fileSize!=0) {
			fileSize +=""; 							// convert to string
			fileSize = fileSize.replace('.',',')+' kb';
		} else {
			fileSize='-';
		}
		setTimeout("document.getElementById('previewUploadFileSize').innerHTML=fileSize;",500);
	} else {
		setTimeout("document.getElementById('previewUploadFileSize').innerHTML='-';",500);
	}
}